libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_tls.h File Reference

Go to the source code of this file.

Macros

#define GBL_TLS(type, name, ...)
 
#define GBL_TLS_LOAD(name)
 

Detailed Description

Thread-local variable management.

This file provides a pair of macros serving as an abstraction layer between a platform's preferred thread-local storage mechanism, and the application.

Where supported, GBL_TLS() will use real, compiler-enabled static TLS by simply declaring the variable with the "thread_local" keyword and proceeding to access it normally.

If this preferred path is not available, using the same semantics, the back-end emulate this behavior by creating OS-level TLS storage using TinyCThread's C11 TLS API, which uses dynamically allocated storage and key-based lookups.

Author
2023 Falco Girgis

Definition in file gimbal_tls.h.

Macro Definition Documentation

◆ GBL_TLS

#define GBL_TLS (   type,
  name,
  ... 
)

Defines a thread-local variable using the given information, and either using compiler or OS-level TLS depending on the platform.

Parameters
typevariable type
namevariable name
initvariable initializer
See also
GBL_TLS_LOAD()

Definition at line 41 of file gimbal_tls.h.

◆ GBL_TLS_LOAD

#define GBL_TLS_LOAD (   name)

Fetches a pointer to a thread-local variable that was previously declared with GBL_TLS()

Parameters
namevariable name
Returns
pointer address of the given TLS variable
See also
GBL_TLS()

Definition at line 77 of file gimbal_tls.h.