Opened 8 years ago
Closed 6 years ago
#7007 closed bug (fixed)
Implement missing <math.h> functions
Reported by: | scottmc | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta1 |
Component: | System/POSIX | Version: | R1/Development |
Keywords: | Cc: | andreasf | |
Blocked By: | Blocking: | ||
Has a Patch: | no | Platform: | All |
Description
These are present in the math.h header, but not yet implemented: math.h:
lgammal gamma_r gammaf_r
The following issues also need to be adressed in math.h:
- Missing definition of float_t and double_t as described at opengroup.org.
- Missing declaration of FLT_EVAL_METHOD.
- Function "int isgreater(real-floating x, real-floating y);" is never defined or declared in the header.
- Function "int isgreaterequal(real-floating x, real-floating y);" is never defined or declared in the header.
- Functions "int isless(real-floating x, real-floating y);,
int islessequal(real-floating x, real-floating y);, int islessgreater(real-floating x, real-floating y);" are never defined or declared in the header.
- Function "int isunordered(real-floating x, real-floating y);" is never defined or declared in the header.
- There is no definition of "MAXFLOAT" constant in the header.
- The following optional macros "FP_FAST_FMA, FP_FAST_FMAF, FP_FAST_FMAL" are not defined in the header.
- The following macros "FP_ILOGB0, FP_ILOGBNAN, MATH_ERRNO, MATH_ERREXCEPT, math_errhandling" are never defined in the header.
The functions need to provide the requirements as defined at: http://www.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html
This is being worked on by a GCI student. This is for the math.h in headers/posix/math.h
Attachments (7)
Change History (22)
Changed 8 years ago by
Attachment: | math_changes.patch added |
---|
comment:1 Changed 8 years ago by
Has a Patch: | set |
---|
comment:2 Changed 8 years ago by
comment:3 Changed 8 years ago by
headers/posix/math.h is a public header owned by Haiku. src/system/libroot/posix/glibc/math/math.h is a private header from Glibc and is maintained there.
Missing definitions (if they're really missing) should be added to headers/posix/math.h to be used by user applications.
Glibc implementations should actually be used (even if they happen to be from Sun). You should find them at this place: http://sourceware.org/git/?p=glibc.git;a=tree;f=math;h=4d12aaac32cd639876398a5732b26a4fd8c5c08b;hb=14b697f75a5f039a0e3155c62399ee217c0f17dc http://sourceware.org/git/?p=glibc.git;a=tree;f=sysdeps/ieee754/flt-32;h=6a47a4d722f4b99d4226f9df047f695dc7aebe3b;hb=14b697f75a5f039a0e3155c62399ee217c0f17dc http://sourceware.org/git/?p=glibc.git;a=tree;f=sysdeps/ieee754/dbl-64;h=a1ee9700d652ca2d8809172aaab6d8d593802289;hb=14b697f75a5f039a0e3155c62399ee217c0f17dc
Beware w_gamma_r.c and w_gammaf_r.c are only wrappers.
A (very simple) test program for these functions would be appreciated.
Changed 8 years ago by
Attachment: | math_changes.2.patch added |
---|
comment:4 Changed 8 years ago by
I undid all of my changes to /system/libroot/posix/glibc/math/math.h and basically did everything the task asked to headers/posix/math.h.
Although everything looks fine to me, I'm sure there is still some work that needs to be done.
Just let me know and i'll do my best.
-Reid
comment:5 follow-up: 9 Changed 8 years ago by
Thanks.
For GCC4, one should use the builtins functions provided by the compiler: #define isgreater(x, y) builtin_isgreater ((x),(y)) #define isgreaterequal(x, y) builtin_isgreaterequal ((x),(y)) #define isless(x, y) builtin_isless ((x),(y)) #define islessequal(x, y) builtin_islessequal ((x),(y)) #define islessgreater(x, y) builtin_islessgreater ((x),(y)) #define isunordered(x, y) builtin_isunordered ((x),(y))
For GCC2, you should definitely rewrite these definitions, sorry but they look like verbatim copies of glibc math.h. I hope you understand this point.
MAXFLOAT should be defined to the max float value FLT_MAX defined by the compiler (including float.h might be required).
Unless fma() calls are indeed fast, FP_FAST_FMA definitions should be better zero valued. Please add a TODO comment if this needs to be revisited. For FP_ILOGB0 and FP_ILOGBNAN, I'd prefer the *_MAX equivalent definitions.
Defining math_errhandling to 3 is a bit fast. Please add a TODO comment if this needs to be revisited. Also 3 is actually the (MATH_ERRNO | MATH_ERREXCEPT).
w_lgammal.c, w_gamma_r.c and w_gammaf_r.c are to be added to respective arch Jamfiles to be included in the build. gamma* functions seem to be deprecated in posix specifications. We might want to only include those for GCC2.
comment:6 Changed 8 years ago by
Cc: | andreasf added |
---|
comment:7 Changed 8 years ago by
@ReidH, If you manage to complete this before the GCI deadline and still want to get the credit for it you can submit your patch(es) here and when they are deemed good then reclaim the task and we can mark it complete, that way you aren't being held up while you have another task open.
comment:8 Changed 7 years ago by
Milestone: | R1 → R1/beta1 |
---|
comment:10 Changed 7 years ago by
Has a Patch: | unset |
---|
Changed 6 years ago by
Attachment: | 0001-Add-missing-definitions-to-math.h.patch added |
---|
Changed 6 years ago by
Attachment: | 0002-Add-glibc-ilogbl-implemenation.patch added |
---|
Changed 6 years ago by
Attachment: | 0003-Add-s_ldexpl.c-to-x86-jamfile.patch added |
---|
Changed 6 years ago by
Attachment: | 0004-Add-s_tanhl.c-to-x86-jamfile.patch added |
---|
Changed 6 years ago by
Attachment: | 0005-Add-gamma-f-_r-declarations-and-aliases.patch added |
---|
comment:11 Changed 6 years ago by
Attached patches from GCI2012 student 'qxcv'. Can someone check these and see if they are acceptable.
comment:13 Changed 6 years ago by
Functions gamma_r and gammaf_r seem not part of the spec. IMO the patch 0005-Add-gamma-f-_r-declarations-and-aliases.patch isn't needed.
comment:14 Changed 6 years ago by
So then can someone apply patches 1-4 and then we can close this ticket out?
I found two headers that seemed to pertain to this ticket. headers/posix/math.h and /system/libroot/posix/glibc/math/math.h.
1, 2, 8 and 9 were added to system/libroot/posix/glibc/math/math.h because there was a whole commented section requesting them.
3, 4, 5 and 6 were already defined as macros in system/libroot/posix/glibc/math/math.h so I made no changes.
This confused me, this ticket says it is for headers/posix/math.h, yet a lot of work seemed like it either needed to be done in, or had already been done in /system/libroot/posix/glibc/math/math.h.
As for gamma_r and gammaf_r, I found their definitions from Sun, where the rest of the definitions apparently came from. And with some slight altering I believed I successfully implemented them in the form of two files (w_gamma_r.c and w_gammaf_r.c) residing in src/system/libroot/posix/glibc/arch/generic.
lgammal seemed to already be implemented, and I saw a page on dev.haiku-os.org that seemed to confirm this.
The only altering made to headers/posix/math.h was the definition of MAXFLOAT.
I don't know if the two headers are in any way linked, or if everything I did in /system/libroot/posix/glibc/math/math.h should have been added to headers/posix/math.h along with redefining all the macros found in /system/libroot/posix/glibc/math/math.h.
Any help is appreciated. -Reid