Skip to content

LLM inference in C/C++

C++ ggml

vulkan: replace std::aligned_alloc with posix_memalign for termux compatibility (#30828)

Bill Siderisd77256999f21
diff --git a/ggml/src/ggml-vulkan/ggml-vulkan-buffers.cpp b/ggml/src/ggml-vulkan/ggml-vulkan-buffers.cpp
index b687b13908..7e9b3fa75e 100644
--- a/ggml/src/ggml-vulkan/ggml-vulkan-buffers.cpp
+++ b/ggml/src/ggml-vulkan/ggml-vulkan-buffers.cpp
@@ -9,7 +9,11 @@ static void * portable_aligned_malloc(size_t align, size_t size) {
#ifdef _WIN32
return _aligned_malloc(size, align);
#else
- return std::aligned_alloc(align, size);
+ void * ptr = nullptr;
+ if (posix_memalign(&ptr, align, size) != 0) {
+ return nullptr;
+ }
+ return ptr;
#endif
}