#ifndef foopulsethreadhfoo
#define foopulsethreadhfoo
-/* $Id$ */
-
/***
This file is part of PulseAudio.
#include <pulse/def.h>
#include <pulsecore/once.h>
+#include <pulsecore/core-util.h>
-/* We have to include config.h here (for the __tls stuff), which sucks */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#ifndef PACKAGE
+#error "Please include config.h before including this file!"
#endif
typedef struct pa_thread pa_thread;
} \
static void name##_tls_destructor(void) PA_GCC_DESTRUCTOR; \
static void name##_tls_destructor(void) { \
- if (name##_tls.tls) \
- pa_tls_free(name##_tls.tls); \
+ static void (*_free_cb)(void*) = free_cb; \
+ if (!pa_in_valgrind()) \
+ return; \
+ if (!name##_tls.tls) \
+ return; \
+ if (_free_cb) { \
+ void *p; \
+ if ((p = pa_tls_get(name##_tls.tls))) \
+ _free_cb(p); \
+ } \
+ pa_tls_free(name##_tls.tls); \
} \
static inline void* name##_tls_get(void) { \
return pa_tls_get(name##_tls_obj()); \
} \
struct __stupid_useless_struct_to_allow_trailing_semicolon
-#ifdef HAVE_TLS_BUILTIN
+#ifdef SUPPORT_TLS___THREAD
/* An optimized version of the above that requires no dynamic
* allocation if the compiler supports __thread */
#define PA_STATIC_TLS_DECLARE_NO_FREE(name) \
- static __thread void *name##_tls; \
+ static __thread void *name##_tls = NULL; \
static inline void* name##_tls_get(void) { \
return name##_tls; \
} \