OpenTTD: src/os/macosx/G5_detector.cpp Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

G5_detector.cpp
Go to the documentation of this file.
1 /* $Id: G5_detector.cpp 24524 2012-09-13 18:42:33Z yexo $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
9
12 #include <mach/mach.h>
13 #include <mach/mach_host.h>
14 #include <mach/host_info.h>
15 #include <mach/machine.h>
16 #include <stdio.h>
17
18
19 #ifndef CPU_SUBTYPE_POWERPC_970
20 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
21 #endif
22
23 /* this function is a lightly modified version of some code from Apple's developer homepage to detect G5 CPUs at runtime */
24 int main()
25 {
26 host_basic_info_data_t hostInfo;
27 mach_msg_type_number_t infoCount;
28 boolean_t is_G5;
29
30 infoCount = HOST_BASIC_INFO_COUNT;
31 host_info(mach_host_self(), HOST_BASIC_INFO,
32 (host_info_t)&hostInfo, &infoCount);
33
34 is_G5 = ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
35 (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
36 if (is_G5)
37 printf("1");
38 }