aboutsummaryrefslogtreecommitdiff
path: root/testsuite/ltrace.main/parameters-lib.c
blob: 893db0270d368ef73342f4fd9f0d46f1f1da6876 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#include <string.h>
#include <stdio.h>

void func_ignore(int a, int b, int c)
{
	printf("%d\n", a + b + c);
}

void func_intptr(int *i)
{
	printf("%d\n", *i);
}

void func_intptr_ret(int *i)
{
	*i = 42;
}

int func_strlen(char* p)
{
	strcpy(p, "Hello world");
	return strlen(p);
}

int func_arg0(char *p)
{
	strcpy(p, "Hello another world!");
	return strlen(p);
}

void func_strfixed(char* p)
{
	strcpy(p, "Hello world");
}

void func_string(char* p)
{
	printf("%s\n", p);
}

void func_ppp(int*** ppp)
{
	printf("%d\n", ***ppp);
}

void func_stringp(char** sP)
{
	printf("%s\n", *sP);
}

void func_enum(int x)
{
	printf("enum: %d\n", x);
}

void func_short(short x1, short x2)
{
	printf("short: %hd %hd\n", x1, x2);
}

void func_ushort(unsigned short x1, unsigned short x2)
{
	printf("ushort: %hu %hu\n", x1, x2);
}

float func_float(float f1, float f2)
{
	printf("%f %f\n", f1, f2);
	return f1;
}

double func_double(double f1, double f2)
{
	printf("%f %f\n", f1, f2);
	return f2;
}

void func_typedef(int x)
{
	printf("typedef'd enum: %d\n", x);
}

void func_arrayi(int* a, int N)
{
    int i;
    printf("array[int]: ");
    for (i = 0; i < N; i++)
	printf("%d ", a[i]);
    printf("\n");
}

void func_arrayf(float* a, int N)
{
    int i;
    printf("array[float]: ");
    for (i = 0; i < N; i++)
	printf("%f ", a[i]);
    printf("\n");
}

struct test_struct {
    int simple;
    int alen;
    int slen;
    struct { int a; int b; }* array;
    struct { int a; int b; } seq[3];
    char* str;
    char* outer_str;
};

void func_struct(struct test_struct* x)
{
    char buf[100];
    int i;

    printf("struct: ");

    printf("%d, [", x->simple);
    for (i = 0; i < x->alen; i++) {
	printf("%d/%d", x->array[i].a, x->array[i].b);
	if (i < x->alen - 1)
	    printf(" ");
    }
    printf("] [");
    for (i = 0; i < 3; i++) {
	printf("%d/%d", x->seq[i].a, x->seq[i].b);
	if (i < 2)
	    printf(" ");
    }
    printf("] ");

    strncpy(buf, x->str, x->slen);
    buf[x->slen] = '\0';
    printf("%s\n", buf);
}

void func_work (char *x)
{
  *x = 'x';
}

void func_call (char *x, char* y, void (*cb) (char *))
{
  cb (y);
  *x = (*y)++;
}

struct S2 {
	float f;
	char a;
	char b;
};

struct S3 {
	char a[6];
	float f;
};

struct S2
func_struct_2(int i, struct S3 s3, double d)
{
	return (struct S2){ s3.f, s3.a[1], s3.a[2] };
}

struct S4 {
	long a;
	long b;
	long c;
	long d;
};

struct S4
func_struct_large(struct S4 a, struct S4 b)
{
	return (struct S4){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d };
}

struct S5 {
	char a;
	char b;
	long c;
	long d;
};

struct S5
func_struct_large2(struct S5 a, struct S5 b)
{
	return (struct S5){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d };
}

struct S6 {
	long a;
	long b;
	char c;
	char d;
};

struct S6
func_struct_large3(struct S6 a, struct S6 b)
{
	return (struct S6){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d };
}

void
func_many_args(int a, int b, long c, double d, char e, int f, float g, char h,
	       int i, double j, int k, double l, char m, int n, short o, int p,
	       char q, float r, float s, double t, long u, float v, float w,
	       float x, float y)
{
}

void
func_lens(int a, long b, short c, long d)
{
}

int
func_bool(int a, int b)
{
	return !b;
}

void
func_hide(int a, int b, int c, int d, int e, int f)
{
}

struct func_hide_struct {
	int a; int b; int c; int d; int e; int f; int g; int h;
};

void
func_hide_struct(struct func_hide_struct s)
{
}

long *
func_short_enums(short values[])
{
	static long retvals[4];
	retvals[0] = values[0];
	retvals[1] = values[1];
	retvals[2] = values[2];
	retvals[3] = values[3];
	return retvals;
}

long
func_negative_enum(short a, unsigned short b, int c, unsigned d,
		   long e, unsigned long f)
{
	return -1;
}

void
func_charp_string(char *p)
{
}

struct struct_empty {};
struct struct_size1 { char a; };
struct struct_size2 { short a; };
struct struct_size4 { int a; };
struct struct_size8 { int a; int b; };

struct struct_empty
func_struct_empty(struct struct_empty e)
{
	return e;
}

struct struct_size1
func_struct_size1(struct struct_size1 e)
{
	return e;
}

struct struct_size2
func_struct_size2(struct struct_size2 e)
{
	return e;
}

struct struct_size4
func_struct_size4(struct struct_size4 e)
{
	return e;
}

struct struct_size8
func_struct_size8(struct struct_size8 e)
{
	return e;
}

void
func_printf(char *format, ...)
{
}

void
func_sprintf(char *str, char *format, ...)
{
}