| * Copyright (C) Igor Sysoev |
| * Copyright (C) Nginx, Inc. |
| #include <ngx_thread_pool.h> |
| * Linux thread id is a pid of thread created by clone(2), |
| * glibc does not provide a wrapper for gettid(). |
| return syscall(SYS_gettid); |
| #elif (NGX_FREEBSD) && (__FreeBSD_version >= 900031) |
| return pthread_getthreadid_np(); |
| * MacOSX thread has two thread ids: |
| * 1) MacOSX 10.6 (Snow Leoprad) has pthread_threadid_np() returning |
| * an uint64_t value, which is obtained using the __thread_selfid() |
| * syscall. It is a number above 300,000. |
| (void) pthread_threadid_np(NULL, &tid); |
| * 2) Kernel thread mach_port_t returned by pthread_mach_thread_np(). |
| * It is a number in range 100-100,000. |
| * return pthread_mach_thread_np(pthread_self()); |
| return (uint64_t) (uintptr_t) pthread_self(); |