path: root/include
diff options
authorRich Felker <>2011-04-27 23:41:48 -0400
committerRich Felker <>2011-04-27 23:41:48 -0400
commitdef0af189871a499efdc9bc37438d8b20eb702ab (patch)
treed63aa5d2b91fd1dfc6098f41871eb582f4da5655 /include
parente6bac87d0eaab116878a04874bc5b6a3496cb938 (diff)
use compiler builtins for variadic macros when available
this slightly cuts down on the degree musl "fights with" gcc, but more importantly, it fixes a critical bug when gcc inlines a variadic function and optimizes out the variadic arguments due to noticing that they were "not used" (by __builtin_va_arg). we leave the old code in place if __GNUC__ >= 3 is false; it seems like it might be necessary at least for tinycc support and perhaps if anyone ever gets around to fixing gcc 2.95.3 enough to make it work..
Diffstat (limited to 'include')
1 files changed, 7 insertions, 0 deletions
diff --git a/include/stdarg.h b/include/stdarg.h
index 2e18e5f5..60d4e2af 100644
--- a/include/stdarg.h
+++ b/include/stdarg.h
@@ -9,7 +9,14 @@ extern "C" {
#include <bits/alltypes.h>
+#if __GNUC__ >= 3
+#define va_start(v,l) __builtin_va_start(v,l)
+#define va_end(v) __builtin_va_end(v)
+#define va_arg(v,l) __builtin_va_arg(v,l)
+#define va_copy(d,s) __builtin_va_copy(d,s)
#include <bits/stdarg.h>
#ifdef __cplusplus