From: zooko Date: Tue, 13 Nov 2007 20:13:52 +0000 (+0530) Subject: zfec: conditionally-compile the right magic to use alloca() with gcc -mno-cygwin X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/biz?a=commitdiff_plain;h=c2627c465c6e2ab5ad2dff721dddda5d79d61bda;p=tahoe-lafs%2Fzfec.git zfec: conditionally-compile the right magic to use alloca() with gcc -mno-cygwin darcs-hash:d1c2597ea94772afcbb81c50ab7ff8efd0eacd6e --- diff --git a/zfec/TODO b/zfec/TODO index 28d0cf1..bad1951 100644 --- a/zfec/TODO +++ b/zfec/TODO @@ -8,6 +8,7 @@ * Jerasure ** try multiplication without a lookup table? (to save cache pressure) * conditional compilation to handle a printf that doesn't understand %Zu + * try malloc() instead of alloca() (more portable, possibly better for keeping stacks aligned) * announce on lwn, p2p-hackers diff --git a/zfec/zfec/_fecmodule.c b/zfec/zfec/_fecmodule.c index 13da1c9..abe21ec 100644 --- a/zfec/zfec/_fecmodule.c +++ b/zfec/zfec/_fecmodule.c @@ -13,6 +13,22 @@ typedef int Py_ssize_t; #include "stdarg.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 +#endif +#endif + + + static PyObject *py_fec_error; static char fec__doc__[] = "\ diff --git a/zfec/zfec/fec.c b/zfec/zfec/fec.c index 62f908f..761e045 100644 --- a/zfec/zfec/fec.c +++ b/zfec/zfec/fec.c @@ -2,13 +2,26 @@ * zfec -- fast forward error correction library with Python interface */ +#include "fec.h" + #include #include #include #include -#include -#include "fec.h" +#if defined(_MSC_VER) +// actually, some of the flavors (i.e. Enterprise) do support it +//#define restrict __restrict +#define restrict +#define inline __inline +#define alloca _alloca +#else +#ifdef __GNUC__ +#define alloca(x) __builtin_alloca(x) +#else +#include +#endif +#endif /* diff --git a/zfec/zfec/fec.h b/zfec/zfec/fec.h index 3931017..2a7981a 100644 --- a/zfec/zfec/fec.h +++ b/zfec/zfec/fec.h @@ -2,13 +2,7 @@ * zfec -- fast forward error correction library with Python interface */ -#if defined(_MSC_VER) -// actually, some of the flavors (i.e. Enterprise) do support it -//#define restrict __restrict -#define restrict -#define inline __inline -#define alloca _alloca -#endif +#include typedef unsigned char gf;