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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [ieee/] [copysign1.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 688 jeremybenn
#include <string.h>
2
#include <stdlib.h>
3
#include <float.h>
4
 
5
#define fpsizeoff       sizeof(float)
6
#define fpsizeof        sizeof(double)
7
#define fpsizeofl       sizeof(long double)
8
 
9
/* Work around the fact that with the Intel double-extended precision,
10
   we've got a 10 byte type stuffed into some amount of padding.  And
11
   the fact that -ffloat-store is going to stuff this value temporarily
12
   into some bit of stack frame that we've no control over and can't zero.  */
13
#if LDBL_MANT_DIG == 64
14
# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)
15
#  undef fpsizeofl
16
#  define fpsizeofl     10
17
# endif
18
#endif
19
 
20
/* Work around the fact that the sign of the second double in the IBM
21
   double-double format is not strictly specified when it contains a zero.
22
   For instance, -0.0L can be represented with either (-0.0, +0.0) or
23
   (-0.0, -0.0).  The former is what we'll get from the compiler when it
24
   builds constants; the later is what we'll get from the negation operator
25
   at runtime.  */
26
/* ??? This hack only works for big-endian, which is fortunately true for
27
   all of AIX, Darwin, and Irix.  */
28
#if LDBL_MANT_DIG == 106
29
# undef fpsizeofl
30
# define fpsizeofl      sizeof(double)
31
#endif
32
 
33
 
34
#define TEST(TYPE, EXT)                                         \
35
TYPE c##EXT (TYPE x, TYPE y)                                    \
36
{                                                               \
37
  return __builtin_copysign##EXT (x, y);                        \
38
}                                                               \
39
                                                                \
40
struct D##EXT { TYPE x, y, z; };                                \
41
                                                                \
42
static const struct D##EXT T##EXT[] = {                         \
43
  { 1.0, 2.0, 1.0 },                                            \
44
  { 1.0, -2.0, -1.0 },                                          \
45
  { -1.0, -2.0, -1.0 },                                         \
46
  { 0.0, -2.0, -0.0 },                                          \
47
  { -0.0, -2.0, -0.0 },                                         \
48
  { -0.0, 2.0, 0.0 },                                           \
49
  { __builtin_inf##EXT (), -0.0, -__builtin_inf##EXT () },      \
50
  { -__builtin_nan##EXT (""), __builtin_inf##EXT (),            \
51
    __builtin_nan##EXT ("") }                                   \
52
};                                                              \
53
                                                                \
54
void test##EXT (void)                                           \
55
{                                                               \
56
  int i, n = sizeof (T##EXT) / sizeof (T##EXT[0]);              \
57
  TYPE r;                                                       \
58
  for (i = 0; i < n; ++i)                                        \
59
    {                                                           \
60
      r = c##EXT (T##EXT[i].x, T##EXT[i].y);                    \
61
      if (memcmp (&r, &T##EXT[i].z, fpsizeof##EXT) != 0)        \
62
        abort ();                                               \
63
    }                                                           \
64
}
65
 
66
TEST(float, f)
67
TEST(double, )
68
TEST(long double, l)
69
 
70
int main()
71
{
72
  testf();
73
  test();
74
  testl();
75
  return 0;
76
}

powered by: WebSVN 2.1.0

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