diff options
author | Lukas Larsson <[email protected]> | 2013-10-21 17:43:32 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2014-02-24 15:15:58 +0100 |
commit | 5dc2c6bfaed18e9a6cd23abe70be785599b5d9cc (patch) | |
tree | 0ccce81a707d93c14bca3cd01389d402cac3c77d | |
parent | 7e6cdce4925cd033812bbb9b9f113c1862225439 (diff) | |
download | otp-5dc2c6bfaed18e9a6cd23abe70be785599b5d9cc.tar.gz otp-5dc2c6bfaed18e9a6cd23abe70be785599b5d9cc.tar.bz2 otp-5dc2c6bfaed18e9a6cd23abe70be785599b5d9cc.zip |
ose: Change get_envp to ose_get_ppdata for tsd
There is a system limit on the number of ppdata that is available
but that should not be reached, and ppdata is faster than using
get_envp.
-rw-r--r-- | erts/include/internal/ethread.h | 6 | ||||
-rw-r--r-- | erts/lib_src/ose/ethread.c | 44 |
2 files changed, 11 insertions, 39 deletions
diff --git a/erts/include/internal/ethread.h b/erts/include/internal/ethread.h index 581eb22edb..7f3786ec63 100644 --- a/erts/include/internal/ethread.h +++ b/erts/include/internal/ethread.h @@ -210,11 +210,7 @@ typedef struct { void *res; } ethr_tid; -struct ethr_tsd_key__ { - PROCESS id; - char key[]; -}; -typedef struct ethr_tsd_key__* ethr_tsd_key; +typedef OSPPDKEY ethr_tsd_key; #undef ETHR_HAVE_ETHR_SIG_FUNCS diff --git a/erts/lib_src/ose/ethread.c b/erts/lib_src/ose/ethread.c index db20eab99f..7046cc8d03 100644 --- a/erts/lib_src/ose/ethread.c +++ b/erts/lib_src/ose/ethread.c @@ -115,11 +115,6 @@ static void thr_exit_cleanup(ethr_tid *tid, void *res) ethr_ts_event_destructor__((void *) ethr_get_tse__()); } -/* For debug purpose. The process name will be stored in a per-process pointer - * for quick access. - */ -static OSPPDKEY nameKey = 0; - //static OS_PROCESS(thr_wrapper); static OS_PROCESS(thr_wrapper) { @@ -152,13 +147,6 @@ static OS_PROCESS(thr_wrapper) SIGSELECT sigsel[] = {1,ETHREADWRAPDATASIG}; union SIGNAL *init_msg = receive(sigsel); - { - char **name = (char**)ose_get_ppdata(nameKey); - - *name = (char*)alloc(strlen(init_msg->data.name)+1, 0); - strcpy(*name, init_msg->data.name); - } - thr_func = init_msg->data.thr_func; arg = init_msg->data.arg; @@ -307,8 +295,6 @@ ethr_init(ethr_init_data *id) ETHR_ASSERT(&main_thr_tid == ETHR_GET_OWN_TID__); - ose_create_ppdata("ProcName", &nameKey); - ethr_not_inited__ = 0; return 0; @@ -537,7 +523,7 @@ int ethr_tsd_key_create(ethr_tsd_key *keyp) { ethr_tid *tid = ETHR_GET_OWN_TID__; - ethr_tsd_key key; + char keyname[31]; #if ETHR_XCHK if (ethr_not_inited__) { @@ -552,13 +538,10 @@ ethr_tsd_key_create(ethr_tsd_key *keyp) if (tid->tsd_key_index > 999) return EAGAIN; - /* ethread_tsd_key_YYYYYYYY_XXX\0 */ - key = malloc(sizeof(ethr_tsd_key)+sizeof(char)*(strlen("ethread_tsd_key_0xYYYYYYYY_XXX")+1)); /* What do we do it tds_key_index happens to wrap? Slot search? */ - sprintf(key->key,"ethread_tsd_key_0x%x_%d",tid->id,tid->tsd_key_index++); - key->id = current_process(); + sprintf(keyname,"ethread_tsd_key_0x%x_%d",tid->id,tid->tsd_key_index++); - *keyp = key; + ose_create_ppdata(keyname,keyp); return 0; } @@ -572,20 +555,24 @@ ethr_tsd_key_delete(ethr_tsd_key key) return EACCES; } #endif - free(key); + /* Not possible to delete ppdata */ + return 0; } int ethr_tsd_set(ethr_tsd_key key, void *value) { + void **ppdp; #if ETHR_XCHK if (ethr_not_inited__) { ETHR_ASSERT(0); return EACCES; } #endif - return set_envp(current_process(), key->key, (OSADDRESS)value)?0:1; + ppdp = (void **)ose_get_ppdata(key); + *ppdp = value; + return 0; } void * @@ -597,7 +584,7 @@ ethr_tsd_get(ethr_tsd_key key) return NULL; } #endif - return (void*)get_envp(current_process(),key->key); + return *(void**)ose_get_ppdata(key); } /* @@ -645,14 +632,3 @@ ethr_abort__(void) { abort(); } - -const char *procName(void); -const char * -procName(void) { - char **procName_p = (char**)ose_get_ppdata(nameKey); - if (procName_p) { - return *procName_p; - } - - return NULL; -} |