]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blobdiff - zfec/zfec/fec.h
docs: update docs and metadata
[tahoe-lafs/zfec.git] / zfec / zfec / fec.h
index 1e8b44d90f5b5e00e26cbe39ba4f7bb9f4391a2c..249fe666f495f647892b73d234d769f5e77e4c77 100644 (file)
@@ -1,62 +1,70 @@
 /**
  * zfec -- fast forward error correction library with Python interface
+ *
+ * See README.rst for documentation.
  */
 
+#include <stddef.h>
+
 typedef unsigned char gf;
 
 typedef struct {
   unsigned long magic;
-  unsigned k, n;                     /* parameters of the code */
+  unsigned short k, n;                     /* parameters of the code */
   gf* enc_matrix;
 } fec_t;
 
+#if defined(_MSC_VER)
+// actually, some of the flavors (i.e. Enterprise) do support restrict
+//#define restrict __restrict
+#define restrict
+#endif
+
 /**
  * param k the number of blocks required to reconstruct
  * param m the total number of blocks created
  */
-fec_t* fec_new(unsigned k, unsigned m);
+fec_t* fec_new(unsigned short k, unsigned short m);
 void fec_free(fec_t* p);
 
 /**
  * @param inpkts the "primary blocks" i.e. the chunks of the input data
  * @param fecs buffers into which the secondary blocks will be written
- * @param block_nums the numbers of the desired blocks -- including both primary blocks (the id < k) which fec_encode() ignores and check blocks (the id >= k) which fec_encode() will produce and store into the buffers of the fecs parameter
+ * @param block_nums the numbers of the desired check blocks (the id >= k) which fec_encode() will produce and store into the buffers of the fecs parameter
  * @param num_block_nums the length of the block_nums array
+ * @param sz size of a packet in bytes
  */
 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);
 
 /**
- * @param inpkts an array of packets (size k)
+ * @param inpkts an array of packets (size k); If a primary block, i, is present then it must be at index i. Secondary blocks can appear anywhere.
  * @param outpkts an array of buffers into which the reconstructed output packets will be written (only packets which are not present in the inpkts input will be reconstructed and written to outpkts)
  * @param index an array of the blocknums of the packets in inpkts
  * @param sz size of a packet in bytes
  */
 void fec_decode(const fec_t* code, const gf*restrict const*restrict const inpkts, gf*restrict const*restrict const outpkts, const unsigned*restrict const index, size_t sz);
 
+#if defined(_MSC_VER)
+#define alloca _alloca
+#else
+#ifdef __GNUC__
+#ifndef alloca
+#define alloca(x) __builtin_alloca(x)
+#endif
+#else
+#include <alloca.h>
+#endif
+#endif
 
 /**
  * zfec -- fast forward error correction library with Python interface
  * 
- * Copyright (C) 2007 Allmydata, Inc.
+ * Copyright (C) 2007-2008 Allmydata, Inc.
  * Author: Zooko Wilcox-O'Hearn
  * 
  * This file is part of zfec.
  * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version, with the added permission that, if you become obligated
- * to release a derived work under this licence (as per section 2.b of the
- * GPL), you may delay the fulfillment of this obligation for up to 12 months.
- *
- * If you would like to inquire about a commercial relationship with Allmydata,
- * Inc., please contact partnerships@allmydata.com and visit
- * http://allmydata.com/.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
+ * See README.rst for licensing information.
  */
 
 /*