]> git.pond.sub.org Git - empserver/commitdiff
Permit empth_self() before empth_init()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 4 Aug 2012 18:07:39 +0000 (20:07 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 5 Aug 2012 07:24:57 +0000 (09:24 +0200)
Next commit wants this.

include/empthread.h
src/lib/empthread/ntthread.c
src/lib/empthread/pthread.c

index 67856cda278efafa96168d15e7d39a6eb0832915..39ef99a3b4c7d813f6d1bed3afc5ea16a7eaf436 100644 (file)
@@ -30,7 +30,7 @@
  *     Sasha Mikheev
  *     Doug Hay, 1998
  *     Steve McClure, 1998
- *     Markus Armbruster, 2005-2009
+ *     Markus Armbruster, 2005-2012
  *     Ron Koenderink, 2005-2009
  */
 
@@ -125,7 +125,8 @@ empth_t *empth_create(void (*entry)(void *),
                      int size, int flags, char *name, void *ud);
 
 /*
- * Return the current thread.
+ * Return the current thread, NULL before empth_init().
+ * This is the only function that may be called before empth_init().
  */
 empth_t *empth_self(void);
 
index 2a39f5bbb0b9e796e20d9b2835b41a52171f8d50..dd41aa745c17233961f9658d8f49ac4904ba5f2f 100644 (file)
@@ -467,9 +467,7 @@ bad:
 empth_t *
 empth_self(void)
 {
-    empth_t *pThread = TlsGetValue(dwTLSIndex);
-
-    return pThread;
+    return ppvUserData ? TlsGetValue(dwTLSIndex) : NULL;
 }
 
 /************************
index 83f2b6c4e96f1699ffd734113c3c8a17b42d3ef7..9c7b24fd03c5a9ef34677dae4ae505f2d193467a 100644 (file)
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Sasha Mikheev
  *     Steve McClure, 1998
- *     Markus Armbruster, 2005-2011
+ *     Markus Armbruster, 2005-2012
  *     Ron Koenderink, 2007-2009
  */
 
@@ -240,7 +240,7 @@ empth_restorectx(void)
 empth_t *
 empth_self(void)
 {
-    return pthread_getspecific(ctx_key);
+    return udata ? pthread_getspecific(ctx_key) : NULL;
 }
 
 char *