discard dso descriptors after performing relocations
[musl] / src / stdio / perror.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <errno.h>
4 #include "stdio_impl.h"
5
6 void perror(const char *msg)
7 {
8 #if 1
9         if (msg) fprintf(stderr, "%s: %m\n", msg, strerror(errno));
10         else fprintf(stderr, "%m\n");
11 #else
12         FILE *f = stderr;
13         char *errstr = strerror(errno);
14
15         FLOCK(f);
16         
17         if (msg) {
18                 __fwritex(msg, strlen(msg), f);
19                 __putc_unlocked(':', f);
20                 __putc_unlocked(' ', f);
21         }
22         __fwritex(errstr, strlen(errstr), f);
23         __putc_unlocked('\n', f);
24
25         FUNLOCK(f);
26 #endif
27 }