Wed May 8 02:08:11 2024 UTC (25d)
libm: Add rintl, rintf to non-IEEE754 architectures.

While here, delete #ifdef to handle ns32k -- I don't think that's
gonna be relevant any time soon; in case you hadn't noticed, the
world has moved on from ns32k to vax by now.

PR 57881


(riastradh)
diff -r1.2 -r1.3 src/lib/libm/m.vax.expsym
diff -r1.8 -r1.9 src/lib/libm/noieee_src/n_floor.c

cvs diff -r1.2 -r1.3 src/lib/libm/m.vax.expsym (expand / switch to unified diff)

--- src/lib/libm/m.vax.expsym 2024/05/08 01:04:24 1.2
+++ src/lib/libm/m.vax.expsym 2024/05/08 02:08:11 1.3
@@ -219,26 +219,28 @@ logbl @@ -219,26 +219,28 @@ logbl
219logf 219logf
220lrint 220lrint
221lrintf 221lrintf
222lround 222lround
223lroundf 223lroundf
224modfl 224modfl
225nan 225nan
226nanf 226nanf
227nanl 227nanl
228pow 228pow
229powf 229powf
230powl 230powl
231rint 231rint
 232rintf
 233rintl
232round 234round
233roundf 235roundf
234roundl 236roundl
235scalb 237scalb
236scalbn 238scalbn
237scalbnf 239scalbnf
238scalbnl 240scalbnl
239signgam 241signgam
240sin 242sin
241sincos 243sincos
242sincosf 244sincosf
243sincosl 245sincosl
244sinf 246sinf

cvs diff -r1.8 -r1.9 src/lib/libm/noieee_src/n_floor.c (expand / switch to unified diff)

--- src/lib/libm/noieee_src/n_floor.c 2014/03/16 09:51:39 1.8
+++ src/lib/libm/noieee_src/n_floor.c 2024/05/08 02:08:11 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: n_floor.c,v 1.8 2014/03/16 09:51:39 martin Exp $ */ 1/* $NetBSD: n_floor.c,v 1.9 2024/05/08 02:08:11 riastradh Exp $ */
2/* 2/*
3 * Copyright (c) 1985, 1993 3 * Copyright (c) 1985, 1993
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the University nor the names of its contributors 14 * 3. Neither the name of the University nor the names of its contributors
@@ -35,31 +35,30 @@ static char sccsid[] = "@(#)floor.c 8.1  @@ -35,31 +35,30 @@ static char sccsid[] = "@(#)floor.c 8.1
35#endif /* not lint */ 35#endif /* not lint */
36 36
37#define _LIBM_STATIC 37#define _LIBM_STATIC
38#include "mathimpl.h" 38#include "mathimpl.h"
39 39
40vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */ 40vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */
41 41
42ic(L, 4503599627370496.0E0, 52, 1.0) /* 2**52 */ 42ic(L, 4503599627370496.0E0, 52, 1.0) /* 2**52 */
43 43
44#ifdef vccast 44#ifdef vccast
45#define L vccast(L) 45#define L vccast(L)
46#endif 46#endif
47 47
48#ifdef __weak_alias 48__weak_alias(ceill, ceil)
49__weak_alias(ceill, ceil); 49__weak_alias(floorl, floor)
50__weak_alias(floorl, floor); 50__weak_alias(truncl, trunc)
51__weak_alias(truncl, trunc); 51__weak_alias(rintl, rint)
52#endif 
53 52
54/* 53/*
55 * floor(x) := the largest integer no larger than x; 54 * floor(x) := the largest integer no larger than x;
56 * ceil(x) := -floor(-x), for all real x. 55 * ceil(x) := -floor(-x), for all real x.
57 * 56 *
58 * Note: Inexact will be signaled if x is not an integer, as is 57 * Note: Inexact will be signaled if x is not an integer, as is
59 * customary for IEEE 754. No other signal can be emitted. 58 * customary for IEEE 754. No other signal can be emitted.
60 */ 59 */
61double 60double
62floor(double x) 61floor(double x)
63{ 62{
64 volatile double y; 63 volatile double y;
65 64
@@ -100,27 +99,26 @@ ceil(double x) @@ -100,27 +99,26 @@ ceil(double x)
100 else { /* now 0 <= x < L */ 99 else { /* now 0 <= x < L */
101 y = L+x; /* destructive store must be forced */ 100 y = L+x; /* destructive store must be forced */
102 y -= L; /* an integer, and |x-y| < 1 */ 101 y -= L; /* an integer, and |x-y| < 1 */
103 return x > y ? y+(double)1 : y; 102 return x > y ? y+(double)1 : y;
104 } 103 }
105} 104}
106 105
107float 106float
108ceilf(float x) 107ceilf(float x)
109{ 108{
110 return ceil((double)x); 109 return ceil((double)x);
111} 110}
112 111
113#ifndef ns32000 /* rint() is in ./NATIONAL/support.s */ 
114/* 112/*
115 * algorithm for rint(x) in pseudo-pascal form ... 113 * algorithm for rint(x) in pseudo-pascal form ...
116 * 114 *
117 * real rint(x): real x; 115 * real rint(x): real x;
118 * ... delivers integer nearest x in direction of prevailing rounding 116 * ... delivers integer nearest x in direction of prevailing rounding
119 * ... mode 117 * ... mode
120 * const L = (last consecutive integer)/2 118 * const L = (last consecutive integer)/2
121 * = 2**55; for VAX D 119 * = 2**55; for VAX D
122 * = 2**52; for IEEE 754 Double 120 * = 2**52; for IEEE 754 Double
123 * real s,t; 121 * real s,t;
124 * begin 122 * begin
125 * if x != x then return x; ... NaN 123 * if x != x then return x; ... NaN
126 * if |x| >= L then return x; ... already an integer 124 * if |x| >= L then return x; ... already an integer
@@ -139,27 +137,32 @@ rint(double x) @@ -139,27 +137,32 @@ rint(double x)
139 volatile double t; 137 volatile double t;
140 const double one = 1.0; 138 const double one = 1.0;
141 139
142#if !defined(__vax__)&&!defined(tahoe) 140#if !defined(__vax__)&&!defined(tahoe)
143 if (x != x) /* NaN */ 141 if (x != x) /* NaN */
144 return (x); 142 return (x);
145#endif /* !defined(__vax__)&&!defined(tahoe) */ 143#endif /* !defined(__vax__)&&!defined(tahoe) */
146 if (copysign(x,one) >= L) /* already an integer */ 144 if (copysign(x,one) >= L) /* already an integer */
147 return (x); 145 return (x);
148 s = copysign(L,x); 146 s = copysign(L,x);
149 t = x + s; /* x+s rounded to integer */ 147 t = x + s; /* x+s rounded to integer */
150 return (t - s); 148 return (t - s);
151} 149}
152#endif /* not national */ 150
 151float
 152rintf(float x)
 153{
 154 return rint((double)x);
 155}
153 156
154long 157long
155lrint(double x) 158lrint(double x)
156{ 159{
157 double s; 160 double s;
158 volatile double t; 161 volatile double t;
159 const double one = 1.0; 162 const double one = 1.0;
160 163
161#if !defined(__vax__)&&!defined(tahoe) 164#if !defined(__vax__)&&!defined(tahoe)
162 if (x != x) /* NaN */ 165 if (x != x) /* NaN */
163 return (x); 166 return (x);
164#endif /* !defined(__vax__)&&!defined(tahoe) */ 167#endif /* !defined(__vax__)&&!defined(tahoe) */
165 if (copysign(x,one) >= L) /* already an integer */ 168 if (copysign(x,one) >= L) /* already an integer */