diff options
Diffstat (limited to 'lib/libkse/sys/thr_error.c')
-rw-r--r-- | lib/libkse/sys/thr_error.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libkse/sys/thr_error.c b/lib/libkse/sys/thr_error.c index f002ee9210148..a4a85078f2279 100644 --- a/lib/libkse/sys/thr_error.c +++ b/lib/libkse/sys/thr_error.c @@ -34,16 +34,21 @@ * $FreeBSD$ */ #include <pthread.h> +#include "libc_private.h" #include "thr_private.h" extern int errno; int * __error() { - int *p_errno; - if (_thread_run == _thread_initial) { - p_errno = &errno; - } else { - p_errno = &_thread_run->error; + struct pthread *curthread; + + if (__isthreaded == 0) + return (&errno); + else { + curthread = _get_curthread(); + if ((curthread == NULL) || (curthread == _thr_initial)) + return (&errno); + else + return (&curthread->error); } - return(p_errno); } |