int status = join(retval);
if (status != 0)
return status;
- *val = retval.stdc_retval;
+ if (val != nullptr)
+ *val = retval.stdc_retval;
return 0;
}
int status = join(retval);
if (status != 0)
return status;
- *val = retval.posix_retval;
+ if (val != nullptr)
+ *val = retval.posix_retval;
return 0;
}
libc.src.pthread.pthread_join
libc.src.__support.CPP.atomic
)
+
+add_integration_test(
+ pthread_join_test
+ SUITE
+ libc-pthread-integration-tests
+ SRCS
+ pthread_join_test.cpp
+ DEPENDS
+ libc.include.pthread
+ libc.include.errno
+ libc.include.stdio
+ libc.src.pthread.pthread_create
+ libc.src.pthread.pthread_join
+)
--- /dev/null
+//===-- Tests for pthread_join-- ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/pthread/pthread_create.h"
+#include "src/pthread/pthread_join.h"
+
+#include "src/errno/libc_errno.h"
+
+#include "test/IntegrationTest/test.h"
+#include <pthread.h>
+
+static void *simpleFunc(void *) { return nullptr; }
+static void nullJoinTest() {
+ pthread_t Tid;
+ ASSERT_EQ(__llvm_libc::pthread_create(&Tid, nullptr, simpleFunc, nullptr), 0);
+ ASSERT_EQ(libc_errno, 0);
+ ASSERT_EQ(__llvm_libc::pthread_join(Tid, nullptr), 0);
+ ASSERT_EQ(libc_errno, 0);
+}
+
+TEST_MAIN() {
+ libc_errno = 0;
+ nullJoinTest();
+ return 0;
+}