svn commit: r250691 - head/lib/libthr/thread

David Xu davidxu at FreeBSD.org
Thu May 16 03:01:05 UTC 2013


Author: davidxu
Date: Thu May 16 03:01:04 2013
New Revision: 250691
URL: http://svnweb.freebsd.org/changeset/base/250691

Log:
  Return one-based key so that user can check if the key is ever allocated
  in the first place.
  
  Initial patch submitted by: phk

Modified:
  head/lib/libthr/thread/thr_spec.c

Modified: head/lib/libthr/thread/thr_spec.c
==============================================================================
--- head/lib/libthr/thread/thr_spec.c	Thu May 16 00:56:41 2013	(r250690)
+++ head/lib/libthr/thread/thr_spec.c	Thu May 16 03:01:04 2013	(r250691)
@@ -70,7 +70,7 @@ _pthread_key_create(pthread_key_t *key, 
 
 			/* Unlock the key table: */
 			THR_LOCK_RELEASE(curthread, &_keytable_lock);
-			*key = i;
+			*key = i + 1;
 			return (0);
 		}
 
@@ -81,9 +81,10 @@ _pthread_key_create(pthread_key_t *key, 
 }
 
 int
-_pthread_key_delete(pthread_key_t key)
+_pthread_key_delete(pthread_key_t userkey)
 {
 	struct pthread *curthread = _get_curthread();
+	int key = userkey - 1;
 	int ret = 0;
 
 	if ((unsigned int)key < PTHREAD_KEYS_MAX) {
@@ -178,9 +179,10 @@ pthread_key_allocate_data(void)
 }
 
 int 
-_pthread_setspecific(pthread_key_t key, const void *value)
+_pthread_setspecific(pthread_key_t userkey, const void *value)
 {
 	struct pthread	*pthread;
+	pthread_key_t	key = userkey - 1;
 	int		ret = 0;
 
 	/* Point to the running thread: */
@@ -209,9 +211,10 @@ _pthread_setspecific(pthread_key_t key, 
 }
 
 void *
-_pthread_getspecific(pthread_key_t key)
+_pthread_getspecific(pthread_key_t userkey)
 {
 	struct pthread	*pthread;
+	pthread_key_t	key = userkey - 1;
 	const void	*data;
 
 	/* Point to the running thread: */


More information about the svn-src-head mailing list