wutstdc++: Fix __wut_key_t.

This commit is contained in:
James Benton 2018-06-02 10:36:28 +01:00
parent f11112ca0f
commit 3c054375db
2 changed files with 9 additions and 7 deletions

View File

@ -16,7 +16,9 @@
#define __WUT_KEY_THREAD_SPECIFIC_ID (0)
typedef volatile uint32_t __wut_once_t;
typedef uint32_t __wut_key_t;
typedef struct {
uint32_t index;
} __wut_key_t;
void
__init_wut_gthread();

View File

@ -29,7 +29,7 @@ __wut_key_create(__wut_key_t *key,
__wut_once(&init_once_control, init);
__wut_mutex_lock(&key_mutex);
for (int i = 0; i < __WUT_MAX_KEYS; ++i) {
for (uint32_t i = 0; i < __WUT_MAX_KEYS; ++i) {
if (key_table[i].in_use) {
continue;
}
@ -38,7 +38,7 @@ __wut_key_create(__wut_key_t *key,
key_table[i].dtor = dtor;
res = 0;
*key = (__wut_key_t)i;
key->index = i;
break;
}
@ -50,8 +50,8 @@ int
__wut_key_delete(__wut_key_t key)
{
__wut_mutex_lock(&key_mutex);
key_table[key].in_use = 0;
key_table[key].dtor = NULL;
key_table[key.index].in_use = 0;
key_table[key.index].dtor = NULL;
__wut_mutex_unlock(&key_mutex);
return -1;
}
@ -81,7 +81,7 @@ __wut_getspecific(__wut_key_t key)
return NULL;
}
return (void *)(keys[key]);
return (void *)(keys[key.index]);
}
int
@ -93,7 +93,7 @@ __wut_setspecific(__wut_key_t key,
return -1;
}
keys[key] = ptr;
keys[key.index] = ptr;
return 0;
}