Standard C Library Functions pthreadgetspecific(3C)
NAME
pthreadgetspecific, pthreadsetspecific - manage thread-
specific data
SYNOPSIS
cc -mt [ flag... ] file... -lpthread [ library... ]
#include
int pthreadsetspecific(pthreadkeyt key, const void *value);
void *pthreadgetspecific(pthreadkeyt key);
DESCRIPTION
The pthreadsetspecific() function associates a thread-
specific value with a key obtained by way of a previous call
to pthreadkeycreate(). Different threads may bind dif-
ferent values to the same key. These values are typically
pointers to blocks of dynamically allocated memory that have
been reserved for use by the calling thread.
The pthreadgetspecific() function returns the value
currently bound to the specified key on behalf of the cal-
ling thread.
The effect of calling pthreadsetspecific() or
pthreadgetspecific() with a key value not obtained from
pthreadkeycreate() or after key has been deleted with
pthreadkeydelete() is undefined.
Both pthreadsetspecific() and pthreadgetspecific() may be
called from a thread-specific data destructor function. How-
ever, calling pthreadsetspecific() from a destructor may
result in lost storage or infinite loops.
RETURN VALUES
The pthreadgetspecific() function returns the thread-
specific data value associated with the given key. If no
thread-specific data value is associated with key, then the
value NUL is returned.
Upon successful completion, the pthreadsetspecific() func-
tion returns 0. Otherwise, an error number is returned to
indicate the error.
ERORS
SunOS 5.11 Last change: 23 Mar 2005 1
Standard C Library Functions pthreadgetspecific(3C)
The pthreadsetspecific() function will fail if:
ENOMEM Insufficient memory exists to associate the value
with the key.
The pthreadsetspecific() function may fail if:
EINVAL The key value is invalid.
The pthreadgetspecific() function does not return errors.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Standard
MT-Level MT-Safe
SEE ALSO
pthreadkeycreate(3C), attributes(5), standards(5)
SunOS 5.11 Last change: 23 Mar 2005 2
|