[Python-checkins] r70752 - in python/branches/py3k-short-float-repr: Include/Python.h Include/dtoa.h Makefile.pre.in PCbuild/pythoncore.vcproj Python/dtoa.c
mark.dickinson
python-checkins at python.org
Mon Mar 30 22:47:52 CEST 2009
Author: mark.dickinson
Date: Mon Mar 30 22:47:52 2009
New Revision: 70752
Log:
Make Gay's dtoa and strtod available to Python, as
_Py_dg_dtoa and _Py_dg_strtod.
Link endianness detection in pyconfig.h to Gay's code.
Minimal changes to dtoa.c required to make it compile.
Added:
python/branches/py3k-short-float-repr/Include/dtoa.h
Modified:
python/branches/py3k-short-float-repr/Include/Python.h
python/branches/py3k-short-float-repr/Makefile.pre.in
python/branches/py3k-short-float-repr/PCbuild/pythoncore.vcproj
python/branches/py3k-short-float-repr/Python/dtoa.c
Modified: python/branches/py3k-short-float-repr/Include/Python.h
==============================================================================
--- python/branches/py3k-short-float-repr/Include/Python.h (original)
+++ python/branches/py3k-short-float-repr/Include/Python.h Mon Mar 30 22:47:52 2009
@@ -118,6 +118,7 @@
#include "pystrtod.h"
#include "pystrcmp.h"
+#include "dtoa.h"
/* _Py_Mangle is defined in compile.c */
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
Added: python/branches/py3k-short-float-repr/Include/dtoa.h
==============================================================================
--- (empty file)
+++ python/branches/py3k-short-float-repr/Include/dtoa.h Mon Mar 30 22:47:52 2009
@@ -0,0 +1,11 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
Modified: python/branches/py3k-short-float-repr/Makefile.pre.in
==============================================================================
--- python/branches/py3k-short-float-repr/Makefile.pre.in (original)
+++ python/branches/py3k-short-float-repr/Makefile.pre.in Mon Mar 30 22:47:52 2009
@@ -304,6 +304,7 @@
Python/getopt.o \
Python/pystrcmp.o \
Python/pystrtod.o \
+ Python/dtoa.o \
Python/formatter_unicode.o \
Python/$(DYNLOADFILE) \
$(LIBOBJS) \
Modified: python/branches/py3k-short-float-repr/PCbuild/pythoncore.vcproj
==============================================================================
--- python/branches/py3k-short-float-repr/PCbuild/pythoncore.vcproj (original)
+++ python/branches/py3k-short-float-repr/PCbuild/pythoncore.vcproj Mon Mar 30 22:47:52 2009
@@ -895,6 +895,10 @@
>
</File>
<File
+ RelativePath="..\Include\dtoa.h"
+ >
+ </File>
+ <File
RelativePath="..\Include\Python-ast.h"
>
</File>
@@ -1743,6 +1747,10 @@
>
</File>
<File
+ RelativePath="..\Python\dtoa.c"
+ >
+ </File>
+ <File
RelativePath="..\Python\Python-ast.c"
>
</File>
Modified: python/branches/py3k-short-float-repr/Python/dtoa.c
==============================================================================
--- python/branches/py3k-short-float-repr/Python/dtoa.c (original)
+++ python/branches/py3k-short-float-repr/Python/dtoa.c Mon Mar 30 22:47:52 2009
@@ -179,6 +179,21 @@
* used for input more than STRTOD_DIGLIM digits long (default 40).
*/
+/* Linking of Python's #defines to Gay's #defines starts here. */
+
+#include "Python.h"
+
+/* use WORDS_BIGENDIAN to determine float endianness. This assumes that ints
+ and floats share the same endianness on the target machine, which appears
+ to be true for every platform that Python currently cares about. We're
+ also assuming IEEE 754 float format for now. */
+
+#ifdef WORDS_BIGENDIAN
+#define IEEE_MC68k
+#else
+#define IEEE_8087
+#endif
+
#ifndef Long
#define Long long
#endif
@@ -293,7 +308,7 @@
#endif
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
-Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
+#error "Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined."
#endif
typedef union { double d; ULong L[2]; } U;
@@ -511,12 +526,6 @@
#define Kmax 7
-#ifdef __cplusplus
-extern "C" double strtod(const char *s00, char **se);
-extern "C" char *dtoa(double d, int mode, int ndigits,
- int *decpt, int *sign, char **rve);
-#endif
-
struct
Bigint {
struct Bigint *next;
@@ -2419,7 +2428,7 @@
#endif /* NO_STRTOD_BIGCOMP */
double
-strtod
+_Py_dg_strtod
#ifdef KR_headers
(s00, se) CONST char *s00; char **se;
#else
@@ -3515,7 +3524,7 @@
*/
char *
-dtoa
+_Py_dg_dtoa
#ifdef KR_headers
(dd, mode, ndigits, decpt, sign, rve)
double dd; int mode, ndigits, *decpt, *sign; char **rve;
More information about the Python-checkins
mailing list