DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

thr_getspecific(THREAD)


thr_getspecific -- get thread-specific data

Synopsis

   cc [options] -Kthread file
   

#include <thread.h>

int thr_getspecific(thread_key_t key, void **value);

Description

thr_getspecific obtains the value currently bound to the specified key on behalf of the calling thread.

Parameters


key
key whose value is to be returned

value
pointer to a location in which thr_getspecific will store the value associated by the calling thread with the specified key.

key parameter

key is a key obtained with a previous call to thr_keycreate(THREAD).

The effect of calling thr_getspecific with a key value not obtained with thr_keycreate or after key has been deleted with thr_keydelete is undefined.

value parameter

If a value is bound to the specified key by the calling thread, that value is placed in the location pointed to by value. If no value is bound to the specified key for the calling thread, the location pointed to by value is set to NULL.

Usage

thr_getspecific is not guaranteed to detect an invalid key. If thr_getspecific returns 0 and sets the location pointed to by value to NULL, either no value is currently bound to key, the value bound to key is NULL, or key is invalid. In this case, the caller can determine whether key is invalid by calling
   thr_setspecific(key, NULL)
to get the applicable error number.

Return values

thr_getspecific returns zero for success and an error number for failure as described below.

Errors

If any of the following conditions is detected, thr_getspecific returns the corresponding value and the contents of the location pointed to by value are unchanged:

EINVAL
key is not a valid key

References

Intro(THREAD), thr_keycreate(THREAD), thr_keydelete(THREAD), thr_setspecific(THREAD)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005