summaryrefslogtreecommitdiffstats
path: root/chrome/browser/zygote_main_linux.cc
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-15 17:34:25 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-15 17:34:25 +0000
commit16b7123730e79f41519d1e8221d0cb0619a89b7c (patch)
treee167f6481501cca760bc9cecdf7c56068113c292 /chrome/browser/zygote_main_linux.cc
parent683e08ff79a7d61902a5d9ef6320a788f554d70d (diff)
downloadchromium_src-16b7123730e79f41519d1e8221d0cb0619a89b7c.zip
chromium_src-16b7123730e79f41519d1e8221d0cb0619a89b7c.tar.gz
chromium_src-16b7123730e79f41519d1e8221d0cb0619a89b7c.tar.bz2
Use magic to init our 'localtime' wrapper.
(See bug for details.) Patch-by: kcc (Chromium) BUG=54264 TEST=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59512 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/zygote_main_linux.cc')
-rw-r--r--chrome/browser/zygote_main_linux.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc
index 98f4701..3e3265a 100644
--- a/chrome/browser/zygote_main_linux.cc
+++ b/chrome/browser/zygote_main_linux.cc
@@ -465,12 +465,11 @@ struct tm* localtime(const time_t* timep) {
return &time_struct;
} else {
typedef struct tm* (*LocaltimeFunction)(const time_t* timep);
- static LocaltimeFunction libc_localtime;
- static bool have_libc_localtime = false;
- if (!have_libc_localtime) {
- libc_localtime = (LocaltimeFunction) dlsym(RTLD_NEXT, "localtime");
- have_libc_localtime = true;
- }
+ // This static declaration is desugared by the compiler into a locked
+ // initialisation which will only call dlsym once, across all threads.
+ // See: http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01598.html
+ static LocaltimeFunction libc_localtime =
+ (LocaltimeFunction) dlsym(RTLD_NEXT, "localtime");
if (!libc_localtime) {
// http://code.google.com/p/chromium/issues/detail?id=16800