Oolite 1.91.0.7644-241112-7f5034b
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 "OOCocoa.h"
28#include <stdint.h>
29
30#if OOLITE_LINUX
31#include <sys/sysinfo.h>
32#endif
33
34
35void OOCPUInfoInit(void);
36
37
38/* Number of processors (whether they be individual or cores), used to select
39 number of threads to use for things like texture loading.
40*/
41NSUInteger OOCPUCount(void);
42
43
44/*
45 Returns the CPU identifier string. Currently Windows and Linux only.
46*/
47#if (OOLITE_WINDOWS || OOLITE_LINUX)
48NSString* OOCPUDescription(void);
49void OOCPUID(int CPUInfo[4], int InfoType);
50
51typedef struct
52{
53 unsigned long long ooPhysicalMemory;
54 unsigned long long ooAvailableMemory;
55} OOMemoryStatus;
56OOMemoryStatus OOSystemMemoryStatus(void);
57#endif
58
59
60#if OOLITE_WINDOWS
61typedef BOOL (WINAPI *IW64PFP)(HANDLE, BOOL *); // for checking for 64/32 bit system
62BOOL is64BitSystem(void);
63NSString* operatingSystemFullVersion(void);
64#endif
65
66/* Set up OOLITE_BIG_ENDIAN and OOLITE_LITTLE_ENDIAN macros. Exactly one must
67 be non-zero. If you're porting Oolite to a middle-endian platform, you'll
68 need to work out what to do with endian-sensitive stuff -- currently, that
69 means texture loading. (The data cache automatically rejects cached data
70 of the wrong byte sex.)
71*/
72#if !defined(OOLITE_BIG_ENDIAN) && !defined(OOLITE_LITTLE_ENDIAN)
73
74#if __BIG_ENDIAN__
75#define OOLITE_BIG_ENDIAN 1
76#endif
77
78#if __LITTLE_ENDIAN__
79#define OOLITE_LITTLE_ENDIAN 1
80#endif
81
82
83#if !defined(OOLITE_BIG_ENDIAN) && !defined(OOLITE_LITTLE_ENDIAN)
84#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
85#define OOLITE_LITTLE_ENDIAN 1
86#endif
87
88#if defined(__sgi__) || defined(__mips__)
89#define OOLITE_BIG_ENDIAN 1
90#endif
91
92// Do not assume PPC == big endian, it can be either.
93
94#endif // inner none defined
95#endif // outer none defined
96
97
98#ifndef OOLITE_BIG_ENDIAN
99#define OOLITE_BIG_ENDIAN 0
100#endif
101
102#ifndef OOLITE_LITTLE_ENDIAN
103#define OOLITE_LITTLE_ENDIAN 0
104#endif
105
106
107#if !OOLITE_BIG_ENDIAN && !OOLITE_LITTLE_ENDIAN
108#error Neither OOLITE_BIG_ENDIAN nor OOLITE_LITTLE_ENDIAN is defined as nonzero!
109
110#undef OOLITE_BIG_ENDIAN
111#undef OOLITE_LITTLE_ENDIAN
112
113// Cause errors where the macros are used
114#define OOLITE_BIG_ENDIAN "BUG"
115#define OOLITE_LITTLE_ENDIAN "BUG"
116#endif
117
118
119/* Set up OOLITE_NATIVE_64_BIT. This is intended for 64-bit optimizations
120 (see OOTextureScaling.m). It is not set for systems where 64-bitness may
121 be determined at runtime (such as 32-bit OS X binaries), because I can't
122 be bothered to do the set-up required to use switch to a 64-bit code path
123 at runtime while being cross-platform.
124 -- Ahruman
125*/
126
127#ifndef OOLITE_NATIVE_64_BIT
128
129#ifdef _UINT64_T
130#ifdef __ppc64__
131#define OOLITE_NATIVE_64_BIT 1
132#elif __amd64__
133#define OOLITE_NATIVE_64_BIT 1
134#elif __x86_64__
135#define OOLITE_NATIVE_64_BIT 1
136#endif
137#endif // _UINT64_T
138
139#ifndef OOLITE_NATIVE_64_BIT
140#define OOLITE_NATIVE_64_BIT 0
141#endif
142
143#endif // defined(OOLITE_NATIVE_64_BIT)
void OOCPUInfoInit(void)
Definition OOCPUInfo.m:60
NSUInteger OOCPUCount(void)
Definition OOCPUInfo.m:101