Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos doesn't have aligned_alloc, so use the posix variant #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ EXE=.exe
LDFLAGS+=-static -s
CFLAGS+=-mstackrealign # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659
RES+=icon.rc.o
else
CFLAGS+=-D_POSIX_C_SOURCE=200112
endif

ifeq ($(SAVE_ASM),1)
Expand Down
7 changes: 5 additions & 2 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ static inline float sqf(float x) {
static inline void *alloc_simd(size_t n) {
#if defined(_WIN32)
void *p = _aligned_malloc(n, 16);
if(!p) { die("allocation error"); }
#else
void *p = aligned_alloc(16, n);
void *p = NULL;
if (posix_memalign(&p, 16, n) != 0) {
die("aligned allocation error");
}
#endif
if(!p) { die("allocation error"); }
ASSUME_ALIGNED(p);
return p;
}
Expand Down