File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 2727
2828namespace swift {
2929
30- // FIXME: Use C11 aligned_alloc if available.
3130inline void *AlignedAlloc (size_t size, size_t align) {
32- // posix_memalign only accepts alignments greater than sizeof(void*).
33- //
34- if (align < sizeof (void *))
35- align = sizeof (void *);
36-
3731#if defined(_WIN32)
3832 void *r = _aligned_malloc (size, align);
3933 assert (r && " _aligned_malloc failed" );
34+ #elif __STDC_VERSION__-0 >= 201112l
35+ // C11 supports aligned_alloc
36+ void *r = aligned_alloc (align, size);
37+ assert (r && " aligned_alloc failed" );
4038#else
39+ // posix_memalign only accepts alignments greater than sizeof(void*).
40+ if (align < sizeof (void *))
41+ align = sizeof (void *);
42+
4143 void *r = nullptr ;
4244 int res = posix_memalign (&r, align, size);
4345 assert (res == 0 && " posix_memalign failed" );
You can’t perform that action at this time.
0 commit comments