Use C scalar-type versions of the cryptohome API in cryptohome_library
[chromium-blink-merge.git] / base / process_util_unittest_mac.mm
blob2ef1868b9fef3a19b25d5196690f36e0710b76bf
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
3 // found in the LICENSE file.
5 #include "base/process_util_unittest_mac.h"
7 #import <Foundation/Foundation.h>
8 #include <CoreFoundation/CoreFoundation.h>
10 #if !defined(ARCH_CPU_64_BITS)
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.
22 @interface PsychoticallyBigObjCObject : NSObject
24   // In the 32-bit environment, the compiler limits Objective-C objects to
25   // < 2GB in size.
26   int justUnder2Gigs_[(2U * 1024 * 1024 * 1024 - 1) / sizeof(int)];
29 @end
31 @implementation PsychoticallyBigObjCObject
33 @end
35 namespace base {
37 void* AllocatePsychoticallyBigObjCObject() {
38   return [[PsychoticallyBigObjCObject alloc] init];
41 }  // namespace base
43 #endif  // ARCH_CPU_64_BITS
45 namespace base {
47 void* AllocateViaCFAllocatorSystemDefault(ssize_t size) {
48   return CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0);
51 void* AllocateViaCFAllocatorMalloc(ssize_t size) {
52   return CFAllocatorAllocate(kCFAllocatorMalloc, size, 0);
55 void* AllocateViaCFAllocatorMallocZone(ssize_t size) {
56   return CFAllocatorAllocate(kCFAllocatorMallocZone, size, 0);
59 }  // namespace base