src/os/macosx/G5_detector.cpp
changeset 5835 e0ff603ae0b7
parent 5726 8f399788f6c9
child 10429 1b99254f9607
equal deleted inserted replaced
5834:7bf92d5a5a0f 5835:e0ff603ae0b7
       
     1 /* $Id$ */
       
     2 
       
     3 #include <mach/mach.h>
       
     4 #include <mach/mach_host.h>
       
     5 #include <mach/host_info.h>
       
     6 #include <mach/machine.h>
       
     7 #include <stdio.h>
       
     8 
       
     9 
       
    10 #ifndef CPU_SUBTYPE_POWERPC_970
       
    11 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
       
    12 #endif
       
    13 
       
    14 // this function is a lightly modified version of some code from Apple's developer homepage to detect G5 CPUs at runtime
       
    15 main()
       
    16 {
       
    17 	host_basic_info_data_t hostInfo;
       
    18 	mach_msg_type_number_t infoCount;
       
    19 	boolean_t is_G5;
       
    20 
       
    21 	infoCount = HOST_BASIC_INFO_COUNT;
       
    22 	host_info(mach_host_self(), HOST_BASIC_INFO,
       
    23 			  (host_info_t)&hostInfo, &infoCount);
       
    24 
       
    25 	 is_G5 = ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
       
    26 			(hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
       
    27 	 if (is_G5)
       
    28 		 printf("1");
       
    29 }