This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On 04/01/2016 09:26 PM, Gregory Pietsch wrote:
They are not C functions. If they even go in, they should be gated by C++. (If I've read it properly, they are in a C99 gate and the long double gate, but no others.) Not only that, but there should then also be a comment explaining that they are purely prototypes for some special purpose and that the functions not only are not supplied but should never be. (I think the motivation for such a comment has been made clear by Gregory's suggestion of the functions being added. What if he thought of it a month from now instead of right away?)isnan and isinf are macros, not functions, so they should work on long doubles. Something like: #define isnan(_X) (fpclassify(_X)==FP_NAN) #define isinf(_X) (fpclassify(_X)==FP_INFINITE)I know Stroustrup hates macros, but we have not expanded into C99 territory, right?Anyway, given the macros, implementations for these two functions are trivial: #include <math.h> int (isnanl)(long double x) { return isnan(x); } #include <math.h> int (isinfl)(long double x) { return isinf(x); } While we're at it, could we add isfinitel and isnormall too? Gregory On 4/1/2016 6:49 PM, Yaakov Selkowitz wrote:libstdc++ requires these to be declared in order to be enabled. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com> --- newlib/libc/include/math.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index e5d6123..a69abe9 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h@@ -460,6 +460,8 @@ extern long double fmodl _PARAMS((long double, long double));extern long double hypotl _PARAMS((long double, long double)); #endif /* ! defined (__math_68881) */ #endif /* ! defined (_REENT_ONLY) */ +extern int isnanl _PARAMS((long double)); +extern int isinfl _PARAMS((long double)); extern long double copysignl _PARAMS((long double, long double)); extern long double nanl _PARAMS((const char *)); extern int ilogbl _PARAMS((long double));
Would you please more fully explain the motivation for wanting to add them? Since the patch is putting in only the prototypes and not the actual functions, are you trying to just pass some kind of compilation check?
My first reaction is that they are not appropriate to add. To frame the issue in a couple of different ways: Why do we care about libstdc++? (Which is different than caring about a C++ compiler.) Why would we pollute the Newlib C library with a C++-only function which is basically improper for C? In C (starting with C99, so 17 years and counting) you're supposed to use the isnan and isinf macros regardless of the floating point type. It's one thing to have a C++ compiler make C99 stuff visible, but it's something different to want to add C++ functions to C99.
Craig
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |