Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Unified Diff: base/process_util_unittest.cc

Issue 2110010: Patch out posix_memalign in the out-of-memory killer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/process_util_mac.mm ('K') | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_unittest.cc
===================================================================
--- base/process_util_unittest.cc (revision 47522)
+++ base/process_util_unittest.cc (working copy)
@@ -17,12 +17,12 @@
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_LINUX)
-#include <dlfcn.h>
#include <errno.h>
#include <malloc.h>
#include <glib.h>
#endif
#if defined(OS_POSIX)
+#include <dlfcn.h>
#include <fcntl.h>
#include <sys/resource.h>
#include <sys/socket.h>
@@ -617,15 +617,27 @@
// libraries as well as for our code.
ASSERT_DEATH(value_ = g_try_malloc(test_size_), "");
}
+#endif // OS_LINUX
-
+#if defined(OS_POSIX)
TEST_F(OutOfMemoryTest, Posix_memalign) {
- // Grab the return value of posix_memalign to silence a compiler warning
- // about unused return values. We don't actually care about the return
- // value, since we're asserting death.
- ASSERT_DEATH(EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)), "");
+ typedef int (*memalign_t)(void **, size_t, size_t);
+#if defined(OS_MACOSX)
+ // posix_memalign only exists on >= 10.6. Use dlsym to grab it at runtime
+ // because it may not be present in the SDK used for compilation.
+ memalign_t memalign =
+ reinterpret_cast<memalign_t>(dlsym(RTLD_DEFAULT, "posix_memalign"));
+#else
+ memalign_t memalign = posix_memalign;
+#endif // OS_*
+ if (memalign) {
+ // Grab the return value of posix_memalign to silence a compiler warning
+ // about unused return values. We don't actually care about the return
+ // value, since we're asserting death.
+ ASSERT_DEATH(EXPECT_EQ(ENOMEM, memalign(&value_, 8, test_size_)), "");
+ }
}
-#endif // OS_LINUX
+#endif // OS_POSIX
#if defined(OS_MACOSX)
« base/process_util_mac.mm ('K') | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698