Skip to content

Commit

Permalink
Merge pull request darktable-org#1264 from mazhe/master
Browse files Browse the repository at this point in the history
Rawspeed: use a non-deprecated way of getting OSX version
  • Loading branch information
LebedevRI authored Sep 15, 2016
2 parents dfea4ed + 71ff823 commit 4f4e89a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/external/rawspeed/RawSpeed/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@


#if defined(__APPLE__)
#include <CoreServices/CoreServices.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <stdlib.h>
#include <string.h>

int macosx_version()
{
SInt32 gestalt_version;
static int ver = 0; // cached
if (0 == ver && (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr)) {
ver = gestalt_version;
char str[256];
size_t strsize = sizeof(str);
if (0 == ver && sysctlbyname("kern.osrelease", str, &strsize, NULL, 0) == 0) {
// kern.osrelease is a string formated as "Major.Minor.Patch"
if (memchr(str, '\0', strsize) != NULL) {
int major, minor, patch;
if (sscanf(str, "%d.%d.%d", &major, &minor, &patch) == 3) {
ver = 0x1000 + major*10;
}
}
}
return ver;
}
Expand Down Expand Up @@ -77,4 +87,4 @@ void writeLog(int priority, const char *format, ...)
va_end(args);
}

} // Namespace RawSpeed
} // Namespace RawSpeed

0 comments on commit 4f4e89a

Please sign in to comment.