-
Notifications
You must be signed in to change notification settings - Fork 284
/
Copy pathconfig.builtin_apply.c
57 lines (49 loc) · 1.13 KB
/
config.builtin_apply.c
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
/*
Copyright (C) 2005 Free Software Foundation
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
*/
typedef void(*apply_t)(void); /* function pointer */
typedef union {
char *arg_ptr;
char arg_regs[sizeof (char*)];
} *arglist_t; /* argument frame */
double ret_double3(int i, int j)
{
static double d = 1.23456;
return d;
}
double ret_double2(int i, int j)
{
double d = 0.0 + i + j;
return d;
}
double ret_double(int i, int j)
{
arglist_t argframe;
int stack_argsize;
int reg_argsize;
void *ret;
void *(*imp)();
imp = ret_double3;
/* void *args = __builtin_apply_args(); */
stack_argsize = 0;
reg_argsize = 8;
argframe = (arglist_t) alloca(sizeof(char*) + reg_argsize);
if (stack_argsize)
argframe->arg_ptr = alloca(stack_argsize);
else
argframe->arg_ptr = 0;
ret = __builtin_apply(imp, argframe, 0);
__builtin_return(ret);
}
int main()
{
double d;
d = ret_double3(2, 3);
printf("got %f\n", d);
d = ret_double(2, 3);
printf("got %f\n", d);
exit(0);
}