Commit | Line | Data |
---|---|---|
ef44eed1 SS |
1 | #ifdef vxworks |
2 | # include <vxWorks.h> | |
3 | # include <stdioLib.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 | if (argc != 2) { | |
57 | fprintf (stderr, "usage: factorial <number>\n"); | |
58 | return 1; | |
59 | } else { | |
60 | printf ("%d\n", factorial (atoi (argv[1]))); | |
61 | } | |
62 | marker1 (); | |
63 | marker2 (43); | |
64 | marker3 ("stack", "trace"); | |
65 | marker4 (177601976L); | |
66 | return 0; | |
67 | } | |
68 | ||
69 | int factorial (value) | |
70 | int value; | |
71 | { | |
72 | if (value > 1) { | |
73 | value *= factorial (value - 1); | |
74 | } | |
75 | return (value); | |
76 | } | |
77 |