1<assertions> 2 <assertion id="1" tag="ref:XSH6:33401:33405"> 3 The function 4 int pthread_key_create(pthread_key_t *key, void (*destructor(void*)); 5 6 shall create a thread-specific data key visible to all threaads in the process. Key values 7 provided by pthread_key_create() are opaque objects used to locate thread-specific data. 8 Although the same key value may be used by different threads, the values bound to the key 9 by pthread_setspecific() are maintained on a per-thread basis and persist for the life of 10 the calling thread. 11 </assertion> 12 13 <assertion id="2" tag="ref:XSH6:33406:33408"> 14 Upon key creation, the value NULL shall be associated with the new key in all active threads. 15 Upon thread creation, the value NULL shall be associated with all defined keys in the new 16 thread. 17 </assertion> 18 19 <assertion id="3" tag="ref:XSH6:33409:33413"> 20 An optional destructor function may be associated with each key value. At thread exit, if 21 a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated 22 with that key, the value of the key is set to NULL, and then the function pointed to is called 23 with the previously associated value as its sole argument. The order of destructor calls is 24 unspecified if more than one destructor exists for a thread when it exits. 25 </assertion> 26 27 <assertion id="4" tag="ref:XSH6:33414:33420"> 28 If, after all the destructors have been called for all non-NULL values with associated 29 destructors, there are still some non-NULL values with associated destructors, then the 30 process is repeated. If, after at least (PTHREAD_DESTRUCTOR_ITERATIONS) iterations of 31 destructor calls for outstanding non-NULL values, there are still some non-NULL values with 32 associated destructors, implemenations may stop calling destructors or they may continue 33 calling destructors until no non-NULL values with associated destructors exist, even though 34 this might result in an infinite loop. 35 </assertion> 36 37 <assertion id="5" tag="ref:XSH6:33422:33423"> 38 If successful, the pthread_key_create() function shall store the newly created key value 39 at *key and shall return zero. Otherwise, an error number shall be returned to indicate 40 an error: 41 42 It shall fail if: 43 [EAGAIN] - the system lacked the necessary resources to create another thread_specific 44 data key, or the system imposed limit on the total number of keys per process 45 [PTHREAD_KEYS_MAX] has been exceeded. 46 47 [ENOMEM] - insufficient memory exists to create the key. 48 49 it shall not return [EINTR]. 50 </assertion> 51 52</assertions> 53