Permit empth_self() before empth_init()

Next commit wants this.
This commit is contained in:
Markus Armbruster 2012-08-04 20:07:39 +02:00
parent 3d7383c548
commit fc64b4fa83
3 changed files with 6 additions and 7 deletions

View file

@ -30,7 +30,7 @@
* Sasha Mikheev * Sasha Mikheev
* Doug Hay, 1998 * Doug Hay, 1998
* Steve McClure, 1998 * Steve McClure, 1998
* Markus Armbruster, 2005-2009 * Markus Armbruster, 2005-2012
* Ron Koenderink, 2005-2009 * Ron Koenderink, 2005-2009
*/ */
@ -125,7 +125,8 @@ empth_t *empth_create(void (*entry)(void *),
int size, int flags, char *name, void *ud); 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); empth_t *empth_self(void);

View file

@ -467,9 +467,7 @@ bad:
empth_t * empth_t *
empth_self(void) empth_self(void)
{ {
empth_t *pThread = TlsGetValue(dwTLSIndex); return ppvUserData ? TlsGetValue(dwTLSIndex) : NULL;
return pThread;
} }
/************************ /************************

View file

@ -29,7 +29,7 @@
* Known contributors to this file: * Known contributors to this file:
* Sasha Mikheev * Sasha Mikheev
* Steve McClure, 1998 * Steve McClure, 1998
* Markus Armbruster, 2005-2011 * Markus Armbruster, 2005-2012
* Ron Koenderink, 2007-2009 * Ron Koenderink, 2007-2009
*/ */
@ -240,7 +240,7 @@ empth_restorectx(void)
empth_t * empth_t *
empth_self(void) empth_self(void)
{ {
return pthread_getspecific(ctx_key); return udata ? pthread_getspecific(ctx_key) : NULL;
} }
char * char *