backend: define z_alloca() and use for both Unix and Windows;

replace double-slash comments with old-skool slash asterisk ones;
  define uint16_t etc for Windows ourselves and remove ms_stdint.h &
  stdint_msvc.h as no longer used;
  (backend (excepting test suite) now C89 compatible)
LICENSE: move from backend to root and move COPYING to frontend, with
  copies in frontend_qt & backend_qt, so in where it applies;
  add LICENSE section from manual to root README
This commit is contained in:
gitlost 2022-07-14 16:01:30 +01:00
parent 5ee3895bca
commit 930f458979
70 changed files with 2650 additions and 2038 deletions

View file

@ -1,6 +1,5 @@
/**
This is a simple Reed-Solomon encoder
/* This is a simple Reed-Solomon encoder */
/*
(C) Cliff Hones 2004
Redistribution and use in source and binary forms, with or without
@ -28,9 +27,9 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
// It is not written with high efficiency in mind, so is probably
/* It is not written with high efficiency in mind, so is probably
// not suitable for real-time encoding. The aim was to keep it
// simple, general and clear.
//
@ -49,15 +48,13 @@
// malloc/free can be avoided by using static arrays of a suitable
// size.
// Note: use of statics has been done for (up to) 8-bit tables.
*/
#ifdef _MSC_VER
#include <malloc.h>
#endif
#include "common.h"
#include "reedsol.h"
#include "reedsol_logs.h"
// rs_init_gf(&rs, prime_poly) initialises the parameters for the Galois Field.
/* rs_init_gf(&rs, prime_poly) initialises the parameters for the Galois Field.
// The symbol size is determined from the highest bit set in poly
// This implementation will support sizes up to 8 bits (see rs_uint_init_gf()
// for sizes > 8 bits and <= 30 bits) - bit sizes of 8 or 4 are typical
@ -65,6 +62,7 @@
// The poly is the bit pattern representing the GF characteristic
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
*/
INTERNAL void rs_init_gf(rs_t *rs, const unsigned int prime_poly) {
struct item {
@ -97,12 +95,13 @@ INTERNAL void rs_init_gf(rs_t *rs, const unsigned int prime_poly) {
rs->alog = data[hash].alog;
}
// rs_init_code(&rs, nsym, index) initialises the Reed-Solomon encoder
/* rs_init_code(&rs, nsym, index) initialises the Reed-Solomon encoder
// nsym is the number of symbols to be generated (to be appended
// to the input data). index is usually 1 - it is the index of
// the constant in the first term (i) of the RS generator polynomial:
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
// For ECC200, index is 1.
*/
INTERNAL void rs_init_code(rs_t *rs, const int nsym, int index) {
int i, k;
@ -225,11 +224,12 @@ INTERNAL void rs_encode_uint(const rs_t *rs, const int datalen, const unsigned i
/* Versions of the above for bitlengths > 8 and <= 30 and unsigned int data and results - Aztec code compatible */
// Usage:
/* Usage:
// First call rs_uint_init_gf(&rs_uint, prime_poly, logmod) to set up the Galois Field parameters.
// Then call rs_uint_init_code(&rs_uint, nsym, index) to set the encoding size
// Then call rs_uint_encode(&rs_uint, datalen, data, out) to encode the data.
// Then call rs_uint_free(&rs_uint) to free the log tables.
*/
/* `logmod` (field characteristic) will be 2**bitlength - 1, eg 1023 for bitlength 10, 4095 for bitlength 12 */
INTERNAL int rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_poly, const int logmod) {
@ -249,7 +249,7 @@ INTERNAL int rs_uint_init_gf(rs_uint_t *rs_uint, const unsigned int prime_poly,
return 0;
}
// Calculate the log/alog tables
/* Calculate the log/alog tables */
for (p = 1, v = 0; v < logmod; v++) {
alog[v] = p;
alog[logmod + v] = p; /* Double up, avoids mod */
@ -352,3 +352,5 @@ INTERNAL void rs_uint_free(rs_uint_t *rs_uint) {
rs_uint->alog = NULL;
}
}
/* vim: set ts=4 sw=4 et : */