1 #include "stdio_impl.h"
2 #include <errno.h>
3 #include <stdio.h>
4 #include <string.h>
5 
perror(const char * msg)6 void perror(const char* msg) {
7     FILE* f = stderr;
8     char* errstr = strerror(errno);
9 
10     FLOCK(f);
11 
12     if (msg && *msg) {
13         fwrite(msg, strlen(msg), 1, f);
14         fputc(':', f);
15         fputc(' ', f);
16     }
17     fwrite(errstr, strlen(errstr), 1, f);
18     fputc('\n', f);
19 
20     FUNLOCK(f);
21 }
22