Module Name:    src
Committed By:   riastradh
Date:           Thu May  9 14:42:10 UTC 2024

Modified Files:
        src/lib/libm: Makefile m.vax.expsym
Added Files:
        src/lib/libm/noieee_src: n_frexpf.c n_frexpl.c

Log Message:
libm: Add frexpf and frexpl on VAX.

These are trivial subroutines, not symbol aliases, for separate
reasons:

- frexpf has a different ABI from frexp (float vs double argument)

- frexp is defined in libc, not libm, so although long double is the
  same as double, frexpl can't be an alias in libm of a symbol
  defined in libc


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/lib/libm/Makefile
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/m.vax.expsym
cvs rdiff -u -r0 -r1.1 src/lib/libm/noieee_src/n_frexpf.c \
    src/lib/libm/noieee_src/n_frexpl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.233 src/lib/libm/Makefile:1.234
--- src/lib/libm/Makefile:1.233	Thu May  9 00:04:23 2024
+++ src/lib/libm/Makefile	Thu May  9 14:42:09 2024
@@ -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} == 
 # 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 \

Index: src/lib/libm/m.vax.expsym
diff -u src/lib/libm/m.vax.expsym:1.3 src/lib/libm/m.vax.expsym:1.4
--- src/lib/libm/m.vax.expsym:1.3	Wed May  8 02:08:11 2024
+++ src/lib/libm/m.vax.expsym	Thu May  9 14:42:09 2024
@@ -188,6 +188,8 @@ fminf
 fmod
 fmodf
 fmodl
+frexpf
+frexpl
 gamma
 hypot
 hypotf

Added files:

Index: src/lib/libm/noieee_src/n_frexpf.c
diff -u /dev/null src/lib/libm/noieee_src/n_frexpf.c:1.1
--- /dev/null	Thu May  9 14:42:10 2024
+++ src/lib/libm/noieee_src/n_frexpf.c	Thu May  9 14:42:10 2024
@@ -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 <sys/cdefs.h>
+__RCSID("$NetBSD: n_frexpf.c,v 1.1 2024/05/09 14:42:10 riastradh Exp $");
+
+#include "namespace.h"
+
+#include <math.h>
+
+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);
+}
Index: src/lib/libm/noieee_src/n_frexpl.c
diff -u /dev/null src/lib/libm/noieee_src/n_frexpl.c:1.1
--- /dev/null	Thu May  9 14:42:10 2024
+++ src/lib/libm/noieee_src/n_frexpl.c	Thu May  9 14:42:10 2024
@@ -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 <sys/cdefs.h>
+__RCSID("$NetBSD: n_frexpl.c,v 1.1 2024/05/09 14:42:10 riastradh Exp $");
+
+#include "namespace.h"
+
+#include <math.h>
+
+#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);
+}

Reply via email to