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

Side by Side Diff: base/process_util_mac.mm

Issue 2131010: Fix definition of CFAllocator (malloc_zone_t changed size between 10.5 and 10... (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include "base/process_util.h" 6 #include "base/process_util.h"
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <crt_externs.h> 9 #include <crt_externs.h>
10 #include <mach/mach.h> 10 #include <mach/mach.h>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // OSX appears to use a different system to get its memory. 225 // OSX appears to use a different system to get its memory.
226 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, 226 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes,
227 size_t* shared_bytes) { 227 size_t* shared_bytes) {
228 if (private_bytes) 228 if (private_bytes)
229 *private_bytes = 0; 229 *private_bytes = 0;
230 if (shared_bytes) 230 if (shared_bytes)
231 *shared_bytes = 0; 231 *shared_bytes = 0;
232 return true; 232 return true;
233 } 233 }
234 234
235 void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const { 235 void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const {
236 } 236 }
237 237
238 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { 238 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
239 size_t priv = GetWorkingSetSize(); 239 size_t priv = GetWorkingSetSize();
240 if (!priv) 240 if (!priv)
241 return false; 241 return false;
242 ws_usage->priv = priv / 1024; 242 ws_usage->priv = priv / 1024;
243 ws_usage->shareable = 0; 243 ws_usage->shareable = 0;
244 ws_usage->shared = 0; 244 ws_usage->shared = 0;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 // === C++ operator new === 412 // === C++ operator new ===
413 413
414 void oom_killer_new() { 414 void oom_killer_new() {
415 DebugUtil::BreakDebugger(); 415 DebugUtil::BreakDebugger();
416 } 416 }
417 417
418 // === Core Foundation CFAllocators === 418 // === Core Foundation CFAllocators ===
419 419
420 // This is the real structure of a CFAllocatorRef behind the scenes. See 420 // This is the real structure of a CFAllocatorRef behind the scenes. See
421 // http://opensource.apple.com/source/CF/CF-550/CFBase.c for details. 421 // http://opensource.apple.com/source/CF/CF-476.19/CFBase.c (10.5.8) and
422 // http://opensource.apple.com/source/CF/CF-550/CFBase.c (10.6) for details.
423 struct ChromeCFRuntimeBase {
424 uintptr_t _cfisa;
425 uint8_t _cfinfo[4];
426 #if __LP64__
427 uint32_t _rc;
428 #endif
429 };
430
422 struct ChromeCFAllocator { 431 struct ChromeCFAllocator {
423 _malloc_zone_t fake_malloc_zone; 432 ChromeCFRuntimeBase cf_runtime_base;
433 size_t (*size)(struct _malloc_zone_t* zone, const void* ptr);
434 void* (*malloc)(struct _malloc_zone_t* zone, size_t size);
435 void* (*calloc)(struct _malloc_zone_t* zone, size_t num_items, size_t size);
436 void* (*valloc)(struct _malloc_zone_t* zone, size_t size);
437 void (*free)(struct _malloc_zone_t* zone, void* ptr);
438 void* (*realloc)(struct _malloc_zone_t* zone, void* ptr, size_t size);
439 void (*destroy)(struct _malloc_zone_t* zone);
440 const char* zone_name;
441 unsigned (*batch_malloc)(struct _malloc_zone_t* zone, size_t size,
442 void** results, unsigned num_requested);
443 void (*batch_free)(struct _malloc_zone_t* zone, void** to_be_freed,
444 unsigned num_to_be_freed);
445 struct malloc_introspection_t* introspect;
446 void* reserved5;
447
424 void* allocator; 448 void* allocator;
425 CFAllocatorContext context; 449 CFAllocatorContext context;
426 }; 450 };
427 typedef ChromeCFAllocator* ChromeCFAllocatorRef; 451 typedef ChromeCFAllocator* ChromeCFAllocatorRef;
428 452
429 CFAllocatorAllocateCallBack g_old_cfallocator_system_default; 453 CFAllocatorAllocateCallBack g_old_cfallocator_system_default;
430 CFAllocatorAllocateCallBack g_old_cfallocator_malloc; 454 CFAllocatorAllocateCallBack g_old_cfallocator_malloc;
431 CFAllocatorAllocateCallBack g_old_cfallocator_malloc_zone; 455 CFAllocatorAllocateCallBack g_old_cfallocator_malloc_zone;
432 456
433 void* oom_killer_cfallocator_system_default(CFIndex alloc_size, 457 void* oom_killer_cfallocator_system_default(CFIndex alloc_size,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 @selector(allocWithZone:)); 599 @selector(allocWithZone:));
576 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( 600 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>(
577 method_getImplementation(orig_method)); 601 method_getImplementation(orig_method));
578 CHECK(g_old_allocWithZone) 602 CHECK(g_old_allocWithZone)
579 << "Failed to get allocWithZone allocation function."; 603 << "Failed to get allocWithZone allocation function.";
580 method_setImplementation(orig_method, 604 method_setImplementation(orig_method,
581 reinterpret_cast<IMP>(oom_killer_allocWithZone)); 605 reinterpret_cast<IMP>(oom_killer_allocWithZone));
582 } 606 }
583 607
584 } // namespace base 608 } // namespace base
OLDNEW
« 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