#define PA_STATIC_FLIST_DECLARE(name, size, free_cb) \
static struct { \
- pa_flist *flist; \
+ pa_flist *volatile flist; \
pa_once once; \
} name##_flist = { NULL, PA_ONCE_INIT }; \
static void name##_flist_init(void) { \
#include "once.h"
pa_bool_t pa_once_begin(pa_once *control) {
- pa_mutex *m;
-
pa_assert(control);
if (pa_atomic_load(&control->done))
* executed by us. Hence the awkward locking. */
for (;;) {
+ pa_mutex *m;
if ((m = pa_atomic_ptr_load(&control->mutex))) {
pa_assert(thread_func);
- t = pa_xnew(pa_thread, 1);
+ t = pa_xnew0(pa_thread, 1);
t->thread_func = thread_func;
t->userdata = userdata;
- t->joined = FALSE;
- pa_atomic_store(&t->running, 0);
if (pthread_create(&t->id, NULL, internal_thread_func, t) < 0) {
pa_xfree(t);
/* This is a foreign thread, let's create a pthread structure to
* make sure that we can always return a sensible pointer */
- t = pa_xnew(pa_thread, 1);
+ t = pa_xnew0(pa_thread, 1);
t->id = pthread_self();
- t->thread_func = NULL;
- t->userdata = NULL;
t->joined = TRUE;
pa_atomic_store(&t->running, 2);