G5_detector.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include <mach/mach.h>
00013 #include <mach/mach_host.h>
00014 #include <mach/host_info.h>
00015 #include <mach/machine.h>
00016 #include <stdio.h>
00017
00018
00019 #ifndef CPU_SUBTYPE_POWERPC_970
00020 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
00021 #endif
00022
00023
00024 main()
00025 {
00026 host_basic_info_data_t hostInfo;
00027 mach_msg_type_number_t infoCount;
00028 boolean_t is_G5;
00029
00030 infoCount = HOST_BASIC_INFO_COUNT;
00031 host_info(mach_host_self(), HOST_BASIC_INFO,
00032 (host_info_t)&hostInfo, &infoCount);
00033
00034 is_G5 = ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
00035 (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
00036 if (is_G5)
00037 printf("1");
00038 }