X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=lib%2Flibuutil%2Fuu_misc.c;h=1b843effe65d578ffa174fea88acf45773ee524d;hb=1e33ac1e2677c898a0b5ef6207048c692cb51bf4;hp=3d5b40ca8549c692be4678b6c625e3592d91f654;hpb=572e285762521df27fe5b026f409ba1a21abb7ac;p=zfs.git diff --git a/lib/libuutil/uu_misc.c b/lib/libuutil/uu_misc.c index 3d5b40c..1b843ef 100644 --- a/lib/libuutil/uu_misc.c +++ b/lib/libuutil/uu_misc.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -68,11 +67,12 @@ static va_list uu_panic_args; static pthread_t uu_panic_thread; static uint32_t _uu_main_error; +static __thread int _uu_main_thread = 0; void uu_set_error(uint_t code) { - if (thr_main() != 0) { + if (_uu_main_thread) { _uu_main_error = code; return; } @@ -101,7 +101,7 @@ uu_set_error(uint_t code) uint32_t uu_error(void) { - if (thr_main() != 0) + if (_uu_main_thread) return (_uu_main_error); if (uu_error_key_setup < 0) /* can't happen? */ @@ -209,7 +209,11 @@ uu_panic(const char *format, ...) int assfail(const char *astring, const char *file, int line) { +#if defined(__STDC__) && __STDC_VERSION__ - 0 >= 199901L + __assert_c99(astring, file, line, "unknown func"); +#else __assert(astring, file, line); +#endif /*NOTREACHED*/ return (0); } @@ -245,10 +249,17 @@ uu_release_child(void) uu_release(); } +#ifdef __GNUC__ +static void +uu_init(void) __attribute__((constructor)); +#else #pragma init(uu_init) +#endif + static void uu_init(void) { + _uu_main_thread = 1; (void) pthread_atfork(uu_lockup, uu_release, uu_release_child); }