Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:45

0001 #ifndef Py_INTERNAL_DTOA_H
0002 #define Py_INTERNAL_DTOA_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 #include "pycore_pymath.h"        // _PY_SHORT_FLOAT_REPR
0012 
0013 
0014 typedef uint32_t ULong;
0015 
0016 struct
0017 Bigint {
0018     struct Bigint *next;
0019     int k, maxwds, sign, wds;
0020     ULong x[1];
0021 };
0022 
0023 #if defined(Py_USING_MEMORY_DEBUGGER) || _PY_SHORT_FLOAT_REPR == 0
0024 
0025 struct _dtoa_state {
0026     int _not_used;
0027 };
0028 #define _dtoa_state_INIT(INTERP) \
0029     {0}
0030 
0031 #else  // !Py_USING_MEMORY_DEBUGGER && _PY_SHORT_FLOAT_REPR != 0
0032 
0033 /* The size of the Bigint freelist */
0034 #define Bigint_Kmax 7
0035 
0036 /* The size of the cached powers of 5 array */
0037 #define Bigint_Pow5size 8
0038 
0039 #ifndef PRIVATE_MEM
0040 #define PRIVATE_MEM 2304
0041 #endif
0042 #define Bigint_PREALLOC_SIZE \
0043     ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
0044 
0045 struct _dtoa_state {
0046     // p5s is an array of powers of 5 of the form:
0047     // 5**(2**(i+2)) for 0 <= i < Bigint_Pow5size
0048     struct Bigint *p5s[Bigint_Pow5size];
0049     // XXX This should be freed during runtime fini.
0050     struct Bigint *freelist[Bigint_Kmax+1];
0051     double preallocated[Bigint_PREALLOC_SIZE];
0052     double *preallocated_next;
0053 };
0054 #define _dtoa_state_INIT(INTERP) \
0055     { \
0056         .preallocated_next = (INTERP)->dtoa.preallocated, \
0057     }
0058 
0059 #endif  // !Py_USING_MEMORY_DEBUGGER
0060 
0061 
0062 extern double _Py_dg_strtod(const char *str, char **ptr);
0063 extern char* _Py_dg_dtoa(double d, int mode, int ndigits,
0064                          int *decpt, int *sign, char **rve);
0065 extern void _Py_dg_freedtoa(char *s);
0066 
0067 
0068 extern PyStatus _PyDtoa_Init(PyInterpreterState *interp);
0069 extern void _PyDtoa_Fini(PyInterpreterState *interp);
0070 
0071 
0072 #ifdef __cplusplus
0073 }
0074 #endif
0075 #endif /* !Py_INTERNAL_DTOA_H */