Sanjay Patel via Phabricator via cfe-commits
2017-11-03 19:11:16 UTC
spatel created this revision.
Herald added a subscriber: mcrosier.
These are 3 errno-related diffs raised in D39841.
1. Cube root
We're going to dismiss POSIX language like this:
"On successful completion, cbrt() returns the cube root of x. If x is NaN, cbrt() returns NaN and errno may be set to [EDOM]. "
http://pubs.opengroup.org/onlinepubs/7908799/xsh/cbrt.html
And favor an interpretation based on the C standard that says:
"Functions with a NaN argument return a NaN result and raise no floating-point exception, except where stated otherwise."
2. Floating multiply-add
The C standard is silent?
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fma.html - clearly says "...then errno shall be set..."
but:
https://linux.die.net/man/3/fma - "These functions do not set errno."
Let's opt for the - hopefully common - implementation where errno is not set. Note that there's no test change because as noted in the earlier discussion, we're ignoring the const attr in CodeGenFunction::EmitBuiltinExpr(). I'll look at what needs fixing in that function next.
3. Complex
This is came up specifically for 'carg', but I'm hoping we can use 1 justification for the whole lib.
The POSIX docs all have language like this for complex calls:
"No errors are defined."
http://pubs.opengroup.org/onlinepubs/9699919799/functions/ccos.html
The lack of errno handling is allowed by the inclusion of "optionally" in the C standard definitions of all of the complex ops?
"csqrt(x + iNaN) returns NaN + iNaN and optionally raises the ââinvalidââ floating-point exception, for finite x"
https://reviews.llvm.org/D39611
Files:
include/clang/Basic/Builtins.def
test/CodeGen/builtin-errno.c
test/CodeGen/libcalls-errno.c
Herald added a subscriber: mcrosier.
These are 3 errno-related diffs raised in D39841.
1. Cube root
We're going to dismiss POSIX language like this:
"On successful completion, cbrt() returns the cube root of x. If x is NaN, cbrt() returns NaN and errno may be set to [EDOM]. "
http://pubs.opengroup.org/onlinepubs/7908799/xsh/cbrt.html
And favor an interpretation based on the C standard that says:
"Functions with a NaN argument return a NaN result and raise no floating-point exception, except where stated otherwise."
2. Floating multiply-add
The C standard is silent?
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fma.html - clearly says "...then errno shall be set..."
but:
https://linux.die.net/man/3/fma - "These functions do not set errno."
Let's opt for the - hopefully common - implementation where errno is not set. Note that there's no test change because as noted in the earlier discussion, we're ignoring the const attr in CodeGenFunction::EmitBuiltinExpr(). I'll look at what needs fixing in that function next.
3. Complex
This is came up specifically for 'carg', but I'm hoping we can use 1 justification for the whole lib.
The POSIX docs all have language like this for complex calls:
"No errors are defined."
http://pubs.opengroup.org/onlinepubs/9699919799/functions/ccos.html
The lack of errno handling is allowed by the inclusion of "optionally" in the C standard definitions of all of the complex ops?
"csqrt(x + iNaN) returns NaN + iNaN and optionally raises the ââinvalidââ floating-point exception, for finite x"
https://reviews.llvm.org/D39611
Files:
include/clang/Basic/Builtins.def
test/CodeGen/builtin-errno.c
test/CodeGen/libcalls-errno.c