summaryrefslogtreecommitdiff
path: root/src/maybe_threads.cc
diff options
context:
space:
mode:
authorcsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2007-04-16 20:49:32 +0000
committercsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2007-04-16 20:49:32 +0000
commit74ad5d57ec08abace386befc6c3c695d85f44d1a (patch)
tree1a5611be12a74fde48de69d13476ab02ca7d20cc /src/maybe_threads.cc
parentddbf2f027fb4ca8781fd50820ceb870570f414bc (diff)
downloadgperftools-74ad5d57ec08abace386befc6c3c695d85f44d1a.tar.gz
Fri Apr 13 14:50:51 2007 Google Inc. <opensource@google.com>
* google-perftools: version 0.90 release * (As the version-number jump hints, this is a major new release: almost every piece of functionality was rewritten. I can't do justice to all the changes, but will concentrate on highlights.) *** USER-VISIBLE CHANGES: * Ability to "release" unused memory added to tcmalloc * Exposed more tweaking knobs via environment variables (see docs) * pprof tries harder to map addresses to functions * tcmalloc_minimal compiles and runs on FreeBSD 6.0 and Solaris 10 *** INTERNAL CHANGES: * Much better 64-bit support * Better multiple-processor support (e.g. multicore contention tweaks) * Support for recent kernel ABI changes (e.g. new arg to mremap) * Addition of spinlocks to tcmalloc to reduce contention cost * Speed up tcmalloc by using __thread on systems that support TLS * Total redesign of heap-checker to improve liveness checking * More portable stack-frame analysis -- no more hard-coded constants! * Disentangled heap-profiler code and heap-checker code * Several new unittests to test, e.g., thread-contention costs * Lots of small (but important!) bug fixes: e.g., fixing GetPC on amd64 *** KNOWN PROBLEMS: * CPU-profiling may crash on x86_64 (64-bit) systems. See the README * Profiling/heap-checking may deadlock on x86_64 systems. See README git-svn-id: http://gperftools.googlecode.com/svn/trunk@28 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/maybe_threads.cc')
-rw-r--r--src/maybe_threads.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/maybe_threads.cc b/src/maybe_threads.cc
index 38fd25f..ebbc1e1 100644
--- a/src/maybe_threads.cc
+++ b/src/maybe_threads.cc
@@ -52,7 +52,7 @@ static pthread_key_t next_key;
// This module will behave very strangely if some pthreads functions
// exist and others don't
-int perftools_pthread_key_create(pthread_key_t *key,
+int perftools_pthread_key_create(pthread_key_t *key,
void (*destr_function) (void *)) {
if (pthread_key_create) {
return pthread_key_create(key, destr_function);
@@ -63,7 +63,7 @@ int perftools_pthread_key_create(pthread_key_t *key,
}
}
-void *perftools_pthread_getspecific(pthread_key_t key) {
+void *perftools_pthread_getspecific(pthread_key_t key) {
if (pthread_getspecific) {
return pthread_getspecific(key);
} else {
@@ -80,14 +80,15 @@ int perftools_pthread_setspecific(pthread_key_t key, void *val) {
}
}
-int perftools_pthread_once(pthread_once_t *ctl,
+static pthread_once_t pthread_once_init = PTHREAD_ONCE_INIT;
+int perftools_pthread_once(pthread_once_t *ctl,
void (*init_routine) (void)) {
if (pthread_once) {
return pthread_once(ctl, init_routine);
} else {
- if (*ctl == PTHREAD_ONCE_INIT) {
+ if (memcmp(ctl, &pthread_once_init, sizeof(*ctl)) == 0) {
init_routine();
- *ctl = 1;
+ ++*(char*)(ctl); // make it so it's no longer equal to init
}
return 0;
}