Fixed problem with _mm_malloc under OSX. Thanks to Callum Lerwick for solving that issue.
This commit is contained in:
parent
1d02a8b595
commit
bd0b6ec2fd
|
@ -32,7 +32,7 @@
|
||||||
The functions in J2K_LIB.C are internal utilities mainly used for memory management.
|
The functions in J2K_LIB.C are internal utilities mainly used for memory management.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __GCC__
|
#ifndef __GNUC__
|
||||||
#define __attribute__(x) /* */
|
#define __attribute__(x) /* */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -62,13 +62,35 @@ Allocate memory aligned to a 16 byte boundry
|
||||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||||
*/
|
*/
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <xmmintrin.h>
|
|
||||||
#else
|
#ifdef __GNUC__
|
||||||
#include <mm_malloc.h>
|
#include <mm_malloc.h>
|
||||||
|
#else /* MSVC, Intel C++ */
|
||||||
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
|
|
||||||
|
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
|
||||||
#define opj_aligned_free(m) _mm_free(m)
|
#define opj_aligned_free(m) _mm_free(m)
|
||||||
|
|
||||||
|
#else /* Not WIN32 */
|
||||||
|
|
||||||
|
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||||
|
#if defined(__amd64__) || defined(__APPLE__)
|
||||||
|
#define opj_aligned_malloc(size) malloc(size)
|
||||||
|
#else
|
||||||
|
extern int posix_memalign (void **, size_t, size_t);
|
||||||
|
|
||||||
|
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
|
||||||
|
void* mem = NULL;
|
||||||
|
posix_memalign(&mem, 16, size);
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define opj_aligned_free(m) free(m)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reallocate memory blocks.
|
Reallocate memory blocks.
|
||||||
@param memblock Pointer to previously allocated memory block
|
@param memblock Pointer to previously allocated memory block
|
||||||
|
|
Loading…
Reference in New Issue