summaryrefslogtreecommitdiff
path: root/tests/stdargs_for_signal_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdargs_for_signal_functions.c')
-rw-r--r--tests/stdargs_for_signal_functions.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/stdargs_for_signal_functions.c b/tests/stdargs_for_signal_functions.c
new file mode 100644
index 0000000..f752630
--- /dev/null
+++ b/tests/stdargs_for_signal_functions.c
@@ -0,0 +1,33 @@
+#include <stdarg.h>
+#include <stdio.h>
+
+static void vf2( const char *s, int a, va_list ap ) {
+ int v;
+
+ printf( "ap: %s %d", s, a );
+ v = va_arg( ap, int );
+ while( v != 0 ) {
+ printf( "%d ", v );
+ v = va_arg( ap, int );
+ }
+ puts( "" );
+}
+
+static void f2( const char *s, int a, ... ) {
+ va_list ap;
+ va_start( ap, a );
+ vf2( s, a, ap );
+ va_end( ap );
+}
+
+static void f( int a, ... ) {
+ va_list ap;
+ va_start( ap, a );
+ vf2( "f", a, ap );
+ va_end( ap );
+}
+
+int main( void ) {
+ f2( "f2", 1, 2, 3, 4, 0 );
+ f( 1, 2, 3, 4, 0 );
+}