OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libffi/] [testsuite/] [libffi.call/] [negint.c] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Area:        ffi_call
2
   Purpose:     Check that negative integers are passed correctly.
3
   Limitations: none.
4
   PR:          none.
5
   Originator:  From the original ffitest.c  */
6
 
7
/* { dg-do run } */
8
/* { dg-options -O2 } */
9
 
10
#include "ffitest.h"
11
 
12
static int checking(int a, short b, signed char c)
13
{
14
  int i;
15
 
16
  return (a < 0 && b < 0 && c < 0);
17
}
18
 
19
int main (void)
20
{
21
  ffi_cif cif;
22
  ffi_type *args[MAX_ARGS];
23
  void *values[MAX_ARGS];
24
  ffi_arg rint;
25
 
26
  signed int si;
27
  signed short ss;
28
  signed char sc;
29
 
30
  args[0] = &ffi_type_sint;
31
  values[0] = &si;
32
  args[1] = &ffi_type_sshort;
33
  values[1] = &ss;
34
  args[2] = &ffi_type_schar;
35
  values[2] = &sc;
36
 
37
  /* Initialize the cif */
38
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
39
                     &ffi_type_sint, args) == FFI_OK);
40
 
41
  si = -6;
42
  ss = -12;
43
  sc = -1;
44
 
45
  checking (si, ss, sc);
46
 
47
  ffi_call(&cif, FFI_FN(checking), &rint, values);
48
 
49
  printf ("%d vs %d\n", (int)rint, checking (si, ss, sc));
50
 
51
  CHECK(rint != 0);
52
 
53
  exit (0);
54
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.