File: config.builtin_apply.c

package info (click to toggle)
gnustep-base 1.26.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 27,260 kB
  • sloc: objc: 204,878; ansic: 32,160; sh: 157; makefile: 128; cpp: 122; xml: 32
file content (57 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (7)
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);
}