src/os/macosx/G5_detector.cpp
author bjarni
Mon, 05 Feb 2007 21:16:56 +0000
changeset 6192 c6adfc929c6b
parent 5835 e0ff603ae0b7
child 10429 1b99254f9607
permissions -rw-r--r--
(svn r8605) -Codechange: [OSX] changed all objective C to objective C++
This will permanently solve the issue where compilation on OSX broke because C++ code was added to some header files

-Note: (important if you develop mac specific code)
taken from http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html
gdb lacks an integrated C++ with Objective-C parser. This means that gdb won't be able to evaluate expressions that contain both C++ and Objective-C constructs.
gdb assumes that the language for ".mm" files is C++.
you can change it to objective C by typing: (gdb) set language objc
Mixing C++ and objective C has some limitation (see link for all of them)
3093
f677403be64f (svn r3682) -Fix: didn't write $ correct in G5_detector in r3673, which caused problems for tortoisesvn
bjarni
parents: 3084
diff changeset
     1
/* $Id$ */
3084
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     2
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     3
#include <mach/mach.h>
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     4
#include <mach/mach_host.h>
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     5
#include <mach/host_info.h>
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     6
#include <mach/machine.h>
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     7
#include <stdio.h>
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     8
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
     9
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    10
#ifndef CPU_SUBTYPE_POWERPC_970
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    11
#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    12
#endif
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    13
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    14
// this function is a lightly modified version of some code from Apple's developer homepage to detect G5 CPUs at runtime
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    15
main()
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    16
{
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    17
	host_basic_info_data_t hostInfo;
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    18
	mach_msg_type_number_t infoCount;
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    19
	boolean_t is_G5;
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    20
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    21
	infoCount = HOST_BASIC_INFO_COUNT;
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    22
	host_info(mach_host_self(), HOST_BASIC_INFO,
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    23
			  (host_info_t)&hostInfo, &infoCount);
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    24
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    25
	 is_G5 = ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    26
			(hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    27
	 if (is_G5)
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    28
		 printf("1");
18abee1dd88d (svn r3673) -Codechange: [OSX] changed the makefile to autodetect if it compiles on G5 and then adds flags to optimise for G5
bjarni
parents:
diff changeset
    29
}