Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOCPUInfo.h File Reference
import "OOCocoa.h"
#include <stdint.h>
+ Include dependency graph for OOCPUInfo.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OOLITE_BIG_ENDIAN   0
 
#define OOLITE_LITTLE_ENDIAN   0
 
#define OOLITE_BIG_ENDIAN   "BUG"
 
#define OOLITE_LITTLE_ENDIAN   "BUG"
 
#define OOLITE_NATIVE_64_BIT   0
 

Functions

void OOCPUInfoInit (void)
 
NSUInteger OOCPUCount (void)
 

Macro Definition Documentation

◆ OOLITE_BIG_ENDIAN [1/2]

#define OOLITE_BIG_ENDIAN   0

Definition at line 99 of file OOCPUInfo.h.

◆ OOLITE_BIG_ENDIAN [2/2]

#define OOLITE_BIG_ENDIAN   "BUG"

Definition at line 99 of file OOCPUInfo.h.

◆ OOLITE_LITTLE_ENDIAN [1/2]

#define OOLITE_LITTLE_ENDIAN   0

Definition at line 103 of file OOCPUInfo.h.

◆ OOLITE_LITTLE_ENDIAN [2/2]

#define OOLITE_LITTLE_ENDIAN   "BUG"

Definition at line 103 of file OOCPUInfo.h.

◆ OOLITE_NATIVE_64_BIT

#define OOLITE_NATIVE_64_BIT   0

Definition at line 140 of file OOCPUInfo.h.

Function Documentation

◆ OOCPUCount()

NSUInteger OOCPUCount ( void )

Definition at line 101 of file OOCPUInfo.m.

102{
103 if (!sInited) OOCPUInfoInit();
104 return (sNumberOfCPUs != 0) ? sNumberOfCPUs : 1;
105}
void OOCPUInfoInit(void)
Definition OOCPUInfo.m:60
static BOOL sInited
Definition OOCPUInfo.m:54
static NSUInteger sNumberOfCPUs
Definition OOCPUInfo.m:57

References OOCPUInfoInit(), sInited, and sNumberOfCPUs.

+ Here is the call graph for this function:

◆ OOCPUInfoInit()

void OOCPUInfoInit ( void )

Definition at line 60 of file OOCPUInfo.m.

61{
62 if (sInited) return;
63
64 // Verify correctness of endian macros
65 uint8_t endianTag[4] = {0x12, 0x34, 0x56, 0x78};
66
67#if OOLITE_BIG_ENDIAN
68 if (*(uint32_t*)endianTag != 0x12345678)
69 {
70 OOLog(@"cpuInfo.endianTest.failed", @"%@", @"OOLITE_BIG_ENDIAN is set, but the system is not big-endian -- aborting.");
71 exit(EXIT_FAILURE);
72 }
73#endif
74
75#if OOLITE_LITTLE_ENDIAN
76 if (*(uint32_t*)endianTag != 0x78563412)
77 {
78 OOLog(@"cpuInfo.endianTest.failed", @"%@", @"OOLITE_LITTLE_ENDIAN is set, but the system is not little-endian -- aborting.");
79 exit(EXIT_FAILURE);
80 }
81#endif
82
83 // Count processors
84#if OOLITE_MAC_OS_X
85 sNumberOfCPUs = [[NSProcessInfo processInfo] processorCount];
86#elif OOLITE_WINDOWS
87 SYSTEM_INFO sysInfo;
88
89 GetSystemInfo(&sysInfo);
90 sNumberOfCPUs = sysInfo.dwNumberOfProcessors;
91#elif defined _SC_NPROCESSORS_ONLN
92 sNumberOfCPUs = sysconf(_SC_NPROCESSORS_ONLN);
93#else
94 #warning Do not know how to find number of CPUs on this architecture.
95#endif // OS selection
96
97 sInited = YES;
98}
#define OOLog(class, format,...)
Definition OOLogging.h:88

References OOLog, sInited, and sNumberOfCPUs.

Referenced by OOCPUCount().

+ Here is the caller graph for this function: