From 94819be610e27eff71e2d692c618345d405dcd17 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Tue, 3 Sep 2024 18:38:34 +0800
Subject: [PATCH] Allocator.cpp: fix for macOS where aligned_alloc may not be
 supported

--- Lib/Allocator.cpp
+++ Lib/Allocator.cpp
@@ -19,6 +19,10 @@
 #include "Allocator.hpp"
 #include "Lib/Timer.hpp"
 
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+#endif
+
 #ifndef INDIVIDUAL_ALLOCATIONS
 Lib::SmallObjectAllocator Lib::GLOBAL_SMALL_OBJECT_ALLOCATOR;
 #endif
@@ -43,9 +47,10 @@
   ALLOCATED += size;
   {
     Lib::TimeoutProtector tp;
+#if !defined(__APPLE__) || (defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101300)
     if(void *ptr = std::aligned_alloc(align, size))
       return ptr;
-
+#endif
     // we might be here because `aligned_alloc` is finicky (Apple, looking at you)
     // so try again with `malloc` and hope for good alignment
     if(void *ptr = std::malloc(size))
