diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-10-09 16:36:37 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-10-09 16:36:37 +0000 |
commit | 21c068f1916330e90f814bed461fe0821d1665ec (patch) | |
tree | 949b73696fff09a44b8d3eb01b70bae7174cbd14 /pd/src/d_math.c | |
parent | bf8ced1efe1a032342e864edc635fa4e2676670d (diff) |
checked in pd-0.43-0.src.tar.gz
svn path=/trunk/; revision=15557
Diffstat (limited to 'pd/src/d_math.c')
-rw-r--r-- | pd/src/d_math.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/pd/src/d_math.c b/pd/src/d_math.c index 31c6c655..f76bffef 100644 --- a/pd/src/d_math.c +++ b/pd/src/d_math.c @@ -67,13 +67,12 @@ static void clip_setup(void) #define DUMTAB1SIZE 256 #define DUMTAB2SIZE 1024 -#ifdef MSW -#define int32 long -#endif - -#if defined(__unix__) || defined(__APPLE__) -#include <sys/types.h> -#define int32 int32_t +#ifdef _MSC_VER + typedef __int32 int32_t; /* use MSVC's internal type */ +#elif defined(IRIX) + typedef long int32_t; /* a data type that has 32 bits */ +#else +# include <stdint.h> /* this is where int32_t is defined in C99 */ #endif static float rsqrt_exptab[DUMTAB1SIZE], rsqrt_mantissatab[DUMTAB2SIZE]; @@ -84,8 +83,8 @@ static void init_rsqrt(void) for (i = 0; i < DUMTAB1SIZE; i++) { float f; - int32 l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23; - *(int32 *)(&f) = l; + int32_t l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23; + *(int32_t *)(&f) = l; rsqrt_exptab[i] = 1./sqrt(f); } for (i = 0; i < DUMTAB2SIZE; i++) @@ -97,16 +96,18 @@ static void init_rsqrt(void) /* these are used in externs like "bonk" */ -t_float q8_rsqrt(t_float f) +t_float q8_rsqrt(t_float f0) { + float f = (float)f0; long l = *(long *)(&f); if (f < 0) return (0); else return (rsqrt_exptab[(l >> 23) & 0xff] * rsqrt_mantissatab[(l >> 13) & 0x3ff]); } -t_float q8_sqrt(t_float f) +t_float q8_sqrt(t_float f0) { + float f = (float)f0; long l = *(long *)(&f); if (f < 0) return (0); else return (f * rsqrt_exptab[(l >> 23) & 0xff] * |