diff -r ebf0ece7d8f6 -r eee46cb39750 src/os/macosx/macos.mm --- a/src/os/macosx/macos.mm Fri Nov 23 16:59:30 2007 +0000 +++ b/src/os/macosx/macos.mm Wed Jan 09 18:11:12 2008 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +#include + #include #include @@ -8,7 +10,7 @@ #include #include #include "../../stdafx.h" -#include "../../macros.h" +#include "../../core/bitmath_func.hpp" #ifndef CPU_SUBTYPE_POWERPC_970 #define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100) @@ -168,6 +170,90 @@ NSArray* languages = [defs objectForKey:@"AppleLanguages"]; NSString* preferredLang = [languages objectAtIndex:0]; /* preferredLang is either 2 or 5 characters long ("xx" or "xx_YY"). */ - [ preferredLang getCString:retbuf maxLength:32 encoding:NSASCIIStringEncoding ]; + + /* MacOS 10.3.9 can't handle encoding:NSASCIIStringEncoding + * we will completely disable compiling it for such old targets to avoid a warning */ +#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_3) + /* Note: MAC_OS_X_VERSION_MAX_ALLOWED is the current OSX version/SDK by default */ + if (MacOSVersionIsAtLeast(10, 4, 0)) { + [ preferredLang getCString:retbuf maxLength:32 encoding:NSASCIIStringEncoding ]; + } else { +#else + /* 10.3.9 needs to start the { too */ + { +#endif + [ preferredLang getCString:retbuf maxLength:32 ]; + } return retbuf; } + + +/* + * This will only give an accurate result for versions before OS X 10.8 since it uses bcd encoding + * for the minor and bugfix version numbers and a scheme of representing all numbers from 9 and up + * with 9. This means we can't tell OS X 10.9 from 10.9 or 10.11. Please use GetMacOSVersionMajor() + * and GetMacOSVersionMinor() instead. + */ +static long GetMacOSVersion() +{ + static long sysVersion = -1; + + if (sysVersion != -1) return sysVersion; + + if (Gestalt(gestaltSystemVersion, &sysVersion) != noErr) sysVersion = -1; + return sysVersion; +} + +long GetMacOSVersionMajor() +{ + static long sysVersion = -1; + + if (sysVersion != -1) return sysVersion; + + sysVersion = GetMacOSVersion(); + if (sysVersion == -1) return -1; + + if (sysVersion >= 0x1040) { + if (Gestalt(gestaltSystemVersionMajor, &sysVersion) != noErr) sysVersion = -1; + } else { + sysVersion = GB(sysVersion, 12, 4) * 10 + GB(sysVersion, 8, 4); + } + + return sysVersion; +} + +long GetMacOSVersionMinor() +{ + static long sysVersion = -1; + + if (sysVersion != -1) return sysVersion; + + sysVersion = GetMacOSVersion(); + if (sysVersion == -1) return -1; + + if (sysVersion >= 0x1040) { + if (Gestalt(gestaltSystemVersionMinor, &sysVersion) != noErr) sysVersion = -1; + } else { + sysVersion = GB(sysVersion, 4, 4); + } + + return sysVersion; +} + +long GetMacOSVersionBugfix() +{ + static long sysVersion = -1; + + if (sysVersion != -1) return sysVersion; + + sysVersion = GetMacOSVersion(); + if (sysVersion == -1) return -1; + + if (sysVersion >= 0x1040) { + if (Gestalt(gestaltSystemVersionBugFix, &sysVersion) != noErr) sysVersion = -1; + } else { + sysVersion = GB(sysVersion, 0, 4); + } + + return sysVersion; +}