File: test-varargs.c

package info (click to toggle)
libunwind 0.98.5-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 3,704 kB
  • ctags: 2,701
  • sloc: ansic: 16,594; sh: 11,043; asm: 1,216; makefile: 482; cpp: 70
file content (52 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

extern int backtrace (void **, int);

static void
b (void)
{
  void *v[20];
  int i, n;

  n = backtrace(v, 20);
  for (i = 0; i < n; ++i)
    printf ("[%d] %p\n", i, v[i]);
}

static void
c (void)
{
    b ();
}

static void
a (int d, ...)
{
  switch (d)
    {
    case 5:
      a (4, 2,4);
      break;
    case 4:
      a (3, 1,3,5);
      break;
    case 3:
      a (2, 11, 13, 17, 23);
      break;
    case 2:
      a (1);
      break;
    case 1:
      c ();
    }
}

int
main (int argc, char **argv)
{
  a (5, 3, 4, 5, 6);
  return 0;
}