Author: post
Date: 2010-08-18 17:39:17 +0200 (Wed, 18 Aug 2010)
New Revision: 265
Modified:
RawSpeed/Common.cpp
RawSpeed/Common.h
RawSpeed/StdAfx.h
Log:
Use properly aligned allocation methods for unix systems.
Modified: RawSpeed/Common.cpp
===================================================================
--- RawSpeed/Common.cpp 2010-08-01 17:33:46 UTC (rev 264)
+++ RawSpeed/Common.cpp 2010-08-18 15:39:17 UTC (rev 265)
@@ -22,4 +22,14 @@
http://www.klauspost.com
*/
+#if defined(__unix__) || defined(__MINGW32__)
+void* _aligned_malloc(size_t bytes, size_t alignment) {
+ void* ret= NULL;
+ if (0==posix_memalign(&ret, alignment, bytes))
+ return ret;
+ else
+ return NULL;
+}
+
+#endif
Modified: RawSpeed/Common.h
===================================================================
--- RawSpeed/Common.h 2010-08-01 17:33:46 UTC (rev 264)
+++ RawSpeed/Common.h 2010-08-18 15:39:17 UTC (rev 265)
@@ -35,7 +35,7 @@
#define _RPT4(a,b,c,d,e,f)
#define __inline inline
#define _strdup(a) strdup(a)
-#define _aligned_malloc(a, alignment) malloc(a)
+void* _aligned_malloc(size_t bytes, size_t alignment);
#define _aligned_free(a) do { free(a); } while (0)
#ifndef MIN
#define MIN(a, b) lmin(a,b)
@@ -65,12 +65,12 @@
typedef unsigned int uint32;
typedef signed int int32;
typedef unsigned short ushort16;
-
-typedef enum Endianness {
- big, little, unknown
-} Endianness;
-
+typedef enum Endianness {
+ big, little, unknown
+} Endianness;
+
+
inline void BitBlt(uchar8* dstp, int dst_pitch, const uchar8* srcp, int
src_pitch, int row_size, int height) {
if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) {
memcpy(dstp, srcp, row_size*height);
@@ -95,25 +95,25 @@
inline uint32 getThreadCount()
{
-#ifdef WIN32
- return pthread_num_processors_np();
-#else
- return rawspeed_get_number_of_processor_cores();
-#endif
+#ifdef WIN32
+ return pthread_num_processors_np();
+#else
+ return rawspeed_get_number_of_processor_cores();
+#endif
}
-inline Endianness getHostEndianness() {
- ushort16 testvar = 0xfeff;
- uint32 firstbyte = ((uchar8 *)&testvar)[0];
- if (firstbyte == 0xff)
- return little;
- else if (firstbyte == 0xfe)
- return big;
- else
- _ASSERTE(FALSE);
-
- // Return something to make compilers happy
- return unknown;
+inline Endianness getHostEndianness() {
+ ushort16 testvar = 0xfeff;
+ uint32 firstbyte = ((uchar8 *)&testvar)[0];
+ if (firstbyte == 0xff)
+ return little;
+ else if (firstbyte == 0xfe)
+ return big;
+ else
+ _ASSERTE(FALSE);
+
+ // Return something to make compilers happy
+ return unknown;
}
inline uint32 clampbits(int x, uint32 n) { uint32 _y_temp; if( (_y_temp=x>>n)
) x = ~_y_temp >> (32-n); return x;}
Modified: RawSpeed/StdAfx.h
===================================================================
--- RawSpeed/StdAfx.h 2010-08-01 17:33:46 UTC (rev 264)
+++ RawSpeed/StdAfx.h 2010-08-18 15:39:17 UTC (rev 265)
@@ -40,6 +40,15 @@
#include <stdexcept>
#endif
#else // if unix
+#ifdef _XOPEN_SOURCE
+#if (_XOPEN_SOURCE < 600)
+#undef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 600 // for posix_memalign()
+#endif // _XOPEN_SOURCE < 600
+#else
+#define _XOPEN_SOURCE 600 // for posix_memalign()
+#endif //_XOPEN_SOURCE
+#include <stdlib.h>
#include <stdarg.h>
#include <stdexcept>
#include <exception>
@@ -48,7 +57,7 @@
#endif // __unix__
#include <malloc.h>
#include <math.h>
-#include "pthread.h"
+#include "pthread.h"
// STL
#include <iostream>
#include <string>
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit