[PATCH] D50937: [Sanitizer] implementing remaining function under OSX
David CARLIER via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 24 09:30:56 PDT 2018
devnexen updated this revision to Diff 162397.
https://reviews.llvm.org/D50937
Files:
lib/sanitizer_common/sanitizer_mac.cc
lib/sanitizer_common/tests/sanitizer_common_test.cc
Index: lib/sanitizer_common/tests/sanitizer_common_test.cc
===================================================================
--- lib/sanitizer_common/tests/sanitizer_common_test.cc
+++ lib/sanitizer_common/tests/sanitizer_common_test.cc
@@ -354,7 +354,8 @@
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 }) {
Index: lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_mac.cc
+++ lib/sanitizer_common/sanitizer_mac.cc
@@ -1064,14 +1064,16 @@
// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50937.162397.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180824/45d30360/attachment.bin>
More information about the llvm-commits
mailing list