-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-45548: Remove _math.c workarounds for pre-C99 libm #29179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ba5de5f
bpo-45548: Remove _math.c workarounds for pre-C99 libm
tiran 0ea1734
Update Misc/NEWS.d/next/Build/2021-10-24-21-49-49.bpo-45548.UWx0UC.rst
tiran fc3db0c
Remove _math.c depends from setup.py
tiran 45b7fa6
Update comments, it's _math.h now
tiran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
bpo-45548: Remove _math.c workarounds for pre-C99 libm
The :mod:`math` and :mod:`cmath` implementation now require a C99 compatible ``libm`` and no longer ship with workarounds for missing acosh, asinh, expm1, and log1p functions. The changeset also removes ``_math.c`` and moves the last remaining workaround into ``_math.h``. This simplifies static builds with ``Modules/Setup`` and resolves symbol conflicts. Co-authored-by: Mark Dickinson <mdickinson@enthought.com> Co-authored-by: Brett Cannon <brett@python.org> Signed-off-by: Christian Heimes <christian@python.org>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Build/2021-10-24-21-49-49.bpo-45548.UWx0UC.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The :mod:`math` and :mod:`cmath` implementation now require a C99 compatible | ||
``libm`` and no longer ship with workarounds for missing acosh, asinh, | ||
expm1, and log1p functions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,24 @@ | ||
#ifdef HAVE_ACOSH | ||
# define m_acosh acosh | ||
#else | ||
/* if the system doesn't have acosh, use the substitute | ||
function defined in Modules/_math.c. */ | ||
double _Py_acosh(double x); | ||
# define m_acosh _Py_acosh | ||
#endif | ||
/* log1p(x) = log(1+x). The log1p function is designed to avoid the | ||
significant loss of precision that arises from direct evaluation when x is | ||
small. Use the substitute from _math.c on all platforms: it includes | ||
workarounds for buggy handling of zeros. | ||
*/ | ||
|
||
#ifdef HAVE_ASINH | ||
# define m_asinh asinh | ||
#else | ||
/* if the system doesn't have asinh, use the substitute | ||
function defined in Modules/_math.c. */ | ||
double _Py_asinh(double x); | ||
# define m_asinh _Py_asinh | ||
#endif | ||
static double | ||
_Py_log1p(double x) | ||
{ | ||
/* Some platforms supply a log1p function but don't respect the sign of | ||
zero: log1p(-0.0) gives 0.0 instead of the correct result of -0.0. | ||
|
||
#ifdef HAVE_ATANH | ||
# define m_atanh atanh | ||
#else | ||
/* if the system doesn't have atanh, use the substitute | ||
function defined in Modules/_math.c. */ | ||
double _Py_atanh(double x); | ||
#define m_atanh _Py_atanh | ||
#endif | ||
To save fiddling with configure tests and platform checks, we handle the | ||
special case of zero input directly on all platforms. | ||
*/ | ||
if (x == 0.0) { | ||
return x; | ||
} | ||
else { | ||
return log1p(x); | ||
} | ||
} | ||
|
||
#ifdef HAVE_EXPM1 | ||
# define m_expm1 expm1 | ||
#else | ||
/* if the system doesn't have expm1, use the substitute | ||
function defined in Modules/_math.c. */ | ||
double _Py_expm1(double x); | ||
#define m_expm1 _Py_expm1 | ||
#endif | ||
|
||
double _Py_log1p(double x); | ||
|
||
/* Use the substitute from _math.c on all platforms: | ||
it includes workarounds for buggy handling of zeros. */ | ||
#define m_log1p _Py_log1p |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.