From 3c054375db5389a7f175d05f2d7a4982060b623f Mon Sep 17 00:00:00 2001 From: James Benton Date: Sat, 2 Jun 2018 10:36:28 +0100 Subject: [PATCH] wutstdc++: Fix __wut_key_t. --- libraries/wutstdc++/wut_gthread.h | 4 +++- libraries/wutstdc++/wut_gthread_keys.cc | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/wutstdc++/wut_gthread.h b/libraries/wutstdc++/wut_gthread.h index e4f44777..0235b7b1 100644 --- a/libraries/wutstdc++/wut_gthread.h +++ b/libraries/wutstdc++/wut_gthread.h @@ -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(); diff --git a/libraries/wutstdc++/wut_gthread_keys.cc b/libraries/wutstdc++/wut_gthread_keys.cc index f11e8565..7ea5cda6 100644 --- a/libraries/wutstdc++/wut_gthread_keys.cc +++ b/libraries/wutstdc++/wut_gthread_keys.cc @@ -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; }