1 |
--- va/va_trace.c.orig 2018-02-12 06:32:11 UTC |
2 |
+++ va/va_trace.c |
3 |
@@ -50,6 +50,9 @@ |
4 |
#include <sys/stat.h> |
5 |
#include <sys/syscall.h> |
6 |
#include <pthread.h> |
7 |
+#ifdef __FreeBSD__ |
8 |
+#include <pthread_np.h> |
9 |
+#endif |
10 |
#include <unistd.h> |
11 |
#include <time.h> |
12 |
#include <errno.h> |
13 |
@@ -290,7 +293,13 @@ static void add_trace_config_info( |
14 |
{ |
15 |
struct trace_config_info *pconfig_info; |
16 |
int idx = 0; |
17 |
+#ifdef __FreeBSD__ |
18 |
+ pid_t thd_id = pthread_getthreadid_np(); |
19 |
+#elif defined __DragonFly__ |
20 |
+ pid_t thd_id = syscall(SYS_lwp_gettid); |
21 |
+#else |
22 |
pid_t thd_id = syscall(__NR_gettid); |
23 |
+#endif |
24 |
|
25 |
LOCK_RESOURCE(pva_trace); |
26 |
|
27 |
@@ -668,7 +677,13 @@ static struct trace_log_file *start_tracing2log_file( |
28 |
{ |
29 |
struct trace_log_files_manager *plog_files_mgr = NULL; |
30 |
struct trace_log_file *plog_file = NULL; |
31 |
+#ifdef __FreeBSD__ |
32 |
+ pid_t thd_id = pthread_getthreadid_np(); |
33 |
+#elif defined __DragonFly__ |
34 |
+ pid_t thd_id = syscall(SYS_lwp_gettid); |
35 |
+#else |
36 |
pid_t thd_id = syscall(__NR_gettid); |
37 |
+#endif |
38 |
int i = 0; |
39 |
|
40 |
LOCK_RESOURCE(pva_trace); |
41 |
@@ -707,7 +722,13 @@ static void refresh_log_file( |
42 |
struct trace_context *ptra_ctx) |
43 |
{ |
44 |
struct trace_log_file *plog_file = NULL; |
45 |
+#ifdef __FreeBSD__ |
46 |
+ pid_t thd_id = pthread_getthreadid_np(); |
47 |
+#elif defined __DragonFly__ |
48 |
+ pid_t thd_id = syscall(SYS_lwp_gettid); |
49 |
+#else |
50 |
pid_t thd_id = syscall(__NR_gettid); |
51 |
+#endif |
52 |
int i = 0; |
53 |
|
54 |
plog_file = ptra_ctx->plog_file; |
55 |
@@ -1230,7 +1251,13 @@ static void internal_TraceUpdateContext ( |
56 |
{ |
57 |
struct trace_context *trace_ctx = NULL; |
58 |
int i = 0, delete = 1; |
59 |
+#ifdef __FreeBSD__ |
60 |
+ pid_t thd_id = pthread_getthreadid_np(); |
61 |
+#elif defined __DragonFly__ |
62 |
+ pid_t thd_id = syscall(SYS_lwp_gettid); |
63 |
+#else |
64 |
pid_t thd_id = syscall(__NR_gettid); |
65 |
+#endif |
66 |
|
67 |
if(tra_ctx_idx >= MAX_TRACE_CTX_NUM) |
68 |
return; |