xref: /unit/src/nxt_thread_id.h (revision 0:a63ceefd6ab0)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #ifndef _NXT_UNIX_THREAD_ID_H_INCLUDED_
8 #define _NXT_UNIX_THREAD_ID_H_INCLUDED_
9 
10 
11 #if (NXT_THREADS)
12 
13 
14 #if (NXT_LINUX)
15 
16 typedef pid_t      nxt_tid_t;
17 
18 #elif (NXT_FREEBSD)
19 
20 typedef uint32_t   nxt_tid_t;
21 
22 #elif (NXT_SOLARIS)
23 
24 typedef pthread_t  nxt_tid_t;
25 
26 #elif (NXT_MACOSX)
27 
28 typedef uint64_t   nxt_tid_t;
29 
30 #elif (NXT_AIX)
31 
32 typedef tid_t      nxt_tid_t;
33 
34 #elif (NXT_HPUX)
35 
36 typedef pthread_t  nxt_tid_t;
37 
38 #else
39 
40 typedef pthread_t  nxt_tid_t;
41 
42 #endif
43 
44 
45 NXT_EXPORT nxt_tid_t nxt_thread_tid(nxt_thread_t *thr);
46 
47 
48 /*
49  * On Linux pthread_t is unsigned long integer.
50  * On FreeBSD, MacOSX, NetBSD, and OpenBSD pthread_t is pointer to a struct.
51  * On Solaris and AIX pthread_t is unsigned integer.
52  * On HP-UX pthread_t is int.
53  * On Cygwin pthread_t is pointer to void.
54  * On z/OS pthread_t is "struct { char __[0x08]; }".
55  */
56 typedef pthread_t  nxt_thread_handle_t;
57 
58 
59 #define                                                                       \
60 nxt_thread_handle_clear(th)                                                   \
61     th = (pthread_t) 0
62 
63 #define                                                                       \
64 nxt_thread_handle_equal(th0, th1)                                             \
65     pthread_equal(th0, th1)
66 
67 
68 #else /* !(NXT_THREADS) */
69 
70 typedef uint32_t   nxt_tid_t;
71 typedef uint32_t   nxt_thread_handle_t;
72 
73 
74 #define                                                                       \
75 nxt_thread_tid(thr)                                                           \
76     0
77 
78 #endif
79 
80 
81 #endif /* _NXT_UNIX_THREAD_ID_H_INCLUDED_ */
82