Differences From Artifact [64a9a45261]:

To Artifact [2f0d3febc7]:


1
2
3
4

5
6
7
8
9
10
11
1
2
3

4
5
6
7
8
9
10
11



-
+







/* Trampoline test */

/*
 * Copyright 1995-1999, 2002, 2005 Bruno Haible, <bruno@clisp.org>
 * Copyright 1995-1999, 2002 Bruno Haible, <bruno@clisp.org>
 *
 * This is free software distributed under the GNU General Public Licence
 * described in the file COPYING. Contact the author if you don't have this
 * or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
 * on this software.
 */

23
24
25
26
27
28
29

30




31
32
33
34
35
36
37
38
39
40
41
42
43
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







+

+
+
+
+













typedef int (*function)(...);
#else
typedef int (*function)();
#endif

void* function_data;

#if defined(__STDC__) || defined(__GNUC__) || defined(__cplusplus)
int f (int x)
#else
int f (x)
  int x;
#endif
{ return *(int*)function_data + x; }

int main ()
{
  function cf = alloc_trampoline((function)&f, &function_data, &magic);
  /* calling cf shall set  function_data = &magic  and then call f(x),
   * thus returning  magic + x.
   */
  if (((*cf)(MAGIC2) == MAGIC1+MAGIC2) && (function_data == &magic))
    { free_trampoline(cf); printf("Works, test1 passed.\n"); exit(0); }
  else
    { printf("Doesn't work!\n"); exit(1); }
}