]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use a better workaround for clang lack of _builtin_va_arg_pack
authorStan Shebs <stanshebs@google.com>
Fri, 12 Nov 2021 14:48:03 +0000 (06:48 -0800)
committerStan Shebs <stanshebs@google.com>
Fri, 12 Nov 2021 14:48:03 +0000 (06:48 -0800)
sysdeps/generic/ldsodefs.h

index 0495f85e845b000a4c88f7dba1e547289895ec81..8759f6e561610e8a43516558899e26771fcd151e 100644 (file)
@@ -744,15 +744,26 @@ extern void _dl_dprintf (int fd, const char *fmt, ...)
      __attribute__ ((__format__ (__printf__, 2, 3)))
      attribute_hidden;
 #else
+#if defined(__clang__)
+#include <stdarg.h>
+#endif
 __attribute__ ((always_inline, __format__ (__printf__, 2, 3)))
 static inline void
 _dl_dprintf (int fd, const char *fmt, ...)
 {
-  /* Use local declaration to avoid includign <stdio.h>.  */
-  extern int __dprintf(int fd, const char *format, ...) attribute_hidden;
 #if defined(__clang__)
-  __dprintf (fd, fmt);
+  /* In the absence of __builtin_va_arg_pack, use varargs macros to construct a
+     direct call to the stdio function that __dprintf eventually gets to.  This
+     is not a robust hack, will break if stdio changes much.  */
+  extern int _IO_vdprintf (int d, const char *format, va_list arg);
+  va_list arg;
+
+  va_start (arg, fmt);
+  _IO_vdprintf (fd, fmt, arg);
+  va_end (arg);
 #else
+  /* Use local declaration to avoid includign <stdio.h>.  */
+  extern int __dprintf(int fd, const char *format, ...) attribute_hidden;
   __dprintf (fd, fmt, __builtin_va_arg_pack ());
 #endif
 }