diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-07-12 03:44:05 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-07-12 03:44:05 +0000 |
commit | f53e1c938396423359e9e0d9f54ac50bd543b2e2 (patch) | |
tree | 672e4dfc099d4a31ba22adbb69f77693e5d374e5 /lib/libthr/sys/thr_error.c | |
parent | 21e00b8d7070c6cac3980116707f1e5007f05fba (diff) | |
download | FreeBSD-src-f53e1c938396423359e9e0d9f54ac50bd543b2e2.zip FreeBSD-src-f53e1c938396423359e9e0d9f54ac50bd543b2e2.tar.gz |
__error could be called too early before libthr is initialized, test
this case and return global varible errno instead.
Diffstat (limited to 'lib/libthr/sys/thr_error.c')
-rw-r--r-- | lib/libthr/sys/thr_error.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libthr/sys/thr_error.c b/lib/libthr/sys/thr_error.c index 902c054..45295c5 100644 --- a/lib/libthr/sys/thr_error.c +++ b/lib/libthr/sys/thr_error.c @@ -45,10 +45,12 @@ extern int errno; int * __error(void) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread; - if (curthread != NULL && curthread != _thr_initial) - return (&curthread->error); - else - return (&errno); + if (_thr_initial != NULL) { + curthread = _get_curthread(); + if (curthread != NULL && curthread != _thr_initial) + return (&curthread->error); + } + return (&errno); } |