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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 732 jeremybenn
/* Area:        ffi_call
2
   Purpose:     Check denorm double value.
3
   Limitations: none.
4
   PR:          PR26483.
5
   Originator:  From the original ffitest.c  */
6
 
7
/* { dg-do run } */
8
/* { dg-options "-mieee" { target alpha*-*-* } } */
9
 
10
#include "ffitest.h"
11
#include "float.h"
12
 
13
typedef union
14
{
15
  double d;
16
  unsigned char c[sizeof (double)];
17
} value_type;
18
 
19
#define CANARY 0xba
20
 
21
static double dblit(double d)
22
{
23
  return d;
24
}
25
 
26
int main (void)
27
{
28
  ffi_cif cif;
29
  ffi_type *args[MAX_ARGS];
30
  void *values[MAX_ARGS];
31
  double d;
32
  value_type result[2];
33
  unsigned int i;
34
 
35
  args[0] = &ffi_type_double;
36
  values[0] = &d;
37
 
38
  /* Initialize the cif */
39
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
40
                     &ffi_type_double, args) == FFI_OK);
41
 
42
  d = DBL_MIN / 2;
43
 
44
  /* Put a canary in the return array.  This is a regression test for
45
     a buffer overrun.  */
46
  memset(result[1].c, CANARY, sizeof (double));
47
 
48
  ffi_call(&cif, FFI_FN(dblit), &result[0].d, values);
49
 
50
  /* The standard delta check doesn't work for denorms.  Since we didn't do
51
     any arithmetic, we should get the original result back, and hence an
52
     exact check should be OK here.  */
53
 
54
  CHECK(result[0].d == dblit(d));
55
 
56
  /* Check the canary.  */
57
  for (i = 0; i < sizeof (double); ++i)
58
    CHECK(result[1].c[i] == CANARY);
59
 
60
  exit(0);
61
 
62
}

powered by: WebSVN 2.1.0

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