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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [libdecnumber/] [decContext.h] - Blame information for rev 199

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

Line No. Rev Author Line
1 38 julius
/* Decimal Context module header for the decNumber C Library
2
   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3
   Contributed by IBM Corporation.  Author Mike Cowlishaw.
4
 
5
   This file is part of GCC.
6
 
7
   GCC is free software; you can redistribute it and/or modify it under
8
   the terms of the GNU General Public License as published by the Free
9
   Software Foundation; either version 2, or (at your option) any later
10
   version.
11
 
12
   In addition to the permissions in the GNU General Public License,
13
   the Free Software Foundation gives you unlimited permission to link
14
   the compiled version of this file into combinations with other
15
   programs, and to distribute those combinations without any
16
   restriction coming from the use of this file.  (The General Public
17
   License restrictions do apply in other respects; for example, they
18
   cover modification of the file, and distribution when not linked
19
   into a combine executable.)
20
 
21
   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
22
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
   for more details.
25
 
26
   You should have received a copy of the GNU General Public License
27
   along with GCC; see the file COPYING.  If not, write to the Free
28
   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29
   02110-1301, USA.  */
30
 
31
/* ------------------------------------------------------------------ */
32
/*                                                                    */
33
/* Context must always be set correctly:                              */
34
/*                                                                    */
35
/*  digits   -- must be in the range 1 through 999999999              */
36
/*  emax     -- must be in the range 0 through 999999999              */
37
/*  emin     -- must be in the range 0 through -999999999             */
38
/*  round    -- must be one of the enumerated rounding modes          */
39
/*  traps    -- only defined bits may be set                          */
40
/*  status   -- [any bits may be cleared, but not set, by user]       */
41
/*  clamp    -- must be either 0 or 1                                 */
42
/*  extended -- must be either 0 or 1 [present only if DECSUBSET]     */
43
/*                                                                    */
44
/* ------------------------------------------------------------------ */
45
 
46
#if !defined(DECCONTEXT)
47
#define DECCONTEXT
48
#define DECCNAME     "decContext"       /* Short name */
49
#define DECCFULLNAME "Decimal Context Descriptor"       /* Verbose name */
50
#define DECCAUTHOR   "Mike Cowlishaw"   /* Who to blame */
51
 
52
#include "gstdint.h"            /* C99 standard integers */
53
#include <signal.h>             /* for traps */
54
 
55
 
56
  /* Conditional code flag -- set this to 0 for best performance */
57
#define DECSUBSET 0             /* 1 to enable subset arithmetic */
58
 
59
  /* Context for operations, with associated constants */
60
enum rounding
61
{
62
  DEC_ROUND_CEILING,            /* round towards +infinity */
63
  DEC_ROUND_UP,                 /* round away from 0 */
64
  DEC_ROUND_HALF_UP,            /* 0.5 rounds up */
65
  DEC_ROUND_HALF_EVEN,          /* 0.5 rounds to nearest even */
66
  DEC_ROUND_HALF_DOWN,          /* 0.5 rounds down */
67
  DEC_ROUND_DOWN,               /* round towards 0 (truncate) */
68
  DEC_ROUND_FLOOR,              /* round towards -infinity */
69
  DEC_ROUND_MAX                 /* enum must be less than this */
70
};
71
 
72
typedef struct
73
{
74
  int32_t digits;               /* working precision */
75
  int32_t emax;                 /* maximum positive exponent */
76
  int32_t emin;                 /* minimum negative exponent */
77
  enum rounding round;          /* rounding mode */
78
  uint32_t traps;               /* trap-enabler flags */
79
  uint32_t status;              /* status flags */
80
  uint8_t clamp;                /* flag: apply IEEE exponent clamp */
81
#if DECSUBSET
82
  uint8_t extended;             /* flag: special-values allowed */
83
#endif
84
} decContext;
85
 
86
  /* Maxima and Minima */
87
#define DEC_MAX_DIGITS 999999999
88
#define DEC_MIN_DIGITS         1
89
#define DEC_MAX_EMAX   999999999
90
#define DEC_MIN_EMAX           0
91
#define DEC_MAX_EMIN           0
92
#define DEC_MIN_EMIN  -999999999
93
 
94
  /* Trap-enabler and Status flags (exceptional conditions), and their names */
95
  /* Top byte is reserved for internal use */
96
#define DEC_Conversion_syntax    0x00000001
97
#define DEC_Division_by_zero     0x00000002
98
#define DEC_Division_impossible  0x00000004
99
#define DEC_Division_undefined   0x00000008
100
#define DEC_Insufficient_storage 0x00000010     /* [used if malloc fails] */
101
#define DEC_Inexact              0x00000020
102
#define DEC_Invalid_context      0x00000040
103
#define DEC_Invalid_operation    0x00000080
104
#if DECSUBSET
105
#define DEC_Lost_digits          0x00000100
106
#endif
107
#define DEC_Overflow             0x00000200
108
#define DEC_Clamped              0x00000400
109
#define DEC_Rounded              0x00000800
110
#define DEC_Subnormal            0x00001000
111
#define DEC_Underflow            0x00002000
112
 
113
  /* IEEE 854 groupings for the flags */
114
  /* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal are */
115
  /* not in IEEE 854] */
116
#define DEC_IEEE_854_Division_by_zero  (DEC_Division_by_zero)
117
#if DECSUBSET
118
#define DEC_IEEE_854_Inexact           (DEC_Inexact | DEC_Lost_digits)
119
#else
120
#define DEC_IEEE_854_Inexact           (DEC_Inexact)
121
#endif
122
#define DEC_IEEE_854_Invalid_operation (DEC_Conversion_syntax |     \
123
                                          DEC_Division_impossible |   \
124
                                          DEC_Division_undefined |    \
125
                                          DEC_Insufficient_storage |  \
126
                                          DEC_Invalid_context |       \
127
                                          DEC_Invalid_operation)
128
#define DEC_IEEE_854_Overflow          (DEC_Overflow)
129
#define DEC_IEEE_854_Underflow         (DEC_Underflow)
130
 
131
  /* flags which are normally errors (results are qNaN, infinite, or 0) */
132
#define DEC_Errors (DEC_IEEE_854_Division_by_zero |                 \
133
                      DEC_IEEE_854_Invalid_operation |                \
134
                      DEC_IEEE_854_Overflow | DEC_IEEE_854_Underflow)
135
  /* flags which cause a result to become qNaN */
136
#define DEC_NaNs    DEC_IEEE_854_Invalid_operation
137
 
138
  /* flags which are normally for information only (have finite results) */
139
#if DECSUBSET
140
#define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact     \
141
                          | DEC_Lost_digits)
142
#else
143
#define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact)
144
#endif
145
 
146
  /* name strings for the exceptional conditions */
147
 
148
#define DEC_Condition_CS "Conversion syntax"
149
#define DEC_Condition_DZ "Division by zero"
150
#define DEC_Condition_DI "Division impossible"
151
#define DEC_Condition_DU "Division undefined"
152
#define DEC_Condition_IE "Inexact"
153
#define DEC_Condition_IS "Insufficient storage"
154
#define DEC_Condition_IC "Invalid context"
155
#define DEC_Condition_IO "Invalid operation"
156
#if DECSUBSET
157
#define DEC_Condition_LD "Lost digits"
158
#endif
159
#define DEC_Condition_OV "Overflow"
160
#define DEC_Condition_PA "Clamped"
161
#define DEC_Condition_RO "Rounded"
162
#define DEC_Condition_SU "Subnormal"
163
#define DEC_Condition_UN "Underflow"
164
#define DEC_Condition_ZE "No status"
165
#define DEC_Condition_MU "Multiple status"
166
#define DEC_Condition_Length 21 /* length of the longest string, */
167
                                   /* including terminator */
168
 
169
  /* Initialization descriptors, used by decContextDefault */
170
#define DEC_INIT_BASE         0
171
#define DEC_INIT_DECIMAL32   32
172
#define DEC_INIT_DECIMAL64   64
173
#define DEC_INIT_DECIMAL128 128
174
 
175
  /* decContext routines */
176
#ifdef IN_LIBGCC2
177
#define decContextDefault __decContextDefault
178
#define decContextSetStatus __decContextSetStatus
179
#define decContextStatusToString __decContextStatusToString
180
#define decContextSetStatusFromString __decContextSetStatusFromString
181
#endif
182
decContext *decContextDefault (decContext *, int32_t);
183
decContext *decContextSetStatus (decContext *, uint32_t);
184
const char *decContextStatusToString (const decContext *);
185
decContext *decContextSetStatusFromString (decContext *, const char *);
186
 
187
#endif

powered by: WebSVN 2.1.0

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