Home | History | Annotate | Line # | Download | only in gdtoa
      1  1.11  riastrad /* $NetBSD: gdtoa.h,v 1.11 2019/08/01 02:27:43 riastradh Exp $ */
      2   1.1    kleink 
      3   1.1    kleink /****************************************************************
      4   1.1    kleink 
      5   1.1    kleink The author of this software is David M. Gay.
      6   1.1    kleink 
      7   1.1    kleink Copyright (C) 1998 by Lucent Technologies
      8   1.1    kleink All Rights Reserved
      9   1.1    kleink 
     10   1.1    kleink Permission to use, copy, modify, and distribute this software and
     11   1.1    kleink its documentation for any purpose and without fee is hereby
     12   1.1    kleink granted, provided that the above copyright notice appear in all
     13   1.1    kleink copies and that both that the copyright notice and this
     14   1.1    kleink permission notice and warranty disclaimer appear in supporting
     15   1.1    kleink documentation, and that the name of Lucent or any of its entities
     16   1.1    kleink not be used in advertising or publicity pertaining to
     17   1.1    kleink distribution of the software without specific, written prior
     18   1.1    kleink permission.
     19   1.1    kleink 
     20   1.1    kleink LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     21   1.1    kleink INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
     22   1.1    kleink IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
     23   1.1    kleink SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     24   1.1    kleink WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
     25   1.1    kleink IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     26   1.1    kleink ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
     27   1.1    kleink THIS SOFTWARE.
     28   1.1    kleink 
     29   1.1    kleink ****************************************************************/
     30   1.1    kleink 
     31   1.1    kleink /* Please send bug reports to David M. Gay (dmg at acm dot org,
     32   1.1    kleink  * with " at " changed at "@" and " dot " changed to ".").	*/
     33   1.1    kleink 
     34   1.1    kleink #ifndef GDTOA_H_INCLUDED
     35   1.1    kleink #define GDTOA_H_INCLUDED
     36   1.1    kleink 
     37   1.1    kleink #include "arith.h"
     38   1.9  christos #include <stddef.h> /* for size_t */
     39   1.9  christos #include <stdint.h>
     40   1.1    kleink 
     41  1.10     joerg #ifndef __LOCALE_T_DECLARED
     42  1.10     joerg typedef struct _locale		*locale_t;
     43  1.10     joerg #define __LOCALE_T_DECLARED
     44  1.10     joerg #endif
     45  1.10     joerg 
     46   1.1    kleink #ifndef Long
     47   1.6  christos #define Long int32_t
     48   1.1    kleink #endif
     49   1.1    kleink #ifndef ULong
     50   1.6  christos #define ULong uint32_t
     51   1.1    kleink #endif
     52   1.1    kleink #ifndef UShort
     53   1.6  christos #define UShort uint16_t
     54   1.1    kleink #endif
     55   1.1    kleink 
     56   1.1    kleink #ifndef ANSI
     57   1.1    kleink #ifdef KR_headers
     58   1.1    kleink #define ANSI(x) ()
     59   1.1    kleink #define Void /*nothing*/
     60   1.1    kleink #else
     61   1.1    kleink #define ANSI(x) x
     62   1.1    kleink #define Void void
     63   1.1    kleink #endif
     64   1.1    kleink #endif /* ANSI */
     65   1.1    kleink 
     66   1.1    kleink #ifndef CONST
     67   1.1    kleink #ifdef KR_headers
     68   1.1    kleink #define CONST /* blank */
     69   1.1    kleink #else
     70   1.1    kleink #define CONST const
     71   1.1    kleink #endif
     72   1.1    kleink #endif /* CONST */
     73   1.1    kleink 
     74   1.1    kleink  enum {	/* return values from strtodg */
     75   1.1    kleink 	STRTOG_Zero	= 0,
     76   1.1    kleink 	STRTOG_Normal	= 1,
     77   1.1    kleink 	STRTOG_Denormal	= 2,
     78   1.1    kleink 	STRTOG_Infinite	= 3,
     79   1.1    kleink 	STRTOG_NaN	= 4,
     80   1.1    kleink 	STRTOG_NaNbits	= 5,
     81   1.1    kleink 	STRTOG_NoNumber	= 6,
     82   1.1    kleink 	STRTOG_Retmask	= 7,
     83   1.1    kleink 
     84   1.1    kleink 	/* The following may be or-ed into one of the above values. */
     85   1.1    kleink 
     86   1.9  christos 	STRTOG_Neg	= 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */
     87   1.9  christos 	STRTOG_Inexlo	= 0x10,	/* returned result rounded toward zero */
     88   1.9  christos 	STRTOG_Inexhi	= 0x20, /* returned result rounded away from zero */
     89   1.1    kleink 	STRTOG_Inexact	= 0x30,
     90   1.1    kleink 	STRTOG_Underflow= 0x40,
     91   1.8  christos 	STRTOG_Overflow	= 0x80,
     92   1.8  christos 	STRTOG_NoMemory = 0x100
     93   1.1    kleink 	};
     94   1.1    kleink 
     95   1.1    kleink  typedef struct
     96   1.1    kleink FPI {
     97   1.1    kleink 	int nbits;
     98   1.1    kleink 	int emin;
     99   1.1    kleink 	int emax;
    100   1.1    kleink 	int rounding;
    101   1.1    kleink 	int sudden_underflow;
    102   1.1    kleink 	} FPI;
    103   1.1    kleink 
    104   1.1    kleink enum {	/* FPI.rounding values: same as FLT_ROUNDS */
    105   1.1    kleink 	FPI_Round_zero = 0,
    106   1.1    kleink 	FPI_Round_near = 1,
    107   1.1    kleink 	FPI_Round_up = 2,
    108   1.1    kleink 	FPI_Round_down = 3
    109   1.1    kleink 	};
    110   1.1    kleink 
    111   1.1    kleink #ifdef __cplusplus
    112   1.1    kleink extern "C" {
    113   1.1    kleink #endif
    114   1.1    kleink 
    115   1.2    kleink #define	dtoa		__dtoa
    116   1.7  christos #define	gdtoa		__gdtoa
    117   1.7  christos #define	ldtoa		__ldtoa
    118   1.7  christos #define	hldtoa		__hldtoa
    119   1.7  christos #define	hdtoa		__hdtoa
    120   1.2    kleink #define	freedtoa	__freedtoa
    121   1.3    kleink #define	strtodg		__strtodg_D2A
    122   1.5    kleink #define	strtopQ		__strtopQ_D2A
    123   1.5    kleink #define	strtopx		__strtopx_D2A
    124   1.5    kleink #define	strtopxL	__strtopxL_D2A
    125   1.2    kleink #define	strtord		__strtord_D2A
    126   1.2    kleink 
    127   1.1    kleink extern char* dtoa  ANSI((double d, int mode, int ndigits, int *decpt,
    128   1.1    kleink 			int *sign, char **rve));
    129   1.7  christos extern char* hdtoa ANSI((double d, const char *xdigs, int ndigits, int *decpt,
    130   1.7  christos 			int *sign, char **rve));
    131   1.7  christos extern char* ldtoa ANSI((long double *ld, int mode, int ndigits, int *decpt,
    132   1.7  christos 			int *sign, char **rve));
    133   1.7  christos extern char* hldtoa ANSI((long double e, const char *xdigs, int ndigits,
    134   1.7  christos 			int *decpt, int *sign, char **rve));
    135   1.7  christos 
    136  1.11  riastrad extern char* gdtoa ANSI((CONST FPI *fpi, int be, ULong *bits, int *kindp,
    137   1.1    kleink 			int mode, int ndigits, int *decpt, char **rve));
    138   1.1    kleink extern void freedtoa ANSI((char*));
    139   1.1    kleink extern float  strtof ANSI((CONST char *, char **));
    140   1.1    kleink extern double strtod ANSI((CONST char *, char **));
    141  1.10     joerg extern int strtodg ANSI((CONST char*, char**, CONST FPI*, Long*, ULong*,
    142  1.10     joerg                          locale_t));
    143   1.1    kleink 
    144   1.9  christos extern char*	g_ddfmt  ANSI((char*, double*, int, size_t));
    145   1.9  christos extern char*	g_dfmt   ANSI((char*, double*, int, size_t));
    146   1.9  christos extern char*	g_ffmt   ANSI((char*, float*,  int, size_t));
    147   1.9  christos extern char*	g_Qfmt   ANSI((char*, void*,   int, size_t));
    148   1.9  christos extern char*	g_xfmt   ANSI((char*, void*,   int, size_t));
    149   1.9  christos extern char*	g_xLfmt  ANSI((char*, void*,   int, size_t));
    150   1.1    kleink 
    151   1.1    kleink extern int	strtoId  ANSI((CONST char*, char**, double*, double*));
    152   1.1    kleink extern int	strtoIdd ANSI((CONST char*, char**, double*, double*));
    153   1.1    kleink extern int	strtoIf  ANSI((CONST char*, char**, float*, float*));
    154   1.1    kleink extern int	strtoIQ  ANSI((CONST char*, char**, void*, void*));
    155   1.1    kleink extern int	strtoIx  ANSI((CONST char*, char**, void*, void*));
    156   1.1    kleink extern int	strtoIxL ANSI((CONST char*, char**, void*, void*));
    157  1.10     joerg extern int	strtord  ANSI((CONST char*, char**, int, double*, locale_t));
    158   1.1    kleink extern int	strtordd ANSI((CONST char*, char**, int, double*));
    159   1.1    kleink extern int	strtorf  ANSI((CONST char*, char**, int, float*));
    160   1.1    kleink extern int	strtorQ  ANSI((CONST char*, char**, int, void*));
    161   1.1    kleink extern int	strtorx  ANSI((CONST char*, char**, int, void*));
    162   1.1    kleink extern int	strtorxL ANSI((CONST char*, char**, int, void*));
    163   1.1    kleink #if 1
    164   1.1    kleink extern int	strtodI  ANSI((CONST char*, char**, double*));
    165   1.1    kleink extern int	strtopd  ANSI((CONST char*, char**, double*));
    166   1.1    kleink extern int	strtopdd ANSI((CONST char*, char**, double*));
    167   1.1    kleink extern int	strtopf  ANSI((CONST char*, char**, float*));
    168  1.10     joerg extern int	strtopQ  ANSI((CONST char*, char**, void*, locale_t));
    169  1.10     joerg extern int	strtopx  ANSI((CONST char*, char**, void*, locale_t));
    170  1.10     joerg extern int	strtopxL ANSI((CONST char*, char**, void*, locale_t));
    171   1.1    kleink #else
    172   1.1    kleink #define strtopd(s,se,x) strtord(s,se,1,x)
    173   1.1    kleink #define strtopdd(s,se,x) strtordd(s,se,1,x)
    174   1.1    kleink #define strtopf(s,se,x) strtorf(s,se,1,x)
    175   1.1    kleink #define strtopQ(s,se,x) strtorQ(s,se,1,x)
    176   1.1    kleink #define strtopx(s,se,x) strtorx(s,se,1,x)
    177   1.1    kleink #define strtopxL(s,se,x) strtorxL(s,se,1,x)
    178   1.1    kleink #endif
    179   1.1    kleink 
    180   1.1    kleink #ifdef __cplusplus
    181   1.1    kleink }
    182   1.1    kleink #endif
    183   1.1    kleink #endif /* GDTOA_H_INCLUDED */
    184