commit eee1cfb14960fa68e69e2fbebc3ac94223a007b3
Author: IOhannes m zmoelnig <zmoelnig@iem.at>
Date:   Tue May 24 19:00:45 2011 +0200

    implement PD_BIGORSMALL() with unions
    
    - using float/int casts (i.e. type-punning) won't work with heavy optimization, as it breaks strict-aliasing, which is required by C99.
    - see http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Optimize-Options.html#index-fstrict_002daliasing-787
    - renamed PD_FLOATSIZE to PD_FLOATPRECISION

diff --git a/src/m_pd.h b/src/m_pd.h
index efee194..5ee3861 100644
--- a/src/m_pd.h
+++ b/src/m_pd.h
@@ -64,9 +64,24 @@ extern "C" {
 #if !defined(PD_LONGINTTYPE)
 #define PD_LONGINTTYPE long
 #endif
-#if !defined(PD_FLOATTYPE)
-#define PD_FLOATTYPE float
+
+#if !defined(PD_FLOATPRECISION)
+  /* normally, our floats (t_float, t_sample,...) are 32bit */
+# define PD_FLOATPRECISION 32
+#endif
+
+#if PD_FLOATPRECISION == 32
+# define PD_FLOATTYPE float
+/* an unsigned int of the same size as FLOATTYPE: */
+# define PD_FLOATUINTTYPE unsigned int
+
+#elif PD_FLOATPRECISION == 64
+# define PD_FLOATTYPE double
+# define PD_FLOATUINTTYPE unsigned long
+#else
+# error invalid FLOATSIZE: must be 32 or 64
 #endif
+
 typedef PD_LONGINTTYPE t_int;       /* pointer-size integer */
 typedef PD_FLOATTYPE t_float;       /* a float type at most the same size */
 typedef PD_FLOATTYPE t_floatarg;    /* float type for function calls */
@@ -508,6 +523,10 @@ EXTERN int sys_trylock(void);
 /* --------------- signals ----------------------------------- */
 
 typedef PD_FLOATTYPE t_sample;
+typedef union _sampleint_union {
+  t_sample f;
+  PD_FLOATUINTTYPE i;
+} t_sampleint_union;
 #define MAXLOGSIG 32
 #define MAXSIGSIZE (1 << MAXLOGSIG)
 
@@ -660,14 +679,26 @@ defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */
 
 #if defined(__i386__) || defined(__x86_64__)
 /* a test for NANs and denormals.  Should only be necessary on i386. */
-#define PD_BADFLOAT(f) ((((*(unsigned int*)&(f))&0x7f800000)==0) || \
-    (((*(unsigned int*)&(f))&0x7f800000)==0x7f800000))
+# if PD_FLOATPRECISION == 32
+static inline int PD_BADFLOAT(t_sample f) {
+  t_sampleint_union u;
+  u.f=f;
+  return ((u.i & 0x7f800000)==0) || ((u.i&0x7f800000)==0x7f800000);
+}
 /* more stringent test: anything not between 1e-19 and 1e19 in absolute val */
-#define PD_BIGORSMALL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \
-    (((*(unsigned int*)&(f))&0x60000000)==0x60000000))
+static inline int PD_BIGORSMALL(t_sample f) {
+  t_sampleint_union u;
+  u.f=f;
+  return ((u.i & 0x60000000)==0) || ((u.i & 0x60000000)==0x60000000);
+}
+# else
+#  warning 64bit mode: BIGORSMALL not implemented yet
+#  define PD_BADFLOAT(f) 0
+#  define PD_BIGORSMALL(f) 0
+# endif
 #else
-#define PD_BADFLOAT(f) 0
-#define PD_BIGORSMALL(f) 0
+# define PD_BADFLOAT(f) 0
+# define PD_BIGORSMALL(f) 0
 #endif
 
     /* get version number at run time */
