1 /** Function pointer tests.
3 type: BOOL, char, int, long
14 /* Must use a typedef as there is no way of adding the code modifier
17 typedef void (*NOARGFUNPTR)(void);
18 typedef void (*ONEARGFUNPTR)({type}) REENTRANT;
19 typedef long int (*FOURARGFUNPTR)(char, char, long int, long int) REENTRANT;
20 typedef {type} (*TYPEFUNPTR)({type}, {type}) REENTRANT;
33 incBy({type} a) REENTRANT
38 long int f6(char a, char b, long int c, long int d) REENTRANT
52 callViaPtr(NOARGFUNPTR fptr)
58 callViaPtr2(ONEARGFUNPTR fptr, {type} arg)
64 callViaPtr3(void (*fptr)(void))
70 callViaPtrAnsi(NOARGFUNPTR fptr)
76 callViaPtr2Ansi(ONEARGFUNPTR fptr, {type} arg)
82 callViaPtr3Ansi(void (*fptr)(void))
87 {type} f_ret({type} arg1, {type} arg2) REENTRANT
91 return (local & arg2);
102 callViaPtr(incCount);
104 callViaPtr2(incBy, 7);
105 ASSERT(count == 8 || count == 2);
107 ASSERT((*fafp)(0, 0x55, 0x12345678, 0x9abcdef0) == 0);
108 ASSERT((*fafp)(1, 0x55, 0x12345678, 0x9abcdef0) == 0x55);
109 ASSERT((*fafp)(2, 0x55, 0x12345678, 0x9abcdef0) == 0x12345678);
110 ASSERT((*fafp)(3, 0x55, 0x12345678, 0x9abcdef0) == 0x9abcdef0);
119 callViaPtrAnsi(incCount);
121 callViaPtr2Ansi(incBy, 7);
122 ASSERT(count == 8 || count == 2);
124 ASSERT(fafp(0, 0x55, 0x12345678, 0x9abcdef0) == 0);
125 ASSERT(fafp(1, 0x55, 0x12345678, 0x9abcdef0) == 0x55);
126 ASSERT(fafp(2, 0x55, 0x12345678, 0x9abcdef0) == 0x12345678);
127 ASSERT(fafp(3, 0x55, 0x12345678, 0x9abcdef0) == 0x9abcdef0);
131 testFunPtrReturn(void)
135 ASSERT(tfp(0, 0) == 0);
136 ASSERT(tfp(0, 1) == 1);
137 ASSERT(tfp(1, 0) == 0);
138 ASSERT(tfp(1, 1) == 0);