#include <string.h>
#include <assert.h>
-#if defined(_MSC_VER)
-// actually, some of the flavors (i.e. Enterprise) do support restrict
-//#define restrict __restrict
-#define restrict
-#define inline __inline
-#define alloca _alloca
-#else
-#ifdef __GNUC__
-#define alloca(x) __builtin_alloca(x)
-#else
-#include <alloca.h>
-#endif
-#endif
-
-
/*
* Primitive polynomials - see Lin & Costello, Appendix A,
* and Lee & Messerschmitt, p. 453.
* modnn(x) computes x % GF_SIZE, where GF_SIZE is 2**GF_BITS - 1,
* without a slow divide.
*/
-static inline gf
+static gf
modnn(int x) {
while (x >= 255) {
x -= 255;
}
fec_t *
-fec_new(unsigned k, unsigned n) {
+fec_new(unsigned short k, unsigned short n) {
unsigned row, col;
gf *p, *tmp_m;
return retval;
}
-/* To make sure that we stay within cache in the inner loops of fec_encode()
- and fec_decode(). */
+/* To make sure that we stay within cache in the inner loops of fec_encode(). (It would
+ probably help to also do this for fec_decode(). */
+#ifndef STRIDE
#define STRIDE 8192
+#endif
void
fec_encode(const fec_t* code, const gf*restrict const*restrict const src, gf*restrict const*restrict const fecs, const unsigned*restrict const block_nums, size_t num_block_nums, size_t sz) {
build_decode_matrix_into_space(code, index, code->k, m_dec);
for (row=0; row<code->k; row++) {
+ assert ((index[row] >= code->k) || (index[row] == row)); /* If the block whose number is i is present, then it is required to be in the i'th element. */
if (index[row] >= code->k) {
memset(outpkts[outix], 0, sz);
for (col=0; col < code->k; col++)
/**
* zfec -- fast forward error correction library with Python interface
- *
- * Copyright (C) 2007 Allmydata, Inc.
+ *
+ * Copyright (C) 2007-2010 Zooko Wilcox-O'Hearn
* Author: Zooko Wilcox-O'Hearn
- *
+ *
* This file is part of zfec.
- *
- * See README.txt for licensing information.
+ *
+ * See README.rst for licensing information.
*/
/*
* Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and Hari
* Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995
*
- * Modifications by Dan Rubenstein (see Modifications.txt for
+ * Modifications by Dan Rubenstein (see Modifications.txt for
* their description.
* Modifications (C) 1998 Dan Rubenstein (drubenst@cs.umass.edu)
*