561
|
1 --- utilities.cc.orig 2012-01-12 09:40:21.000000000 +0100
|
|
2 +++ utilities.cc 2013-09-23 17:37:35.033275313 +0200
|
|
3 @@ -233,40 +233,7 @@
|
|
4 }
|
|
5
|
|
6 pid_t GetTID() {
|
|
7 - // On Linux and FreeBSD, we try to use gettid().
|
|
8 -#if defined OS_LINUX || defined OS_FREEBSD || defined OS_MACOSX
|
|
9 -#ifndef __NR_gettid
|
|
10 -#ifdef OS_MACOSX
|
|
11 -#define __NR_gettid SYS_gettid
|
|
12 -#elif ! defined __i386__
|
|
13 -#error "Must define __NR_gettid for non-x86 platforms"
|
|
14 -#else
|
|
15 -#define __NR_gettid 224
|
|
16 -#endif
|
|
17 -#endif
|
|
18 - static bool lacks_gettid = false;
|
|
19 - if (!lacks_gettid) {
|
|
20 - pid_t tid = syscall(__NR_gettid);
|
|
21 - if (tid != -1) {
|
|
22 - return tid;
|
|
23 - }
|
|
24 - // Technically, this variable has to be volatile, but there is a small
|
|
25 - // performance penalty in accessing volatile variables and there should
|
|
26 - // not be any serious adverse effect if a thread does not immediately see
|
|
27 - // the value change to "true".
|
|
28 - lacks_gettid = true;
|
|
29 - }
|
|
30 -#endif // OS_LINUX || OS_FREEBSD
|
|
31 -
|
|
32 - // If gettid() could not be used, we use one of the following.
|
|
33 -#if defined OS_LINUX
|
|
34 - return getpid(); // Linux: getpid returns thread ID when gettid is absent
|
|
35 -#elif defined OS_WINDOWS || defined OS_CYGWIN
|
|
36 - return GetCurrentThreadId();
|
|
37 -#else
|
|
38 - // If none of the techniques above worked, we use pthread_self().
|
|
39 return (pid_t)(uintptr_t)pthread_self();
|
|
40 -#endif
|
|
41 }
|
|
42
|
|
43 const char* const_basename(const char* filepath) {
|
|
44 @@ -295,7 +262,7 @@
|
|
45 g_my_user_name = "invalid-user";
|
|
46 }
|
|
47 }
|
|
48 -REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer());
|
|
49 +REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer())
|
|
50
|
|
51 #ifdef HAVE_STACKTRACE
|
|
52 void DumpStackTraceToString(string* stacktrace) {
|