mirror of
https://github.com/fluencelabs/musl
synced 2025-06-12 06:21:39 +00:00
first commit of the new libm!
thanks to the hard work of Szabolcs Nagy (nsz), identifying the best (from correctness and license standpoint) implementations from freebsd and openbsd and cleaning them up! musl should now fully support c99 float and long double math functions, and has near-complete complex math support. tgmath should also work (fully on gcc-compatible compilers, and mostly on any c99 compiler). based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from nsz's libm git repo, with some additions (dummy versions of a few missing long double complex functions, etc.) by me. various cleanups still need to be made, including re-adding (if they're correct) some asm functions that were dropped.
This commit is contained in:
@ -1,14 +1,10 @@
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "libm.h"
|
||||
|
||||
int __fpclassifyf(float __x)
|
||||
int __fpclassifyf(float x)
|
||||
{
|
||||
union {
|
||||
float __f;
|
||||
__uint32_t __i;
|
||||
} __y = { __x };
|
||||
int __ee = __y.__i>>23 & 0xff;
|
||||
if (!__ee) return __y.__i<<1 ? FP_SUBNORMAL : FP_ZERO;
|
||||
if (__ee==0xff) return __y.__i<<9 ? FP_NAN : FP_INFINITE;
|
||||
union fshape u = { x };
|
||||
int e = u.bits>>23 & 0xff;
|
||||
if (!e) return u.bits<<1 ? FP_SUBNORMAL : FP_ZERO;
|
||||
if (e==0xff) return u.bits<<9 ? FP_NAN : FP_INFINITE;
|
||||
return FP_NORMAL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user