diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-20 19:27:16 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-20 19:27:16 +0000 |
commit | 015e850f64af9428d24d916dd3165df23aab3812 (patch) | |
tree | e2fc85364fe8e6c2cd83a7a47a9ede58d9296aff | |
parent | c1d5022564c2b0c5aaae139ef3d9b0510ca25590 (diff) | |
download | chromium_src-015e850f64af9428d24d916dd3165df23aab3812.zip chromium_src-015e850f64af9428d24d916dd3165df23aab3812.tar.gz chromium_src-015e850f64af9428d24d916dd3165df23aab3812.tar.bz2 |
Replicate r59512 for localtime_r
Use magic to init our 'localtime_r' wrapper.
(See bug for details.)
Patch-by: kcc (Chromium)
BUG=54264
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59956 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/zygote_main_linux.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc index b4dd7be..c913788 100644 --- a/chrome/browser/zygote_main_linux.cc +++ b/chrome/browser/zygote_main_linux.cc @@ -543,12 +543,11 @@ struct tm* localtime_r(const time_t* timep, struct tm* result) { } else { typedef struct tm* (*LocaltimeRFunction)(const time_t* timep, struct tm* result); - static LocaltimeRFunction libc_localtime_r; - static bool have_libc_localtime_r = false; - if (!have_libc_localtime_r) { - libc_localtime_r = (LocaltimeRFunction) dlsym(RTLD_NEXT, "localtime_r"); - have_libc_localtime_r = 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 LocaltimeRFunction libc_localtime_r = + (LocaltimeRFunction) dlsym(RTLD_NEXT, "localtime_r"); if (!libc_localtime_r) { // See |localtime|, above. |