1 #ifndef Py_INTERNAL_DTOA_H 2 #define Py_INTERNAL_DTOA_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #ifndef Py_BUILD_CORE 8 # error "this header requires Py_BUILD_CORE define" 9 #endif 10 11 #include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR 12 13 14 typedef uint32_t ULong; 15 16 struct 17 Bigint { 18 struct Bigint *next; 19 int k, maxwds, sign, wds; 20 ULong x[1]; 21 }; 22 23 #if defined(Py_USING_MEMORY_DEBUGGER) || _PY_SHORT_FLOAT_REPR == 0 24 25 struct _dtoa_state { 26 int _not_used; 27 }; 28 #define _dtoa_state_INIT(INTERP) \ 29 {0} 30 31 #else // !Py_USING_MEMORY_DEBUGGER && _PY_SHORT_FLOAT_REPR != 0 32 33 /* The size of the Bigint freelist */ 34 #define Bigint_Kmax 7 35 36 /* The size of the cached powers of 5 array */ 37 #define Bigint_Pow5size 8 38 39 #ifndef PRIVATE_MEM 40 #define PRIVATE_MEM 2304 41 #endif 42 #define Bigint_PREALLOC_SIZE \ 43 ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) 44 45 struct _dtoa_state { 46 // p5s is an array of powers of 5 of the form: 47 // 5**(2**(i+2)) for 0 <= i < Bigint_Pow5size 48 struct Bigint *p5s[Bigint_Pow5size]; 49 // XXX This should be freed during runtime fini. 50 struct Bigint *freelist[Bigint_Kmax+1]; 51 double preallocated[Bigint_PREALLOC_SIZE]; 52 double *preallocated_next; 53 }; 54 #define _dtoa_state_INIT(INTERP) \ 55 { \ 56 .preallocated_next = (INTERP)->dtoa.preallocated, \ 57 } 58 59 #endif // !Py_USING_MEMORY_DEBUGGER 60 61 62 extern double _Py_dg_strtod(const char *str, char **ptr); 63 extern char* _Py_dg_dtoa(double d, int mode, int ndigits, 64 int *decpt, int *sign, char **rve); 65 extern void _Py_dg_freedtoa(char *s); 66 67 68 extern PyStatus _PyDtoa_Init(PyInterpreterState *interp); 69 extern void _PyDtoa_Fini(PyInterpreterState *interp); 70 71 72 #ifdef __cplusplus 73 } 74 #endif 75 #endif /* !Py_INTERNAL_DTOA_H */ 76