Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Include/internal/pycore_dtoa.h
12 views
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
#if _PY_SHORT_FLOAT_REPR == 1
15
16
typedef uint32_t ULong;
17
18
struct
19
Bigint {
20
struct Bigint *next;
21
int k, maxwds, sign, wds;
22
ULong x[1];
23
};
24
25
#ifdef Py_USING_MEMORY_DEBUGGER
26
27
struct _dtoa_state {
28
int _not_used;
29
};
30
#define _dtoa_interp_state_INIT(INTERP) \
31
{0}
32
33
#else // !Py_USING_MEMORY_DEBUGGER
34
35
/* The size of the Bigint freelist */
36
#define Bigint_Kmax 7
37
38
#ifndef PRIVATE_MEM
39
#define PRIVATE_MEM 2304
40
#endif
41
#define Bigint_PREALLOC_SIZE \
42
((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
43
44
struct _dtoa_state {
45
/* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */
46
// XXX This should be freed during runtime fini.
47
struct Bigint *p5s;
48
struct Bigint *freelist[Bigint_Kmax+1];
49
double preallocated[Bigint_PREALLOC_SIZE];
50
double *preallocated_next;
51
};
52
#define _dtoa_state_INIT(INTERP) \
53
{ \
54
.preallocated_next = (INTERP)->dtoa.preallocated, \
55
}
56
57
#endif // !Py_USING_MEMORY_DEBUGGER
58
59
60
/* These functions are used by modules compiled as C extension like math:
61
they must be exported. */
62
63
PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
64
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
65
int *decpt, int *sign, char **rve);
66
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
67
68
#endif // _PY_SHORT_FLOAT_REPR == 1
69
70
#ifdef __cplusplus
71
}
72
#endif
73
#endif /* !Py_INTERNAL_DTOA_H */
74
75