1 typedef unsigned short uint16_t;
2 typedef unsigned char uint8_t;
4 typedef union Unaligned16a
{
7 } __attribute__((packed
)) Unaligned16a
;
9 typedef union __attribute__((packed
)) Unaligned16b
{
14 extern void foo (void) __attribute__((stdcall));
15 void __attribute__((stdcall)) foo (void)
19 #define __stdcall __attribute__((stdcall))
20 extern int some_stdcall_func (int, int, int) __stdcall
;
21 __stdcall
int __stdcall
some_stdcall_func(int foo
, int bar
, int baz
) {
22 //printf("Hello from stdcall: %i %i %i\n", foo, bar, baz);
26 /* The actual attribute isn't important, must just be
28 #define ATTR __attribute__((__noinline__))
29 int ATTR
actual_function() {
33 extern int printf (const char *, ...);
37 void *function_pointer
= &actual_function
;
40 int a
= ((ATTR
int(*) (void)) function_pointer
)();
43 /* In the following we once misparsed 'ATTR *' is a btype
44 and hence the whole type was garbled. */
45 int b
= ( (int(ATTR
*)(void)) function_pointer
)();
48 /* All these should work and leave the stack pointer in its original
50 some_stdcall_func(1, 10, 100);
51 ((int __stdcall (*)(int, int, int))some_stdcall_func
) (2, 20, 200);
52 ((int(*__stdcall
)(int, int, int))some_stdcall_func
) (3, 30, 300);
53 for (i
= 0; i
< 1024; i
++) {
55 /* This was once misparsed at <= gitrev 325241c0, forgetting
56 the stdcall attribute on the function pointer leading to
57 stack increment being done twice (in callee and caller).
58 This will clobber 'i' and 'localvar' which is how we detect
60 ((int(__stdcall
*)(int, int, int))some_stdcall_func
) (4, 40, 400);
61 if (localvar
!= 42 || globalvar
!= i
)
62 printf("error, localvar=%d i=%d globalvar=%d\n", localvar
, i
, globalvar
);