Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSAN] Add interceptor for pthread_getaffinity_np.
Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D127185
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 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,15 @@ | ||
// RUN: %clangxx_msan -O0 %s -o %t && %run %t | ||
|
||
#include <assert.h> | ||
#include <pthread.h> | ||
|
||
#include <sanitizer/msan_interface.h> | ||
|
||
int main() { | ||
cpu_set_t set_x; | ||
int res = pthread_getaffinity_np(pthread_self(), sizeof(set_x), &set_x); | ||
assert(res == 0); | ||
__msan_check_mem_is_initialized(&set_x, sizeof(set_x)); | ||
|
||
return 0; | ||
} |
16 changes: 16 additions & 0 deletions
16
compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_getaffinity_np.cpp
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,16 @@ | ||
// RUN: %clangxx -O0 %s -o %t && %run %t | ||
|
||
#include <assert.h> | ||
#include <pthread.h> | ||
#include <sys/sysinfo.h> | ||
|
||
#include <sanitizer/msan_interface.h> | ||
|
||
int main() { | ||
cpu_set_t set_x; | ||
int res = pthread_getaffinity_np(pthread_self(), sizeof(set_x), &set_x); | ||
assert(res == 0); | ||
assert(CPU_COUNT_S(sizeof(set_x), &set_x) == get_nprocs()); | ||
|
||
return 0; | ||
} |