blob: 03b087fc2c19a376216abf3459592a6d2360b987 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
--- a/lib/direct/os/linux/glibc/mutex.h
+++ b/lib/direct/os/linux/glibc/mutex.h
@@ -46,7 +46,6 @@ struct __D_DirectMutex {
/**********************************************************************************************************************/
#define DIRECT_MUTEX_INITIALIZER(name) { PTHREAD_MUTEX_INITIALIZER }
-#define DIRECT_RECURSIVE_MUTEX_INITIALIZER(name) { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP }
#endif
--- a/lib/direct/trace.c
+++ b/lib/direct/trace.c
@@ -89,7 +89,7 @@ struct __D_DirectTraceBuffer {
/**************************************************************************************************/
static DirectLink *buffers;
-static DirectMutex buffers_lock = DIRECT_RECURSIVE_MUTEX_INITIALIZER(buffers_lock);
+static DirectMutex buffers_lock = DIRECT_MUTEX_INITIALIZER(buffers_lock);
/**************************************************************************************************/
--- a/src/directfb.c
+++ b/src/directfb.c
@@ -163,6 +163,15 @@ DirectFBSetOption( const char *name, const char *value )
return DFB_OK;
}
+
+static pthread_once_t lock_init_once = PTHREAD_ONCE_INIT;
+static DirectMutex lock;
+
+static void lock_init(void)
+{
+ direct_recursive_mutex_init(&lock);
+}
+
/*
* Programs have to call this to get the super interface
* which is needed to access other functions
@@ -215,7 +224,7 @@ DirectFBCreate( IDirectFB **interface_ptr )
if (dfb_config->remote.host)
return CreateRemote( dfb_config->remote.host, dfb_config->remote.port, interface_ptr );
- static DirectMutex lock = DIRECT_RECURSIVE_MUTEX_INITIALIZER(lock);
+ pthread_once(&lock_init_once, lock_init);
direct_mutex_lock( &lock );
|