summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
beaeea1)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3969
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
/* thread-specific data containing the xbt_os_thread_t structure */
static pthread_key_t xbt_self_thread_key;
/* thread-specific data containing the xbt_os_thread_t structure */
static pthread_key_t xbt_self_thread_key;
+static int thread_mod_inited = 0;
/* frees the xbt_os_thread_t corresponding to the current thread */
static void xbt_os_thread_free_thread_data(void*d){
/* frees the xbt_os_thread_t corresponding to the current thread */
static void xbt_os_thread_free_thread_data(void*d){
void xbt_os_thread_mod_init(void) {
int errcode;
void xbt_os_thread_mod_init(void) {
int errcode;
+ if (thread_mod_inited)
+ return;
+
if ((errcode=pthread_key_create(&xbt_self_thread_key, NULL)))
THROW0(system_error,errcode,"pthread_key_create failed for xbt_self_thread_key");
if ((errcode=pthread_key_create(&xbt_self_thread_key, NULL)))
THROW0(system_error,errcode,"pthread_key_create failed for xbt_self_thread_key");
+
+ thread_mod_inited = 1;
}
void xbt_os_thread_mod_exit(void) {
/* FIXME: don't try to free our key on shutdown. Valgrind detects no leak if we don't, and whine if we try to */
}
void xbt_os_thread_mod_exit(void) {
/* FIXME: don't try to free our key on shutdown. Valgrind detects no leak if we don't, and whine if we try to */
}
xbt_os_thread_t xbt_os_thread_self(void) {
}
xbt_os_thread_t xbt_os_thread_self(void) {
- return pthread_getspecific(xbt_self_thread_key);
+ return thread_mod_inited ? pthread_getspecific(xbt_self_thread_key):NULL;
void *xbt_os_thread_getparam(void) {
xbt_os_thread_t t = xbt_os_thread_self();
void *xbt_os_thread_getparam(void) {
xbt_os_thread_t t = xbt_os_thread_self();
+ return t?t->param:NULL;
}
/* ********************************* WINDOWS IMPLEMENTATION ************************************ */
}
/* ********************************* WINDOWS IMPLEMENTATION ************************************ */