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

Side by Side Diff: base/process_util_unittest_mac.mm

Issue 2126001: 64-bit support for Mac OS X in base_unittests (Closed) Base URL: svn://svn.chromium.org/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 | « base/process_util_unittest_mac.h ('k') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "base/process_util_unittest_mac.h" 5 #include "base/process_util_unittest_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Foundation/Foundation.h>
8 #include <CoreFoundation/CoreFoundation.h>
9
10 #if !defined(ARCH_CPU_64_BITS)
11
12 // In the 64-bit environment, the Objective-C 2.0 Runtime Reference states
13 // that sizeof(anInstance) is constrained to 32 bits. That's not necessarily
14 // "psychotically big" and in fact a 64-bit program is expected to be able to
15 // successfully allocate an object that large, likely reserving a good deal of
16 // swap space. The only way to test the behavior of memory exhaustion for
17 // Objective-C allocation in this environment would be to loop over allocation
18 // of these large objects, but that would slowly consume all available memory
19 // and cause swap file proliferation. That's bad, so this behavior isn't
20 // tested in the 64-bit environment.
8 21
9 @interface PsychoticallyBigObjCObject : NSObject 22 @interface PsychoticallyBigObjCObject : NSObject
10 { 23 {
11 // On 32 bits, the compiler limits Objective C objects to < 2G in size, and on 24 // In the 32-bit environment, the compiler limits Objective-C objects to
12 // 64 bits, the ObjC2 Runtime Reference says that sizeof(anInstance) is 25 // < 2GB in size.
13 // constrained to 32 bits. Keep it < 2G for simplicity.
14 int justUnder2Gigs_[(2U * 1024 * 1024 * 1024 - 1) / sizeof(int)]; 26 int justUnder2Gigs_[(2U * 1024 * 1024 * 1024 - 1) / sizeof(int)];
15 } 27 }
16 28
17 @end 29 @end
18 30
19 @implementation PsychoticallyBigObjCObject 31 @implementation PsychoticallyBigObjCObject
20 32
21 @end 33 @end
22 34
23
24 namespace base { 35 namespace base {
25 36
26 void* AllocateViaCFAllocatorSystemDefault(int32 size) {
27 return CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0);
28 }
29
30 void* AllocateViaCFAllocatorMalloc(int32 size) {
31 return CFAllocatorAllocate(kCFAllocatorMalloc, size, 0);
32 }
33
34 void* AllocateViaCFAllocatorMallocZone(int32 size) {
35 return CFAllocatorAllocate(kCFAllocatorMallocZone, size, 0);
36 }
37
38 void* AllocatePsychoticallyBigObjCObject() { 37 void* AllocatePsychoticallyBigObjCObject() {
39 return [[PsychoticallyBigObjCObject alloc] init]; 38 return [[PsychoticallyBigObjCObject alloc] init];
40 } 39 }
41 40
42 } // namespace base 41 } // namespace base
42
43 #endif // ARCH_CPU_64_BITS
44
45 namespace base {
46
47 void* AllocateViaCFAllocatorSystemDefault(ssize_t size) {
48 return CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0);
49 }
50
51 void* AllocateViaCFAllocatorMalloc(ssize_t size) {
52 return CFAllocatorAllocate(kCFAllocatorMalloc, size, 0);
53 }
54
55 void* AllocateViaCFAllocatorMallocZone(ssize_t size) {
56 return CFAllocatorAllocate(kCFAllocatorMallocZone, size, 0);
57 }
58
59 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_unittest_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698