--- a/Source/WTF/wtf/FastMalloc.cpp
+++ b/Source/WTF/wtf/FastMalloc.cpp
@@ -184,7 +184,9 @@ void fastAlignedFree(void* p)
 void* fastAlignedMalloc(size_t alignment, size_t size) 
 {
     ASSERT_IS_WITHIN_LIMIT(size);
-    void* p = aligned_alloc(alignment, size);
+    void* p = nullptr;
+    if (posix_memalign(&p, alignment, size) != 0)
+        p = nullptr;
     if (!p) [[unlikely]]
         CRASH();
     return p;
@@ -193,7 +195,10 @@ void* fastAlignedMalloc(size_t alignment, size_t size)
 void* tryFastAlignedMalloc(size_t alignment, size_t size) 
 {
     FAIL_IF_EXCEEDS_LIMIT(size);
-    return aligned_alloc(alignment, size);
+    void* p = nullptr;
+    if (posix_memalign(&p, alignment, size) != 0)
+        p = nullptr;
+    return p;
 }
 
 void fastAlignedFree(void* p) 
--- a/Source/bmalloc/bmalloc/SystemHeap.cpp
+++ b/Source/bmalloc/bmalloc/SystemHeap.cpp
@@ -173,7 +173,9 @@ void* SystemHeap::malloc(size_t size, FailureAction action)
 
 void* SystemHeap::memalign(size_t alignment, size_t size, FailureAction action)
 {
-    void* result = ::aligned_alloc(alignment, size);
+    void* result = nullptr;
+    if (posix_memalign(&result, alignment, size) != 0)
+        result = nullptr;
     RELEASE_BASSERT(action == FailureAction::ReturnNull || result);
     return result;
 }
