Some build script code cleaning and environment change for one of slave builders.
[llvm-gcc-4.2.git] / libdecnumber / decimal32.h
blobbb228243299498b47adf51568382f96c9c88eb76
1 /* Decimal 32-bit format module header for the decNumber C Library
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 Contributed by IBM Corporation. Author Mike Cowlishaw.
5 This file is part of GCC.
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.
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.)
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.
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. */
31 #if !defined(DECIMAL32)
32 #define DECIMAL32
33 #define DEC32NAME "decimal32" /* Short name */
34 #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */
35 #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */
37 /* parameters for decimal32s */
38 #define DECIMAL32_Bytes 4 /* length */
39 #define DECIMAL32_Pmax 7 /* maximum precision (digits) */
40 #define DECIMAL32_Emax 96 /* maximum adjusted exponent */
41 #define DECIMAL32_Emin -95 /* minimum adjusted exponent */
42 #define DECIMAL32_Bias 101 /* bias for the exponent */
43 #define DECIMAL32_String 15 /* maximum string length, +1 */
44 /* highest biased exponent (Elimit-1) */
45 #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)
47 #ifndef DECNUMDIGITS
48 #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined */
49 #endif
50 #ifndef DECNUMBER
51 #include "decNumber.h" /* context and number library */
52 #endif
54 /* Decimal 32-bit type, accessible by bytes */
55 typedef struct
57 uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits */
58 } decimal32;
60 /* special values [top byte excluding sign bit; last two bits are
61 don't-care for Infinity on input, last bit don't-care for NaN] */
62 #if !defined(DECIMAL_NaN)
63 #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
64 #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
65 #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
66 #endif
68 /* Macros for accessing decimal32 fields. These assume the argument
69 is a reference (pointer) to the decimal32 structure */
70 /* Get sign */
71 #define decimal32Sign(d) ((unsigned)(d)->bytes[0]>>7)
73 /* Get combination field */
74 #define decimal32Comb(d) (((d)->bytes[0] & 0x7c)>>2)
76 /* Get exponent continuation [does not remove bias] */
77 #define decimal32ExpCon(d) ((((d)->bytes[0] & 0x03)<<4) \
78 | ((unsigned)(d)->bytes[1]>>4))
80 /* Set sign [this assumes sign previously 0] */
81 #define decimal32SetSign(d, b) { \
82 (d)->bytes[0]|=((unsigned)(b)<<7);}
84 /* Set exponent continuation [does not apply bias] */
85 /* This assumes range has been checked and exponent previously 0; */
86 /* type of exponent must be unsigned */
87 #define decimal32SetExpCon(d, e) { \
88 (d)->bytes[0]|=(uint8_t)((e)>>4); \
89 (d)->bytes[1]|=(uint8_t)(((e)&0x0F)<<4);}
91 /* ------------------------------------------------------------------ */
92 /* Routines */
93 /* ------------------------------------------------------------------ */
95 #ifdef IN_LIBGCC2
96 #define decimal32FromString __decimal32FromString
97 #define decimal32ToString __decimal32ToString
98 #define decimal32ToEngString __decimal32ToEngString
99 #define decimal32FromNumber __decimal32FromNumber
100 #define decimal32ToNumber __decimal32ToNumber
101 #endif
103 /* String conversions. */
104 decimal32 *decimal32FromString (decimal32 *, const char *, decContext *);
105 char *decimal32ToString (const decimal32 *, char *);
106 char *decimal32ToEngString (const decimal32 *, char *);
108 /* decNumber conversions. */
109 decimal32 *decimal32FromNumber (decimal32 *, const decNumber *, decContext *);
110 decNumber *decimal32ToNumber (const decimal32 *, decNumber *);
112 #endif