1 #include <stdlib.h> 2 #include <errno.h> 3 posix_memalign(void ** res,size_t align,size_t len)4int posix_memalign(void **res, size_t align, size_t len) 5 { 6 if (align < sizeof(void *)) return EINVAL; 7 void *mem = aligned_alloc(align, len); 8 if (!mem) return errno; 9 *res = mem; 10 return 0; 11 } 12