forked from OSchip/llvm-project
[Sanitizer] implementing remaining function under OSX
- GetRandom and GetnumberOfCPUs using sys call for the former. - enabling unit tests for the other oses. Reviewers: kubamracek Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D50937 llvm-svn: 340621
This commit is contained in:
parent
b8ff56c726
commit
60251a5eb7
|
@ -1064,14 +1064,16 @@ void CheckNoDeepBind(const char *filename, int flag) {
|
|||
// Do nothing.
|
||||
}
|
||||
|
||||
// FIXME: implement on this platform.
|
||||
bool GetRandom(void *buffer, uptr length, bool blocking) {
|
||||
UNIMPLEMENTED();
|
||||
if (!buffer || !length || length > 256)
|
||||
return false;
|
||||
// arc4random never fails.
|
||||
arc4random_buf(buffer, length);
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: implement on this platform.
|
||||
u32 GetNumberOfCPUs() {
|
||||
UNIMPLEMENTED();
|
||||
return (u32)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
|
|
@ -354,7 +354,8 @@ TEST(SanitizerCommon, InternalScopedString) {
|
|||
EXPECT_STREQ("012345678", str.data());
|
||||
}
|
||||
|
||||
#if SANITIZER_LINUX
|
||||
#if SANITIZER_LINUX || SANITIZER_FREEBSD || \
|
||||
SANITIZER_OPENBSD || SANITIZER_MAC || SANITIZER_IOS
|
||||
TEST(SanitizerCommon, GetRandom) {
|
||||
u8 buffer_1[32], buffer_2[32];
|
||||
for (bool blocking : { false, true }) {
|
||||
|
|
Loading…
Reference in New Issue