Commit | Line | Data |
---|---|---|
085dd6e6 | 1 | #include <stdlib.h> |
7022349d PA |
2 | #include <stdint.h> |
3 | ||
c906108c SS |
4 | /* Test that things still (sort of) work when compiled without -g. */ |
5 | ||
6 | int dataglobal = 3; /* Should go in global data */ | |
7 | static int datalocal = 4; /* Should go in local data */ | |
8 | int bssglobal; /* Should go in global bss */ | |
9 | static int bsslocal; /* Should go in local bss */ | |
10 | ||
46a4882b PA |
11 | /* Non-int-sized global data variables. */ |
12 | uint8_t dataglobal8 = 0xff; | |
13 | uint32_t dataglobal32_1 = 0x7fffffff; | |
14 | uint32_t dataglobal32_2 = 0x000000ff; | |
15 | uint64_t dataglobal64_1 = 0x7fffffffffffffff; | |
16 | uint64_t dataglobal64_2 = 0x00000000000000ff; | |
17 | ||
085dd6e6 JM |
18 | int |
19 | inner (int x) | |
c906108c SS |
20 | { |
21 | return x + dataglobal + datalocal + bssglobal + bsslocal; | |
22 | } | |
23 | ||
085dd6e6 JM |
24 | static short |
25 | middle (int x) | |
c906108c SS |
26 | { |
27 | return 2 * inner (x); | |
28 | } | |
29 | ||
085dd6e6 JM |
30 | short |
31 | top (int x) | |
c906108c SS |
32 | { |
33 | return 2 * middle (x); | |
34 | } | |
35 | ||
085dd6e6 JM |
36 | int |
37 | main (int argc, char **argv) | |
c906108c | 38 | { |
c906108c SS |
39 | return top (argc); |
40 | } | |
41 | ||
c906108c SS |
42 | int *x; |
43 | ||
085dd6e6 | 44 | int array_index (char *arr, int i) |
c906108c SS |
45 | { |
46 | /* The basic concept is just "return arr[i];". But call malloc so that gdb | |
47 | will be able to call functions. */ | |
48 | char retval; | |
49 | x = (int *) malloc (sizeof (int)); | |
50 | *x = i; | |
51 | retval = arr[*x]; | |
52 | free (x); | |
53 | return retval; | |
54 | } | |
7022349d PA |
55 | |
56 | float | |
57 | multf (float v1, float v2) | |
58 | { | |
59 | return v1 * v2; | |
60 | } | |
61 | ||
62 | float | |
63 | multf_noproto (v1, v2) | |
64 | float v1, v2; | |
65 | { | |
66 | return v1 * v2; | |
67 | } | |
68 | ||
69 | double | |
70 | mult (double v1, double v2) | |
71 | { | |
72 | return v1 * v2; | |
73 | } | |
74 | ||
75 | double | |
76 | mult_noproto (v1, v2) | |
77 | double v1, v2; | |
78 | { | |
79 | return v1 * v2; | |
80 | } | |
81 | ||
82 | uint8_t | |
83 | add8 (uint8_t v1, uint8_t v2) | |
84 | { | |
85 | return v1 + v2; | |
86 | } | |
87 | ||
88 | uint8_t | |
89 | add8_noproto (v1, v2) | |
90 | uint8_t v1, v2; | |
91 | { | |
92 | return v1 + v2; | |
93 | } |