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

Unified Diff: base/process_util_mac.mm

Issue 3162034: Avoid spawning a thread while enabling the OOM killer on the Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_mac.mm
===================================================================
--- base/process_util_mac.mm (revision 57057)
+++ base/process_util_mac.mm (working copy)
@@ -17,6 +17,7 @@
#include <sys/mman.h>
#include <sys/sysctl.h>
#include <sys/types.h>
+#include <sys/utsname.h>
#include <sys/wait.h>
#include <new>
@@ -613,11 +614,18 @@
g_oom_killer_enabled = true;
- int32 os_major;
- int32 os_minor;
- int32 os_bugfix;
- SysInfo::OperatingSystemVersionNumbers(&os_major, &os_minor, &os_bugfix);
+ // Not SysInfo::OperatingSystemVersionNumbers as that calls through to Gestalt
+ // which ends up (on > 10.6) spawning threads.
+ struct utsname machine_info;
+ if (uname(&machine_info)) {
+ return;
+ }
+ // The string machine_info.release is the xnu/Darwin version number, "9.xxx"
+ // on Mac OS X 10.5, and "10.xxx" on Mac OS X 10.6. See
+ // http://en.wikipedia.org/wiki/Darwin_(operating_system) .
+ long darwin_version = strtol(machine_info.release, (char**)NULL, 10);
Mark Mentovai 2010/08/24 15:13:24 Do you really need this cast?
Avi (use Gerrit) 2010/08/24 15:16:37 No. Done.
+
// === C malloc/calloc/valloc/realloc/posix_memalign ===
// This approach is not perfect, as requests for amounts of memory larger than
@@ -635,8 +643,7 @@
!g_old_memalign_purgeable) << "Old allocators unexpectedly non-null";
// See http://trac.webkit.org/changeset/53362/trunk/WebKitTools/DumpRenderTree/mac
- bool zone_allocators_protected =
- ((os_major == 10 && os_minor > 6) || os_major > 10);
+ bool zone_allocators_protected = darwin_version > 10;
ChromeMallocZone* default_zone =
reinterpret_cast<ChromeMallocZone*>(malloc_default_zone());
@@ -752,7 +759,7 @@
<< "Old allocators unexpectedly non-null";
bool cf_allocator_internals_known =
- (os_major == 10 && (os_minor == 5 || os_minor == 6));
+ (darwin_version == 9) || (darwin_version == 10);
Mark Mentovai 2010/08/24 15:13:24 The parentheses aren’t necessary and I don’t think
Avi (use Gerrit) 2010/08/24 15:16:37 Done.
if (cf_allocator_internals_known) {
ChromeCFAllocatorRef allocator = const_cast<ChromeCFAllocatorRef>(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698