Tizen 2.1 base
[platform/upstream/gcd.git] / pthread_workqueue-0.8.2 / src / posix / platform.h
1 #ifndef _PTWQ_POSIX_PLATFORM_H
2 #define _PTWQ_POSIX_PLATFORM_H 1
3
4 /* Workaround to get visibility for _SC_NPROCESSORS_ONLN on FreeBSD */
5 #define __BSD_VISIBLE 1
6
7 #include <sys/resource.h>
8 #include <sys/queue.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <strings.h>
12 #include <unistd.h>
13 #include <pthread.h>
14
15 #ifdef __sun
16 # include <sys/loadavg.h>
17 #endif
18
19 /* GCC atomic builtins. 
20  * See: http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html 
21  */
22 #ifdef __sun
23 # include <atomic.h>
24 # define atomic_inc      atomic_inc_32
25 # define atomic_dec      atomic_dec_32
26 # define atomic_and      atomic_and_uint_nv
27 # define atomic_or      atomic_or_uint_nv
28 #else
29 # define atomic_inc(p)   __sync_add_and_fetch((p), 1)
30 # define atomic_dec(p)   __sync_sub_and_fetch((p), 1)
31 # define atomic_and(p,v)   __sync_and_and_fetch((p), (v))
32 # define atomic_or(p,v)   __sync_or_and_fetch((p), (v))
33 #endif
34
35 #ifdef MAKE_STATIC
36 # define CONSTRUCTOR
37 #else
38 # define CONSTRUCTOR __attribute__ ((constructor))
39 #endif
40 #define VISIBLE     __attribute__((visibility("default")))
41
42
43 #endif  /* _PTWQ_POSIX_PLATFORM_H */