]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/ldso/dlerror.c
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 hidden
void __dl_vseterr(const char *fmt
, va_list ap
)
30 pthread_t self
= __pthread_self();
31 if (self
->dlerror_buf
!= (void *)-1)
32 free(self
->dlerror_buf
);
33 size_t len
= vsnprintf(0, 0, fmt
, ap2
);
35 char *buf
= malloc(len
+1);
37 vsnprintf(buf
, len
+1, fmt
, ap
);
41 self
->dlerror_buf
= buf
;
42 self
->dlerror_flag
= 1;
45 hidden
void __dl_seterr(const char *fmt
, ...)
49 __dl_vseterr(fmt
, ap
);
53 static int stub_invalid_handle(void *h
)
55 __dl_seterr("Invalid library handle %p", (void *)h
);
59 weak_alias(stub_invalid_handle
, __dl_invalid_handle
);