Skip to content

Commit 6ef84f2

Browse files
[libc][pthread] fix -Wmissing-field-initializers
Fixes: llvm-project/libc/test/integration/src/pthread/pthread_rwlock_test.cpp:59:29: warning: missing field '__preference' initializer [-Wmissing-field-initializers] 59 | pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; | ^ Also, add a test that demonstrates the same issue for PTHREAD_MUTEX_INITIALIZER, and fix that, too. PTHREAD_ONCE_INIT does not have this issue and does have test coverage.
1 parent 72aa388 commit 6ef84f2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#define PTHREAD_PROCESS_PRIVATE 0
2626
#define PTHREAD_PROCESS_SHARED 1
2727

28-
#define PTHREAD_MUTEX_INITIALIZER {0}
29-
#define PTHREAD_RWLOCK_INITIALIZER {0}
28+
#define PTHREAD_MUTEX_INITIALIZER {}
29+
#define PTHREAD_RWLOCK_INITIALIZER {}
3030

3131
// glibc extensions
3232
#define PTHREAD_STACK_MIN (1 << 14) // 16KB

libc/test/integration/src/pthread/pthread_mutex_test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ void multiple_waiters() {
186186
LIBC_NAMESPACE::pthread_mutex_destroy(&counter_lock);
187187
}
188188

189+
// Test the initializer
190+
[[gnu::unused]]
191+
static pthread_mutex_t test_initializer = PTHREAD_MUTEX_INITIALIZER;
192+
189193
TEST_MAIN() {
190194
relay_counter();
191195
wait_and_step();

0 commit comments

Comments
 (0)