Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: third_party/tcmalloc/chromium/src/maybe_threads.cc

Issue 7430007: Merge tcmalloc r111 (perftools v. 1.8) with the chromium/ branch. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/maybe_threads.cc
===================================================================
--- third_party/tcmalloc/chromium/src/maybe_threads.cc (revision 94429)
+++ third_party/tcmalloc/chromium/src/maybe_threads.cc (working copy)
@@ -39,6 +39,7 @@
#include "config.h"
#include <assert.h>
#include <string.h> // for memcmp
+#include <stdio.h> // for __isthreaded on FreeBSD
// We don't actually need strings. But including this header seems to
// stop the compiler trying to short-circuit our pthreads existence
// tests and claiming that the address of a function is always
@@ -98,9 +99,28 @@
}
}
+
static pthread_once_t pthread_once_init = PTHREAD_ONCE_INIT;
int perftools_pthread_once(pthread_once_t *ctl,
void (*init_routine) (void)) {
+#ifdef __FreeBSD__
+ // On __FreeBSD__, calling pthread_once on a system that is not
+ // linked with -pthread is silently a noop. :-( Luckily, we have a
+ // workaround: FreeBSD exposes __isthreaded in <stdio.h>, which is
+ // set to 1 when the first thread is spawned. So on those systems,
+ // we can use our own separate pthreads-once mechanism, which is
+ // used until __isthreaded is 1 (which will never be true if the app
+ // is not linked with -pthread).
+ static bool pthread_once_ran_before_threads = false;
+ if (pthread_once_ran_before_threads) {
+ return 0;
+ }
+ if (!__isthreaded) {
+ init_routine();
+ pthread_once_ran_before_threads = true;
+ return 0;
+ }
+#endif
if (pthread_once) {
return pthread_once(ctl, init_routine);
} else {
Property changes on: third_party/tcmalloc/chromium/src/maybe_threads.cc
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/src/third_party/tcmalloc/vendor/src/maybe_threads.cc:r93000

Powered by Google App Engine
This is Rietveld 408576698