diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-07-24 09:31:08 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-07-24 09:31:08 +0000 |
commit | 32ce90013e67e48625b106481449cbc0273c9a09 (patch) | |
tree | 60ae8b08b0204363ecd694ec015820aa03e02bb9 /lib/libc/gen/isinf.c | |
parent | a4a31c8ba6ef66cebd6cfb35c065d837ce7e796c (diff) |
- move isinf, isnan dups to gen, since most is ieee 754
- is{inf,nan} should be macros for real-floating, so rename to
__is{inf,nan}, per C99
- implement C99 __fpclassify(), __fpclassifyf(), __isfinite(),
__isfinitef(), __isnormal(), __isnormalf(), __signbit(), __signbitf()
- long functions added, but not yet enabled, till ieee.h is fixed
- implement vax equivalents of the functions
- reimplement isinff, isnanf in a better way, and move to libc
- add qnan bytes for all archs
- bump major
man pages will follow
ok millert@. arm bits looked over by drahn@
discussed w/ theo, who showed the right direction, to put these
functions in libc
Diffstat (limited to 'lib/libc/gen/isinf.c')
-rw-r--r-- | lib/libc/gen/isinf.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/libc/gen/isinf.c b/lib/libc/gen/isinf.c new file mode 100644 index 00000000000..f8dae2a5402 --- /dev/null +++ b/lib/libc/gen/isinf.c @@ -0,0 +1,49 @@ +/* $OpenBSD: isinf.c,v 1.1 2008/07/24 09:31:07 martynas Exp $ */ +/* + * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/types.h> +#include <machine/ieee.h> + +int +__isinf(double d) +{ + struct ieee_double *p = (struct ieee_double *)&d; + + return (p->dbl_exp == DBL_EXP_INFNAN && + p->dbl_frach == 0 && p->dbl_fracl == 0); +} + +int +isinff(float f) +{ + struct ieee_single *p = (struct ieee_single *)&f; + + return (p->sng_exp == SNG_EXP_INFNAN && p->sng_frac == 0); +} + +#if 0 /* XXX */ +int +__isinfl(long double e) +{ + struct ieee_ext *p = (struct ieee_ext *)&e; + + p->ext_frach &= ~0x80000000; /* clear sign bit */ + + return (p->ext_exp == EXT_EXP_INFNAN && + p->ext_frach == 0 && p->ext_fracl == 0); +} +#endif /* XXX */ |