|
@@ -24,7 +24,6 @@
|
|
|
#include "spinlock.h"
|
|
#include "spinlock.h"
|
|
|
#include "restart.h"
|
|
#include "restart.h"
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/* Table of keys. */
|
|
/* Table of keys. */
|
|
|
|
|
|
|
|
static struct pthread_key_struct pthread_keys[PTHREAD_KEYS_MAX] =
|
|
static struct pthread_key_struct pthread_keys[PTHREAD_KEYS_MAX] =
|
|
@@ -42,21 +41,21 @@ static pthread_mutex_t pthread_keys_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
int pthread_key_create(pthread_key_t * key, destr_function destr)
|
|
int pthread_key_create(pthread_key_t * key, destr_function destr)
|
|
|
{
|
|
{
|
|
|
- int i;
|
|
|
|
|
-
|
|
|
|
|
- pthread_mutex_lock(&pthread_keys_mutex);
|
|
|
|
|
- for (i = 0; i < PTHREAD_KEYS_MAX; i++) {
|
|
|
|
|
- if (! pthread_keys[i].in_use) {
|
|
|
|
|
- /* Mark key in use */
|
|
|
|
|
- pthread_keys[i].in_use = 1;
|
|
|
|
|
- pthread_keys[i].destr = destr;
|
|
|
|
|
- pthread_mutex_unlock(&pthread_keys_mutex);
|
|
|
|
|
- *key = i;
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ pthread_mutex_lock(&pthread_keys_mutex);
|
|
|
|
|
+ for (i = 0; i < PTHREAD_KEYS_MAX; i++) {
|
|
|
|
|
+ if (! pthread_keys[i].in_use) {
|
|
|
|
|
+ /* Mark key in use */
|
|
|
|
|
+ pthread_keys[i].in_use = 1;
|
|
|
|
|
+ pthread_keys[i].destr = destr;
|
|
|
|
|
+ pthread_mutex_unlock(&pthread_keys_mutex);
|
|
|
|
|
+ *key = i;
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
- pthread_mutex_unlock(&pthread_keys_mutex);
|
|
|
|
|
- return EAGAIN;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ pthread_mutex_unlock(&pthread_keys_mutex);
|
|
|
|
|
+ return EAGAIN;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Delete a key */
|
|
/* Delete a key */
|