Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
gdtoa.h
Go to the documentation of this file.
1 /****************************************************************
2 
3 The author of this software is David M. Gay.
4 
5 Copyright (C) 1998 by Lucent Technologies
6 All Rights Reserved
7 
8 Permission to use, copy, modify, and distribute this software and
9 its documentation for any purpose and without fee is hereby
10 granted, provided that the above copyright notice appear in all
11 copies and that both that the copyright notice and this
12 permission notice and warranty disclaimer appear in supporting
13 documentation, and that the name of Lucent or any of its entities
14 not be used in advertising or publicity pertaining to
15 distribution of the software without specific, written prior
16 permission.
17 
18 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
20 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
21 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25 THIS SOFTWARE.
26 
27 ****************************************************************/
28 
29 /* Please send bug reports to David M. Gay (dmg at acm dot org,
30  * with " at " changed at "@" and " dot " changed to "."). */
31 
32 #ifndef GDTOA_H_INCLUDED
33 #define GDTOA_H_INCLUDED
34 
35 #include "arith.h"
36 
37 #ifndef Long
38 #define Long long
39 #endif
40 #ifndef ULong
41 typedef unsigned Long ULong;
42 #endif
43 #ifndef UShort
44 typedef unsigned short UShort;
45 #endif
46 
47 #ifndef ANSI
48 #ifdef KR_headers
49 #define ANSI(x) ()
50 #define Void /*nothing*/
51 #else
52 #define ANSI(x) x
53 #define Void void
54 #endif
55 #endif /* ANSI */
56 
57 #ifndef CONST
58 #ifdef KR_headers
59 #define CONST /* blank */
60 #else
61 #define CONST const
62 #endif
63 #endif /* CONST */
64 
65 enum
66 { /* return values from strtodg */
75 
76  /* The following may be or-ed into one of the above values. */
77 
78  STRTOG_Neg = 0x08,
79  STRTOG_Inexlo = 0x10,
80  STRTOG_Inexhi = 0x20,
84 };
85 
86 typedef struct FPI
87 {
88  int nbits;
89  int emin;
90  int emax;
91  int rounding;
93 } FPI;
94 
95 enum
96 { /* FPI.rounding values: same as FLT_ROUNDS */
101 };
102 
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106 
107 extern char* dtoa ANSI((double d, int mode, int ndigits, int* decpt, int* sign, char** rve));
108 extern char* gdtoa ANSI((FPI * fpi, int be, ULong* bits, int* kindp, int mode, int ndigits,
109  int* decpt, char** rve));
110 extern void freedtoa ANSI((char*));
111 extern float strtof ANSI((CONST char*, char**));
112 extern double strtod ANSI((CONST char*, char**));
113 extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*));
114 
115 extern char* g_ddfmt ANSI((char*, double*, int, unsigned));
116 extern char* g_dfmt ANSI((char*, double*, int, unsigned));
117 extern char* g_ffmt ANSI((char*, float*, int, unsigned));
118 extern char* g_Qfmt ANSI((char*, void*, int, unsigned));
119 extern char* g_xfmt ANSI((char*, void*, int, unsigned));
120 extern char* g_xLfmt ANSI((char*, void*, int, unsigned));
121 
122 extern int strtoId ANSI((CONST char*, char**, double*, double*));
123 extern int strtoIdd ANSI((CONST char*, char**, double*, double*));
124 extern int strtoIf ANSI((CONST char*, char**, float*, float*));
125 extern int strtoIQ ANSI((CONST char*, char**, void*, void*));
126 extern int strtoIx ANSI((CONST char*, char**, void*, void*));
127 extern int strtoIxL ANSI((CONST char*, char**, void*, void*));
128 extern int strtord ANSI((CONST char*, char**, int, double*));
129 extern int strtordd ANSI((CONST char*, char**, int, double*));
130 extern int strtorf ANSI((CONST char*, char**, int, float*));
131 extern int strtorQ ANSI((CONST char*, char**, int, void*));
132 extern int strtorx ANSI((CONST char*, char**, int, void*));
133 extern int strtorxL ANSI((CONST char*, char**, int, void*));
134 #if 1
135 extern int strtodI ANSI((CONST char*, char**, double*));
136 extern int strtopd ANSI((CONST char*, char**, double*));
137 extern int strtopdd ANSI((CONST char*, char**, double*));
138 extern int strtopf ANSI((CONST char*, char**, float*));
139 extern int strtopQ ANSI((CONST char*, char**, void*));
140 extern int strtopx ANSI((CONST char*, char**, void*));
141 extern int strtopxL ANSI((CONST char*, char**, void*));
142 #else
143 #define strtopd(s, se, x) strtord(s, se, 1, x)
144 #define strtopdd(s, se, x) strtordd(s, se, 1, x)
145 #define strtopf(s, se, x) strtorf(s, se, 1, x)
146 #define strtopQ(s, se, x) strtorQ(s, se, 1, x)
147 #define strtopx(s, se, x) strtorx(s, se, 1, x)
148 #define strtopxL(s, se, x) strtorxL(s, se, 1, x)
149 #endif
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 #endif /* GDTOA_H_INCLUDED */
int strtorxL(CONST char *s, char **sp, int rounding, void *L)
Definition: strtorxL.c:100
int strtopd(CONST char *s, char **sp, double *d)
Definition: strtopd.c:40
int emax
Definition: gdtoa.h:90
int strtoIQ(CONST char *s, char **sp, void *a, void *b)
Definition: strtoIQ.c:41
int strtoIf(CONST char *s, char **sp, float *f0, float *f1)
Definition: strtoIf.c:40
struct FPI FPI
int strtoIx(CONST char *s, char **sp, void *a, void *b)
Definition: strtoIx.c:41
int sudden_underflow
Definition: gdtoa.h:92
char * g_Qfmt(char *buf, void *V, int ndig, unsigned bufsize)
Definition: g_Qfmt.c:59
#define CONST
Definition: gdtoa.h:61
void freedtoa(char *s)
Definition: dmisc.c:99
float strtof(const char *__restrict str, char **__restrict str_end)
Interprets a floating-point value in a byte string pointed to by str.
char * gdtoa(FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve)
Definition: gdtoa.c:130
int strtorf(CONST char *s, char **sp, int rounding, float *f)
Definition: strtorf.c:82
char * g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
Definition: g_xfmt.c:61
int rounding
Definition: gdtoa.h:91
int nbits
Definition: gdtoa.h:88
int strtoId(CONST char *s, char **sp, double *f0, double *f1)
Definition: strtoId.c:40
char * g_ffmt(char *buf, float *f, int ndig, unsigned bufsize)
Definition: g_ffmt.c:41
unsigned short UShort
Definition: gdtoa.h:44
char * g_xLfmt(char *buf, void *V, int ndig, unsigned bufsize)
Definition: g_xLfmt.c:57
char * dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
Definition: dtoa.c:84
#define ANSI(x)
Definition: gdtoa.h:52
int strtopdd(CONST char *s, char **sp, double *dd)
Definition: strtopdd.c:40
int strtopx(CONST char *s, char **sp, void *V)
Definition: strtopx.c:60
char * g_dfmt(char *buf, double *d, int ndig, unsigned bufsize)
Definition: g_dfmt.c:41
unsigned Long ULong
Definition: gdtoa.h:41
int strtopf(CONST char *s, char **sp, float *f)
Definition: strtopf.c:40
int strtodI(CONST char *s, char **sp, double *dd)
Definition: strtodI.c:60
int emin
Definition: gdtoa.h:89
int strtorQ(CONST char *s, char **sp, int rounding, void *L)
Definition: strtorQ.c:110
int strtord(CONST char *s, char **sp, int rounding, double *d)
Definition: strtord.c:86
int strtoIdd(CONST char *s, char **sp, double *f0, double *f1)
Definition: strtoIdd.c:40
Definition: gdtoa.h:86
int strtorx(CONST char *s, char **sp, int rounding, void *L)
Definition: strtorx.c:112
int strtopQ(CONST char *s, char **sp, void *V)
Definition: strtopQ.c:58
#define Long
Definition: gdtoa.h:38
int strtordd(CONST char *s, char **sp, int rounding, double *dd)
Definition: strtordd.c:212
char * g_ddfmt(char *buf, double *dd, int ndig, unsigned bufsize)
Definition: g_ddfmt.c:41
int strtopxL(CONST char *s, char **sp, void *V)
Definition: strtopxL.c:56
int strtoIxL(CONST char *s, char **sp, void *a, void *b)
Definition: strtoIxL.c:41
double strtod(const char *__restrict str, char **__restrict str_end)
Interprets a floating-point value in a byte string pointed to by str.
int strtodg(CONST char *s00, char **se, FPI *fpi, Long *exp, ULong *bits)
Definition: strtodg.c:443