xref: /unit/src/nxt_thread_id.h (revision 223:bf98efe2c55c)
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_LINUX)
12 
13 typedef pid_t      nxt_tid_t;
14 
15 #elif (NXT_FREEBSD)
16 
17 typedef uint32_t   nxt_tid_t;
18 
19 #elif (NXT_SOLARIS)
20 
21 typedef pthread_t  nxt_tid_t;
22 
23 #elif (NXT_MACOSX)
24 
25 typedef uint64_t   nxt_tid_t;
26 
27 #elif (NXT_AIX)
28 
29 typedef tid_t      nxt_tid_t;
30 
31 #elif (NXT_HPUX)
32 
33 typedef pthread_t  nxt_tid_t;
34 
35 #else
36 
37 typedef pthread_t  nxt_tid_t;
38 
39 #endif
40 
41 
42 NXT_EXPORT nxt_tid_t nxt_thread_tid(nxt_thread_t *thr);
43 
44 
45 /*
46  * On Linux pthread_t is unsigned long integer.
47  * On FreeBSD, MacOSX, NetBSD, and OpenBSD pthread_t is pointer to a struct.
48  * On Solaris and AIX pthread_t is unsigned integer.
49  * On HP-UX pthread_t is int.
50  * On Cygwin pthread_t is pointer to void.
51  * On z/OS pthread_t is "struct { char __[0x08]; }".
52  */
53 typedef pthread_t  nxt_thread_handle_t;
54 
55 
56 #define                                                                       \
57 nxt_thread_handle_clear(th)                                                   \
58     th = (pthread_t) 0
59 
60 #define                                                                       \
61 nxt_thread_handle_equal(th0, th1)                                             \
62     pthread_equal(th0, th1)
63 
64 
65 #endif /* _NXT_UNIX_THREAD_ID_H_INCLUDED_ */
66