Author: post
Date: 2013-09-30 20:05:34 +0200 (Mon, 30 Sep 2013)
New Revision: 599
Modified:
RawSpeed/Common.cpp
Log:
Fix aligned allocation on Mac OSX 10.5 and earlier. Patch by Alex Tutubalin
Modified: RawSpeed/Common.cpp
===================================================================
--- RawSpeed/Common.cpp 2013-09-30 14:51:32 UTC (rev 598)
+++ RawSpeed/Common.cpp 2013-09-30 18:05:34 UTC (rev 599)
@@ -22,11 +22,36 @@
http://www.klauspost.com
*/
-#if defined(__unix__) || defined(__APPLE__) || defined(__MINGW32__)
+
+#if defined(__APPLE__)
+#include <CoreServices/CoreServices.h>
+
+int macosx_version()
+{
+ SInt32 gestalt_version;
+ static int ver = 0; // cached
+ if (0 == ver && (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr)) {
+ ver = ((gestalt_version & 0x00F0) >> 4);
+ }
+ return ver;
+}
+void* _aligned_malloc(size_t bytes, size_t alignment) {
+
+ if (macosx_version() >=6) { // 10.6+
+ void* ret= NULL;
+ if (0 == posix_memalign(&ret, alignment, bytes))
+ return ret;
+ else
+ return NULL;
+ }
+ return malloc(bytes); // Mac OS X malloc is usually aligned to 16 bytes
+}
+
+#elif defined(__unix__) || defined(__MINGW32__)
void* _aligned_malloc(size_t bytes, size_t alignment) {
void* ret= NULL;
- if (0==posix_memalign(&ret, alignment, bytes))
+ if (0 == posix_memalign(&ret, alignment, bytes))
return ret;
else
return NULL;
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit