msg245879 - (view) |
Author: Andrew Turner (Andrew Turner) |
Date: 2015-06-27 15:08 |
The attached patch moves to use the fenv functions on FreeBSD to control the floating-point environment. This will be needed as I don't expect FreeBSD will have these functions on arm64.
I would expect a similar change should be applied to any supported development branch.
|
msg251221 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2015-09-21 12:12 |
It looks like fpsetmask() was deprecated since many years, and that fedisableexcept() is available since FreeBSD 5.3. Since we try to support FreeBSD 9, it's fine to drop support of FreeBSD < 5.3.
I'm concerned by the "CAVEATS" section below. Should we put "#pragma STDC FENV_ACCESS ON" in all .c file using a C double?
@skrah: I saw this pragma in Modules/_decimal/libmpdec/mpdecimal.c. Any idea if applying this patch is fine?
Maybe we can start by applying it to the default branch?
If this patch is required to support arm64, I think that it's ok to apply it to 2.7, 3.4 and 3.5 since we still accept changes to fix platform compatibility issues.
http://www.unix.com/man-page/freebsd/3/fpsetmask/
---
DESCRIPTION
The routines described herein are deprecated. New code should use the functionality provided by fenv(3).
---
http://www.unix.com/man-page/freebsd/3/fenv/
---
HISTORY
The <fenv.h> header first appeared in FreeBSD 5.3. It supersedes the non-standard routines defined in <ieeefp.h> and documented in fpgetround(3).
CAVEATS
The FENV_ACCESS pragma can be enabled with
#pragma STDC FENV_ACCESS ON
---
|
msg251227 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2015-09-21 14:42 |
In theory we should set FENV_ACCESS whenever the control word is
changed (C99):
"If part of a program tests floating-point status flags, sets
floating-point control modes, or runs under non-default mode
settings, but was translated with the state for the FENV_ACCESS
pragma "off", the behavior is undefined."
In practice gcc ignores the pragma, icc and cl.exe use it, not
sure about clang.
|
msg251228 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2015-09-21 14:53 |
FYI in Python/pytime.c, I put a lot of "volatile double" when tests started to fail on some platforms. It's inefficient, but it's easier than teaching how to disable optimizations on each different compiler :-p
|
msg251230 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2015-09-21 14:58 |
Ok, clang does not support it either:
https://llvm.org/bugs/show_bug.cgi?id=10409
|
msg251231 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2015-09-21 15:20 |
Regarding volatile: gcc/clang seem to honor *some* changes to
the control word. At least in libmpdec both compilers have
always left the settings 80bit-prec/ROUND_CHOP intact, even
though it's not the default.
Let's rewrite Python in asm to avoid these issues. :)
|
msg251258 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2015-09-21 20:48 |
Sorry, I don't understand if we should apply or not the patch :-/
|
msg257429 - (view) |
Author: Andrew Turner (Andrew Turner) |
Date: 2016-01-03 21:49 |
Can this be applied?
|
msg258690 - (view) |
Author: Kubilay Kocak (koobs)  |
Date: 2016-01-20 16:23 |
This issue is becoming increasingly important as FreeBSD 11.0-RELEASE time nears.
What remains to be done/identified/answers here to make progress?
|
msg258691 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2016-01-20 16:27 |
Andrew Turner: "Can this be applied?"
koobs: "What remains to be done/identified/answers here to make progress?"
*I* don't understand if replacing fpsetmask() with fedisableexcept() is enough, or if we also need to starting putting "#pragma STDC FENV_ACCESS ON" in all .c file using a C double? It's not a rhetorical question, I don't understand the consequence of the attached patch.
If two FreeBSD developers (Andrew Turner and koobs) are confident, maybe I should trust them and apply blindly the patch without trying to understand it :-D
|
msg258692 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2016-01-20 16:30 |
1) Feedback whether the compiler used on FreeBSD recognizes FENV_ACCESS.
2) If not, an indication why the man page mentions it.
|
msg258694 - (view) |
Author: Andrew Turner (Andrew Turner) |
Date: 2016-01-20 17:03 |
I think this patch is correct.
Clang, as shipped by FreeBSD, doesn't support FENV_ACCESS. It raises the following warning:
fenv_test.c:2:14: warning: pragma STDC FENV_ACCESS ON is not supported, ignoring pragma [-Wunknown-pragmas]
#pragma STDC FENV_ACCESS ON
^
1 warning generated.
I expect the man page mentions it because it is mentioned in the standard. In the bugs section it does say the pragma is unimplemented.
|
msg258695 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2016-01-20 17:10 |
Thanks, then the patch looks good to me.
|
msg258720 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-01-20 21:31 |
New changeset 76f35f35be50 by Victor Stinner in branch '3.5':
Replace fpgetmask() with fedisableexcept()
https://hg.python.org/cpython/rev/76f35f35be50
New changeset 6134d9ecab60 by Victor Stinner in branch 'default':
Merge 3.5 (issue #24520)
https://hg.python.org/cpython/rev/6134d9ecab60
New changeset 394ae9efc5c2 by Victor Stinner in branch '2.7':
Replace fpgetmask() with fedisableexcept()
https://hg.python.org/cpython/rev/394ae9efc5c2
|
msg258721 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2016-01-20 21:33 |
"I expect the man page mentions it because it is mentioned in the standard. In the bugs section it does say the pragma is unimplemented."
Ah ah, funnny. Sorry, I was confused by the manual page.
I pushed your patch to Python 2.7, 3.5 and default (3.6) branches.
@koobs: sorry, 3.4 now only accept security fixes :-p
|
msg258819 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2016-01-22 16:04 |
> @koobs: sorry, 3.4 now only accept security fixes :-p
I wrote a table giving the status of each Python branch to know which ones still accept bugfixes or not:
https://docs.python.org/devguide/#status-of-python-branches
|
|
Date |
User |
Action |
Args |
2022-04-11 14:58:18 | admin | set | github: 68708 |
2016-01-22 16:04:35 | vstinner | set | status: open -> closed resolution: fixed messages:
+ msg258819
|
2016-01-20 21:33:55 | vstinner | set | messages:
+ msg258721 |
2016-01-20 21:31:32 | python-dev | set | nosy:
+ python-dev messages:
+ msg258720
|
2016-01-20 17:10:25 | skrah | set | messages:
+ msg258695 |
2016-01-20 17:03:03 | Andrew Turner | set | messages:
+ msg258694 |
2016-01-20 16:30:30 | skrah | set | messages:
+ msg258692 |
2016-01-20 16:28:00 | vstinner | set | messages:
+ msg258691 |
2016-01-20 16:23:36 | koobs | set | messages:
+ msg258690 versions:
+ Python 2.7, Python 3.5 |
2016-01-03 21:49:55 | Andrew Turner | set | messages:
+ msg257429 |
2015-09-21 20:48:05 | vstinner | set | messages:
+ msg251258 |
2015-09-21 15:20:06 | skrah | set | messages:
+ msg251231 |
2015-09-21 14:58:15 | skrah | set | messages:
+ msg251230 |
2015-09-21 14:53:20 | vstinner | set | messages:
+ msg251228 |
2015-09-21 14:42:49 | skrah | set | messages:
+ msg251227 |
2015-09-21 12:19:01 | Arfrever | set | nosy:
+ Arfrever
|
2015-09-21 12:13:00 | vstinner | set | nosy:
+ skrah, vstinner messages:
+ msg251221
|
2015-07-03 17:38:57 | terry.reedy | set | nosy:
+ mark.dickinson
|
2015-06-30 12:00:26 | emaste | set | nosy:
+ emaste
|
2015-06-30 12:00:07 | koobs | set | keywords:
+ needs review nosy:
+ koobs
|
2015-06-27 15:08:23 | Andrew Turner | create | |