NAME

tss_get, tss_set — thread-specific data management

SYNOPSIS

#include <threads.h>

void *tss_get(tss_t
key);
int tss_set(tss_t
key, void *val);

DESCRIPTION

[CX] [Option Start] The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2024 defers to the ISO C standard. [Option End]

The tss_get() function shall return the value for the current thread held in the thread-specific storage identified by key.

The tss_set() function shall set the value for the current thread held in the thread-specific storage identified by key to val. This action shall not invoke the destructor associated with the key on the value being replaced.

The application shall ensure that the tss_get() and tss_set() functions are only called with a value for key that was returned by a call to tss_create() before the thread commenced executing destructors.

The effect of calling tss_get() or tss_set() after key has been deleted with tss_delete() is undefined.

[CX] [Option Start] Both tss_get() and tss_set() can be called from a thread-specific data destructor function. A call to tss_get() for the thread-specific data key being destroyed shall return a null pointer, unless the value is changed (after the destructor starts) by a call to tss_set(). Calling tss_set() from a thread-specific data destructor function may result either in lost storage (after at least {PTHREAD_DESTRUCTOR_ITERATIONS} attempts at destruction) or in an infinite loop.

These functions shall not be affected if the calling thread executes a signal handler during the call. [Option End]

RETURN VALUE

The tss_get() function shall return the value for the current thread. If no thread-specific data value is associated with key, then a null pointer shall be returned.

The tss_set() function shall return thrd_success on success or thrd_error if the request could not be honored.

ERRORS

No errors are defined.


The following sections are informative.

EXAMPLES

None.

APPLICATION USAGE

None.

RATIONALE

These functions are not affected by signal handlers for the reasons stated in XRAT B.2.3 Error Numbers .

FUTURE DIRECTIONS

None.

SEE ALSO

pthread_getspecific , tss_create

XBD <threads.h>

CHANGE HISTORY

First released in Issue 8. Included for alignment with the ISO/IEC 9899:2018 standard.

End of informative text.