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.
15 #ifdef __UCLIBC_HAS_THREADS__
19 #ifdef __UCLIBC_MJN3_ONLY__
20 #warning REMINDER: Deal with wide oriented stderr case.
23 libc_hidden_proto(vwarn)
24 libc_hidden_proto(vwarnx)
25 libc_hidden_proto(err)
26 libc_hidden_proto(verr)
27 libc_hidden_proto(verrx)
29 libc_hidden_proto(fprintf)
30 libc_hidden_proto(vfprintf)
31 libc_hidden_proto(__xpg_strerror_r)
32 libc_hidden_proto(exit)
33 libc_hidden_proto(vfprintf)
35 static void vwarn_work(const char *format, va_list args, int showerr)
38 static const char fmt[] = "%s: \0: %s\n\0\n";
41 __STDIO_AUTO_THREADLOCK_VAR;
43 /* Do this first, in case something below changes errno. */
44 f = fmt + 11; /* At 11. */
47 __xpg_strerror_r(errno, buf, sizeof(buf));
50 __STDIO_AUTO_THREADLOCK(stderr);
52 fprintf(stderr, fmt, __uclibc_progname);
54 vfprintf(stderr, format, args);
55 f -= 2; /* At 5 (showerr) or 9. */
57 fprintf(stderr, f, buf);
59 __STDIO_AUTO_THREADUNLOCK(stderr);
62 void vwarn(const char *format, va_list args)
64 vwarn_work(format, args, 1);
66 libc_hidden_def(vwarn)
68 void warn(const char *format, ...)
72 va_start(args, format);
77 void vwarnx(const char *format, va_list args)
79 vwarn_work(format, args, 0);
81 libc_hidden_def(vwarnx)
83 void warnx(const char *format, ...)
87 va_start(args, format);
92 void verr(int status, const char *format, va_list args)
99 void attribute_noreturn err(int status, const char *format, ...)
103 va_start(args, format);
104 verr(status, format, args);
105 /* This should get optimized away. We'll leave it now for safety. */
106 /* The loop is added only to keep gcc happy. */
111 void verrx(int status, const char *format, va_list args)
113 vwarnx(format, args);
116 libc_hidden_def(verrx)
118 void attribute_noreturn errx(int status, const char *format, ...)
122 va_start(args, format);
123 verrx(status, format, args);
124 /* This should get optimized away. We'll leave it now for safety. */
125 /* The loop is added only to keep gcc happy. */