aboutsummaryrefslogtreecommitdiff
path: root/testsuite/libffi.go/aa-direct.c
blob: b00c404ab353afaff3a75eb8582bc5e82c54b573 (plain)
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
/* { dg-do run } */

#include "static-chain.h"

#if defined(__GNUC__) && !defined(__clang__) && defined(STATIC_CHAIN_REG)

#include "ffitest.h"

/* Blatent assumption here that the prologue doesn't clobber the
   static chain for trivial functions.  If this is not true, don't
   define STATIC_CHAIN_REG, and we'll test what we can via other tests.  */
void *doit(void)
{
  register void *chain __asm__(STATIC_CHAIN_REG);
  return chain;
}

int main()
{
  ffi_cif cif;
  void *result;

  CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK);

  ffi_call_go(&cif, FFI_FN(doit), &result, NULL, &result);

  CHECK(result == &result);

  return 0;
}

#else /* UNSUPPORTED */
int main() { return 0; }
#endif