[mlir] Fix building CRunnerUtils on OpenBSD with 15.x

CRunnerUtils builds as C++11. 9c1d133c3a broke
the build on OpenBSD. aligned_alloc() was only introduced in C++17.
This commit is contained in:
Brad Smith 2022-09-09 20:33:30 -04:00 committed by Tobias Hieta
parent 1a5c5e0f67
commit c643956d69

View file

@ -127,14 +127,10 @@ extern "C" void *_mlir_alloc(uint64_t size) { return malloc(size); }
extern "C" void *_mlir_aligned_alloc(uint64_t alignment, uint64_t size) { extern "C" void *_mlir_aligned_alloc(uint64_t alignment, uint64_t size) {
#ifdef _WIN32 #ifdef _WIN32
return _aligned_malloc(size, alignment); return _aligned_malloc(size, alignment);
#elif defined(__APPLE__) #else
// aligned_alloc was added in MacOS 10.15. Fall back to posix_memalign to also
// support older versions.
void *result = nullptr; void *result = nullptr;
(void)::posix_memalign(&result, alignment, size); (void)::posix_memalign(&result, alignment, size);
return result; return result;
#else
return aligned_alloc(alignment, size);
#endif #endif
} }