mutex: add initializer for static mutexes
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Apr 2009 19:25:01 +0000 (21:25 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Apr 2009 19:25:01 +0000 (21:25 +0200)
src/pulsecore/mutex.h
src/pulsecore/ratelimit.c

index a4dd673..b1edc13 100644 (file)
@@ -46,10 +46,14 @@ void pa_cond_free(pa_cond *c);
 void pa_cond_signal(pa_cond *c, int broadcast);
 int pa_cond_wait(pa_cond *c, pa_mutex *m);
 
+/* Static mutexes are basically just atomically updated pointers to pa_mutex objects */
+
 typedef struct pa_static_mutex {
     pa_atomic_ptr_t ptr;
 } pa_static_mutex;
 
+#define PA_STATIC_MUTEX_INIT { PA_ATOMIC_PTR_INIT(NULL) }
+
 pa_mutex* pa_static_mutex_get(pa_static_mutex *m, pa_bool_t recursive, pa_bool_t inherit_priority);
 
 #endif
index 29e6fb1..e913ca1 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "ratelimit.h"
 
-static pa_static_mutex mutex;
+static pa_static_mutex mutex = PA_STATIC_MUTEX_INIT;
 
 /* Modelled after Linux' lib/ratelimit.c by Dave Young
  * <hidave.darkstar@gmail.com>, which is licensed GPLv2. */