Lines Matching refs:key

46  * half a gigabyte of memory for each thread that uses the largest key.
63 * pthread_getspecific() on an allocated key upon which the
67 * pthread_key_create(&key);
68 * pthread_setspecific(key, datum);
69 * pthread_key_delete(&key);
70 * pthread_key_create(&key);
71 * val = pthread_getspecific(key);
73 * According to POSIX, if the deleted key is reused for the new
74 * key returned by the second pthread_key_create(), then the
81 * the value NULL with the new (reused) key for each thread.
88 * specified key is larger than the highest set key. This has
92 * pthread_getspecific() while allowing for simple key creation
117 /* key == 0 is always invalid */
146 * Same as thr_keycreate(), above, except that the key creation
147 * is performed only once. This relies upon the fact that a key
148 * value of THR_ONCE_KEY is invalid, and requires that the key be
154 * static pthread_key_t key = PTHREAD_ONCE_KEY_NP;
156 * pthread_key_create_once_np(&key, destructor);
163 thread_key_t key;
169 error = thr_keycreate(&key, destructor);
175 *keyp = key;
185 pthread_key_delete(pthread_key_t key)
191 if (key >= tsdm->tsdm_nused ||
192 tsdm->tsdm_destro[key] == TSD_UNALLOCATED) {
197 tsdm->tsdm_destro[key] = TSD_UNALLOCATED;
206 * Thus, if the key specified is bogus, pthread_getspecific()'s behavior
214 pthread_getspecific(pthread_key_t key)
223 * for the invalid key == 0 in curthread->ul_ftsd[0] rather
224 * than adjusting the key by subtracting one.
226 if (key < TSD_NFAST)
227 return (curthread->ul_ftsd[key]);
229 if ((stsd = curthread->ul_stsd) != NULL && key < stsd->tsd_nalloc)
230 return (stsd->tsd_data[key]);
236 thr_getspecific(thread_key_t key, void **valuep)
243 * an invalid key. To preserve this semantic, 0 is never returned
244 * as a key from thr_/pthread_key_create(); we explicitly check
247 if (key == 0)
250 if (key < TSD_NFAST)
251 *valuep = curthread->ul_ftsd[key];
252 else if ((stsd = curthread->ul_stsd) != NULL && key < stsd->tsd_nalloc)
253 *valuep = stsd->tsd_data[key];
261 * We call thr_setspecific_slow() when the key specified
267 thr_setspecific_slow(thread_key_t key, void *value)
279 if (key >= tsdm->tsdm_nused)
283 * We would like to test (tsdm->tsdm_destro[key] == TSD_UNALLOCATED)
287 * We have a key which is (or at least _was_) valid. If this key
293 * have to, continue doubling our size only until the new key fits.
297 for (; key >= nkeys; nkeys <<= 1)
315 ntsd->tsd_data[key] = value;
322 thr_setspecific(thread_key_t key, void *value)
331 if (key == 0)
334 if (key < TSD_NFAST) {
335 curthread->ul_ftsd[key] = value;
339 if ((stsd = curthread->ul_stsd) != NULL && key < stsd->tsd_nalloc) {
340 stsd->tsd_data[key] = value;
349 ret = thr_setspecific_slow(key, value);
355 pthread_setspecific(pthread_key_t key, const void *value)
357 return (thr_setspecific(key, (void *)value));
363 * If the key falls within the TSD_NFAST range, return a non-negative
372 * On failure (key is not in the TSD_NFAST range), return -1.
375 _thr_slot_offset(thread_key_t key)
377 if (key != 0 && key < TSD_NFAST)
378 return ((ptrdiff_t)offsetof(ulwp_t, ul_ftsd[key]));
390 thread_key_t key;
400 for (key = 1; key < TSD_NFAST &&
401 key < tsdm->tsdm_nused; key++) {
402 if ((func = tsdm->tsdm_destro[key]) != NULL &&
404 (val = self->ul_ftsd[key]) != NULL) {
405 self->ul_ftsd[key] = NULL;
421 for (; key < self->ul_stsd->tsd_nalloc &&
422 key < tsdm->tsdm_nused; key++) {
423 if ((func = tsdm->tsdm_destro[key]) != NULL &&
425 (val = self->ul_stsd->tsd_data[key]) != NULL) {
426 self->ul_stsd->tsd_data[key] = NULL;