annotate Resources/Patches/glog-utilities-lsb.diff @ 994:b3d4f8a30324 lua-scripting

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