#include <stdlib.h>
#include <string.h>
#include <sys/debug.h>
-#include <thread.h>
#include <unistd.h>
#include <ctype.h>
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;
}
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? */
(void) pause();
}
-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);
-}
-
static void
uu_lockup(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);
}