-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LIBC] Fix incorrect handling of
pthread_join(tid, nullptr)
Previously unconditionally stored to the return value. This is incorrect, we should only return if user value is non-null. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148293
- Loading branch information
1 parent
8d2bae9
commit ef09498
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===-- 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; | ||
} |