summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/stdio/vasprintf.c14
-rw-r--r--libc/stdio/vfprintf.c22
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_va_copy.h27
3 files changed, 29 insertions, 34 deletions
diff --git a/libc/stdio/vasprintf.c b/libc/stdio/vasprintf.c
index 1ef75df94..688ab7cd5 100644
--- a/libc/stdio/vasprintf.c
+++ b/libc/stdio/vasprintf.c
@@ -7,6 +7,7 @@
#include "_stdio.h"
#include <stdarg.h>
+#include <bits/uClibc_va_copy.h>
#ifdef __UCLIBC_MJN3_ONLY__
/* Do the memstream stuff inline to avoid fclose and the openlist? */
@@ -17,19 +18,6 @@
#warning Skipping vasprintf since no vsnprintf!
#else
-/* Deal with pre-C99 compilers. */
-
-#ifndef va_copy
-
-#ifdef __va_copy
-#define va_copy(A,B) __va_copy(A,B)
-#else
-#warning Neither va_copy (C99/SUSv3) nor __va_copy is defined. Using a simple copy instead. But you should really check that this is appropriate...
-#define va_copy(A,B) A = B
-#endif
-
-#endif /* va_copy */
-
int vasprintf(char **__restrict buf, const char * __restrict format,
va_list arg)
{
diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c
index 49b4d11a3..d3214fff0 100644
--- a/libc/stdio/vfprintf.c
+++ b/libc/stdio/vfprintf.c
@@ -118,6 +118,7 @@
#endif /* __UCLIBC_HAS_WCHAR__ */
#include <bits/uClibc_uintmaxtostr.h>
+#include <bits/uClibc_va_copy.h>
/* Some older or broken gcc toolchains define LONG_LONG_MAX but not
* LLONG_MAX. Since LLONG_MAX is part of the standard, that's what
@@ -205,27 +206,6 @@
#define MAX_ARGS (MAX_ARGS_PER_SPEC + 2)
#endif
-
-/**********************************************************************/
-/* Deal with pre-C99 compilers. */
-
-#ifndef va_copy
-
-#ifdef __va_copy
-#define va_copy(A,B) __va_copy(A,B)
-#else
- /* TODO -- maybe create a bits/vacopy.h for arch specific versions
- * to ensure we get the right behavior? Either that or fall back
- * on the portable (but costly in size) method of using a va_list *.
- * That means a pointer derefs in the va_arg() invocations... */
-#warning Neither va_copy (C99/SUSv3) or __va_copy is defined. Using a simple copy instead. But you should really check that this is appropriate...
- /* the glibc manual suggests that this will usually suffice when
- __va_copy doesn't exist. */
-#define va_copy(A,B) A = B
-#endif
-
-#endif /* va_copy */
-
/**********************************************************************/
#define __PA_FLAG_INTMASK \
diff --git a/libc/sysdeps/linux/common/bits/uClibc_va_copy.h b/libc/sysdeps/linux/common/bits/uClibc_va_copy.h
new file mode 100644
index 000000000..cc41b6029
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/uClibc_va_copy.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2005 Manuel Novoa III <mjn3@codepoet.org>
+ *
+ * GNU Library General Public License (LGPL) version 2 or later.
+ *
+ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
+ */
+
+#ifndef _UCLIBC_VA_COPY_H
+#define _UCLIBC_VA_COPY_H 1
+
+#include <stdarg.h>
+
+/* Deal with pre-C99 compilers. */
+#ifndef va_copy
+
+#ifdef __va_copy
+#define va_copy(A,B) __va_copy(A,B)
+#else
+#warning Neither va_copy (C99/SUSv3) or __va_copy is defined. Using a simple copy instead. But you should really check that this is appropriate and supply an arch-specific override if necessary.
+ /* the glibc manual suggests that this will usually suffice when
+ __va_copy doesn't exist. */
+#define va_copy(A,B) A = B
+#endif
+
+#endif /* va_copy */
+
+#endif /* _UCLIBC_VA_COPY_H */