1 #ifndef _TEST_THREAD_ID_H
2 #define _TEST_THREAD_ID_H
7 * Userspace RCU library - thread ID
9 * Copyright 2013 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
11 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
12 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
14 * Permission is hereby granted to use or copy this program
15 * for any purpose, provided the above notices are retained on all copies.
16 * Permission to modify the code and to distribute modified code is granted,
17 * provided the above notices are retained, and a notice that the code was
18 * modified is included with the above copyright notice.
23 # include <urcu/syscall-compat.h>
25 # if defined(HAVE_GETTID)
27 * Do not redefine gettid() as it is already included
28 * in bionic through <unistd.h>. Some other libc
29 * may also already contain an implementation of gettid.
31 # elif defined(_syscall0)
32 _syscall0(pid_t
, gettid
)
33 # elif defined(__NR_gettid)
34 static inline pid_t
gettid(void)
36 return syscall(__NR_gettid
);
41 unsigned long urcu_get_thread_id(void)
43 return (unsigned long) gettid();
45 #elif defined(__FreeBSD__)
46 # include <pthread_np.h>
49 unsigned long urcu_get_thread_id(void)
51 return (unsigned long) pthread_getthreadid_np();
54 # warning "use pid as thread ID"
56 unsigned long urcu_get_thread_id(void)
58 return (unsigned long) getpid();
62 #endif /* _TEST_THREAD_ID_H */
This page took 0.03033 seconds and 4 git commands to generate.