diff options
author | Keir Mierle <mierle@gmail.com> | 2011-12-04 03:30:11 +0400 |
---|---|---|
committer | Keir Mierle <mierle@gmail.com> | 2011-12-04 03:30:11 +0400 |
commit | bc8fb9ff37d694c1b91f9c9d8aad9b3de20924b5 (patch) | |
tree | be5f61cf0d5e77ad67ff1956662d229aceb4938b /extern | |
parent | 232248d2e0cc988ebacd8f631b681a8abe14699d (diff) |
Add a fix for compiling the brute force region tracker from libmv on Mac OS X.
Diffstat (limited to 'extern')
-rw-r--r-- | extern/libmv/libmv/tracking/brute_region_tracker.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/extern/libmv/libmv/tracking/brute_region_tracker.cc b/extern/libmv/libmv/tracking/brute_region_tracker.cc index bda1a6e2cd2..29b0fc5ff38 100644 --- a/extern/libmv/libmv/tracking/brute_region_tracker.cc +++ b/extern/libmv/libmv/tracking/brute_region_tracker.cc @@ -24,7 +24,14 @@ #include <emmintrin.h> #endif -#include <malloc.h> // For memalign. +#ifndef __APPLE__ +// Needed for memalign on Linux and _aligned_alloc on Windows. +#include <malloc.h> +#else +// Apple's malloc is 16-byte aligned, and does not have malloc.h, so include +// stdilb instead. +#include <cstdlib> +#endif #include "libmv/image/image.h" #include "libmv/image/convolve.h" @@ -38,7 +45,12 @@ namespace { void *aligned_malloc(int size, int alignment) { #ifdef _WIN32 return _aligned_malloc(size, alignment); -#else // TODO(keir): Will this work on Mac OS X? +#elif __APPLE__ + // On Mac OS X, both the heap and the stack are guaranteed 16-byte aligned so + // they work natively with SSE types with no further work. + CHECK_EQ(alignment, 16); + return malloc(size); +#else // This is for Linux. return memalign(alignment, size); #endif } |