|
39 | 39 | #include <unistd.h> |
40 | 40 | #include <chrono> |
41 | 41 |
|
42 | | -#elif __FreeBSD__ |
43 | | -#include <sys/thr.h> //Use thr_self() syscall under FreeBSD to get thread id |
| 42 | +#elif defined(_AIX) |
| 43 | +#include <pthread.h> // for pthread_getthreadid_np |
| 44 | + |
| 45 | +#elif defined(__DragonFly__) || defined(__FreeBSD__) |
| 46 | +#include <pthread_np.h> // for pthread_getthreadid_np |
| 47 | + |
| 48 | +#elif defined(__NetBSD__) |
| 49 | +#include <lwp.h> // for _lwp_self |
| 50 | + |
| 51 | +#elif defined(__OpenBSD__) |
| 52 | +#include <unistd.h> // for getthrid |
| 53 | + |
| 54 | +#elif defined(__sun) |
| 55 | +#include <thread.h> // for thr_self |
44 | 56 |
|
45 | 57 | #else |
46 | 58 | #include <thread> |
@@ -213,7 +225,7 @@ inline size_t filesize(FILE *f) |
213 | 225 | #else // unix |
214 | 226 | int fd = fileno(f); |
215 | 227 | //64 bits(but not in osx, where fstat64 is deprecated) |
216 | | -#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) |
| 228 | +#if (defined(__linux__) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64)) |
217 | 229 | struct stat64 st; |
218 | 230 | if (fstat64(fd, &st) == 0) |
219 | 231 | return static_cast<size_t>(st.st_size); |
@@ -302,10 +314,14 @@ inline size_t thread_id() |
302 | 314 | # define SYS_gettid __NR_gettid |
303 | 315 | # endif |
304 | 316 | return static_cast<size_t>(syscall(SYS_gettid)); |
305 | | -#elif __FreeBSD__ |
306 | | - long tid; |
307 | | - thr_self(&tid); |
308 | | - return static_cast<size_t>(tid); |
| 317 | +#elif defined(_AIX) || defined(__DragonFly__) || defined(__FreeBSD__) |
| 318 | + return static_cast<size_t>(pthread_getthreadid_np()); |
| 319 | +#elif defined(__NetBSD__) |
| 320 | + return static_cast<size_t>(_lwp_self()); |
| 321 | +#elif defined(__OpenBSD__) |
| 322 | + return static_cast<size_t>(getthrid()); |
| 323 | +#elif defined(__sun) |
| 324 | + return static_cast<size_t>(thr_self()); |
309 | 325 | #else //Default to standard C++11 (OSX and other Unix) |
310 | 326 | return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id())); |
311 | 327 | #endif |
|
0 commit comments