summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2021-10-31 22:19:55 (GMT)
committermarc_culler <marc.culler@gmail.com>2021-10-31 22:19:55 (GMT)
commit667103246a8da98919364cf6ad50c5ad13e662c0 (patch)
tree0ccb19c0d9cac2e04876c060ee6135d2e001a12b
parent19ae628fd1d0a5aa7a2c32e0268c3110ea144222 (diff)
downloadtk-667103246a8da98919364cf6ad50c5ad13e662c0.zip
tk-667103246a8da98919364cf6ad50c5ad13e662c0.tar.gz
tk-667103246a8da98919364cf6ad50c5ad13e662c0.tar.bz2
If the system claims to be macOS 10.16 then guess the real OS version from the kernel version as reported by uname.
-rw-r--r--macosx/tkMacOSXInit.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 440383f..bd0199a 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -17,6 +17,7 @@
#include <dlfcn.h>
#include <objc/objc-auto.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
static char tkLibPath[PATH_MAX + 1] = "";
@@ -188,6 +189,7 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
*/
int minorVersion, majorVersion;
+
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion);
majorVersion = 10;
@@ -197,6 +199,24 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
majorVersion = systemVersion.majorVersion;
minorVersion = systemVersion.minorVersion;
#endif
+
+ if (majorVersion == 10 && minorVersion == 16) {
+
+ /*
+ * If a program compiled with a macOS 10.XX SDK is run on macOS 11.0 or
+ * later then it will report majorVersion 10 and minorVersion 16, no
+ * matter what the actual OS version of the host may be. And of course
+ * Apple never released macOS 10.16. To work around this we guess the
+ * OS version from the kernel release number, as reported by uname.
+ */
+
+ struct utsname name;
+ char *endptr;
+ if (uname(&name) == 0) {
+ majorVersion = strtol(name.release, &endptr, 10) - 9;
+ minorVersion = 0;
+ }
+ }
[NSApp setMacOSVersion: 10000*majorVersion + 100*minorVersion];
/*