4 #include "pthread_impl.h"
9 pthread_t self = __pthread_self();
10 if (!self->dlerror_flag) return 0;
11 self->dlerror_flag = 0;
12 char *s = self->dlerror_buf;
14 return "Dynamic linker failed to allocate memory for error message";
19 void __dl_thread_cleanup(void)
21 pthread_t self = __pthread_self();
22 if (self->dlerror_buf != (void *)-1)
23 free(self->dlerror_buf);
26 __attribute__((__visibility__("hidden")))
27 void __dl_vseterr(const char *fmt, va_list ap)
31 pthread_t self = __pthread_self();
32 if (self->dlerror_buf != (void *)-1)
33 free(self->dlerror_buf);
34 size_t len = vsnprintf(0, 0, fmt, ap2);
36 char *buf = malloc(len+1);
38 vsnprintf(buf, len+1, fmt, ap);
42 self->dlerror_buf = buf;
43 self->dlerror_flag = 1;
46 __attribute__((__visibility__("hidden")))
47 void __dl_seterr(const char *fmt, ...)
51 __dl_vseterr(fmt, ap);
55 __attribute__((__visibility__("hidden")))
56 int __dl_invalid_handle(void *);
58 static int stub_invalid_handle(void *h)
60 __dl_seterr("Invalid library handle %p", (void *)h);
64 weak_alias(stub_invalid_handle, __dl_invalid_handle);