Skip to content

Commit

Permalink
Fixes #95, compilation issue with mingw
Browse files Browse the repository at this point in the history
The tree now compiles using mingw to compile, tested by cross compiling
for windows from linux

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
  • Loading branch information
kdt3rd committed Jul 17, 2019
1 parent e90f1b0 commit 2cf0560
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 84 deletions.
104 changes: 21 additions & 83 deletions OpenEXR/IlmImf/ImfSystemSpecific.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,111 +51,49 @@ static unsigned long* systemEndianCheckPointer = &systemEndianCheckValue;
static bool GLOBAL_SYSTEM_LITTLE_ENDIAN =
(*(unsigned char*)systemEndianCheckPointer == 0x78 ? true : false);


#ifdef IMF_HAVE_SSE2

#if defined(__GNUC__)
// Causes issues on certain gcc versions
//#define EXR_FORCEINLINE inline __attribute__((always_inline))
#define EXR_FORCEINLINE inline
#define EXR_RESTRICT __restrict

static void* EXRAllocAligned(size_t size, size_t alignment)
inline void*
EXRAllocAligned (size_t size, size_t alignment)
{
// GNUC is used for things like mingw to (cross-)compile for windows
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#else
return _aligned_malloc (size, alignment);
#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
return _mm_malloc (size, alignment);
#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)
void* ptr = 0;
posix_memalign(&ptr, alignment, size);
posix_memalign (&ptr, alignment, size);
return ptr;
#else
return malloc(size);
#endif
}


static void EXRFreeAligned(void* ptr)
inline void
EXRFreeAligned (void* ptr)
{
#ifdef _WIN32
_aligned_free(ptr);
_aligned_free (ptr);
#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || \
defined(__ECC)
_mm_free (ptr);
#else
free(ptr);
free (ptr);
#endif
}

#elif defined _MSC_VER

#define EXR_FORCEINLINE __forceinline
#define EXR_RESTRICT __restrict

static void* EXRAllocAligned(size_t size, size_t alignment)
{
return _aligned_malloc(size, alignment);
}


static void EXRFreeAligned(void* ptr)
{
_aligned_free(ptr);
}

#elif defined (__INTEL_COMPILER) || \
defined(__ICL) || \
defined(__ICC) || \
defined(__ECC)

#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
// Causes issues on certain gcc versions
//#define EXR_FORCEINLINE inline __attribute__((always_inline))
#define EXR_FORCEINLINE inline
#define EXR_RESTRICT restrict

static void* EXRAllocAligned(size_t size, size_t alignment)
{
return _mm_malloc(size, alignment);
}


static void EXRFreeAligned(void* ptr)
{
_mm_free(ptr);
}
#define EXR_RESTRICT __restrict

#else

// generic compiler
#define EXR_FORCEINLINE inline
#define EXR_RESTRICT

static void* EXRAllocAligned(size_t size, size_t alignment)
{
return malloc(size);
}


static void EXRFreeAligned(void* ptr)
{
free(ptr);
}

#endif // compiler switch


#else // IMF_HAVE_SSE2


#define EXR_FORCEINLINE inline
#define EXR_RESTRICT

static void* EXRAllocAligned(size_t size, size_t alignment)
{
return malloc(size);
}


static void EXRFreeAligned(void* ptr)
{
free(ptr);
}


#endif // IMF_HAVE_SSE2
#endif

//
// Simple CPUID based runtime detection of various capabilities
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImfTest/bswap_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright Contributors to the OpenEXR Project. See LICENSE file for details.
//

#ifdef _MSC_VER
#if defined(_WIN32) || defined(_WIN64)
#include <stdlib.h>
#define bswap_32(x) _byteswap_ulong(x)
#elif defined(__APPLE__)
Expand Down

0 comments on commit 2cf0560

Please sign in to comment.