API Reference | developer.brewmp.com API Reference | developer.brewmp.com


API Reference


Brew Release
Brew MP 1.0.2
See Also
tls Interface

ITLS describes an API for storing data in thread local storage (TLS).
It is designed for implementations of TLS that can automatically clean up entries at thread-exit time. It also inherits from ILocalStorage, for non-automatic cleanup/allocation of thread-local data.
Keys for the "ID" methods are AEEUIDs. They should be allocated from the BREW classID generator, to guarantee uniqueness.
Keys for the non-ID methods are pointers. The pointers used must have a longer lifetime than the record itself. One possibility is a pointer to a function.
The expected customers of the ID-based functions are C runtime library support routines that need to allocate space on a per-thread basis. Examples are errno and floating-point status.
Here's a version of the ARM C runtime support function __rt_errno_addr() that uses ITLS to implement per-thread errno:
#include "AEEtls.h" #include "AEEITLS.h"
__pure volatile int* __rt_errno_addr(void) { // get the current ITLS context (API supplied in AEEtls.h) ITLS* pitls = (ITLS*)tls_QueryInterface(AEEIID_ITLS); int * errno_addr = 0;
// got ITLS if ((ITLS*)0 != pitls) {
// find rt_errno_addr in ITLS if (AEE_SUCCESS == ITLS_GetID(pitls, AEEUID_ARM__RT_ERRNO_ADDR, (void *)&errno_addr)) { return errno_addr; }
// else allocate space for rt_errno_addr in ITLS if (AEE_SUCCESS == ITLS_AddID(pitls, AEEUID_ARM__RT_ERRNO_ADDR, STD_SIZEOF(int), 0, 0, 0, (void **)&errno_addr)) { return errno_addr; } } }
// pseudo-safe fallback { int dummy = 0; return &dummy; }