Skip to content

Commit

Permalink
make code more amenable to compiling with mingw for cross-compiling
Browse files Browse the repository at this point in the history
Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
  • Loading branch information
kdt3rd authored and nickrasmussen committed Aug 8, 2018
1 parent d3512e0 commit dd86766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfOptimizedPixelReading.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ EXR_FORCEINLINE
bool
isPointerSSEAligned (const void* EXR_RESTRICT pPointer)
{
unsigned long trailingBits = ((unsigned long)pPointer) & 15;
uintptr_t trailingBits = ((uintptr_t)pPointer) & 15;
return trailingBits == 0;
}

Expand Down
11 changes: 10 additions & 1 deletion OpenEXR/IlmImf/ImfSystemSpecific.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,32 @@ static bool GLOBAL_SYSTEM_LITTLE_ENDIAN =

#ifdef IMF_HAVE_SSE2

#ifdef __GNUC__
#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)
{
// GNUC is used for things like mingw to (cross-)compile for windows
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#else
void* ptr = 0;
posix_memalign(&ptr, alignment, size);
return ptr;
#endif
}


static void EXRFreeAligned(void* ptr)
{
#ifdef _WIN32
_aligned_free(ptr);
#else
free(ptr);
#endif
}

#elif defined _MSC_VER
Expand Down

0 comments on commit dd86766

Please sign in to comment.