fixed opj_malloc.h for macosx (bugfix provided by janpeder, thanks)
[openjpeg.git] / libopenjpeg / opj_includes.h
index 4d48f2c8b9890b2e268170d4b0174ed174259236..80d43df990f85ec9d544cccf2e81a0470c20748c 100644 (file)
  ==========================================================
 */
 
+/* Ignore GCC attributes if this is not GCC */
+#ifndef __GNUC__
+       #define __attribute__(x) /* __attribute__(x) */
+#endif
+
 /*
 The inline keyword is supported by C99 but not by C90. 
 Most compilers implement their own version of this keyword ... 
@@ -71,7 +76,32 @@ Most compilers implement their own version of this keyword ...
        #endif /* defined(<Compiler>) */
 #endif /* INLINE */
 
+/* Are restricted pointers available? (C99) */
+#if (__STDC_VERSION__ != 199901L)
+       /* Not a C99 compiler */
+       #ifdef __GNUC__
+               #define restrict __restrict__
+       #else
+               #define restrict /* restrict */
+       #endif
+#endif
+
+/* MSVC does not have lrintf */
+#ifdef _MSC_VER
+static INLINE long lrintf(float f){
+       int i;
+
+       _asm{
+               fld f
+               fistp i
+       };
+
+       return i;
+}
+#endif
+
 #include "j2k_lib.h"
+#include "opj_malloc.h"
 #include "event.h"
 #include "cio.h"
 
@@ -84,10 +114,10 @@ Most compilers implement their own version of this keyword ...
 #include "raw.h"
 #include "bio.h"
 #include "tgt.h"
+#include "pi.h"
 #include "tcd.h"
 #include "t1.h"
 #include "dwt.h"
-#include "pi.h"
 #include "t2.h"
 #include "mct.h"
 #include "int.h"