4
* Copyright 1995-1999, 2002, 2005 Bruno Haible, <bruno@clisp.org>
6
* This is free software distributed under the GNU General Public Licence
7
* described in the file COPYING. Contact the author if you don't have this
8
* or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
15
#include "trampoline.h"
17
#define MAGIC1 0x9db9af42
18
#define MAGIC2 0x614a13c9
20
static int magic = MAGIC1;
23
typedef int (*function)(...);
25
typedef int (*function)();
31
{ return *(int*)function_data + x; }
35
function cf = alloc_trampoline((function)&f, &function_data, &magic);
36
/* calling cf shall set function_data = &magic and then call f(x),
37
* thus returning magic + x.
39
if (((*cf)(MAGIC2) == MAGIC1+MAGIC2) && (function_data == &magic))
40
{ free_trampoline(cf); printf("Works, test1 passed.\n"); exit(0); }
42
{ printf("Doesn't work!\n"); exit(1); }