Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOLogHeader.m File Reference
import "OOLogHeader.h"
import "OOCPUInfo.h"
import "OOLogging.h"
import "OOOXPVerifier.h"
import "Universe.h"
import "OOStellarBody.h"
import "OOJavaScriptEngine.h"
import "OOSound.h"
#include <sys/sysctl.h>
+ Include dependency graph for OOLogHeader.m:

Go to the source code of this file.

Macros

#define CPU_TYPE_STRING   "<unknown architecture with unknown byte order>"
 
#define OS_TYPE_STRING   "Mac OS X"
 
#define RELEASE_VARIANT_STRING   " test release"
 
#define CPUFAMILY_INTEL_MEROM   0x426f69ef
 
#define CPUFAMILY_INTEL_HASWELL   0x10b282dc
 
#define CPUFAMILY_INTEL_BROADWELL   0x582ed09c
 
#define CPUFAMILY_INTEL_SKYLAKE   0x37fc219f
 

Functions

static NSString * AdditionalLogHeaderInfo (void)
 
NSString * OOPlatformDescription (void)
 
void OOPrintLogHeader (void)
 
static NSString * GetSysCtlString (const char *name)
 
static unsigned long long GetSysCtlInt (const char *name)
 
static NSString * GetCPUDescription (void)
 

Macro Definition Documentation

◆ CPU_TYPE_STRING

#define CPU_TYPE_STRING   "<unknown architecture with unknown byte order>"

◆ CPUFAMILY_INTEL_BROADWELL

#define CPUFAMILY_INTEL_BROADWELL   0x582ed09c

Definition at line 226 of file OOLogHeader.m.

Referenced by GetCPUDescription().

◆ CPUFAMILY_INTEL_HASWELL

#define CPUFAMILY_INTEL_HASWELL   0x10b282dc

Definition at line 222 of file OOLogHeader.m.

Referenced by GetCPUDescription().

◆ CPUFAMILY_INTEL_MEROM

#define CPUFAMILY_INTEL_MEROM   0x426f69ef

Definition at line 218 of file OOLogHeader.m.

Referenced by GetCPUDescription().

◆ CPUFAMILY_INTEL_SKYLAKE

#define CPUFAMILY_INTEL_SKYLAKE   0x37fc219f

Definition at line 230 of file OOLogHeader.m.

Referenced by GetCPUDescription().

◆ OS_TYPE_STRING

#define OS_TYPE_STRING   "Mac OS X"

◆ RELEASE_VARIANT_STRING

#define RELEASE_VARIANT_STRING   " test release"

Function Documentation

◆ AdditionalLogHeaderInfo()

static NSString * AdditionalLogHeaderInfo ( void )
static

Definition at line 206 of file OOLogHeader.m.

207{
208 NSString *sysModel = nil;
209 unsigned long long sysPhysMem;
210
211 sysModel = GetSysCtlString("hw.model");
212 sysPhysMem = GetSysCtlInt("hw.memsize");
213
214 return [NSString stringWithFormat:@"Machine type: %@, %llu MiB memory, %@.", sysModel, sysPhysMem >> 20, GetCPUDescription()];
215}
static NSString * GetSysCtlString(const char *name)
static unsigned long long GetSysCtlInt(const char *name)
return nil

References GetSysCtlInt(), GetSysCtlString(), and nil.

+ Here is the call graph for this function:

◆ GetCPUDescription()

static NSString * GetCPUDescription ( void )
static

Definition at line 234 of file OOLogHeader.m.

235{
236 NSString *typeStr = nil, *subTypeStr = nil;
237
238 unsigned long long sysCPUType = GetSysCtlInt("hw.cputype");
239 unsigned long long sysCPUFamily = GetSysCtlInt("hw.cpufamily");
240 unsigned long long sysCPUFrequency = GetSysCtlInt("hw.cpufrequency");
241 unsigned long long sysCPUCount = GetSysCtlInt("hw.physicalcpu");
242 unsigned long long sysLogicalCPUCount = GetSysCtlInt("hw.logicalcpu");
243
244 /* Note: CPU_TYPE_STRING tells us the build architecture. This gets the
245 physical CPU type. They may differ, for instance, when running under
246 Rosetta. The code is written for flexibility, although ruling out
247 x86 code running on PPC would be entirely reasonable.
248 */
249 switch (sysCPUType)
250 {
251 case CPU_TYPE_POWERPC:
252 typeStr = @"PowerPC";
253 break;
254
255 case CPU_TYPE_I386:
256 typeStr = @"x86";
257 switch (sysCPUFamily)
258 {
260 subTypeStr = @" (Core 2/Merom)";
261 break;
262
263 case CPUFAMILY_INTEL_PENRYN:
264 subTypeStr = @" (Penryn)";
265 break;
266
267 case CPUFAMILY_INTEL_NEHALEM:
268 subTypeStr = @" (Nehalem)";
269 break;
270
271 case CPUFAMILY_INTEL_WESTMERE:
272 subTypeStr = @" (Westmere)";
273 break;
274
275 case CPUFAMILY_INTEL_SANDYBRIDGE:
276 subTypeStr = @" (Sandy Bridge)";
277 break;
278
279 case CPUFAMILY_INTEL_IVYBRIDGE:
280 subTypeStr = @" (Ivy Bridge)";
281 break;
282
284 subTypeStr = @" (Haswell)";
285 break;
286
288 subTypeStr = @" (Broadwell)";
289 break;
290
292 subTypeStr = @" (Skylake)";
293 break;
294
295 default:
296 subTypeStr = [NSString stringWithFormat:@" (family 0x%llx)", sysCPUFamily];
297 }
298 break;
299
300 case CPU_TYPE_ARM:
301 typeStr = @"ARM";
302 }
303
304 if (typeStr == nil) typeStr = [NSString stringWithFormat:@"CPU type %llu", sysCPUType];
305
306 NSString *countStr = nil;
307 if (sysCPUCount == sysLogicalCPUCount) countStr = [NSString stringWithFormat:@"%llu", sysCPUCount];
308 else countStr = [NSString stringWithFormat:@"%llu (%llu logical)", sysCPUCount, sysLogicalCPUCount];
309
310 return [NSString stringWithFormat:@"%@ x %@%@ @ %llu MHz", countStr, typeStr, subTypeStr, (sysCPUFrequency + 500000) / 1000000];
311}
#define CPUFAMILY_INTEL_HASWELL
#define CPUFAMILY_INTEL_SKYLAKE
#define CPUFAMILY_INTEL_BROADWELL
#define CPUFAMILY_INTEL_MEROM

References CPUFAMILY_INTEL_BROADWELL, CPUFAMILY_INTEL_HASWELL, CPUFAMILY_INTEL_MEROM, CPUFAMILY_INTEL_SKYLAKE, GetSysCtlInt(), and nil.

+ Here is the call graph for this function:

◆ GetSysCtlInt()

static unsigned long long GetSysCtlInt ( const char * name)
static

Definition at line 329 of file OOLogHeader.m.

330{
331 unsigned long long llresult = 0;
332 unsigned int intresult = 0;
333 size_t size;
334
335 size = sizeof llresult;
336 if (sysctlbyname(name, &llresult, &size, NULL, 0) != 0) return 0;
337 if (size == sizeof llresult) return llresult;
338
339 size = sizeof intresult;
340 if (sysctlbyname(name, &intresult, &size, NULL, 0) != 0) return 0;
341 if (size == sizeof intresult) return intresult;
342
343 return 0;
344}
voidpf void uLong size
Definition ioapi.h:134

Referenced by AdditionalLogHeaderInfo(), and GetCPUDescription().

+ Here is the caller graph for this function:

◆ GetSysCtlString()

static NSString * GetSysCtlString ( const char * name)
static

Definition at line 314 of file OOLogHeader.m.

315{
316 char *buffer = NULL;
317 size_t size = 0;
318
319 // Get size
320 sysctlbyname(name, NULL, &size, NULL, 0);
321 if (size == 0) return nil;
322
323 buffer = alloca(size);
324 if (sysctlbyname(name, buffer, &size, NULL, 0) != 0) return nil;
325 return [NSString stringWithUTF8String:buffer];
326}

References nil.

Referenced by AdditionalLogHeaderInfo().

+ Here is the caller graph for this function:

◆ OOPlatformDescription()

NSString * OOPlatformDescription ( void )

Definition at line 185 of file OOLogHeader.m.

186{
187 #if OOLITE_MAC_OS_X
188 NSString *systemString = [NSString stringWithFormat:@OS_TYPE_STRING " %@", [[NSProcessInfo processInfo] operatingSystemVersionString]];
189 #else
190 #define systemString @OS_TYPE_STRING
191 #endif
192
193 return [NSString stringWithFormat:@"%@ ("CPU_TYPE_STRING RELEASE_VARIANT_STRING")", systemString];
194}

Referenced by ConsoleGetProperty().

+ Here is the caller graph for this function:

◆ OOPrintLogHeader()

void OOPrintLogHeader ( void )

Definition at line 60 of file OOLogHeader.m.

61{
62 // Bunch of string literal macros which are assembled into a CPU info string.
63 #if defined (__ppc__)
64 #define CPU_TYPE_STRING "PPC-32"
65 #elif defined (__ppc64__)
66 #define CPU_TYPE_STRING "PPC-64"
67 #elif defined (__i386__)
68 #define CPU_TYPE_STRING "x86-32"
69 #elif defined (__x86_64__)
70 #define CPU_TYPE_STRING "x86-64"
71 #else
72 #if OOLITE_BIG_ENDIAN
73 #define CPU_TYPE_STRING "<unknown big-endian architecture>"
74 #elif OOLITE_LITTLE_ENDIAN
75 #define CPU_TYPE_STRING "<unknown little-endian architecture>"
76 #else
77 #define CPU_TYPE_STRING "<unknown architecture with unknown byte order>"
78 #endif
79 #endif
80
81 #if OOLITE_MAC_OS_X
82 #define OS_TYPE_STRING "Mac OS X"
83 #elif OOLITE_WINDOWS
84 #define OS_TYPE_STRING "Windows"
85 #elif OOLITE_LINUX
86 #define OS_TYPE_STRING "Linux" // Hmm, what about other unices?
87 #elif OOLITE_SDL
88 #define OS_TYPE_STRING "unknown SDL system"
89 #else
90 #define OS_TYPE_STRING "unknown system"
91 #endif
92
93 #if OO_DEBUG
94 #define RELEASE_VARIANT_STRING " debug"
95 #elif !defined (NDEBUG)
96 #define RELEASE_VARIANT_STRING " test release"
97 #else
98 #define RELEASE_VARIANT_STRING ""
99 #endif
100
101 NSArray *featureStrings = [NSArray arrayWithObjects:
102 // User features
103 #if OOLITE_OPENAL
104 @"OpenAL",
105 #endif
106
107 #if OO_SHADERS
108 @"GLSL shaders",
109 #endif
110
111 #if NEW_PLANETS
112 @"new planets",
113 #endif
114
115 // Debug features
116 #if OO_CHECK_GL_HEAVY
117 @"heavy OpenGL error checking",
118 #endif
119
120 #ifndef OO_EXCLUDE_DEBUG_SUPPORT
121 @"JavaScript console support",
122 #if OOLITE_MAC_OS_X
123 // Under Mac OS X, Debug.oxp adds more than console support.
124 @"Debug plug-in support",
125 #endif
126 #endif
127
128 #if OO_OXP_VERIFIER_ENABLED
129 @"OXP verifier",
130 #endif
131
132 #if OO_LOCALIZATION_TOOLS
133 @"localization tools",
134 #endif
135
136 #if DEBUG_GRAPHVIZ
137 @"debug GraphViz support",
138 #endif
139
140 #if OOJS_PROFILE
141 #ifdef MOZ_TRACE_JSCALLS
142 @"JavaScript profiling",
143 #else
144 @"JavaScript native callback profiling",
145 #endif
146 #endif
147
148 #if OO_FOV_INFLIGHT_CONTROL_ENABLED
149 @"FOV in-flight control",
150 #endif
151
152 nil];
153
154 // systemString: NSString with system type and possibly version.
155 #if (OOLITE_MAC_OS_X || (OOLITE_GNUSTEP_1_20 && !OOLITE_WINDOWS))
156 NSString *systemString = [NSString stringWithFormat:@OS_TYPE_STRING " %@", [[NSProcessInfo processInfo] operatingSystemVersionString]];
157 #elif OOLITE_WINDOWS
158 NSString *systemString = [NSString stringWithFormat:@OS_TYPE_STRING " %@ %@-bit", operatingSystemFullVersion(), is64BitSystem() ? @"64":@"32"];
159 #else
160 #define systemString @OS_TYPE_STRING
161 #endif
162
163 NSString *versionString = nil;
164 #if (defined (SNAPSHOT_BUILD) && defined (OOLITE_SNAPSHOT_VERSION))
165 versionString = @"development version " OOLITE_SNAPSHOT_VERSION;
166 #else
167 versionString = [NSString stringWithFormat:@"version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
168 #endif
169 if (versionString == nil) versionString = @"<unknown version>";
170
171 NSMutableString *miscString = [NSMutableString stringWithFormat:@"Opening log for Oolite %@ (" CPU_TYPE_STRING RELEASE_VARIANT_STRING ") under %@ at %@.\n", versionString, systemString, [NSDate date]];
172
173 [miscString appendString:AdditionalLogHeaderInfo()];
174
175 NSString *featureDesc = [featureStrings componentsJoinedByString:@", "];
176 if ([featureDesc length] == 0) featureDesc = @"none";
177 [miscString appendFormat:@"\nBuild options: %@.\n", featureDesc];
178
179 [miscString appendString:@"\nNote that the contents of the log file can be adjusted by editing logcontrol.plist."];
180
181 OOLog(@"log.header", @"%@\n", miscString);
182}
#define OOLog(class, format,...)
Definition OOLogging.h:88

References nil, and OOLog.

Referenced by OOLoggingInit().

+ Here is the caller graph for this function: