1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/cairo/libpixman/src/pixman-compiler.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,247 @@ 1.4 +/* Pixman uses some non-standard compiler features. This file ensures 1.5 + * they exist 1.6 + * 1.7 + * The features are: 1.8 + * 1.9 + * FUNC must be defined to expand to the current function 1.10 + * PIXMAN_EXPORT should be defined to whatever is required to 1.11 + * export functions from a shared library 1.12 + * limits limits for various types must be defined 1.13 + * inline must be defined 1.14 + * force_inline must be defined 1.15 + */ 1.16 +#if defined (__GNUC__) 1.17 +# define FUNC ((const char*) (__PRETTY_FUNCTION__)) 1.18 +#elif defined (__sun) || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) 1.19 +# define FUNC ((const char*) (__func__)) 1.20 +#else 1.21 +# define FUNC ((const char*) ("???")) 1.22 +#endif 1.23 + 1.24 +#if defined (__GNUC__) 1.25 +# define MAYBE_UNUSED __attribute__((unused)) 1.26 +#else 1.27 +# define MAYBE_UNUSED 1.28 +#endif 1.29 + 1.30 +#ifndef INT16_MIN 1.31 +# define INT16_MIN (-32767-1) 1.32 +#endif 1.33 + 1.34 +#ifndef INT16_MAX 1.35 +# define INT16_MAX (32767) 1.36 +#endif 1.37 + 1.38 +#ifndef INT32_MIN 1.39 +# define INT32_MIN (-2147483647-1) 1.40 +#endif 1.41 + 1.42 +#ifndef INT32_MAX 1.43 +# define INT32_MAX (2147483647) 1.44 +#endif 1.45 + 1.46 +#ifndef UINT32_MIN 1.47 +# define UINT32_MIN (0) 1.48 +#endif 1.49 + 1.50 +#ifndef UINT32_MAX 1.51 +# define UINT32_MAX (4294967295U) 1.52 +#endif 1.53 + 1.54 +#ifndef INT64_MIN 1.55 +# define INT64_MIN (-9223372036854775807-1) 1.56 +#endif 1.57 + 1.58 +#ifndef INT64_MAX 1.59 +# define INT64_MAX (9223372036854775807) 1.60 +#endif 1.61 + 1.62 +#ifndef SIZE_MAX 1.63 +# define SIZE_MAX ((size_t)-1) 1.64 +#endif 1.65 + 1.66 + 1.67 +#ifndef M_PI 1.68 +# define M_PI 3.14159265358979323846 1.69 +#endif 1.70 + 1.71 +#ifdef _MSC_VER 1.72 +/* 'inline' is available only in C++ in MSVC */ 1.73 +# define inline __inline 1.74 +# define force_inline __forceinline 1.75 +# define noinline __declspec(noinline) 1.76 +#elif defined __GNUC__ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) 1.77 +# define inline __inline__ 1.78 +# define force_inline __inline__ __attribute__ ((__always_inline__)) 1.79 +# define noinline __attribute__((noinline)) 1.80 +#else 1.81 +# ifndef force_inline 1.82 +# define force_inline inline 1.83 +# endif 1.84 +# ifndef noinline 1.85 +# define noinline 1.86 +# endif 1.87 +#endif 1.88 + 1.89 +/* In libxul builds we don't ever want to export pixman symbols */ 1.90 +#if 1 1.91 +#include "prcpucfg.h" 1.92 + 1.93 +#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE 1.94 +#define CVISIBILITY_HIDDEN __attribute__((visibility("hidden"))) 1.95 +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) 1.96 +#define CVISIBILITY_HIDDEN __hidden 1.97 +#else 1.98 +#define CVISIBILITY_HIDDEN 1.99 +#endif 1.100 + 1.101 +/* In libxul builds we don't ever want to export cairo symbols */ 1.102 +#define PIXMAN_EXPORT extern CVISIBILITY_HIDDEN 1.103 + 1.104 +#else 1.105 + 1.106 +/* GCC visibility */ 1.107 +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32) 1.108 +# define PIXMAN_EXPORT __attribute__ ((visibility("default"))) 1.109 +/* Sun Studio 8 visibility */ 1.110 +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) 1.111 +# define PIXMAN_EXPORT __global 1.112 +#else 1.113 +# define PIXMAN_EXPORT 1.114 +#endif 1.115 + 1.116 +#endif 1.117 + 1.118 +/* member offsets */ 1.119 +#define CONTAINER_OF(type, member, data) \ 1.120 + ((type *)(((uint8_t *)data) - offsetof (type, member))) 1.121 + 1.122 +/* TLS */ 1.123 +#if defined(PIXMAN_NO_TLS) 1.124 + 1.125 +# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ 1.126 + static type name 1.127 +# define PIXMAN_GET_THREAD_LOCAL(name) \ 1.128 + (&name) 1.129 + 1.130 +#elif defined(TLS) 1.131 + 1.132 +# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ 1.133 + static TLS type name 1.134 +# define PIXMAN_GET_THREAD_LOCAL(name) \ 1.135 + (&name) 1.136 + 1.137 +#elif defined(__MINGW32__) || defined(PIXMAN_USE_XP_DLL_TLS_WORKAROUND) 1.138 + 1.139 +# define _NO_W32_PSEUDO_MODIFIERS 1.140 +# include <windows.h> 1.141 +#undef IN 1.142 +#undef OUT 1.143 + 1.144 +# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ 1.145 + static volatile int tls_ ## name ## _initialized = 0; \ 1.146 + static void *tls_ ## name ## _mutex = NULL; \ 1.147 + static unsigned tls_ ## name ## _index; \ 1.148 + \ 1.149 + static type * \ 1.150 + tls_ ## name ## _alloc (void) \ 1.151 + { \ 1.152 + type *value = calloc (1, sizeof (type)); \ 1.153 + if (value) \ 1.154 + TlsSetValue (tls_ ## name ## _index, value); \ 1.155 + return value; \ 1.156 + } \ 1.157 + \ 1.158 + static force_inline type * \ 1.159 + tls_ ## name ## _get (void) \ 1.160 + { \ 1.161 + type *value; \ 1.162 + if (!tls_ ## name ## _initialized) \ 1.163 + { \ 1.164 + if (!tls_ ## name ## _mutex) \ 1.165 + { \ 1.166 + void *mutex = CreateMutexA (NULL, 0, NULL); \ 1.167 + if (InterlockedCompareExchangePointer ( \ 1.168 + &tls_ ## name ## _mutex, mutex, NULL) != NULL) \ 1.169 + { \ 1.170 + CloseHandle (mutex); \ 1.171 + } \ 1.172 + } \ 1.173 + WaitForSingleObject (tls_ ## name ## _mutex, 0xFFFFFFFF); \ 1.174 + if (!tls_ ## name ## _initialized) \ 1.175 + { \ 1.176 + tls_ ## name ## _index = TlsAlloc (); \ 1.177 + tls_ ## name ## _initialized = 1; \ 1.178 + } \ 1.179 + ReleaseMutex (tls_ ## name ## _mutex); \ 1.180 + } \ 1.181 + if (tls_ ## name ## _index == 0xFFFFFFFF) \ 1.182 + return NULL; \ 1.183 + value = TlsGetValue (tls_ ## name ## _index); \ 1.184 + if (!value) \ 1.185 + value = tls_ ## name ## _alloc (); \ 1.186 + return value; \ 1.187 + } 1.188 + 1.189 +# define PIXMAN_GET_THREAD_LOCAL(name) \ 1.190 + tls_ ## name ## _get () 1.191 + 1.192 +#elif defined(_MSC_VER) 1.193 + 1.194 +# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ 1.195 + static __declspec(thread) type name 1.196 +# define PIXMAN_GET_THREAD_LOCAL(name) \ 1.197 + (&name) 1.198 + 1.199 +#elif defined(HAVE_PTHREAD_SETSPECIFIC) 1.200 + 1.201 +#include <pthread.h> 1.202 + 1.203 +# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ 1.204 + static pthread_once_t tls_ ## name ## _once_control = PTHREAD_ONCE_INIT; \ 1.205 + static pthread_key_t tls_ ## name ## _key; \ 1.206 + \ 1.207 + static void \ 1.208 + tls_ ## name ## _destroy_value (void *value) \ 1.209 + { \ 1.210 + free (value); \ 1.211 + } \ 1.212 + \ 1.213 + static void \ 1.214 + tls_ ## name ## _make_key (void) \ 1.215 + { \ 1.216 + pthread_key_create (&tls_ ## name ## _key, \ 1.217 + tls_ ## name ## _destroy_value); \ 1.218 + } \ 1.219 + \ 1.220 + static type * \ 1.221 + tls_ ## name ## _alloc (void) \ 1.222 + { \ 1.223 + type *value = calloc (1, sizeof (type)); \ 1.224 + if (value) \ 1.225 + pthread_setspecific (tls_ ## name ## _key, value); \ 1.226 + return value; \ 1.227 + } \ 1.228 + \ 1.229 + static force_inline type * \ 1.230 + tls_ ## name ## _get (void) \ 1.231 + { \ 1.232 + type *value = NULL; \ 1.233 + if (pthread_once (&tls_ ## name ## _once_control, \ 1.234 + tls_ ## name ## _make_key) == 0) \ 1.235 + { \ 1.236 + value = pthread_getspecific (tls_ ## name ## _key); \ 1.237 + if (!value) \ 1.238 + value = tls_ ## name ## _alloc (); \ 1.239 + } \ 1.240 + return value; \ 1.241 + } 1.242 + 1.243 +# define PIXMAN_GET_THREAD_LOCAL(name) \ 1.244 + tls_ ## name ## _get () 1.245 + 1.246 +#else 1.247 + 1.248 +# error "Unknown thread local support for this system. Pixman will not work with multiple threads. Define PIXMAN_NO_TLS to acknowledge and accept this limitation and compile pixman without thread-safety support." 1.249 + 1.250 +#endif