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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [sun4/] [ieee.c] - Blame information for rev 829

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
2
#include <ieeefp.h>
3
 
4
 
5
fp_rnd
6
_DEFUN_VOID(fpgetround)
7
{
8
  char *out;
9
  ieee_flags("get", "direction","", &out);
10
  if (strcmp(out,"nearest") == 0) return FP_RN;
11
  if (strcmp(out,"negative") == 0) return FP_RM;
12
  if (strcmp(out,"positive") == 0) return FP_RP;
13
  if (strcmp(out,"tozero") == 0) return FP_RZ;
14
  abort();
15
 
16
}
17
 
18
fp_rnd
19
_DEFUN(fpsetround,(new),
20
       fp_rnd new)
21
{
22
  fp_rnd old = fpgetround();
23
  char *dummy;
24
 
25
  switch (new)
26
  {
27
  case FP_RN:
28
    ieee_flags("set", "direction", "nearest", &dummy);
29
    break;
30
  case FP_RM:
31
    ieee_flags("set", "direction", "negative", &dummy);
32
    break;
33
  case FP_RP:
34
    ieee_flags("set", "direction", "positive", &dummy);
35
    break;
36
  case FP_RZ:
37
    ieee_flags("set", "direction", "tozero", &dummy);
38
    break;
39
  default:
40
    break;
41
  }
42
  return old;
43
}
44
 
45
 
46
fp_except
47
_DEFUN_VOID(fpgetmask)
48
{
49
  char *out;
50
  int r = 0;
51
 
52
  int i = ieee_flags("get","exception","",&out);
53
  if (i & 1) r |= FP_X_IMP;
54
  if (i & 2) r |= FP_X_DX;
55
  if (i & 4) r |= FP_X_UFL;
56
  if (i & 8) r |= FP_X_OFL;
57
  if (i & 16) r |= FP_X_INV;
58
  return r;
59
 
60
}
61
 
62
fp_except
63
_DEFUN(fpsetmask,(mask),
64
       fp_except mask)
65
{
66
  fp_except old = fpgetmask();
67
 
68
  char *out;
69
  ieee_flags("clear","exception", "all", &out);
70
 
71
 
72
  if (mask & FP_X_IMP)
73
   ieee_flags("set","exception","inexact", &out);
74
  if (mask  & FP_X_DX)
75
   ieee_flags("set","exception","division", &out);
76
  if (mask & FP_X_UFL)
77
   ieee_flags("set","exception","underflow", &out);
78
  if (mask & FP_X_OFL)
79
   ieee_flags("set","exception","overflow", &out);
80
  if (mask & FP_X_INV)
81
   ieee_flags("set","exception","invalid", &out);
82
 
83
  return old;
84
 
85
}
86
 
87
fp_except
88
_DEFUN(fpsetsticky,(mask),
89
       fp_except mask)
90
{
91
  return fpsetmask(mask);
92
}
93
 
94
fp_except
95
_DEFUN_VOID(fpgetsticky)
96
{
97
  return fpgetmask();
98
}
99
 
100
int
101
_DEFUN(fpsetroundtoi,(rdi_mode),
102
       fp_rdi rdi_mode)
103
{
104
 
105
  return 0;
106
 
107
}
108
 
109
int
110
_DEFUN_VOID(fpgetroundtoi)
111
{
112
 
113
  return 0;
114
 
115
}

powered by: WebSVN 2.1.0

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