summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_thread_id.h
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
commit16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch)
treee6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_thread_id.h
downloadunit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz
unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2
Initial version.
Diffstat (limited to 'src/nxt_thread_id.h')
-rw-r--r--src/nxt_thread_id.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/nxt_thread_id.h b/src/nxt_thread_id.h
new file mode 100644
index 00000000..d083b8fc
--- /dev/null
+++ b/src/nxt_thread_id.h
@@ -0,0 +1,81 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_UNIX_THREAD_ID_H_INCLUDED_
+#define _NXT_UNIX_THREAD_ID_H_INCLUDED_
+
+
+#if (NXT_THREADS)
+
+
+#if (NXT_LINUX)
+
+typedef pid_t nxt_tid_t;
+
+#elif (NXT_FREEBSD)
+
+typedef uint32_t nxt_tid_t;
+
+#elif (NXT_SOLARIS)
+
+typedef pthread_t nxt_tid_t;
+
+#elif (NXT_MACOSX)
+
+typedef uint64_t nxt_tid_t;
+
+#elif (NXT_AIX)
+
+typedef tid_t nxt_tid_t;
+
+#elif (NXT_HPUX)
+
+typedef pthread_t nxt_tid_t;
+
+#else
+
+typedef pthread_t nxt_tid_t;
+
+#endif
+
+
+NXT_EXPORT nxt_tid_t nxt_thread_tid(nxt_thread_t *thr);
+
+
+/*
+ * On Linux pthread_t is unsigned long integer.
+ * On FreeBSD, MacOSX, NetBSD, and OpenBSD pthread_t is pointer to a struct.
+ * On Solaris and AIX pthread_t is unsigned integer.
+ * On HP-UX pthread_t is int.
+ * On Cygwin pthread_t is pointer to void.
+ * On z/OS pthread_t is "struct { char __[0x08]; }".
+ */
+typedef pthread_t nxt_thread_handle_t;
+
+
+#define \
+nxt_thread_handle_clear(th) \
+ th = (pthread_t) 0
+
+#define \
+nxt_thread_handle_equal(th0, th1) \
+ pthread_equal(th0, th1)
+
+
+#else /* !(NXT_THREADS) */
+
+typedef uint32_t nxt_tid_t;
+typedef uint32_t nxt_thread_handle_t;
+
+
+#define \
+nxt_thread_tid(thr) \
+ 0
+
+#endif
+
+
+#endif /* _NXT_UNIX_THREAD_ID_H_INCLUDED_ */