OpenTTD Source  1.11.2
G5_detector.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #include <mach/mach.h>
11 #include <mach/mach_host.h>
12 #include <mach/host_info.h>
13 #include <mach/machine.h>
14 #include <stdio.h>
15 
16 
17 #ifndef CPU_SUBTYPE_POWERPC_970
18 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
19 #endif
20 
21 /* this function is a lightly modified version of some code from Apple's developer homepage to detect G5 CPUs at runtime */
22 int main()
23 {
24  host_basic_info_data_t hostInfo;
25  mach_msg_type_number_t infoCount;
26  boolean_t is_G5;
27 
28  infoCount = HOST_BASIC_INFO_COUNT;
29  host_info(mach_host_self(), HOST_BASIC_INFO,
30  (host_info_t)&hostInfo, &infoCount);
31 
32  is_G5 = ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
33  (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
34  if (is_G5)
35  printf("1");
36 }
main
int CDECL main(int argc, char *argv[])
And the main program (what else?)
Definition: settingsgen.cpp:455