diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index beabc1bc721849..4e7da2b67d9afd 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -806,7 +806,7 @@ def StdC : StandardSpec<"stdc"> { "thrd_join", RetValSpec, [ - ArgSpec, + ArgSpec, ArgSpec, ] >, diff --git a/libc/src/threads/thrd_join.cpp b/libc/src/threads/thrd_join.cpp index 4c3ecac34a4e95..e4cf5522db92f7 100644 --- a/libc/src/threads/thrd_join.cpp +++ b/libc/src/threads/thrd_join.cpp @@ -17,8 +17,8 @@ namespace __llvm_libc { static_assert(sizeof(thrd_t) == sizeof(__llvm_libc::Thread), "Mismatch between thrd_t and internal Thread."); -LLVM_LIBC_FUNCTION(int, thrd_join, (thrd_t * th, int *retval)) { - auto *thread = reinterpret_cast(th); +LLVM_LIBC_FUNCTION(int, thrd_join, (thrd_t th, int *retval)) { + auto *thread = reinterpret_cast(&th); int result = thread->join(retval); return result == 0 ? thrd_success : thrd_error; } diff --git a/libc/src/threads/thrd_join.h b/libc/src/threads/thrd_join.h index fc36503dc521c5..248bced10263ac 100644 --- a/libc/src/threads/thrd_join.h +++ b/libc/src/threads/thrd_join.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int thrd_join(thrd_t *thread, int *retval); +int thrd_join(thrd_t thread, int *retval); } // namespace __llvm_libc diff --git a/libc/test/integration/src/threads/call_once_test.cpp b/libc/test/integration/src/threads/call_once_test.cpp index 1de8a621779a2b..dcb3f2507ca16d 100644 --- a/libc/test/integration/src/threads/call_once_test.cpp +++ b/libc/test/integration/src/threads/call_once_test.cpp @@ -47,7 +47,7 @@ void call_from_5_threads() { for (unsigned int i = 0; i < NUM_THREADS; ++i) { int retval; - ASSERT_EQ(__llvm_libc::thrd_join(threads + i, &retval), + ASSERT_EQ(__llvm_libc::thrd_join(threads[i], &retval), static_cast(thrd_success)); ASSERT_EQ(retval, 0); } @@ -102,10 +102,10 @@ void test_synchronization() { static_cast(thrd_success)); int retval; - ASSERT_EQ(__llvm_libc::thrd_join(&t1, &retval), + ASSERT_EQ(__llvm_libc::thrd_join(t1, &retval), static_cast(thrd_success)); ASSERT_EQ(retval, 0); - ASSERT_EQ(__llvm_libc::thrd_join(&t2, &retval), + ASSERT_EQ(__llvm_libc::thrd_join(t2, &retval), static_cast(thrd_success)); ASSERT_EQ(retval, 0); diff --git a/libc/test/integration/src/threads/cnd_test.cpp b/libc/test/integration/src/threads/cnd_test.cpp index 3690a979fe759c..c833fcb1775c11 100644 --- a/libc/test/integration/src/threads/cnd_test.cpp +++ b/libc/test/integration/src/threads/cnd_test.cpp @@ -77,7 +77,7 @@ void wait_notify_broadcast_test() { for (unsigned int i = 0; i < THRD_COUNT; ++i) { int retval = 0xBAD; - __llvm_libc::thrd_join(&threads[i], &retval); + __llvm_libc::thrd_join(threads[i], &retval); ASSERT_EQ(retval, 0); } @@ -134,7 +134,7 @@ void single_waiter_test() { ASSERT_EQ(__llvm_libc::mtx_unlock(&waiter_mtx), int(thrd_success)); int retval; - __llvm_libc::thrd_join(&waiter_thread, &retval); + __llvm_libc::thrd_join(waiter_thread, &retval); ASSERT_EQ(retval, 0x600D); __llvm_libc::mtx_destroy(&waiter_mtx); diff --git a/libc/test/integration/src/threads/mtx_test.cpp b/libc/test/integration/src/threads/mtx_test.cpp index 34e060a4a0d55c..cb955c97008e71 100644 --- a/libc/test/integration/src/threads/mtx_test.cpp +++ b/libc/test/integration/src/threads/mtx_test.cpp @@ -64,7 +64,7 @@ void relay_counter() { } int retval = 123; - __llvm_libc::thrd_join(&thread, &retval); + __llvm_libc::thrd_join(thread, &retval); ASSERT_EQ(retval, 0); __llvm_libc::mtx_destroy(&mutex); @@ -129,7 +129,7 @@ void wait_and_step() { } int retval = 123; - __llvm_libc::thrd_join(&thread, &retval); + __llvm_libc::thrd_join(thread, &retval); ASSERT_EQ(retval, 0); __llvm_libc::mtx_destroy(&start_lock); @@ -183,7 +183,7 @@ void multiple_waiters() { int retval; for (int i = 0; i < THREAD_COUNT; ++i) { - __llvm_libc::thrd_join(waiters + i, &retval); + __llvm_libc::thrd_join(waiters[i], &retval); } ASSERT_EQ(wait_count, 0); diff --git a/libc/test/integration/src/threads/thrd_equal_test.cpp b/libc/test/integration/src/threads/thrd_equal_test.cpp index e743836fd78771..24c5240718be9f 100644 --- a/libc/test/integration/src/threads/thrd_equal_test.cpp +++ b/libc/test/integration/src/threads/thrd_equal_test.cpp @@ -57,7 +57,7 @@ TEST_MAIN() { ASSERT_EQ(__llvm_libc::mtx_unlock(&mutex), int(thrd_success)); int retval; - ASSERT_EQ(__llvm_libc::thrd_join(&th, &retval), int(thrd_success)); + ASSERT_EQ(__llvm_libc::thrd_join(th, &retval), int(thrd_success)); ASSERT_EQ(retval, 0); // The child thread should see that thrd_current return value is the same as // |child_thread|. diff --git a/libc/test/integration/src/threads/thrd_exit_test.cpp b/libc/test/integration/src/threads/thrd_exit_test.cpp index d5f7259b2e17a7..b3317178496930 100644 --- a/libc/test/integration/src/threads/thrd_exit_test.cpp +++ b/libc/test/integration/src/threads/thrd_exit_test.cpp @@ -42,7 +42,7 @@ TEST_MAIN() { int retval; ASSERT_EQ(__llvm_libc::thrd_create(&th, func, nullptr), thrd_success); - ASSERT_EQ(__llvm_libc::thrd_join(&th, &retval), thrd_success); + ASSERT_EQ(__llvm_libc::thrd_join(th, &retval), thrd_success); ASSERT_TRUE(dtor_called); __llvm_libc::thrd_exit(0); diff --git a/libc/test/integration/src/threads/thrd_test.cpp b/libc/test/integration/src/threads/thrd_test.cpp index 63ddb1798a6a5c..d71d61ce44cec9 100644 --- a/libc/test/integration/src/threads/thrd_test.cpp +++ b/libc/test/integration/src/threads/thrd_test.cpp @@ -27,7 +27,7 @@ void create_and_join() { ASSERT_EQ(__llvm_libc::thrd_create(&thread, thread_func, nullptr), (int)thrd_success); int retval = thread_count + 1; // Start with a retval we dont expect. - ASSERT_EQ(__llvm_libc::thrd_join(&thread, &retval), (int)thrd_success); + ASSERT_EQ(__llvm_libc::thrd_join(thread, &retval), (int)thrd_success); ASSERT_EQ(retval, 0); ASSERT_EQ(counter, old_counter_val + 1); } @@ -47,7 +47,7 @@ void spawn_and_join() { for (int i = 0; i < thread_count; ++i) { int retval = thread_count + 1; // Start with a retval we dont expect. - ASSERT_EQ(__llvm_libc::thrd_join(&thread_list[i], &retval), + ASSERT_EQ(__llvm_libc::thrd_join(thread_list[i], &retval), (int)thrd_success); ASSERT_EQ(retval, i); }