MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / emutls_memalign_alloc

Function emutls_memalign_alloc

components/libc/posix/tls/emutls.c:59–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57} __emutls_control;
58
59static __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
77static __inline void emutls_memalign_free(void *base)
78{

Callers 1

emutls_allocate_objectFunction · 0.85

Calls 2

abortFunction · 0.50
mallocFunction · 0.50

Tested by

no test coverage detected