summaryrefslogtreecommitdiffstats
path: root/lib/libthr/sys
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2006-07-12 03:44:05 +0000
committerdavidxu <davidxu@FreeBSD.org>2006-07-12 03:44:05 +0000
commitf53e1c938396423359e9e0d9f54ac50bd543b2e2 (patch)
tree672e4dfc099d4a31ba22adbb69f77693e5d374e5 /lib/libthr/sys
parent21e00b8d7070c6cac3980116707f1e5007f05fba (diff)
downloadFreeBSD-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')
-rw-r--r--lib/libthr/sys/thr_error.c12
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);
}
OpenPOWER on IntegriCloud