Oolite
Loading...
Searching...
No Matches
OOCPUInfo.h
Go to the documentation of this file.
1/*
2
3OOCPUInfo.h
4
5Capabilities and features of CPUs.
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import "OOFoundation.h"
28#include <stdint.h>
29
30#if OOLITE_LINUX
31#include <sys/sysinfo.h>
32#endif
33
34void OOCPUInfoInit(void);
35
36/* Number of processors (whether they be individual or cores), used to select
37 number of threads to use for things like texture loading.
38*/
39NSUInteger OOCPUCount(void);
40
41/*
42 Returns the CPU identifier string. Currently Windows and Linux only.
43*/
44#if (OOLITE_WINDOWS || OOLITE_LINUX)
45NSString* OOCPUDescription(void);
46void OOCPUID(int CPUInfo[4], int InfoType);
47
48typedef struct
49{
50 unsigned long long ooPhysicalMemory;
51 unsigned long long ooAvailableMemory;
52} OOMemoryStatus;
53OOMemoryStatus OOSystemMemoryStatus(void);
54#endif
55
56#if OOLITE_WINDOWS
57typedef BOOL(WINAPI* IW64PFP)(HANDLE, BOOL*); // for checking for 64/32 bit system
58BOOL is64BitSystem(void);
59NSString* operatingSystemFullVersion(void);
60#endif
61
62/* Set up OOLITE_BIG_ENDIAN and OOLITE_LITTLE_ENDIAN macros. Exactly one must
63 be non-zero. If you're porting Oolite to a middle-endian platform, you'll
64 need to work out what to do with endian-sensitive stuff -- currently, that
65 means texture loading. (The data cache automatically rejects cached data
66 of the wrong byte sex.)
67*/
68#if !defined(OOLITE_BIG_ENDIAN) && !defined(OOLITE_LITTLE_ENDIAN)
69
70#if __BIG_ENDIAN__
71#define OOLITE_BIG_ENDIAN 1
72#endif
73
74#if __LITTLE_ENDIAN__
75#define OOLITE_LITTLE_ENDIAN 1
76#endif
77
78#if !defined(OOLITE_BIG_ENDIAN) && !defined(OOLITE_LITTLE_ENDIAN)
79#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
80#define OOLITE_LITTLE_ENDIAN 1
81#endif
82
83#if defined(__sgi__) || defined(__mips__)
84#define OOLITE_BIG_ENDIAN 1
85#endif
86
87// Do not assume PPC == big endian, it can be either.
88
89#endif // inner none defined
90#endif // outer none defined
91
92#ifndef OOLITE_BIG_ENDIAN
93#define OOLITE_BIG_ENDIAN 0
94#endif
95
96#ifndef OOLITE_LITTLE_ENDIAN
97#define OOLITE_LITTLE_ENDIAN 0
98#endif
99
100#if !OOLITE_BIG_ENDIAN && !OOLITE_LITTLE_ENDIAN
101#error Neither OOLITE_BIG_ENDIAN nor OOLITE_LITTLE_ENDIAN is defined as nonzero!
102
103#undef OOLITE_BIG_ENDIAN
104#undef OOLITE_LITTLE_ENDIAN
105
106// Cause errors where the macros are used
107#define OOLITE_BIG_ENDIAN "BUG"
108#define OOLITE_LITTLE_ENDIAN "BUG"
109#endif
110
111/* Set up OOLITE_NATIVE_64_BIT. This is intended for 64-bit optimizations
112 (see OOTextureScaling.m). It is not set for systems where 64-bitness may
113 be determined at runtime (such as 32-bit OS X binaries), because I can't
114 be bothered to do the set-up required to use switch to a 64-bit code path
115 at runtime while being cross-platform.
116 -- Ahruman
117*/
118
119#ifndef OOLITE_NATIVE_64_BIT
120
121#ifdef _UINT64_T
122#ifdef __ppc64__
123#define OOLITE_NATIVE_64_BIT 1
124#elif __amd64__
125#define OOLITE_NATIVE_64_BIT 1
126#elif __x86_64__
127#define OOLITE_NATIVE_64_BIT 1
128#endif
129#endif // _UINT64_T
130
131#ifndef OOLITE_NATIVE_64_BIT
132#define OOLITE_NATIVE_64_BIT 0
133#endif
134
135#endif // defined(OOLITE_NATIVE_64_BIT)
void OOCPUInfoInit(void)
Definition OOCPUInfo.m:60
NSUInteger OOCPUCount(void)
Definition OOCPUInfo.m:99