Files
zig/lib/libc/musl/src/stdio/perror.c
Andrew Kelley 49d1a4c562 move lib dirs to lib subdir
also start prefering NtDll API. so far:
 * NtQueryInformationFile
 * NtClose

adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
2019-07-15 17:54:50 -04:00

31 lines
549 B
C
Vendored

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "stdio_impl.h"
void perror(const char *msg)
{
FILE *f = stderr;
char *errstr = strerror(errno);
FLOCK(f);
/* Save stderr's orientation and encoding rule, since perror is not
* permitted to change them. */
void *old_locale = f->locale;
int old_mode = f->mode;
if (msg && *msg) {
fwrite(msg, strlen(msg), 1, f);
fputc(':', f);
fputc(' ', f);
}
fwrite(errstr, strlen(errstr), 1, f);
fputc('\n', f);
f->mode = old_mode;
f->locale = old_locale;
FUNLOCK(f);
}