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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libffi/] [testsuite/] [libffi.call/] [negint.c] - Blame information for rev 732

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 732 jeremybenn
/* 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
 
15
  return (a < 0 && b < 0 && c < 0);
16
}
17
 
18
int main (void)
19
{
20
  ffi_cif cif;
21
  ffi_type *args[MAX_ARGS];
22
  void *values[MAX_ARGS];
23
  ffi_arg rint;
24
 
25
  signed int si;
26
  signed short ss;
27
  signed char sc;
28
 
29
  args[0] = &ffi_type_sint;
30
  values[0] = &si;
31
  args[1] = &ffi_type_sshort;
32
  values[1] = &ss;
33
  args[2] = &ffi_type_schar;
34
  values[2] = &sc;
35
 
36
  /* Initialize the cif */
37
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
38
                     &ffi_type_sint, args) == FFI_OK);
39
 
40
  si = -6;
41
  ss = -12;
42
  sc = -1;
43
 
44
  checking (si, ss, sc);
45
 
46
  ffi_call(&cif, FFI_FN(checking), &rint, values);
47
 
48
  printf ("%d vs %d\n", (int)rint, checking (si, ss, sc));
49
 
50
  CHECK(rint != 0);
51
 
52
  exit (0);
53
}

powered by: WebSVN 2.1.0

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