netinet/in.h: add IPPROTO_MH
[uclibc-ng.git] / libc / stdio / perror.c
blobd36d75bcfd3bf7ec6943e0aa737179662a304096
1 /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
3 * GNU Library General Public License (LGPL) version 2 or later.
5 * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
6 */
8 #include "_stdio.h"
10 void perror(register const char *s)
12 /* If the program is calling perror, it's a safe bet that printf and
13 * friends are used as well. It is also possible that the calling
14 * program could buffer stderr, or reassign it. */
16 register const char *sep;
18 sep = ": ";
19 if (!(s && *s)) { /* Caller did not supply a prefix message */
20 s = (sep += 2); /* or passed an empty string. */
23 #ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
24 fprintf(stderr, "%s%s%m\n", s, sep); /* Use the gnu %m feature. */
25 #else
27 char buf[64];
28 fprintf(stderr, "%s%s%s\n", s, sep,
29 __glibc_strerror_r(errno, buf, sizeof(buf)));
31 #endif
33 libc_hidden_def(perror)