Skip to content

Commit c380f97

Browse files
switch to aggregate initialization
1 parent 6ef84f2 commit c380f97

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

libc/include/llvm-libc-macros/pthread-macros.h

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef LLVM_LIBC_MACROS_PTHREAD_MACRO_H
1010
#define LLVM_LIBC_MACROS_PTHREAD_MACRO_H
1111

12+
#include "include/llvm-libc-macros/null-macro.h"
13+
1214
#define PTHREAD_CREATE_JOINABLE 0
1315
#define PTHREAD_CREATE_DETACHED 1
1416

@@ -25,8 +27,55 @@
2527
#define PTHREAD_PROCESS_PRIVATE 0
2628
#define PTHREAD_PROCESS_SHARED 1
2729

28-
#define PTHREAD_MUTEX_INITIALIZER {}
29-
#define PTHREAD_RWLOCK_INITIALIZER {}
30+
#ifdef __linux__
31+
#define PTHREAD_MUTEX_INITIALIZER \
32+
{ \
33+
/* .__timed = */ 0, \
34+
/* .__recursive = */ 0, \
35+
/* .__robust = */ 0, \
36+
/* .__owner = */ NULL, \
37+
/* .__lock_count = */ 0, \
38+
/* .__futex_word = */ \
39+
{ \
40+
/* .__word = */ 0, \
41+
}, \
42+
}
43+
#else
44+
#define PTHREAD_MUTEX_INITIALIZER \
45+
{ \
46+
/* .__timed = */ 0, /* .__recursive = */ 0, \
47+
/* .__robust = */ 0, /* .__owner = */ NULL, \
48+
/* .__lock_count = */ 0, \
49+
}
50+
#endif
51+
52+
#define PTHREAD_RWLOCK_INITIALIZER \
53+
{ \
54+
/* .__is_pshared = */ 0, \
55+
/* .__preference = */ 0, \
56+
/* .__state = */ 0, \
57+
/* .__write_tid = */ 0, \
58+
/* .__wait_queue_mutex = */ \
59+
{ \
60+
/* .__word = */ 0, \
61+
}, \
62+
/* .__pending_readers = */ \
63+
{ \
64+
/* .__word = */ 0, \
65+
}, \
66+
/* .__pending_writers = */ \
67+
{ \
68+
/* .__word = */ 0, \
69+
}, \
70+
/* .__reader_serialization = */ \
71+
{ \
72+
/* .__word = */ 0, \
73+
}, \
74+
/* .__writer_serialization = */ \
75+
{ \
76+
/* .__word = */ 0, \
77+
}, \
78+
}
3079

3180
// glibc extensions
3281
#define PTHREAD_STACK_MIN (1 << 14) // 16KB

0 commit comments

Comments
 (0)