]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | #ifdef vxworks |
2 | ||
3 | # include <stdio.h> | |
4 | ||
5 | /* VxWorks does not supply atoi. */ | |
6 | static int | |
7 | atoi (z) | |
8 | char *z; | |
9 | { | |
10 | int i = 0; | |
11 | ||
12 | while (*z >= '0' && *z <= '9') | |
13 | i = i * 10 + (*z++ - '0'); | |
14 | return i; | |
15 | } | |
16 | ||
17 | /* I don't know of any way to pass an array to VxWorks. This function | |
18 | can be called directly from gdb. */ | |
19 | ||
20 | vxmain (arg) | |
21 | char *arg; | |
22 | { | |
23 | char *argv[2]; | |
24 | ||
25 | argv[0] = ""; | |
26 | argv[1] = arg; | |
27 | main (2, argv, (char **) 0); | |
28 | } | |
29 | ||
30 | #else /* ! vxworks */ | |
31 | # include <stdio.h> | |
32 | #endif /* ! vxworks */ | |
33 | ||
34 | /* | |
35 | * The following functions do nothing useful. They are included simply | |
36 | * as places to try setting breakpoints at. They are explicitly | |
37 | * "one-line functions" to verify that this case works (some versions | |
38 | * of gcc have or have had problems with this). | |
39 | */ | |
40 | ||
41 | int marker1 () { return (0); } | |
42 | int marker2 (a) int a; { return (1); } | |
43 | void marker3 (a, b) char *a, *b; {} | |
44 | void marker4 (d) long d; {} | |
45 | ||
46 | /* | |
47 | * This simple classical example of recursion is useful for | |
48 | * testing stack backtraces and such. | |
49 | */ | |
50 | ||
51 | int | |
52 | main (argc, argv, envp) | |
53 | int argc; | |
54 | char *argv[], **envp; | |
55 | { | |
56 | #ifdef usestubs | |
57 | set_debug_traps(); | |
58 | breakpoint(); | |
59 | #endif | |
60 | if (argc == 123456) { | |
61 | fprintf (stderr, "usage: factorial <number>\n"); | |
62 | return 1; | |
63 | } | |
64 | printf ("%d\n", factorial (atoi ("6"))); | |
65 | ||
66 | marker1 (); | |
67 | marker2 (43); | |
68 | marker3 ("stack", "trace"); | |
69 | marker4 (177601976L); | |
70 | return 0; | |
71 | } | |
72 | ||
73 | int factorial (value) | |
74 | int value; | |
75 | { | |
76 | if (value > 1) { | |
77 | value *= factorial (value - 1); | |
78 | } | |
79 | return (value); | |
80 | } | |
81 |