Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:43

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 #ifndef PRIVATE_MEM
0037 #define PRIVATE_MEM 2304
0038 #endif
0039 #define Bigint_PREALLOC_SIZE \
0040     ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
0041 
0042 struct _dtoa_state {
0043     /* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */
0044     // XXX This should be freed during runtime fini.
0045     struct Bigint *p5s;
0046     struct Bigint *freelist[Bigint_Kmax+1];
0047     double preallocated[Bigint_PREALLOC_SIZE];
0048     double *preallocated_next;
0049 };
0050 #define _dtoa_state_INIT(INTERP) \
0051     { \
0052         .preallocated_next = (INTERP)->dtoa.preallocated, \
0053     }
0054 
0055 #endif  // !Py_USING_MEMORY_DEBUGGER
0056 
0057 
0058 /* These functions are used by modules compiled as C extension like math:
0059    they must be exported. */
0060 
0061 PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
0062 PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
0063                         int *decpt, int *sign, char **rve);
0064 PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
0065 
0066 #ifdef __cplusplus
0067 }
0068 #endif
0069 #endif /* !Py_INTERNAL_DTOA_H */