| 57 | } __emutls_control; |
| 58 | |
| 59 | static __inline void *emutls_memalign_alloc(size_t align, size_t size) |
| 60 | { |
| 61 | void *base; |
| 62 | #if EMUTLS_USE_POSIX_MEMALIGN |
| 63 | if (posix_memalign(&base, align, size) != 0) |
| 64 | abort(); |
| 65 | #else |
| 66 | #define EXTRA_ALIGN_PTR_BYTES (align - 1 + sizeof(void *)) |
| 67 | char *object; |
| 68 | if ((object = (char *)malloc(EXTRA_ALIGN_PTR_BYTES + size)) == NULL) |
| 69 | abort(); |
| 70 | base = (void *)(((uintptr_t)(object + EXTRA_ALIGN_PTR_BYTES)) & ~(uintptr_t)(align - 1)); |
| 71 | |
| 72 | ((void **)base)[-1] = object; |
| 73 | #endif |
| 74 | return base; |
| 75 | } |
| 76 | |
| 77 | static __inline void emutls_memalign_free(void *base) |
| 78 | { |
no test coverage detected