diff options
author | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2007-07-18 18:30:50 +0000 |
---|---|---|
committer | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2007-07-18 18:30:50 +0000 |
commit | c437e1fcdd1e6ff3f032928d460cbfc115e2324f (patch) | |
tree | 482360b82db4bc64880e187b9b5af82e840df47c /src/maybe_threads.cc | |
parent | 6878379d5bab87c787cdd3487b5620a9c8adf376 (diff) | |
download | gperftools-c437e1fcdd1e6ff3f032928d460cbfc115e2324f.tar.gz |
Tue Jul 17 22:26:27 2007 Google Inc. <opensource@google.com>
* google-perftools: version 0.92 release
* PERFORMANCE: use a packed cache to speed up tcmalloc
* PORTING: preliminary windows support! (see README.windows)
* PORTING: better support for solaris, OS X, FreeBSD (see INSTALL)
* Envvar support for running the heap-checker under gdb
* Add weak declarations to maybe_threads to fix no-pthreads compile bugs
* Some 64bit fixes, especially with pprof
* Better heap-checker support for some low-level allocations
* Fix bug where heap-profiles would sometimes get truncated
* New documentation about how to handle common heap leak situations
* Use computed includes for hash_map/set: easier config
* Added all used .m4 templates to the distribution
git-svn-id: http://gperftools.googlecode.com/svn/trunk@36 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/maybe_threads.cc')
-rw-r--r-- | src/maybe_threads.cc | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/maybe_threads.cc b/src/maybe_threads.cc index ebbc1e1..a3e0450 100644 --- a/src/maybe_threads.cc +++ b/src/maybe_threads.cc @@ -29,29 +29,46 @@ // --- // Author: Paul Menage <opensource@google.com> - -//------------------------------------------------------------------- +// // Some wrappers for pthread functions so that we can be LD_PRELOADed // against non-pthreads apps. -//------------------------------------------------------------------- +// +// This module will behave very strangely if some pthreads functions +// exist and others don't. #include "config.h" #include <assert.h> -#include <pthread.h> // 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 // non-zero. I have no idea why ... #include <string> #include "maybe_threads.h" +#include "base/basictypes.h" + +// __THROW is defined in glibc systems. It means, counter-intuitively, +// "This function will never throw an exception." It's an optional +// optimization tool, but we may need to use it to match glibc prototypes. +#ifndef __THROW // I guess we're not on a glibc system +# define __THROW // __THROW is just an optimization, so ok to make it "" +#endif + +// These are the methods we're going to conditionally include. +extern "C" { + int pthread_key_create (pthread_key_t*, void (*)(void*)) + __THROW ATTRIBUTE_WEAK; + void *pthread_getspecific(pthread_key_t) + __THROW ATTRIBUTE_WEAK; + int pthread_setspecific(pthread_key_t, const void*) + __THROW ATTRIBUTE_WEAK; + int pthread_once(pthread_once_t *, void (*)(void)) + __THROW ATTRIBUTE_WEAK; +} #define MAX_PERTHREAD_VALS 16 static void *perftools_pthread_specific_vals[MAX_PERTHREAD_VALS]; 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, void (*destr_function) (void *)) { if (pthread_key_create) { @@ -82,7 +99,7 @@ int perftools_pthread_setspecific(pthread_key_t key, void *val) { static pthread_once_t pthread_once_init = PTHREAD_ONCE_INIT; int perftools_pthread_once(pthread_once_t *ctl, - void (*init_routine) (void)) { + void (*init_routine) (void)) { if (pthread_once) { return pthread_once(ctl, init_routine); } else { |