mmx: add add_0565_0565
[profile/ivi/pixman.git] / pixman / pixman-compiler.h
index f0f9d91..ffd5172 100644 (file)
 #  define FUNC     ((const char*) ("???"))
 #endif
 
+#if defined (__GNUC__)
+#  define MAYBE_UNUSED  __attribute__((unused))
+#else
+#  define MAYBE_UNUSED
+#endif
+
 #ifndef INT16_MIN
 # define INT16_MIN              (-32767-1)
 #endif
 # define UINT32_MAX             (4294967295U)
 #endif
 
+#ifndef INT64_MIN
+# define INT64_MIN              (-9223372036854775807-1)
+#endif
+
+#ifndef INT64_MAX
+# define INT64_MAX              (9223372036854775807)
+#endif
+
+
 #ifndef M_PI
 # define M_PI                  3.14159265358979323846
 #endif
 /* 'inline' is available only in C++ in MSVC */
 #   define inline __inline
 #   define force_inline __forceinline
+#   define noinline __declspec(noinline)
 #elif defined __GNUC__ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
 #   define inline __inline__
 #   define force_inline __inline__ __attribute__ ((__always_inline__))
+#   define noinline __attribute__((noinline))
 #else
 #   ifndef force_inline
 #      define force_inline inline
 #   endif
+#   ifndef noinline
+#      define noinline
+#   endif
 #endif
 
 /* GCC visibility */
-#if defined(__GNUC__) && __GNUC__ >= 4
+#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32)
 #   define PIXMAN_EXPORT __attribute__ ((visibility("default")))
 /* Sun Studio 8 visibility */
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
 /* TLS */
 #if defined(PIXMAN_NO_TLS)
 
-#   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)            \
+#   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
     static type name
-#   define PIXMAN_GET_THREAD_LOCAL(name)                \
+#   define PIXMAN_GET_THREAD_LOCAL(name)                               \
     (&name)
 
-#elif defined(TOOLCHAIN_SUPPORTS__THREAD)
+#elif defined(TLS)
 
 #   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
-    static __thread type name
+    static TLS type name
 #   define PIXMAN_GET_THREAD_LOCAL(name)                               \
     (&name)
 
-#elif defined(__MINGW32__) && !defined(__WIN64)
+#elif defined(__MINGW32__)
 
-/* We can't include <windows.h> as it causes carious clashes with
- * identifiers in pixman, sigh. So just declare the functions we need
- * here.
- */
-extern __stdcall long InterlockedCompareExchange(long volatile *, long, long);
-#define InterlockedCompareExchangePointer(d,e,c)                       \
-    (void *)InterlockedCompareExchange((long volatile *)(d),(long)(e),(long)(c))
-extern __stdcall int TlsAlloc (void);
-extern __stdcall void *TlsGetValue (unsigned);
-extern __stdcall int TlsSetValue (unsigned, void *);
-extern __stdcall void *CreateMutexA(void *, int, char *);
-extern __stdcall int CloseHandle(void *);
-extern __stdcall unsigned WaitForSingleObject (void *, unsigned);
-extern __stdcall int ReleaseMutex (void *);
+#   define _NO_W32_PSEUDO_MODIFIERS
+#   include <windows.h>
 
 #   define PIXMAN_DEFINE_THREAD_LOCAL(type, name)                      \
     static volatile int tls_ ## name ## _initialized = 0;              \
@@ -165,9 +173,16 @@ extern __stdcall int ReleaseMutex (void *);
     static pthread_key_t tls_ ## name ## _key;                         \
                                                                        \
     static void                                                                \
+    tls_ ## name ## _destroy_value (void *value)                       \
+    {                                                                  \
+       free (value);                                                   \
+    }                                                                  \
+                                                                       \
+    static void                                                                \
     tls_ ## name ## _make_key (void)                                   \
     {                                                                  \
-       pthread_key_create (&tls_ ## name ## _key, NULL);               \
+       pthread_key_create (&tls_ ## name ## _key,                      \
+                           tls_ ## name ## _destroy_value);            \
     }                                                                  \
                                                                        \
     static type *                                                      \