• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #ifndef PTHREADPOOL_USE_CPUINFO
4 	#define PTHREADPOOL_USE_CPUINFO 0
5 #endif
6 
7 #ifndef PTHREADPOOL_USE_FUTEX
8 	#if defined(__linux__)
9 		#define PTHREADPOOL_USE_FUTEX 1
10 	#elif defined(__EMSCRIPTEN__)
11 		#define PTHREADPOOL_USE_FUTEX 1
12 	#else
13 		#define PTHREADPOOL_USE_FUTEX 0
14 	#endif
15 #endif
16 
17 #ifndef PTHREADPOOL_USE_GCD
18 	#if defined(__APPLE__)
19 		#define PTHREADPOOL_USE_GCD 1
20 	#else
21 		#define PTHREADPOOL_USE_GCD 0
22 	#endif
23 #endif
24 
25 #ifndef PTHREADPOOL_USE_EVENT
26 	#if defined(_WIN32) || defined(__CYGWIN__)
27 		#define PTHREADPOOL_USE_EVENT 1
28 	#else
29 		#define PTHREADPOOL_USE_EVENT 0
30 	#endif
31 #endif
32 
33 #ifndef PTHREADPOOL_USE_CONDVAR
34 	#if PTHREADPOOL_USE_GCD || PTHREADPOOL_USE_FUTEX || PTHREADPOOL_USE_EVENT
35 		#define PTHREADPOOL_USE_CONDVAR 0
36 	#else
37 		#define PTHREADPOOL_USE_CONDVAR 1
38 	#endif
39 #endif
40 
41 
42 /* Number of iterations in spin-wait loop before going into futex/condvar wait */
43 #define PTHREADPOOL_SPIN_WAIT_ITERATIONS 1000000
44 
45 #define PTHREADPOOL_CACHELINE_SIZE 64
46 #if defined(__GNUC__)
47 	#define PTHREADPOOL_CACHELINE_ALIGNED __attribute__((__aligned__(PTHREADPOOL_CACHELINE_SIZE)))
48 #elif defined(_MSC_VER)
49 	#define PTHREADPOOL_CACHELINE_ALIGNED __declspec(align(PTHREADPOOL_CACHELINE_SIZE))
50 #else
51 	#error "Platform-specific implementation of PTHREADPOOL_CACHELINE_ALIGNED required"
52 #endif
53 
54 #if defined(__clang__)
55 	#if __has_extension(c_static_assert) || __has_feature(c_static_assert)
56 		#define PTHREADPOOL_STATIC_ASSERT(predicate, message) _Static_assert((predicate), message)
57 	#else
58 		#define PTHREADPOOL_STATIC_ASSERT(predicate, message)
59 	#endif
60 #elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
61 	/* Static assert is supported by gcc >= 4.6 */
62 	#define PTHREADPOOL_STATIC_ASSERT(predicate, message) _Static_assert((predicate), message)
63 #else
64 	#define PTHREADPOOL_STATIC_ASSERT(predicate, message)
65 #endif
66 
67 #ifndef PTHREADPOOL_INTERNAL
68 	#if defined(__ELF__)
69 		#define PTHREADPOOL_INTERNAL __attribute__((__visibility__("internal")))
70 	#elif defined(__MACH__)
71 		#define PTHREADPOOL_INTERNAL __attribute__((__visibility__("hidden")))
72 	#else
73 		#define PTHREADPOOL_INTERNAL
74 	#endif
75 #endif
76