diff --git a/lib/libm/Makefile b/lib/libm/Makefile index 495c257071ad..ae827f09deaa 100644 --- a/lib/libm/Makefile +++ b/lib/libm/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.233 2024/05/09 00:04:23 riastradh Exp $ +# $NetBSD: Makefile,v 1.234 2024/05/09 14:42:09 riastradh Exp $ # # @(#)Makefile 5.1beta 93/09/24 # @@ -359,8 +359,9 @@ COPTS.compat_cabsf.c= ${${ACTIVE_CC} == "gcc":? -fno-builtin-cabsf :} # math routines for non-IEEE architectures. NOIEEE_SRCS = n_asincos.c n_acosh.c n_asinh.c n_atan.c n_atanh.c n_atanhf.c \ n_cosh.c \ - n_erf.c n_exp.c n_exp2.c n_exp2f.c n_exp__E.c n_expm1.c n_floor.c \ - n_fmod.c n_gamma.c n_ilogb.c \ + n_erf.c n_exp.c n_exp2.c n_exp2f.c n_exp__E.c n_expm1.c \ + n_floor.c n_fmod.c n_frexpf.c n_frexpl.c \ + n_gamma.c n_ilogb.c \ n_lgamma.c n_j0.c n_j1.c n_jn.c n_log.c n_log10.c n_log1p.c \ n_log2.c n_log__L.c n_pow.c n_sinh.c n_tanh.c \ n_sincos.c n_sincos1.c n_tan.c \ diff --git a/lib/libm/m.vax.expsym b/lib/libm/m.vax.expsym index 3246c596c644..aae08cc605f0 100644 --- a/lib/libm/m.vax.expsym +++ b/lib/libm/m.vax.expsym @@ -188,6 +188,8 @@ fminf fmod fmodf fmodl +frexpf +frexpl gamma hypot hypotf diff --git a/lib/libm/noieee_src/n_frexpf.c b/lib/libm/noieee_src/n_frexpf.c new file mode 100644 index 000000000000..0fa86c70a146 --- /dev/null +++ b/lib/libm/noieee_src/n_frexpf.c @@ -0,0 +1,52 @@ +/* $NetBSD: n_frexpf.c,v 1.1 2024/05/09 14:42:10 riastradh Exp $ */ + +/*- + * Copyright (c) 2024 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__RCSID("$NetBSD: n_frexpf.c,v 1.1 2024/05/09 14:42:10 riastradh Exp $"); + +#include "namespace.h" + +#include + +float +frexpf(float x, int *e) +{ + + /* + * We assume every value representable by float is also + * representable by double. The normalized result of frexp + * differs only by the exponent, which is set to -1 (result + * lies in [1/2, 1) or is zero), so it is also still + * representable by float. + * + * This can't simply be a symbol alias, however, because the + * ABI of float frexpf(float, int *) is different from the ABI + * of double frexp(double, int *). + */ + return frexp(x, e); +} diff --git a/lib/libm/noieee_src/n_frexpl.c b/lib/libm/noieee_src/n_frexpl.c new file mode 100644 index 000000000000..21b7b7fc0301 --- /dev/null +++ b/lib/libm/noieee_src/n_frexpl.c @@ -0,0 +1,50 @@ +/* $NetBSD: n_frexpl.c,v 1.1 2024/05/09 14:42:10 riastradh Exp $ */ + +/*- + * Copyright (c) 2024 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__RCSID("$NetBSD: n_frexpl.c,v 1.1 2024/05/09 14:42:10 riastradh Exp $"); + +#include "namespace.h" + +#include + +#ifdef __HAVE_LONG_DOUBLE +#error This file is only for machiens where long double is the same as double. +#endif + +long double +frexpl(long double x, int *e) +{ + + /* + * This can't be a symbol alias because frexp is defined in + * libc, but frexpl is defined in libm, and ELF symbol aliases + * can't reach across libraries. + */ + return frexp(x, e); +}