Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
#include "pyctype.h"
#include "pystrtod.h"
#include "pystrcmp.h"
#include "dtoa.h"
#include "fileutils.h"
#include "pyfpe.h"
#include "tracemalloc.h"
Expand Down
12 changes: 8 additions & 4 deletions Include/dtoa.h → Include/internal/pycore_dtoa.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#ifndef Py_LIMITED_API
#ifndef PY_NO_SHORT_FLOAT_REPR
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

/* These functions are used by modules compiled as C extension like math:
they must be exported. */

PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
int *decpt, int *sign, char **rve);
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
PyAPI_FUNC(double) _Py_dg_stdnan(int sign);
PyAPI_FUNC(double) _Py_dg_infinity(int sign);


#ifdef __cplusplus
}
#endif
#endif
#endif
#endif /* !PY_NO_SHORT_FLOAT_REPR */
2 changes: 1 addition & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/context.h \
$(srcdir)/Include/descrobject.h \
$(srcdir)/Include/dictobject.h \
$(srcdir)/Include/dtoa.h \
$(srcdir)/Include/dynamic_annotations.h \
$(srcdir)/Include/enumobject.h \
$(srcdir)/Include/errcode.h \
Expand Down Expand Up @@ -1082,6 +1081,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_code.h \
$(srcdir)/Include/internal/pycore_condvar.h \
$(srcdir)/Include/internal/pycore_context.h \
$(srcdir)/Include/internal/pycore_dtoa.h \
$(srcdir)/Include/internal/pycore_fileutils.h \
$(srcdir)/Include/internal/pycore_getopt.h \
$(srcdir)/Include/internal/pycore_gil.h \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Move the ``dtoa.h`` header file to the internal C API as ``pycore_dtoa.h``:
it only contains private functions (prefixed by ``_Py``). The :mod:`math` and
:mod:`cmath` modules must now be compiled with the ``Py_BUILD_CORE`` macro
defined.

4 changes: 2 additions & 2 deletions Modules/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ _symtable symtablemodule.c
# Modules that should always be present (non UNIX dependent):

#array arraymodule.c # array objects
#cmath cmathmodule.c _math.c # -lm # complex math library functions
#math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
#cmath cmathmodule.c _math.c -DPy_BUILD_CORE_MODULE # -lm # complex math library functions
#math mathmodule.c _math.c -DPy_BUILD_CORE_MODULE # -lm # math library functions, e.g. sin()
#_contextvars _contextvarsmodule.c # Context Variables
#_struct _struct.c # binary structure packing/unpacking
#_weakref _weakref.c # basic weak reference support
Expand Down
1 change: 1 addition & 0 deletions Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* much code borrowed from mathmodule.c */

#include "Python.h"
#include "pycore_dtoa.h"
#include "_math.h"
/* we need DBL_MAX, DBL_MIN, DBL_EPSILON, DBL_MANT_DIG and FLT_RADIX from
float.h. We assume that FLT_RADIX is either 2 or 16. */
Expand Down
1 change: 1 addition & 0 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ raised for division by zero and mod by zero.
*/

#include "Python.h"
#include "pycore_dtoa.h"
#include "_math.h"

#include "clinic/mathmodule.c.h"
Expand Down
1 change: 1 addition & 0 deletions Objects/floatobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
for any kind of float exception without losing portability. */

#include "Python.h"
#include "pycore_dtoa.h"

#include <ctype.h>
#include <float.h>
Expand Down
2 changes: 1 addition & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
<ClInclude Include="..\Include\internal\pycore_code.h" />
<ClInclude Include="..\Include\internal\pycore_condvar.h" />
<ClInclude Include="..\Include\internal\pycore_context.h" />
<ClInclude Include="..\Include\internal\pycore_dtoa.h" />
<ClInclude Include="..\Include\internal\pycore_fileutils.h" />
<ClInclude Include="..\Include\internal\pycore_getopt.h" />
<ClInclude Include="..\Include\internal\pycore_gil.h" />
Expand Down Expand Up @@ -223,7 +224,6 @@
<ClInclude Include="..\Include\pystrcmp.h" />
<ClInclude Include="..\Include\pystrtod.h" />
<ClInclude Include="..\Include\pystrhex.h" />
<ClInclude Include="..\Include\dtoa.h" />
<ClInclude Include="..\Include\Python-ast.h" />
<ClInclude Include="..\Include\Python.h" />
<ClInclude Include="..\Include\pythonrun.h" />
Expand Down
6 changes: 3 additions & 3 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@
<ClInclude Include="..\Include\internal\pycore_context.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_dtoa.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_fileutils.h">
<Filter>Include</Filter>
</ClInclude>
Expand Down Expand Up @@ -360,9 +363,6 @@
<ClInclude Include="..\Include\pystrhex.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\dtoa.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\Python-ast.h">
<Filter>Include</Filter>
</ClInclude>
Expand Down
1 change: 1 addition & 0 deletions Python/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
/* Linking of Python's #defines to Gay's #defines starts here. */

#include "Python.h"
#include "pycore_dtoa.h"

/* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile
the following code */
Expand Down
1 change: 1 addition & 0 deletions Python/pystrtod.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* -*- Mode: C; c-file-style: "python" -*- */

#include <Python.h>
#include "pycore_dtoa.h"
#include <locale.h>

/* Case-insensitive string match used for nan and inf detection; t should be
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,12 +734,14 @@ def detect_simple_extensions(self):

# math library functions, e.g. sin()
self.add(Extension('math', ['mathmodule.c'],
extra_compile_args=['-DPy_BUILD_CORE_MODULE'],
extra_objects=[shared_math],
depends=['_math.h', shared_math],
libraries=['m']))

# complex math library functions
self.add(Extension('cmath', ['cmathmodule.c'],
extra_compile_args=['-DPy_BUILD_CORE_MODULE'],
extra_objects=[shared_math],
depends=['_math.h', shared_math],
libraries=['m']))
Expand Down