~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to testsuite/ffitest.h

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 *  ffitest.h
 
3
 *  
 
4
 *   Copyright (c) 2006 KOGURO, Naoki (naoki@koguro.net)
 
5
 *  
 
6
 *   Permission is hereby granted, free of charge, to any person 
 
7
 *   obtaining a copy of this software and associated 
 
8
 *   documentation files (the "Software"), to deal in the 
 
9
 *   Software without restriction, including without limitation 
 
10
 *   the rights to use, copy, modify, merge, publish, distribute, 
 
11
 *   sublicense, and/or sell copies of the Software, and to 
 
12
 *   permit persons to whom the Software is furnished to do so, 
 
13
 *   subject to the following conditions:
 
14
 *  
 
15
 *   The above copyright notice and this permission notice shall 
 
16
 *   be included in all copies or substantial portions of the 
 
17
 *   Software.
 
18
 *  
 
19
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 
 
20
 *   KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
 
21
 *   WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 
22
 *   PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 
 
23
 *   OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
 
24
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
 
25
 *   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 
26
 *   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
27
 *  
 
28
 *   $Id: $
 
29
 */
 
30
 
 
31
#include <stdio.h>
 
32
#include <string.h>
 
33
#include <stdlib.h>
 
34
#include <stdarg.h>
 
35
 
 
36
extern char var_char;
 
37
extern short var_short;
 
38
extern int var_int;
 
39
extern long var_long;
 
40
extern long long var_longlong;
 
41
extern unsigned char var_uchar;
 
42
extern unsigned short var_ushort;
 
43
extern unsigned int var_uint;
 
44
extern unsigned long var_ulong;
 
45
extern unsigned long long var_ulonglong;
 
46
extern float var_float;
 
47
extern double var_double;
 
48
extern char *var_string;
 
49
 
 
50
extern void test_var(void);
 
51
 
 
52
struct test_uchar {
 
53
    char dummy;
 
54
    unsigned char value;
 
55
};
 
56
 
 
57
struct test_ushort {
 
58
    char dummy;
 
59
    unsigned short value;
 
60
};
 
61
 
 
62
struct test_uint {
 
63
    char dummy;
 
64
    unsigned int value;
 
65
};
 
66
 
 
67
struct test_ulong {
 
68
    char dummy;
 
69
    unsigned long value;
 
70
};
 
71
 
 
72
struct test_ulonglong {
 
73
    char dummy;
 
74
    unsigned long long value;
 
75
};
 
76
 
 
77
struct test_schar {
 
78
    char dummy;
 
79
    signed char value;
 
80
};
 
81
 
 
82
struct test_sshort {
 
83
    char dummy;
 
84
    signed short value;
 
85
};
 
86
 
 
87
struct test_sint {
 
88
    char dummy;
 
89
    signed int value;
 
90
};
 
91
 
 
92
struct test_slong {
 
93
    char dummy;
 
94
    signed long value;
 
95
};
 
96
 
 
97
struct test_slonglong {
 
98
    char dummy;
 
99
    signed long long value;
 
100
};
 
101
 
 
102
struct test_float {
 
103
    char dummy;
 
104
    float value;
 
105
};
 
106
 
 
107
struct test_double {
 
108
    char dummy;
 
109
    double value;
 
110
};
 
111
 
 
112
struct test_string {
 
113
    char dummy;
 
114
    char *value;
 
115
};
 
116
 
 
117
#define DEFINE_TEST_STRUCT_ARRAY(type, ctype) \
 
118
struct test_array_##type { \
 
119
    char dummy; \
 
120
    ctype value[3]; \
 
121
};
 
122
 
 
123
DEFINE_TEST_STRUCT_ARRAY(uchar, unsigned char)
 
124
DEFINE_TEST_STRUCT_ARRAY(ushort, unsigned short)
 
125
DEFINE_TEST_STRUCT_ARRAY(uint, unsigned int)
 
126
DEFINE_TEST_STRUCT_ARRAY(ulong, unsigned long)
 
127
DEFINE_TEST_STRUCT_ARRAY(ulonglong, unsigned long long)
 
128
DEFINE_TEST_STRUCT_ARRAY(schar, signed char)
 
129
DEFINE_TEST_STRUCT_ARRAY(sshort, signed short)
 
130
DEFINE_TEST_STRUCT_ARRAY(sint, signed int)
 
131
DEFINE_TEST_STRUCT_ARRAY(slong, signed long)
 
132
DEFINE_TEST_STRUCT_ARRAY(slonglong, signed long long)
 
133
DEFINE_TEST_STRUCT_ARRAY(float, float)
 
134
DEFINE_TEST_STRUCT_ARRAY(double, double)
 
135
DEFINE_TEST_STRUCT_ARRAY(string, char*)
 
136
 
 
137
extern struct test_uchar add_struct_uchar(struct test_uchar v1,
 
138
                                          struct test_uchar v2);
 
139
extern struct test_ushort add_struct_ushort(struct test_ushort v1,
 
140
                                            struct test_ushort v2);
 
141
extern struct test_uint add_struct_uint(struct test_uint v1,
 
142
                                        struct test_uint v2);
 
143
extern struct test_ulong add_struct_ulong(struct test_ulong v1,
 
144
                                          struct test_ulong v2);
 
145
extern struct test_ulonglong add_struct_ulonglong(struct test_ulonglong v1,
 
146
                                                  struct test_ulonglong v2);
 
147
extern struct test_schar add_struct_schar(struct test_schar v1,
 
148
                                          struct test_schar v2);
 
149
extern struct test_sshort add_struct_sshort(struct test_sshort v1,
 
150
                                            struct test_sshort v2);
 
151
extern struct test_sint add_struct_sint(struct test_sint v1,
 
152
                                        struct test_sint v2);
 
153
extern struct test_slong add_struct_slong(struct test_slong v1,
 
154
                                          struct test_slong v2);
 
155
extern struct test_slonglong add_struct_slonglong(struct test_slonglong v1,
 
156
                                                  struct test_slonglong v2);
 
157
extern struct test_float add_struct_float(struct test_float v1,
 
158
                                          struct test_float v2);
 
159
extern struct test_double add_struct_double(struct test_double v1,
 
160
                                            struct test_double v2);
 
161
extern struct test_string add_struct_string(struct test_string v1,
 
162
                                            struct test_string v2);
 
163
 
 
164
#define EXTERN_FUNC_TEST_STRUCT_ARRAY(type) \
 
165
extern struct test_array_##type \
 
166
add_struct_array_##type(struct test_array_##type v1, \
 
167
                        struct test_array_##type v2);
 
168
 
 
169
EXTERN_FUNC_TEST_STRUCT_ARRAY(uchar)
 
170
EXTERN_FUNC_TEST_STRUCT_ARRAY(ushort)
 
171
EXTERN_FUNC_TEST_STRUCT_ARRAY(uint)
 
172
EXTERN_FUNC_TEST_STRUCT_ARRAY(ulong)
 
173
EXTERN_FUNC_TEST_STRUCT_ARRAY(ulonglong)
 
174
EXTERN_FUNC_TEST_STRUCT_ARRAY(schar)
 
175
EXTERN_FUNC_TEST_STRUCT_ARRAY(sshort)
 
176
EXTERN_FUNC_TEST_STRUCT_ARRAY(sint)
 
177
EXTERN_FUNC_TEST_STRUCT_ARRAY(slong)
 
178
EXTERN_FUNC_TEST_STRUCT_ARRAY(slonglong)
 
179
EXTERN_FUNC_TEST_STRUCT_ARRAY(float)
 
180
EXTERN_FUNC_TEST_STRUCT_ARRAY(double)
 
181
EXTERN_FUNC_TEST_STRUCT_ARRAY(string)
 
182
 
 
183
extern unsigned char add_uchar(unsigned char v1, unsigned char v2);
 
184
extern signed char add_schar(signed char v1, signed char v2);
 
185
extern unsigned short add_ushort(unsigned short v1, unsigned short v2);
 
186
extern signed short add_sshort(signed short v1, signed short v2);
 
187
extern unsigned int add_uint(unsigned int v1, unsigned int v2);
 
188
extern signed int add_sint(signed int v1, signed int v2);
 
189
extern unsigned long add_ulong(unsigned long v1, unsigned long v2);
 
190
extern signed long add_slong(signed long v1, signed long v2);
 
191
extern unsigned long long add_ulonglong(unsigned long long v1,
 
192
                                        unsigned long long v2);
 
193
extern signed long long add_slonglong(signed long long v1, signed long long v2);
 
194
extern float add_float(float v1, float v2);
 
195
extern double add_double(double v1, double v2);
 
196
extern const char *add_string(const char *v1, const char *v2);
 
197
 
 
198
extern unsigned char *add_array_uchar(int size, unsigned char v1[],
 
199
                                      unsigned char v2[]);
 
200
extern signed char *add_array_schar(int size, signed char v1[],
 
201
                                    signed char v2[]);
 
202
extern unsigned short *add_array_ushort(int size, unsigned short v1[],
 
203
                                        unsigned short v2[]);
 
204
extern signed short *add_array_sshort(int size, signed short v1[],
 
205
                                      signed short v2[]);
 
206
extern unsigned int *add_array_uint(int size, unsigned int v1[],
 
207
                                    unsigned int v2[]);
 
208
extern signed int *add_array_sint(int size, signed int v1[], signed int v2[]);
 
209
extern unsigned long *add_array_ulong(int size, unsigned long v1[],
 
210
                                      unsigned long v2[]);
 
211
extern signed long *add_array_slong(int size, signed long v1[],
 
212
                                    signed long v2[]);
 
213
extern unsigned long long *add_array_ulonglong(int size, unsigned long long v1[], 
 
214
                                               unsigned long long v2[]);
 
215
extern signed long long *add_array_slonglong(int size, signed long long v1[], 
 
216
                                             signed long long v2[]);
 
217
extern float *add_array_float(int size, float v1[], float v2[]);
 
218
extern double *add_array_double(int size, double v1[], double v2[]);
 
219
extern char **add_array_string(int size, const char *v1[], const char *v2[]);
 
220
 
 
221
extern unsigned char callback_uchar(unsigned char (*fn)(unsigned char,
 
222
                                                        unsigned char),
 
223
                                    unsigned char v1, unsigned char v2);
 
224
extern signed char callback_schar(signed char (*)(signed char, signed char),
 
225
                                  signed char v1, signed char v2);
 
226
extern unsigned short callback_ushort(unsigned short (*fn)(unsigned short, 
 
227
                                                           unsigned short),
 
228
                                      unsigned short v1, unsigned short v2);
 
229
extern signed short callback_sshort(signed short (*fn)(signed short,
 
230
                                                       signed short),
 
231
                                    signed short v1, signed short v2);
 
232
extern unsigned int callback_uint(unsigned int (*fn)(unsigned int, unsigned int),
 
233
                                  unsigned int v1, unsigned int v2);
 
234
extern signed int callback_sint(signed int (*fn)(signed int, signed int),
 
235
                                signed int v1, signed int v2);
 
236
extern unsigned long callback_ulong(unsigned long (*fn)(unsigned long,
 
237
                                                        unsigned long),
 
238
                                    unsigned long v1, unsigned long v2);
 
239
extern signed long callback_slong(signed long (*fn)(signed long, signed long),
 
240
                                  signed long v1, signed long v2);
 
241
extern unsigned long long callback_ulonglong(unsigned long long (*fn)(unsigned long long,
 
242
                                                                      unsigned long long),
 
243
                                             unsigned long long v1, unsigned long long v2);
 
244
extern signed long long callback_slonglong(signed long long (*fn)(signed long long,
 
245
                                                                  signed long long),
 
246
                                           signed long long v1, signed long long v2);
 
247
extern float callback_float(float (*fn)(float, float), float v1, float v2);
 
248
extern double callback_double(double (*fn)(double, double), double v1, double v2);
 
249
extern const char *callback_string(const char *(*fn)(const char *, const char*),
 
250
                                   const char *v1, const char *v2);
 
251
 
 
252
#define EXTERN_FUNC_VAARG(type, ctype) extern ctype *vaarg_##type(int nargs, ...);
 
253
EXTERN_FUNC_VAARG(uint, unsigned int)
 
254
EXTERN_FUNC_VAARG(ulong, unsigned long)
 
255
EXTERN_FUNC_VAARG(ulonglong, unsigned long long)
 
256
EXTERN_FUNC_VAARG(sint, signed int)
 
257
EXTERN_FUNC_VAARG(slong, signed long)
 
258
EXTERN_FUNC_VAARG(slonglong, signed long long)
 
259
EXTERN_FUNC_VAARG(double, double)
 
260
EXTERN_FUNC_VAARG(string, char*)
 
261
 
 
262
union test {
 
263
    char c;
 
264
    short s;
 
265
    int i;
 
266
    long l;
 
267
    long long ll;
 
268
    float f;
 
269
    double d;
 
270
    char *str;
 
271
};
 
272
#define EXTERN_FUNC_TEST_UNION(name) extern union test test_union_##name(union test v1, union test v2);
 
273
EXTERN_FUNC_TEST_UNION(c)
 
274
EXTERN_FUNC_TEST_UNION(s)
 
275
EXTERN_FUNC_TEST_UNION(i)
 
276
EXTERN_FUNC_TEST_UNION(l)
 
277
EXTERN_FUNC_TEST_UNION(ll)
 
278
EXTERN_FUNC_TEST_UNION(f)
 
279
EXTERN_FUNC_TEST_UNION(d)
 
280
EXTERN_FUNC_TEST_UNION(str)
 
281
 
 
282
extern void test_modify(int *v);
 
283
 
 
284
extern int incomplete_array[];
 
285
 
 
286
extern int test_null_ptr(void *ptr1);
 
287
extern int test_null_func_ptr(int (*fn)(void *ptr));
 
288
 
 
289
extern int test_val;
 
290
 
 
291
extern int *test_ptr;
 
292
extern int test_array[];
 
293
extern void init_test_ptr();
 
294
 
 
295
#define post_pp(x) ((x)++)
 
296
#define post_mm(x) ((x)--)
 
297
#define pre_pp(x) (++(x))
 
298
#define pre_mm(x) (--(x))
 
299
#define plus(x, y) ((x)+(y))
 
300
#define minus(x, y) ((x)-(y))
 
301
 
 
302
struct bitfield_rec {
 
303
    signed v1 : 3;
 
304
    unsigned v2 : 3;
 
305
    signed dummy1 : 30;
 
306
    unsigned v3 : 2;
 
307
    signed v4 : 16;
 
308
    float dummy2;
 
309
    unsigned : 4;
 
310
    unsigned v5 : 3;
 
311
};
 
312
extern struct bitfield_rec test_bitfield(struct bitfield_rec dat);
 
313
 
 
314
#define IFMAC(test,then_expr,else_expr) ((test)?(then_expr):(else_expr))
 
315
 
 
316
/* test funcations for inline function */
 
317
inline int return_const()
 
318
{
 
319
    return 1;
 
320
}
 
321
 
 
322
inline char *return_string()
 
323
{
 
324
    return "foo";
 
325
}
 
326
 
 
327
inline int ref_array(int a[])
 
328
{
 
329
    return a[1];
 
330
}
 
331
 
 
332
inline void funccall1()
 
333
{
 
334
    init_test_ptr();
 
335
}
 
336
 
 
337
inline int funcall2(int a, int b)
 
338
{
 
339
    return add_sint(a, b);
 
340
}
 
341
 
 
342
inline int ref_struct1()
 
343
{
 
344
    struct test_sint a;
 
345
    a.value = 1;
 
346
    return a.value;
 
347
}
 
348
 
 
349
inline int ref_struct2(struct test_sint *p)
 
350
{
 
351
    return p->value;
 
352
}
 
353
 
 
354
inline int post_inc()
 
355
{
 
356
    int a = 1;
 
357
    a++;
 
358
    return a;
 
359
}
 
360
 
 
361
inline int post_dec()
 
362
{
 
363
    int a = 2;
 
364
    a--;
 
365
    return a;
 
366
}
 
367
 
 
368
inline int pre_inc()
 
369
{
 
370
    int a = 1;
 
371
    return ++a;
 
372
}
 
373
 
 
374
inline int pre_dec()
 
375
{
 
376
    int a = 2;
 
377
    return --a;
 
378
}
 
379
 
 
380
inline int unary_plus()
 
381
{
 
382
    return +1;
 
383
}
 
384
 
 
385
inline int unary_minus()
 
386
{
 
387
    return -1;
 
388
}
 
389
 
 
390
inline int unary_logneg(int a)
 
391
{
 
392
    return !a;
 
393
}
 
394
 
 
395
inline int unary_bitneg(int a)
 
396
{
 
397
    return ~a;
 
398
}
 
399
 
 
400
inline int unary_ref()
 
401
{
 
402
    int a;
 
403
    sscanf("123", "%d", &a);
 
404
    return a;
 
405
}
 
406
 
 
407
inline int *unary_deref()
 
408
{
 
409
    void *p0 = (int*) malloc(sizeof(int));
 
410
    int *p = (int*)p0;
 
411
    *p = 456;
 
412
    return p;
 
413
}
 
414
 
 
415
inline long op_sizeof()
 
416
{
 
417
    return sizeof(int);
 
418
}
 
419
 
 
420
inline int mul(int a, int b)
 
421
{
 
422
    return a*b;
 
423
}
 
424
 
 
425
inline int divi(int a, int b)
 
426
{
 
427
    return a/b;
 
428
}
 
429
 
 
430
inline int mod(int a, int b)
 
431
{
 
432
    return a%b;
 
433
}
 
434
 
 
435
inline int add(int a, int b)
 
436
{
 
437
    return a+b;
 
438
}
 
439
 
 
440
inline int sub(int a, int b)
 
441
{
 
442
    return a-b;
 
443
}
 
444
 
 
445
inline int left_shift(int a, int b)
 
446
{
 
447
    return a<<b;
 
448
}
 
449
 
 
450
inline int right_shift(int a, int b)
 
451
{
 
452
    return a>>b;
 
453
}
 
454
 
 
455
inline int op_lt(int a, int b)
 
456
{
 
457
    if (a<b) {
 
458
        return 1;
 
459
    } else 
 
460
        return 0;
 
461
}
 
462
 
 
463
inline int op_gt(int a, int b)
 
464
{
 
465
    if (a>b)
 
466
        return 1;
 
467
    else {
 
468
        return 0;
 
469
    }
 
470
}
 
471
 
 
472
inline int op_lteq(int a, int b)
 
473
{
 
474
    if (a<=b)
 
475
        return 1;
 
476
    else 
 
477
        return 0;
 
478
}
 
479
 
 
480
inline int op_gteq(int a, int b)
 
481
{
 
482
    if (a>=b) {
 
483
        return 1;
 
484
    } else {
 
485
        return 0;
 
486
    }
 
487
}
 
488
 
 
489
inline int op_eq(int a, int b)
 
490
{
 
491
    if (a==b) {
 
492
        return 1;
 
493
    } else {
 
494
        return 0;
 
495
    }
 
496
}
 
497
 
 
498
inline int op_noteq(int a, int b)
 
499
{
 
500
    if (a!=b) {
 
501
        return 1;
 
502
    } else {
 
503
        return 0;
 
504
    }
 
505
}
 
506
 
 
507
inline int bitand(int a, int b)
 
508
{
 
509
    return a&b;
 
510
}
 
511
 
 
512
inline int bitxor(int a, int b)
 
513
{
 
514
    return a ^ b;
 
515
}
 
516
 
 
517
inline int bitor(int a, int b)
 
518
{
 
519
    return a | b;
 
520
}
 
521
 
 
522
inline int op_logand(int a, int b, int c)
 
523
{
 
524
    if ((a == b) && (b == c)) {
 
525
        return 1;
 
526
    } else {
 
527
        return 0;
 
528
    }
 
529
}
 
530
 
 
531
inline int op_logor(int a, int b, int c)
 
532
{
 
533
    return ((a == b) || (b == c))?1:0;
 
534
}
 
535
 
 
536
inline int assign_mul(int a, int b)
 
537
{
 
538
    a *= b;
 
539
    return a;
 
540
}
 
541
 
 
542
inline int assign_div(int a, int b)
 
543
{
 
544
    a /= b;
 
545
    return a;
 
546
}
 
547
 
 
548
inline int assign_mod(int a, int b)
 
549
{
 
550
    a %= b;
 
551
    return a;
 
552
}
 
553
 
 
554
inline int assign_add(int a, int b)
 
555
{
 
556
    a += b;
 
557
    return a;
 
558
}
 
559
 
 
560
inline int assign_sub(int a, int b)
 
561
{
 
562
    a -= b;
 
563
    return a;
 
564
}
 
565
 
 
566
inline int assign_left_shift(int a, int b)
 
567
{
 
568
    a <<= b;
 
569
    return a;
 
570
}
 
571
 
 
572
inline int assign_right_shift(int a, int b)
 
573
{
 
574
    a >>= b;
 
575
    return a;
 
576
}
 
577
 
 
578
inline int assign_bitand(int a, int b)
 
579
{
 
580
    a &= b;
 
581
    return a;
 
582
}
 
583
 
 
584
inline int assign_bitor(int a, int b)
 
585
{
 
586
    a |= b;
 
587
    return a;
 
588
}
 
589
 
 
590
inline int assign_bitxor(int a, int b)
 
591
{
 
592
    a ^= b;
 
593
    return a;
 
594
}
 
595
 
 
596
inline int multi_expr(int a, int b)
 
597
{
 
598
    return (a + b), (a - b), (a * b);
 
599
}
 
600
 
 
601
inline int test_while()
 
602
{
 
603
    int i = 1;
 
604
    int sum = 0;
 
605
    while (i <= 10) {
 
606
        sum += i;
 
607
        ++i;
 
608
    }
 
609
    return sum;
 
610
}
 
611
 
 
612
inline int test_while_break()
 
613
{
 
614
    int i = 1;
 
615
    int sum = 0;
 
616
    while (1) {
 
617
        sum += i;
 
618
        ++i;
 
619
        if (i > 10) break;
 
620
    }
 
621
    return sum;
 
622
}
 
623
 
 
624
inline int test_while_continue()
 
625
{
 
626
    int i = -10;
 
627
    int sum = 0;
 
628
    while (i < 10) {
 
629
        if (i++ < 0) {
 
630
            continue;
 
631
        }
 
632
        sum += i;
 
633
    }
 
634
    return sum;
 
635
}
 
636
 
 
637
inline int test_dowhile()
 
638
{
 
639
    int i = 1;
 
640
    int sum = 0;
 
641
    do {
 
642
        sum += i++;
 
643
    } while (i <= 10);
 
644
    return sum;
 
645
}
 
646
 
 
647
inline int test_dowhile_break()
 
648
{
 
649
    int i = 1;
 
650
    int sum = 0;
 
651
    do {
 
652
        sum += i++;
 
653
        if (i > 10) break;
 
654
    } while (1);
 
655
    return sum;
 
656
}
 
657
 
 
658
inline int test_dowhile_continue()
 
659
{
 
660
    int i = -10;
 
661
    int sum = 0;
 
662
    do {
 
663
        if (++i <= 0) {
 
664
            continue;
 
665
        }
 
666
        sum += i;
 
667
    } while ((0 < i) && (i < 10));
 
668
    return sum;
 
669
}
 
670
 
 
671
inline int test_for()
 
672
{
 
673
    int i;
 
674
    int sum;
 
675
    for (i = 0, sum = 0; i <= 10; ++i) {
 
676
        sum += i;
 
677
    }
 
678
    return sum;
 
679
}
 
680
 
 
681
inline int test_for_noinit_notest_noupdate()
 
682
{
 
683
    int i = 0, sum = 0;
 
684
    for (;;) {
 
685
        sum += ++i;
 
686
        if (10 <= i) break;
 
687
    }
 
688
    return sum;
 
689
}
 
690
 
 
691
inline int test_for_noinit_notest()
 
692
{
 
693
    int i = 0, sum = 0;
 
694
    for (;;sum += ++i) {
 
695
        if (10 <= i) break;
 
696
    }
 
697
    return sum;
 
698
}
 
699
 
 
700
inline int test_for_noinit_noupdate()
 
701
{
 
702
    int i = 0, sum = 0;
 
703
    for (;i < 10;) {
 
704
        sum += ++i;
 
705
    }
 
706
    return sum;
 
707
}
 
708
 
 
709
inline int test_for_noinit()
 
710
{
 
711
    int i = 0, sum = 0;
 
712
    for (;i < 10; sum += ++i);
 
713
    return sum;
 
714
}
 
715
 
 
716
inline int test_for_notest_noupdate()
 
717
{
 
718
    int i, sum;
 
719
    for (i = 0, sum = 0;;) {
 
720
        sum += ++i;
 
721
        if (10 <= i) break;
 
722
    }
 
723
    return sum;
 
724
}
 
725
 
 
726
inline int test_for_notest()
 
727
{
 
728
    int i, sum;
 
729
    for (i = 0, sum = 0;;sum += ++i) {
 
730
        if (10 <= i) break;
 
731
    }
 
732
    return sum;
 
733
}
 
734
 
 
735
inline int test_for_noupdate()
 
736
{
 
737
    int i, sum;
 
738
    for (i = sum = 0;i < 10;) {
 
739
        sum += ++i;
 
740
    }
 
741
    return sum;
 
742
}
 
743
 
 
744
inline int offset_calc()
 
745
{
 
746
    return (int) &(((struct test_uchar*)0)->value);
 
747
}
 
748
 
 
749
inline void not_supported(int a)
 
750
{
 
751
    switch (a) {
 
752
    case 1:
 
753
        break;
 
754
    default:
 
755
        break;
 
756
    }
 
757
}
 
758
    
 
759
/* 
 
760
   ISO/IEC 9899:1999 6.7.5.3
 
761
   a declaration of a parameter as ``function returning type'' shall be
 
762
   adjusted to ``pointer to function returning type''
 
763
*/
 
764
extern char *param_func_test(void *allocator(size_t));
 
765
 
 
766
typedef signed int (*sint_adder)(signed int v1, signed int v2);
 
767
extern sint_adder get_fptr();