CVS commit: src/lib/libm

2021-07-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Jul 21 12:05:02 UTC 2021

Modified Files:
src/lib/libm: Makefile

Log Message:
libm: build fma(3), fmaf(3), fmal(3) on alpha

Alpha has no hardware-assisted fused multiply-add, so the fallback
C implementation must be used. A basic smoke test shows the
implementation works for
"x * x - 1.0f" vs "fmaf(x, x, -1.0f)" with "volatile float x = 1.0008f;"


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/lib/libm/Makefile

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.213 src/lib/libm/Makefile:1.214
--- src/lib/libm/Makefile:1.213	Sun Apr 25 23:43:20 2021
+++ src/lib/libm/Makefile	Wed Jul 21 12:05:02 2021
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.213 2021/04/25 23:43:20 christos Exp $
+#  $NetBSD: Makefile,v 1.214 2021/07/21 12:05:02 tnn Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -71,6 +71,7 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
 COMMON_SRCS+= fenv.c
+COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 COPTS+=	-mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
 
 .elif (${LIBC_MACHINE_CPU} == "arm")



CVS commit: src/lib/libm

2021-04-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr 25 23:43:20 UTC 2021

Modified Files:
src/lib/libm: Makefile

Log Message:
Use ${MACHINE_MIPS64}


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/lib/libm/Makefile

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.212 src/lib/libm/Makefile:1.213
--- src/lib/libm/Makefile:1.212	Mon Nov 11 17:45:27 2019
+++ src/lib/libm/Makefile	Sun Apr 25 19:43:20 2021
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.212 2019/11/11 22:45:27 joerg Exp $
+#  $NetBSD: Makefile,v 1.213 2021/04/25 23:43:20 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -200,8 +200,7 @@ COMMON_SRCS += fenv.c
 COMMON_SRCS += fenv.c
 .endif
 COMMON_SRCS+= s_rintl.c
-.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") \
-&& (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
+.if ${MACHINE_MIPS64} && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
 COMMON_SRCS+= s_nexttoward.c
 .endif
 



CVS commit: src/lib/libm/src

2021-04-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Apr 12 09:15:52 UTC 2021

Modified Files:
src/lib/libm/src: k_standard.c

Log Message:
add a default: case to __kernel_standard(), failing with EDOM


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libm/src/k_standard.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/src/k_standard.c
diff -u src/lib/libm/src/k_standard.c:1.22 src/lib/libm/src/k_standard.c:1.23
--- src/lib/libm/src/k_standard.c:1.22	Sat Aug 27 10:03:16 2016
+++ src/lib/libm/src/k_standard.c	Mon Apr 12 09:15:52 2021
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: k_standard.c,v 1.22 2016/08/27 10:03:16 christos Exp $");
+__RCSID("$NetBSD: k_standard.c,v 1.23 2021/04/12 09:15:52 mrg Exp $");
 #endif
 
 #include "math.h"
@@ -825,6 +825,13 @@ __kernel_standard(double x, double y, in
 		  errno = EDOM;
 		}
 		break;
+	default:
+		if (_LIB_VERSION == _SVID_)
+		  exc.retval = -HUGE;
+		else
+		  exc.retval = -HUGE_VAL;
+		errno = EDOM;
+		break;
 	}
 	return exc.retval;
 }



CVS commit: src/lib/libm/src

2020-01-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jan 30 20:31:50 UTC 2020

Modified Files:
src/lib/libm/src: s_frexp.c

Log Message:
Provide frexpl on non-long-double systems as alias to frexp.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libm/src/s_frexp.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/src/s_frexp.c
diff -u src/lib/libm/src/s_frexp.c:1.13 src/lib/libm/src/s_frexp.c:1.14
--- src/lib/libm/src/s_frexp.c:1.13	Sun Sep 28 18:54:55 2008
+++ src/lib/libm/src/s_frexp.c	Thu Jan 30 20:31:50 2020
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_frexp.c,v 1.13 2008/09/28 18:54:55 christos Exp $");
+__RCSID("$NetBSD: s_frexp.c,v 1.14 2020/01/30 20:31:50 joerg Exp $");
 #endif
 
 /*
@@ -28,6 +28,10 @@ __RCSID("$NetBSD: s_frexp.c,v 1.13 2008/
 #include "math.h"
 #include "math_private.h"
 
+#ifndef __HAVE_LONG_DOUBLE
+__strong_alias(frexpl, frexp)
+#endif
+
 static const double
 two54 =  1.8014398509481984e+16; /* 0x4350, 0x */
 



CVS commit: src/lib/libm/man

2019-05-02 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Thu May  2 15:08:35 UTC 2019

Modified Files:
src/lib/libm/man: nextafter.3

Log Message:
Explicitly indicate that nexttowardl() is identical to nextafterl().

Requested by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libm/man/nextafter.3

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/man/nextafter.3
diff -u src/lib/libm/man/nextafter.3:1.7 src/lib/libm/man/nextafter.3:1.8
--- src/lib/libm/man/nextafter.3:1.7	Sun Apr 28 07:33:02 2019
+++ src/lib/libm/man/nextafter.3	Thu May  2 15:08:35 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: nextafter.3,v 1.7 2019/04/28 07:33:02 wiz Exp $
+.\" $NetBSD: nextafter.3,v 1.8 2019/05/02 15:08:35 mgorny Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -78,10 +78,9 @@ The three functions differ only in the t
 .Fa x .
 .Pp
 The
-.Fn nexttoward ,
-.Fn nexttowardf
+.Fn nexttoward
 and
-.Fn nexttowardl
+.Fn nexttowardf
 functions are equivalent to the
 .Fn nextafter
 family of functions with two exceptions:
@@ -97,6 +96,10 @@ converted to the type of the function, p
 equals
 .Fa y .
 .El
+.Pp
+.Fn nexttowardl
+is equivalent to
+.Fn nextafterl .
 .Sh RETURN VALUES
 Upon successful completion, the described functions return
 the next representable floating-point value as described above.



CVS commit: src/lib/libm/man

2019-04-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Apr 28 07:33:02 UTC 2019

Modified Files:
src/lib/libm/man: nextafter.3

Log Message:
Remove undefined \*H


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libm/man/nextafter.3

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/man/nextafter.3
diff -u src/lib/libm/man/nextafter.3:1.6 src/lib/libm/man/nextafter.3:1.7
--- src/lib/libm/man/nextafter.3:1.6	Sat Apr 27 23:04:32 2019
+++ src/lib/libm/man/nextafter.3	Sun Apr 28 07:33:02 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: nextafter.3,v 1.6 2019/04/27 23:04:32 kamil Exp $
+.\" $NetBSD: nextafter.3,v 1.7 2019/04/28 07:33:02 wiz Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -104,10 +104,10 @@ If
 .Fa x
 is finite but an overflow would occur,
 a range error follows and the functions return
-.Dv \*(Pm\*HHUGE_VAL ,
-.Dv  \*(Pm\*HHUGE_VALF ,
+.Dv \*(PmHUGE_VAL ,
+.Dv \*(PmHUGE_VALF ,
 or
-.Dv  \*(Pm\*HHUGE_VALL
+.Dv \*(PmHUGE_VALL
 with the same sign as
 .Fa x .
 When either



CVS commit: src/lib/libm/arch/i387

2019-04-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Apr 26 10:11:14 UTC 2019

Removed Files:
src/lib/libm/arch/i387: s_cos.S s_cosf.S s_ilogb.S s_ilogbf.S s_modf.S
s_sin.S s_sinf.S s_tan.S s_tanf.S

Log Message:
Remove unused 387 implementations.

These were removed from the build for being wrong, but the implementation
stayed around. This is confusing, we have the attic for old code,
let's delete the unused implementations.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r0 src/lib/libm/arch/i387/s_cos.S
cvs rdiff -u -r1.6 -r0 src/lib/libm/arch/i387/s_cosf.S \
src/lib/libm/arch/i387/s_ilogbf.S
cvs rdiff -u -r1.7 -r0 src/lib/libm/arch/i387/s_ilogb.S \
src/lib/libm/arch/i387/s_sin.S src/lib/libm/arch/i387/s_tan.S
cvs rdiff -u -r1.1 -r0 src/lib/libm/arch/i387/s_modf.S
cvs rdiff -u -r1.5 -r0 src/lib/libm/arch/i387/s_sinf.S \
src/lib/libm/arch/i387/s_tanf.S

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



CVS commit: src/lib/libm

2019-04-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Apr 17 07:45:23 UTC 2019

Modified Files:
src/lib/libm: Makefile

Log Message:
also want s_nexttoward.c on riscv.  now tests/lib/libm links.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/lib/libm/Makefile

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.207 src/lib/libm/Makefile:1.208
--- src/lib/libm/Makefile:1.207	Mon Apr 15 18:44:26 2019
+++ src/lib/libm/Makefile	Wed Apr 17 07:45:23 2019
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.207 2019/04/15 18:44:26 maya Exp $
+#  $NetBSD: Makefile,v 1.208 2019/04/17 07:45:23 mrg Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -176,7 +176,7 @@ WARNS?=5
 .elif (${LIBC_MACHINE_CPU} == "riscv")
 .PATH:	${.CURDIR}/arch/riscv
 
-COMMON_SRCS+= s_rintl.c
+COMMON_SRCS+= s_nexttoward.c s_rintl.c
 
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c



CVS commit: src/lib/libm

2019-04-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Apr 15 18:44:26 UTC 2019

Modified Files:
src/lib/libm: Makefile

Log Message:
we need rintl (long double) to link binaries


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/lib/libm/Makefile

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.206 src/lib/libm/Makefile:1.207
--- src/lib/libm/Makefile:1.206	Fri Feb 22 18:17:22 2019
+++ src/lib/libm/Makefile	Mon Apr 15 18:44:26 2019
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.206 2019/02/22 18:17:22 maya Exp $
+#  $NetBSD: Makefile,v 1.207 2019/04/15 18:44:26 maya Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -176,6 +176,8 @@ WARNS?=5
 .elif (${LIBC_MACHINE_CPU} == "riscv")
 .PATH:	${.CURDIR}/arch/riscv
 
+COMMON_SRCS+= s_rintl.c
+
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 ARCH_SRCS = e_sqrt.S e_sqrtf.S



CVS commit: src/lib/libm/arch/riscv

2019-04-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Apr 13 17:18:26 UTC 2019

Modified Files:
src/lib/libm/arch/riscv: s_copysign.S

Log Message:
Don't alias the long double version to the double version.
We now have 128bit long double (by the upstream GCC changing things)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/arch/riscv/s_copysign.S

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/arch/riscv/s_copysign.S
diff -u src/lib/libm/arch/riscv/s_copysign.S:1.4 src/lib/libm/arch/riscv/s_copysign.S:1.5
--- src/lib/libm/arch/riscv/s_copysign.S:1.4	Fri Mar 27 23:35:40 2015
+++ src/lib/libm/arch/riscv/s_copysign.S	Sat Apr 13 17:18:26 2019
@@ -1,12 +1,9 @@
-/* $NetBSD: s_copysign.S,v 1.4 2015/03/27 23:35:40 matt Exp $ */
+/* $NetBSD: s_copysign.S,v 1.5 2019/04/13 17:18:26 maya Exp $ */
 
 /* The contents of this file are in the public domain. */
 
 #include 
 
-STRONG_ALIAS(_copysignl, copysign)
-WEAK_ALIAS(copysignl, _copysignl)
-
 ENTRY(copysign)
 	fsgnj.d	fa0, fa0, fa1
 	ret



CVS commit: src/lib/libm

2019-02-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Feb 22 18:17:23 UTC 2019

Modified Files:
src/lib/libm: Makefile

Log Message:
Default our libm to -frounding-math, if built with GCC.

The long-standing GCC default is to not respect rounding mode.
it looks like GCC 7 optimizes rint to a builtin, causing our few
rounding mode tests to fail.

Fixes PR port-amd64/54000: FP tests failing on amd64 since gcc7 import


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/lib/libm/Makefile

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.205 src/lib/libm/Makefile:1.206
--- src/lib/libm/Makefile:1.205	Wed Nov  7 04:00:12 2018
+++ src/lib/libm/Makefile	Fri Feb 22 18:17:22 2019
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.205 2018/11/07 04:00:12 riastradh Exp $
+#  $NetBSD: Makefile,v 1.206 2019/02/22 18:17:22 maya Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -14,6 +14,7 @@
 #
 
 NOSANITIZER=		# defined
+COPTS+=			${${ACTIVE_CC} == "gcc":? -frounding-math :}
 
 #
 # There are two options in making libm at fdlibm compile time:



CVS commit: src/lib/libm/noieee_src

2019-02-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  4 03:30:20 UTC 2019

Modified Files:
src/lib/libm/noieee_src: n_lgamma.c

Log Message:
add some fallthru comments.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libm/noieee_src/n_lgamma.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/noieee_src/n_lgamma.c
diff -u src/lib/libm/noieee_src/n_lgamma.c:1.6 src/lib/libm/noieee_src/n_lgamma.c:1.7
--- src/lib/libm/noieee_src/n_lgamma.c:1.6	Fri Nov 24 21:15:54 2006
+++ src/lib/libm/noieee_src/n_lgamma.c	Mon Feb  4 03:30:20 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: n_lgamma.c,v 1.6 2006/11/24 21:15:54 wiz Exp $ */
+/*  $NetBSD: n_lgamma.c,v 1.7 2019/02/04 03:30:20 mrg Exp $ */
 /*-
  * Copyright (c) 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -221,15 +221,15 @@ CONTINUE:
 		t = .5*t*t;
 		z = 1.0;
 		switch (x_int) {
-		case 6:	z  = (y + 5);
-		case 5:	z *= (y + 4);
-		case 4:	z *= (y + 3);
+		case 6:	z  = (y + 5); /* FALLTHROUGH */
+		case 5:	z *= (y + 4); /* FALLTHROUGH */
+		case 4:	z *= (y + 3); /* FALLTHROUGH */
 		case 3:	z *= (y + 2);
 			rr = __log__D(z);
 			rr.b += a0_lo; rr.a += a0_hi;
 			return(((r+rr.b)+t+rr.a));
 		case 2: return(((r+a0_lo)+t)+a0_hi);
-		case 0: r -= log1p(x);
+		case 0: r -= log1p(x); /* FALLTHROUGH */
 		default: rr = __log__D(x);
 			rr.a -= a0_hi; rr.b -= a0_lo;
 			return(((r - rr.b) + t) - rr.a);
@@ -246,9 +246,9 @@ CONTINUE:
 		q = hi*t;
 		z = 1.0;
 		switch (x_int) {
-		case 6:	z  = (y + 5);
-		case 5:	z *= (y + 4);
-		case 4:	z *= (y + 3);
+		case 6:	z  = (y + 5); /* FALLTHROUGH */
+		case 5:	z *= (y + 4); /* FALLTHROUGH */
+		case 4:	z *= (y + 3); /* FALLTHROUGH */
 		case 3:	z *= (y + 2);
 			rr = __log__D(z);
 			r += rr.b; r += q;



CVS commit: src/lib/libm/noieee_src

2018-11-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov  9 10:19:47 UTC 2018

Modified Files:
src/lib/libm/noieee_src: n_fmod.c

Log Message:
Add modfl alias.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libm/noieee_src/n_fmod.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/noieee_src/n_fmod.c
diff -u src/lib/libm/noieee_src/n_fmod.c:1.10 src/lib/libm/noieee_src/n_fmod.c:1.11
--- src/lib/libm/noieee_src/n_fmod.c:1.10	Sat Jan 16 21:31:38 2016
+++ src/lib/libm/noieee_src/n_fmod.c	Fri Nov  9 10:19:47 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: n_fmod.c,v 1.10 2016/01/16 21:31:38 christos Exp $	*/
+/*	$NetBSD: n_fmod.c,v 1.11 2018/11/09 10:19:47 martin Exp $	*/
 /*
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -70,6 +70,7 @@ extern int isnan(),finite();
 	 && DBL_MIN_EXP == LDBL_MIN_EXP
 #ifdef __weak_alias
 __weak_alias(fmodl, fmod);
+__weak_alias(modfl, fmod);
 #endif
 #endif
 



CVS commit: src/lib/libm/src

2018-03-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar 27 11:59:49 UTC 2018

Modified Files:
src/lib/libm/src: s_scalbn.c

Log Message:
Add missing alias for ldexpl on ! __HAVE_LONG_DOUBLE architectures.
Pointed out by Hal Murray on port-arm.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libm/src/s_scalbn.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/src/s_scalbn.c
diff -u src/lib/libm/src/s_scalbn.c:1.18 src/lib/libm/src/s_scalbn.c:1.19
--- src/lib/libm/src/s_scalbn.c:1.18	Mon May 20 19:40:09 2013
+++ src/lib/libm/src/s_scalbn.c	Tue Mar 27 11:59:49 2018
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_scalbn.c,v 1.18 2013/05/20 19:40:09 joerg Exp $");
+__RCSID("$NetBSD: s_scalbn.c,v 1.19 2018/03/27 11:59:49 martin Exp $");
 #endif
 
 /*
@@ -35,6 +35,7 @@ __strong_alias(_scalbnl, _scalbn)
 __strong_alias(_scalblnl, _scalbln)
 __weak_alias(scalbnl, _scalbnl)
 __weak_alias(scalblnl, _scalblnl)
+__weak_alias(ldexpl, _scalblnl)
 #endif
 
 #ifdef __weak_alias



CVS commit: src/lib/libm/src

2018-03-10 Thread Eitan Adler
Module Name:src
Committed By:   eadler
Date:   Sat Mar 10 09:44:47 UTC 2018

Modified Files:
src/lib/libm/src: e_atan2.c

Log Message:
Fix signed overflow in atan2

As a component of atan2(y, x), the case of x == 1.0 is farmed out to
atan(y). The current implementation of this comparison is vulnerable
to signed integer underflow (that is, undefined behavior), and it's
performed in a somewhat more complicated way than it need be. Change
it to not be quite so cute, rather directly comparing the high/low
bits of x to the specific IEEE-754 bit pattern that encodes 1.0.

ok martin@ pgoyette@ maya@
obtained from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libm/src/e_atan2.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/src/e_atan2.c
diff -u src/lib/libm/src/e_atan2.c:1.12 src/lib/libm/src/e_atan2.c:1.13
--- src/lib/libm/src/e_atan2.c:1.12	Sun May 26 22:01:48 2002
+++ src/lib/libm/src/e_atan2.c	Sat Mar 10 09:44:47 2018
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_atan2.c,v 1.12 2002/05/26 22:01:48 wiz Exp $");
+__RCSID("$NetBSD: e_atan2.c,v 1.13 2018/03/10 09:44:47 eadler Exp $");
 #endif
 
 /* __ieee754_atan2(y,x)
@@ -67,7 +67,7 @@ __ieee754_atan2(double y, double x)
 	if(((ix|((lx|-lx)>>31))>0x7ff0)||
 	   ((iy|((ly|-ly)>>31))>0x7ff0))	/* x or y is NaN */
 	   return x+y;
-	if(((hx-0x3ff0)|lx)==0) return atan(y);   /* x=1.0 */
+	if(hx==0x3ff0&&lx==0) return atan(y);   /* x=1.0 */
 	m = ((hy>>31)&1)|((hx>>30)&2);	/* 2*sign(x)+sign(y) */
 
 /* when y = 0 */



CVS commit: src/lib/libm/noieee_src

2018-03-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar  6 01:14:41 UTC 2018

Modified Files:
src/lib/libm/noieee_src: n_exp2.c

Log Message:
avoid negative shift


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/noieee_src/n_exp2.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/noieee_src/n_exp2.c
diff -u src/lib/libm/noieee_src/n_exp2.c:1.3 src/lib/libm/noieee_src/n_exp2.c:1.4
--- src/lib/libm/noieee_src/n_exp2.c:1.3	Sun Mar 23 11:26:47 2014
+++ src/lib/libm/noieee_src/n_exp2.c	Mon Mar  5 20:14:41 2018
@@ -25,7 +25,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: n_exp2.c,v 1.3 2014/03/23 15:26:47 martin Exp $");
+__RCSID("$NetBSD: n_exp2.c,v 1.4 2018/03/06 01:14:41 christos Exp $");
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: src/lib/msun/src/s_exp2.c,v 1.7 2008/02/22 02:27:34 das Exp $");
 #endif
@@ -372,7 +372,8 @@ exp2(double x)
 	/* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
 	t = tbl[i0];		/* exp2t[i0] */
 	z -= tbl[i0 + 1];	/* eps[i0]   */
-	big = k >= -1021 << 20;
+	/* -1021 << 20 == 3075 << 20 */
+	big = k >= 3075 << 20;
 	if (big) {
 		temp = 0x3ff0+k;
 		twopk = 0.0;



CVS commit: src/lib/libm/noieee_src

2018-03-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  5 23:00:55 UTC 2018

Modified Files:
src/lib/libm/noieee_src: n_jn.c

Log Message:
comment out unused variable.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libm/noieee_src/n_jn.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/noieee_src/n_jn.c
diff -u src/lib/libm/noieee_src/n_jn.c:1.7 src/lib/libm/noieee_src/n_jn.c:1.8
--- src/lib/libm/noieee_src/n_jn.c:1.7	Tue Nov  1 22:34:56 2011
+++ src/lib/libm/noieee_src/n_jn.c	Mon Mar  5 18:00:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: n_jn.c,v 1.7 2011/11/02 02:34:56 christos Exp $	*/
+/*	$NetBSD: n_jn.c,v 1.8 2018/03/05 23:00:55 christos Exp $	*/
 /*-
  * Copyright (c) 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -102,7 +102,9 @@ static char sccsid[] = "@(#)jn.c	8.2 (Be
 #endif
 
 static const double
+#if _IEEE
 invsqrtpi= 5.641895835477562869480794515607725858441e-0001,
+#endif
 two  = 2.0,
 zero = 0.0,
 one  = 1.0;



CVS commit: src/lib/libm/arch/i387

2018-01-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 25 03:54:21 UTC 2018

Modified Files:
src/lib/libm/arch/i387: fenv.c

Log Message:
use named initializers


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/arch/i387/fenv.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/arch/i387/fenv.c
diff -u src/lib/libm/arch/i387/fenv.c:1.8 src/lib/libm/arch/i387/fenv.c:1.9
--- src/lib/libm/arch/i387/fenv.c:1.8	Wed Mar 22 19:11:08 2017
+++ src/lib/libm/arch/i387/fenv.c	Wed Jan 24 22:54:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.8 2017/03/22 23:11:08 chs Exp $ */
+/* $NetBSD: fenv.c,v 1.9 2018/01/25 03:54:21 christos Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.8 2017/03/22 23:11:08 chs Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.9 2018/01/25 03:54:21 christos Exp $");
 
 #include "namespace.h"
 
@@ -106,19 +106,18 @@ __weak_alias(feupdateenv,_feupdateenv)
  * consumers of FE_DFL_ENV, during runtime.
  */
 fenv_t __fe_dfl_env = {
-	{
-		__NetBSD_NPXCW__,   /* Control word register */
-		0x0,			/* Unused */
-		0x, /* Status word register */
-		0x0,			/* Unused */
-		0x, /* Tag word register */
-		0x0,			/* Unused */
-		{
-			0x, 0x,
-			0x, 0x
+	.x87 = {
+		.control = __NetBSD_NPXCW__,/* Control word register */
+		.unused1 = 0,			/* Unused */
+		.status = 0,  		 	/* Status word register */
+		.unused2 = 0,			/* Unused */
+		.tag = 0x,  	/* Tag word register */
+		.unused3 = 0,			/* Unused */
+		.others = {
+			0, 0, 0, 0x,
 		}
 	},
-	__INITIAL_MXCSR__		/* MXCSR register */
+	.mxcsr = __INITIAL_MXCSR__		/* MXCSR register */
 };
 
 /*



CVS commit: src/lib/libm/arch/alpha

2017-12-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 30 17:59:25 UTC 2017

Modified Files:
src/lib/libm/arch/alpha: fenv.c

Log Message:
Fix usage of sysarch(ALPHA_FPGETMASK)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/arch/alpha/fenv.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/arch/alpha/fenv.c
diff -u src/lib/libm/arch/alpha/fenv.c:1.2 src/lib/libm/arch/alpha/fenv.c:1.3
--- src/lib/libm/arch/alpha/fenv.c:1.2	Wed Mar 22 23:11:08 2017
+++ src/lib/libm/arch/alpha/fenv.c	Sat Dec 30 17:59:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fenv.c,v 1.2 2017/03/22 23:11:08 chs Exp $	*/
+/*	$NetBSD: fenv.c,v 1.3 2017/12/30 17:59:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2004-2005 David Schultz 
@@ -28,7 +28,7 @@
  * $FreeBSD: src/lib/msun/alpha/fenv.c,v 1.2 2005/03/16 19:03:44 das Exp $
  */
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.2 2017/03/22 23:11:08 chs Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.3 2017/12/30 17:59:24 martin Exp $");
 
 #include "namespace.h"
 
@@ -63,7 +63,7 @@ fegetenv(fenv_t *envp)
 	 * only need to issue an excb after the mf_fpcr to ensure that
 	 * the read is executed before any subsequent FP ops.
 	 */
-	sysarch(ALPHA_FPGETMASK, (char *)&p);
+	p.mask = sysarch(ALPHA_FPGETMASK, 0);
 	__mf_fpcr(&r.__d);
 	*envp = r.__bits | p.mask;
 	__excb();
@@ -76,7 +76,7 @@ feholdexcept(fenv_t *envp)
 	struct alpha_fp_except_args p;
 	union __fpcr r;
 
-	sysarch(ALPHA_FPGETMASK, (char *)&p);
+	p.mask = sysarch(ALPHA_FPGETMASK, 0);
 	__mf_fpcr(&r.__d);
 	*envp = r.__bits | p.mask;
 	r.__bits &= ~((fenv_t)FE_ALL_EXCEPT << _FPUSW_SHIFT);
@@ -124,7 +124,7 @@ feenableexcept(int mask)
 {
 	struct alpha_fp_except_args p;
 
-	sysarch(ALPHA_FPGETMASK, &p);
+	p.mask = sysarch(ALPHA_FPGETMASK, 0);
 	p.mask |= (mask & FE_ALL_EXCEPT);
 	sysarch(ALPHA_FPSETMASK, &p);
 	return p.mask;
@@ -135,7 +135,7 @@ fedisableexcept(int mask)
 {
 	struct alpha_fp_except_args p;
 
-	sysarch(ALPHA_FPGETMASK, &p);
+	p.mask = sysarch(ALPHA_FPGETMASK, 0);
 	p.mask &= ~(mask & FE_ALL_EXCEPT);
 	sysarch(ALPHA_FPSETMASK, &p);
 	return p.mask;
@@ -144,8 +144,6 @@ fedisableexcept(int mask)
 int
 fegetexcept(void)
 {
-	struct alpha_fp_except_args p;
 
-	sysarch(ALPHA_FPGETMASK, &p);
-	return p.mask;
+	return sysarch(ALPHA_FPGETMASK, 0);
 }



CVS commit: src/lib/libm/man

2017-09-28 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Sep 28 15:03:18 UTC 2017

Modified Files:
src/lib/libm/man: copysign.3

Log Message:
Restore CAVEATS section unmodified.

It apparently refers to VAX and its lack of a negative zero.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/man/copysign.3

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/man/copysign.3
diff -u src/lib/libm/man/copysign.3:1.3 src/lib/libm/man/copysign.3:1.4
--- src/lib/libm/man/copysign.3:1.3	Thu Sep 28 11:09:05 2017
+++ src/lib/libm/man/copysign.3	Thu Sep 28 15:03:18 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: copysign.3,v 1.3 2017/09/28 11:09:05 maya Exp $
+.\" $NetBSD: copysign.3,v 1.4 2017/09/28 15:03:18 maya Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -87,3 +87,7 @@ The described functions conform to
 .\"
 .\" These functions first appeared in ???.
 .\"
+.Sh CAVEATS
+Note that on implementations that represent a signed zero
+but do not treat negative zero consistently in arithmetic operations,
+these functions may regard the sign of zero as positive.



CVS commit: src/lib/libm/man

2017-09-28 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Sep 28 11:18:41 UTC 2017

Modified Files:
src/lib/libm/man: math.3

Log Message:
List a few more functions


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libm/man/math.3

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/man/math.3
diff -u src/lib/libm/man/math.3:1.27 src/lib/libm/man/math.3:1.28
--- src/lib/libm/man/math.3:1.27	Mon Jul  3 21:32:50 2017
+++ src/lib/libm/man/math.3	Thu Sep 28 11:18:41 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: math.3,v 1.27 2017/07/03 21:32:50 wiz Exp $
+.\"	$NetBSD: math.3,v 1.28 2017/09/28 11:18:41 maya Exp $
 .\"
 .\" Copyright (c) 1985 Regents of the University of California.
 .\" All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)math.3	6.10 (Berkeley) 5/6/91
 .\"
-.Dd February 23, 2007
+.Dd September 28, 2017
 .Dt MATH 3
 .Os
 .Sh NAME
@@ -62,11 +62,16 @@ Declarations for these functions may be 
 .It cosh Ta Xr cosh 3 Ta hyperbolic function Ta 3
 .It erf Ta Xr erf 3 Ta error function Ta ???
 .It erfc Ta Xr erf 3 Ta complementary error function Ta ???
-.It exp Ta Xr exp 3 Ta exponential Ta 1
-.It expm1 Ta Xr exp 3 Ta exp(x)\-1 Ta 1
+.It exp Ta Xr exp 3 Ta base e exponential Ta 1
+.It exp2 Ta Xr exp2 3 Ta base 2 exponential Ta ???
+.It expm1 Ta Xr expm1 3 Ta exp(x)\-1 Ta 1
 .It fabs Ta Xr fabs 3 Ta absolute value Ta 0
+.It fdim Ta Xr erf 3 Ta positive difference Ta ???
 .It finite Ta Xr finite 3 Ta test for finity Ta 0
 .It floor Ta Xr floor 3 Ta integer no greater than Ta 0
+.It fma Ta Xr fmod 3 Ta fused multiply-add Ta ???
+.It fmax Ta Xr fmax 3 Ta maximum Ta 0
+.It fmin Ta Xr fmin 3 Ta minimum Ta 0
 .It fmod Ta Xr fmod 3 Ta remainder Ta ???
 .It hypot Ta Xr hypot 3 Ta Euclidean distance Ta 1
 .It ilogb Ta Xr ilogb 3 Ta exponent extraction Ta 0



CVS commit: src/lib/libm/man

2017-09-28 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Sep 28 11:09:05 UTC 2017

Modified Files:
src/lib/libm/man: copysign.3

Log Message:
Remove CAVEATS section

The man page for an individual function is not the right place to discuss
the issues with negative zero


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/man/copysign.3

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/man/copysign.3
diff -u src/lib/libm/man/copysign.3:1.2 src/lib/libm/man/copysign.3:1.3
--- src/lib/libm/man/copysign.3:1.2	Tue Sep 26 15:12:57 2017
+++ src/lib/libm/man/copysign.3	Thu Sep 28 11:09:05 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: copysign.3,v 1.2 2017/09/26 15:12:57 maya Exp $
+.\" $NetBSD: copysign.3,v 1.3 2017/09/28 11:09:05 maya Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 26, 2017
+.Dd September 28, 2017
 .Dt COPYSIGN 3
 .Os
 .Sh NAME
@@ -87,7 +87,3 @@ The described functions conform to
 .\"
 .\" These functions first appeared in ???.
 .\"
-.Sh CAVEATS
-Note that on implementations that represent a signed zero
-but do not treat negative zero consistently in arithmetic operations,
-these functions may regard the sign of zero as positive.



CVS commit: src/lib/libm/man

2017-09-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Sep 28 05:51:26 UTC 2017

Modified Files:
src/lib/libm/man: hypot.3

Log Message:
Remove Tn.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libm/man/hypot.3

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/man/hypot.3
diff -u src/lib/libm/man/hypot.3:1.18 src/lib/libm/man/hypot.3:1.19
--- src/lib/libm/man/hypot.3:1.18	Tue Sep 26 15:42:54 2017
+++ src/lib/libm/man/hypot.3	Thu Sep 28 05:51:26 2017
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)hypot.3	6.7 (Berkeley) 5/6/91
-.\"	$NetBSD: hypot.3,v 1.18 2017/09/26 15:42:54 maya Exp $
+.\"	$NetBSD: hypot.3,v 1.19 2017/09/28 05:51:26 wiz Exp $
 .\"
 .Dd September 26, 2017
 .Dt HYPOT 3
@@ -87,10 +87,8 @@ are \*(Na for all
 .Em finite
 .Ar v ;
 with "reserved operand" in place of "\*(Na", the
-same is true on a
-.Tn VAX .
-But programmers on machines other than a
-.Tn VAX
+same is true on a VAX.
+But programmers on machines other than a VAX
 (it has no \*(If)
 might be surprised at first to discover that
 .Fn hypot "\(+-\*(If" "\*(Na"
@@ -106,10 +104,7 @@ Hence
 .Fn hypot "\*(If" "v"
 is independent of
 .Ar v .
-Unlike the reserved operand fault on a
-.Tn VAX ,
-the
-.Tn IEEE
+Unlike the reserved operand fault on a VAX, the IEEE
 \*(Na is designed to
 disappear when it turns out to be irrelevant, as it does in
 .Fn hypot "\*(If" "\*(Na" .



CVS commit: src/lib/libm/man

2017-09-27 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Sep 27 10:12:47 UTC 2017

Modified Files:
src/lib/libm/man: fma.3

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/man/fma.3

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/man/fma.3
diff -u src/lib/libm/man/fma.3:1.2 src/lib/libm/man/fma.3:1.3
--- src/lib/libm/man/fma.3:1.2	Sat Dec 12 23:55:42 2015
+++ src/lib/libm/man/fma.3	Wed Sep 27 10:12:47 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: fma.3,v 1.2 2015/12/12 23:55:42 wiz Exp $
+.\" $NetBSD: fma.3,v 1.3 2017/09/27 10:12:47 maya Exp $
 .\" Copyright (c) 2005 David Schultz 
 .\" All rights reserved.
 .\"
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD: head/lib/msun/man/fma.3 152755 2005-11-24 09:25:10Z joel $
 .\"
-.Dd November 23, 2015
+.Dd September 27, 2017
 .Dt FMA 3
 .Os
 .Sh NAME
@@ -120,7 +120,7 @@ The
 .Fn fmaf
 and
 .Fn fmal
-routines where imported into
+routines were imported into
 .Nx
 in
 .Nx 7.0 .



CVS commit: src/lib/libm/complex

2017-09-27 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Sep 27 09:20:27 UTC 2017

Modified Files:
src/lib/libm/complex: cabs.3 cproj.3 creal.3

Log Message:
Mention tgmath cproj, creal, cabs

following copysign example use of "real-floating" with "complex-floating"


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/complex/cabs.3
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/complex/cproj.3 \
src/lib/libm/complex/creal.3

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/complex/cabs.3
diff -u src/lib/libm/complex/cabs.3:1.3 src/lib/libm/complex/cabs.3:1.4
--- src/lib/libm/complex/cabs.3:1.3	Tue Jan 29 02:05:08 2013
+++ src/lib/libm/complex/cabs.3	Wed Sep 27 09:20:27 2017
@@ -1,6 +1,6 @@
-.\" $NetBSD: cabs.3,v 1.3 2013/01/29 02:05:08 matt Exp $
+.\" $NetBSD: cabs.3,v 1.4 2017/09/27 09:20:27 maya Exp $
 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
-.Dd January 29, 2013
+.Dd September 27, 2017
 .Dt CABS 3
 .Os
 .Sh NAME
@@ -16,6 +16,9 @@
 .Fn cabsf "float complex z"
 .Ft long double
 .Fn cabsl "long double complex z"
+.In tgmath.h
+.Ft complex-floating
+.Fn cabs "complex-floating z"
 .Sh DESCRIPTION
 These functions compute the complex absolute value (also called
 norm, modulus, or magnitude) of

Index: src/lib/libm/complex/cproj.3
diff -u src/lib/libm/complex/cproj.3:1.4 src/lib/libm/complex/cproj.3:1.5
--- src/lib/libm/complex/cproj.3:1.4	Thu Dec 27 21:34:10 2012
+++ src/lib/libm/complex/cproj.3	Wed Sep 27 09:20:27 2017
@@ -1,6 +1,6 @@
-.\" $NetBSD: cproj.3,v 1.4 2012/12/27 21:34:10 wiz Exp $
+.\" $NetBSD: cproj.3,v 1.5 2017/09/27 09:20:27 maya Exp $
 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
-.Dd December 27, 2012
+.Dd September 27, 2017
 .Dt CPROJ 3
 .Os
 .Sh NAME
@@ -16,6 +16,9 @@
 .Fn cprojf "float complex z"
 .Ft long double
 .Fn cprojl "long double complex z"
+.In tgmath.h
+.Ft complex-floating
+.Fn cproj "complex-floating z"
 .Sh DESCRIPTION
 These functions compute a projection of
 .Ar z
Index: src/lib/libm/complex/creal.3
diff -u src/lib/libm/complex/creal.3:1.4 src/lib/libm/complex/creal.3:1.5
--- src/lib/libm/complex/creal.3:1.4	Thu Dec 27 21:34:10 2012
+++ src/lib/libm/complex/creal.3	Wed Sep 27 09:20:27 2017
@@ -1,6 +1,6 @@
-.\" $NetBSD: creal.3,v 1.4 2012/12/27 21:34:10 wiz Exp $
+.\" $NetBSD: creal.3,v 1.5 2017/09/27 09:20:27 maya Exp $
 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
-.Dd December 27, 2012
+.Dd September 27, 2017
 .Dt CREAL 3
 .Os
 .Sh NAME
@@ -16,6 +16,9 @@
 .Fn crealf "float complex z"
 .Ft long double
 .Fn creall "long double complex z"
+.In tgmath.h
+.Ft complex-float
+.Fn creal "complex-float z"
 .Sh DESCRIPTION
 These functions compute the real part of
 .Ar z .



CVS commit: src/lib/libm

2017-09-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Sep 26 18:03:30 UTC 2017

Modified Files:
src/lib/libm: shlib_version

Log Message:
Mention wanting to remove isnanf too, reword


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libm/shlib_version

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/shlib_version
diff -u src/lib/libm/shlib_version:1.16 src/lib/libm/shlib_version:1.17
--- src/lib/libm/shlib_version:1.16	Sat May 13 13:17:11 2017
+++ src/lib/libm/shlib_version	Tue Sep 26 18:03:30 2017
@@ -1,8 +1,8 @@
-#	$NetBSD: shlib_version,v 1.16 2017/05/13 13:17:11 maya Exp $
+#	$NetBSD: shlib_version,v 1.17 2017/09/26 18:03:30 maya Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 # things we wish to do on next major version bump:
 # - remove compatibility cabs
-# - hide isinff
+# - not provide isinff / isnanf (only provide __isinff version)
 major=0
 minor=12



CVS commit: src/lib/libm/man

2017-09-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Sep 26 15:42:54 UTC 2017

Modified Files:
src/lib/libm/man: hypot.3

Log Message:
omit mention of cabs (not relevant to this man page)
mention type-generic hypot
mention hypotl


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libm/man/hypot.3

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/man/hypot.3
diff -u src/lib/libm/man/hypot.3:1.17 src/lib/libm/man/hypot.3:1.18
--- src/lib/libm/man/hypot.3:1.17	Thu Feb 22 22:08:20 2007
+++ src/lib/libm/man/hypot.3	Tue Sep 26 15:42:54 2017
@@ -26,14 +26,15 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)hypot.3	6.7 (Berkeley) 5/6/91
-.\"	$NetBSD: hypot.3,v 1.17 2007/02/22 22:08:20 drochner Exp $
+.\"	$NetBSD: hypot.3,v 1.18 2017/09/26 15:42:54 maya Exp $
 .\"
-.Dd February 12, 2007
+.Dd September 26, 2017
 .Dt HYPOT 3
 .Os
 .Sh NAME
 .Nm hypot ,
-.Nm hypotf
+.Nm hypotf ,
+.Nm hypotl
 .Nd Euclidean distance and complex absolute value functions
 .Sh LIBRARY
 .Lb libm
@@ -43,6 +44,11 @@
 .Fn hypot "double x" "double y"
 .Ft float
 .Fn hypotf "float x" "float y"
+.Ft long double
+.Fn hypotl "long double x" "long double y"
+.In tgmath.h
+.Ft real-floating
+.Fn hypot "real-floating" "real-floating"
 .Sh DESCRIPTION
 The
 .Fn hypot
@@ -111,14 +117,7 @@ disappear when it turns out to be irrele
 .Xr math 3 ,
 .Xr sqrt 3
 .Sh HISTORY
-Both a
+The
 .Fn hypot
-function and a
-.Fn cabs
-function
 appeared in
 .At v7 .
-.Fn cabs
-was removed from public namespace in
-.Nx 5.0
-to avoid conflicts with the complex function in C99.



CVS commit: src/lib/libm/man

2017-09-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Sep 26 15:12:57 UTC 2017

Modified Files:
src/lib/libm/man: copysign.3

Log Message:
Mention there's a type generic variant in tgmath.h

(XXX and in math.h, if you're netbsd)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/man/copysign.3

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/man/copysign.3
diff -u src/lib/libm/man/copysign.3:1.1 src/lib/libm/man/copysign.3:1.2
--- src/lib/libm/man/copysign.3:1.1	Wed Apr 13 04:57:10 2011
+++ src/lib/libm/man/copysign.3	Tue Sep 26 15:12:57 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: copysign.3,v 1.1 2011/04/13 04:57:10 jruoho Exp $
+.\" $NetBSD: copysign.3,v 1.2 2017/09/26 15:12:57 maya Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 13, 2011
+.Dd September 26, 2017
 .Dt COPYSIGN 3
 .Os
 .Sh NAME
@@ -42,6 +42,9 @@
 .Fn copysignf "float x" "float y"
 .Ft long double
 .Fn copysignl "long double x" "long double y"
+.In tgmath.h
+.Ft real-floating
+.Fn copysign "real-floating x" "real-floating y"
 .Sh DESCRIPTION
 The
 .Fn copysign ,



CVS commit: src/lib/libm

2017-08-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 21 17:10:34 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
add nexttoward for mips64 and aarch64


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/lib/libm/Makefile

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.201 src/lib/libm/Makefile:1.202
--- src/lib/libm/Makefile:1.201	Thu Aug 17 09:58:39 2017
+++ src/lib/libm/Makefile	Mon Aug 21 13:10:34 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.201 2017/08/17 13:58:39 he Exp $
+#  $NetBSD: Makefile,v 1.202 2017/08/21 17:10:34 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -60,7 +60,7 @@ ARCH_SRCS+= s_fma.S s_fmaf.S s_fmax.S s_
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS+= fenv.c
 .endif
-COMMON_SRCS+= s_rintl.c
+COMMON_SRCS+= s_nexttoward.c s_rintl.c
 COMMON_SRCS+= e_sqrtl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 
@@ -195,6 +195,10 @@ COMMON_SRCS += fenv.c
 COMMON_SRCS += fenv.c
 .endif
 COMMON_SRCS+= s_rintl.c
+.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") \
+&& (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
+COMMON_SRCS+= s_nexttoward.c
+.endif
 
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3



CVS commit: src/lib/libm

2017-08-17 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Thu Aug 17 13:58:40 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
Actually... s_nexttowardf.c appears to be usable on soft-float as well;
it was for arm earlier and briefly for all mips, so just move it into
COMMON_SRCS.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/lib/libm/Makefile

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.200 src/lib/libm/Makefile:1.201
--- src/lib/libm/Makefile:1.200	Thu Aug 17 09:06:21 2017
+++ src/lib/libm/Makefile	Thu Aug 17 13:58:39 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.200 2017/08/17 09:06:21 he Exp $
+#  $NetBSD: Makefile,v 1.201 2017/08/17 13:58:39 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -242,10 +242,6 @@ COMMON_SRCS += \
 	feupdateenv.c
 .endif
 
-.if (${MKSOFTFLOAT} == "no")
-COMMON_SRCS+= s_nexttowardf.c
-.endif
-
 LIB=	m
 COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c \
 	e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
@@ -273,7 +269,7 @@ COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c
 	s_lround.c s_lroundf.c s_lroundl.c \
 	s_log1pf.c s_logb.c s_logbf.c s_logbl.c \
 	s_matherr.c s_modff.c s_modfl.c s_nearbyint.c s_nextafter.c s_nextafterl.c \
-	s_nextafterf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c \
+	s_nextafterf.c s_nexttowardf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c \
 	s_round.c s_roundf.c s_roundl.c s_scalbn.c \
 	s_scalbnf.c s_scalbnl.c s_signgam.c s_significand.c s_significandf.c s_sin.c \
 	s_sinf.c s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_tgammaf.c \



CVS commit: src/lib/libm

2017-08-17 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Thu Aug 17 09:06:21 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
Move the inclusion of s_nexttowardf.c into a common test for
MKSOFTFLOAT=="no".  This brings us nexttowardf() for sparc, at least.


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/lib/libm/Makefile

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.199 src/lib/libm/Makefile:1.200
--- src/lib/libm/Makefile:1.199	Wed Aug 16 13:34:59 2017
+++ src/lib/libm/Makefile	Thu Aug 17 09:06:21 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.199 2017/08/16 13:34:59 nisimura Exp $
+#  $NetBSD: Makefile,v 1.200 2017/08/17 09:06:21 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -75,7 +75,7 @@ COPTS+=	-mfloat-ieee -mieee-with-inexact
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS+= fenv.c
 .endif
-COMMON_SRCS+= s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= s_rintl.c
 .for f in fenv.c lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
 COPTS.$f +=	-mfpu=vfp
 .endfor
@@ -91,7 +91,7 @@ COMMON_SRCS += fenv.c
 
 .elif (${LIBC_MACHINE_ARCH} == "hppa")
 .PATH.c: ${.CURDIR}/arch/hppa
-COMMON_SRCS+= fenv.c s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= fenv.c s_rintl.c
 
 .elif (${LIBC_MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
@@ -101,7 +101,7 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${LIBC_MACHINE_ARCH} == "sparc64")
 .PATH: ${.CURDIR}/arch/sparc64
 COMMON_SRCS+= fenv.c
-COMMON_SRCS+= s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= s_rintl.c
 .ifndef _COMPAT_M32_MK_
 COMMON_SRCS+= s_nexttoward.c
 .endif
@@ -115,7 +115,7 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .endif
 .PATH:	${.CURDIR}/arch/i387
 
-COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= fenv.c s_nexttoward.c s_rintl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 
 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
@@ -154,7 +154,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 	e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
 	s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
 	s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-COMMON_SRCS += fenv.c s_nexttoward.c s_nexttowardf.c s_rintl.c
+COMMON_SRCS += fenv.c s_nexttoward.c s_rintl.c
 .endif
 .endif
 # end of m68k
@@ -194,7 +194,7 @@ COMMON_SRCS += fenv.c
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
-COMMON_SRCS+= s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= s_rintl.c
 
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3
@@ -242,6 +242,10 @@ COMMON_SRCS += \
 	feupdateenv.c
 .endif
 
+.if (${MKSOFTFLOAT} == "no")
+COMMON_SRCS+= s_nexttowardf.c
+.endif
+
 LIB=	m
 COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c \
 	e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \



CVS commit: src/lib/libm

2017-08-16 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Aug 16 13:34:59 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
add s_rintl.c for aarch64. ok by ryo@.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/lib/libm/Makefile

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.198 src/lib/libm/Makefile:1.199
--- src/lib/libm/Makefile:1.198	Wed Aug 16 09:18:24 2017
+++ src/lib/libm/Makefile	Wed Aug 16 13:34:59 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.198 2017/08/16 09:18:24 he Exp $
+#  $NetBSD: Makefile,v 1.199 2017/08/16 13:34:59 nisimura Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -60,6 +60,7 @@ ARCH_SRCS+= s_fma.S s_fmaf.S s_fmax.S s_
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS+= fenv.c
 .endif
+COMMON_SRCS+= s_rintl.c
 COMMON_SRCS+= e_sqrtl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 



CVS commit: src/lib/libm/src

2017-08-16 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Aug 16 11:22:52 UTC 2017

Modified Files:
src/lib/libm/src: s_nextafter.c

Log Message:
On second thought, don't introduce nexttowardl() since we don't have that
yet elsewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libm/src/s_nextafter.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/src/s_nextafter.c
diff -u src/lib/libm/src/s_nextafter.c:1.15 src/lib/libm/src/s_nextafter.c:1.16
--- src/lib/libm/src/s_nextafter.c:1.15	Wed Aug 16 09:15:48 2017
+++ src/lib/libm/src/s_nextafter.c	Wed Aug 16 11:22:52 2017
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_nextafter.c,v 1.15 2017/08/16 09:15:48 he Exp $");
+__RCSID("$NetBSD: s_nextafter.c,v 1.16 2017/08/16 11:22:52 he Exp $");
 #endif
 
 /* IEEE functions
@@ -28,7 +28,6 @@ __RCSID("$NetBSD: s_nextafter.c,v 1.15 2
 #ifndef __HAVE_LONG_DOUBLE
 __strong_alias(nextafterl, nextafter)
 __strong_alias(nexttoward, nextafter)
-__strong_alias(nexttowardl, nextafter)
 #endif
 
 double



CVS commit: src/lib/libm

2017-08-16 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Aug 16 09:18:24 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
In the non-softfloat m68k part, add s_nexttoward.c and s_nexttowardf.c,
so that we get nexttoward() and nexttowardf() implemented here as well.


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/lib/libm/Makefile

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.197 src/lib/libm/Makefile:1.198
--- src/lib/libm/Makefile:1.197	Tue Aug 15 10:40:28 2017
+++ src/lib/libm/Makefile	Wed Aug 16 09:18:24 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.197 2017/08/15 10:40:28 mlelstv Exp $
+#  $NetBSD: Makefile,v 1.198 2017/08/16 09:18:24 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -153,7 +153,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 	e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
 	s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
 	s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-COMMON_SRCS += fenv.c s_rintl.c
+COMMON_SRCS += fenv.c s_nexttoward.c s_nexttowardf.c s_rintl.c
 .endif
 .endif
 # end of m68k



CVS commit: src/lib/libm/src

2017-08-16 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Aug 16 09:15:49 UTC 2017

Modified Files:
src/lib/libm/src: s_nextafter.c

Log Message:
On systems without __HAVE_LONG_DOUBLE, also alias nexttoward() and
nexttowardl() to nextafter().


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libm/src/s_nextafter.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/src/s_nextafter.c
diff -u src/lib/libm/src/s_nextafter.c:1.14 src/lib/libm/src/s_nextafter.c:1.15
--- src/lib/libm/src/s_nextafter.c:1.14	Tue Mar 18 18:20:37 2014
+++ src/lib/libm/src/s_nextafter.c	Wed Aug 16 09:15:48 2017
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_nextafter.c,v 1.14 2014/03/18 18:20:37 riastradh Exp $");
+__RCSID("$NetBSD: s_nextafter.c,v 1.15 2017/08/16 09:15:48 he Exp $");
 #endif
 
 /* IEEE functions
@@ -27,6 +27,8 @@ __RCSID("$NetBSD: s_nextafter.c,v 1.14 2
 
 #ifndef __HAVE_LONG_DOUBLE
 __strong_alias(nextafterl, nextafter)
+__strong_alias(nexttoward, nextafter)
+__strong_alias(nexttowardl, nextafter)
 #endif
 
 double



CVS commit: src/lib/libm

2017-08-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Aug 15 10:40:28 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
rintl is required for archs that support long double.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/lib/libm/Makefile

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.196 src/lib/libm/Makefile:1.197
--- src/lib/libm/Makefile:1.196	Fri Aug 11 20:24:56 2017
+++ src/lib/libm/Makefile	Tue Aug 15 10:40:28 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.196 2017/08/11 20:24:56 he Exp $
+#  $NetBSD: Makefile,v 1.197 2017/08/15 10:40:28 mlelstv Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -193,6 +193,7 @@ COMMON_SRCS += fenv.c
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
+COMMON_SRCS+= s_nexttowardf.c s_rintl.c
 
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3



CVS commit: src/lib/libm

2017-08-11 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Fri Aug 11 20:24:56 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
Move s_nearbyint.c out of the cpu ifdefs and into COMMON_SRCS,
which is used everywhere except on vax.  This is to simplify and
to ensure the function is included in the build, allowing us to
re-add the nearbyint() test.


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/lib/libm/Makefile

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.195 src/lib/libm/Makefile:1.196
--- src/lib/libm/Makefile:1.195	Thu Jul 27 10:03:10 2017
+++ src/lib/libm/Makefile	Fri Aug 11 20:24:56 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.195 2017/07/27 10:03:10 he Exp $
+#  $NetBSD: Makefile,v 1.196 2017/08/11 20:24:56 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -66,7 +66,7 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${LIBC_MACHINE_ARCH} == "alpha")
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
-COMMON_SRCS+= fenv.c s_nearbyint.c
+COMMON_SRCS+= fenv.c
 COPTS+=	-mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
 
 .elif (${LIBC_MACHINE_CPU} == "arm")
@@ -74,7 +74,7 @@ COPTS+=	-mfloat-ieee -mieee-with-inexact
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS+= fenv.c
 .endif
-COMMON_SRCS+= s_nexttowardf.c s_nearbyint.c s_rintl.c
+COMMON_SRCS+= s_nexttowardf.c s_rintl.c
 .for f in fenv.c lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
 COPTS.$f +=	-mfpu=vfp
 .endfor
@@ -86,21 +86,21 @@ ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S l
 
 .elif (${LIBC_MACHINE_ARCH} == "ia64")
 .PATH: ${.CURDIR}/arch/ia64
-COMMON_SRCS += fenv.c s_nearbyint.c
+COMMON_SRCS += fenv.c
 
 .elif (${LIBC_MACHINE_ARCH} == "hppa")
 .PATH.c: ${.CURDIR}/arch/hppa
-COMMON_SRCS+= fenv.c s_nexttowardf.c s_nearbyint.c s_rintl.c
+COMMON_SRCS+= fenv.c s_nexttowardf.c s_rintl.c
 
 .elif (${LIBC_MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
-COMMON_SRCS+= fenv.c s_nearbyint.c
+COMMON_SRCS+= fenv.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 
 .elif (${LIBC_MACHINE_ARCH} == "sparc64")
 .PATH: ${.CURDIR}/arch/sparc64
 COMMON_SRCS+= fenv.c
-COMMON_SRCS+= s_nexttowardf.c s_nearbyint.c s_rintl.c
+COMMON_SRCS+= s_nexttowardf.c s_rintl.c
 .ifndef _COMPAT_M32_MK_
 COMMON_SRCS+= s_nexttoward.c
 .endif
@@ -114,8 +114,7 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .endif
 .PATH:	${.CURDIR}/arch/i387
 
-COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.c \
-	s_nearbyint.c s_rintl.c
+COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.c s_rintl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 
 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
@@ -154,7 +153,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 	e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
 	s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
 	s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-COMMON_SRCS += fenv.c s_nearbyint.c s_rintl.c
+COMMON_SRCS += fenv.c s_rintl.c
 .endif
 .endif
 # end of m68k
@@ -174,7 +173,7 @@ WARNS?=5
 .PATH:	${.CURDIR}/arch/riscv
 
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c s_nearbyint.c
+COMMON_SRCS += fenv.c
 ARCH_SRCS = e_sqrt.S e_sqrtf.S
 ARCH_SRCS += s_copysign.S s_copysignf.S
 ARCH_SRCS += s_fabs.S s_fabsf.S
@@ -186,19 +185,19 @@ ARCH_SRCS += s_fmin.S s_fminf.S
 .elif (${LIBC_MACHINE_ARCH} == "powerpc")
 .PATH:	${.CURDIR}/arch/powerpc
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c s_nearbyint.c
+COMMON_SRCS += fenv.c
 .endif
 
 .elif (${LIBC_MACHINE_CPU} == "mips")
 .PATH:	${.CURDIR}/arch/mips
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c s_nearbyint.c
+COMMON_SRCS += fenv.c
 .endif
 
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c s_nearbyint.c
+COMMON_SRCS += fenv.c
 .endif
 .endif
 # End of list of CPU tests
@@ -267,7 +266,7 @@ COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c
 	s_lrint.c s_lrintf.c s_lrintl.c \
 	s_lround.c s_lroundf.c s_lroundl.c \
 	s_log1pf.c s_logb.c s_logbf.c s_logbl.c \
-	s_matherr.c s_modff.c s_modfl.c s_nextafter.c s_nextafterl.c \
+	s_matherr.c s_modff.c s_modfl.c s_nearbyint.c s_nextafter.c s_nextafterl.c \
 	s_nextafterf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c \
 	s_round.c s_roundf.c s_roundl.c s_scalbn.c \
 	s_scalbnf.c s_scalbnl.c s_signgam.c s_significand.c s_significandf.c s_sin.c \



CVS commit: src/lib/libm

2017-07-27 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Thu Jul 27 10:03:10 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
The sparc port needs s_nearbyint.c as well.


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/lib/libm/Makefile

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.194 src/lib/libm/Makefile:1.195
--- src/lib/libm/Makefile:1.194	Thu Jul 27 07:01:58 2017
+++ src/lib/libm/Makefile	Thu Jul 27 10:03:10 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.194 2017/07/27 07:01:58 he Exp $
+#  $NetBSD: Makefile,v 1.195 2017/07/27 10:03:10 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -94,7 +94,7 @@ COMMON_SRCS+= fenv.c s_nexttowardf.c s_n
 
 .elif (${LIBC_MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
-COMMON_SRCS+= fenv.c
+COMMON_SRCS+= fenv.c s_nearbyint.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 
 .elif (${LIBC_MACHINE_ARCH} == "sparc64")



CVS commit: src/lib/libm

2017-07-27 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Thu Jul 27 07:01:58 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
Non-softfloat m68k needs s_rintl.c.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/lib/libm/Makefile

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.193 src/lib/libm/Makefile:1.194
--- src/lib/libm/Makefile:1.193	Wed Jul 26 09:53:09 2017
+++ src/lib/libm/Makefile	Thu Jul 27 07:01:58 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.193 2017/07/26 09:53:09 he Exp $
+#  $NetBSD: Makefile,v 1.194 2017/07/27 07:01:58 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -154,7 +154,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 	e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
 	s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
 	s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-COMMON_SRCS += fenv.c s_nearbyint.c
+COMMON_SRCS += fenv.c s_nearbyint.c s_rintl.c
 .endif
 .endif
 # end of m68k



CVS commit: src/lib/libm

2017-07-26 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Jul 26 09:53:09 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
Add s_nearbyint.c to alpha, ia64, riscv, mips, powerpc, and sh3 ports.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/lib/libm/Makefile

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.192 src/lib/libm/Makefile:1.193
--- src/lib/libm/Makefile:1.192	Wed Jul 26 09:42:12 2017
+++ src/lib/libm/Makefile	Wed Jul 26 09:53:09 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.192 2017/07/26 09:42:12 he Exp $
+#  $NetBSD: Makefile,v 1.193 2017/07/26 09:53:09 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -62,11 +62,11 @@ COMMON_SRCS+= fenv.c
 .endif
 COMMON_SRCS+= e_sqrtl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
-.elif (${LIBC_MACHINE_ARCH} == "alpha")
 
+.elif (${LIBC_MACHINE_ARCH} == "alpha")
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
-COMMON_SRCS+= fenv.c
+COMMON_SRCS+= fenv.c s_nearbyint.c
 COPTS+=	-mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
 
 .elif (${LIBC_MACHINE_CPU} == "arm")
@@ -82,11 +82,11 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .if (${MKSOFTFLOAT} == "no")
 .PATH.S: ${.CURDIR}/arch/arm
 ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
-
 .endif
+
 .elif (${LIBC_MACHINE_ARCH} == "ia64")
 .PATH: ${.CURDIR}/arch/ia64
-COMMON_SRCS += fenv.c
+COMMON_SRCS += fenv.c s_nearbyint.c
 
 .elif (${LIBC_MACHINE_ARCH} == "hppa")
 .PATH.c: ${.CURDIR}/arch/hppa
@@ -154,7 +154,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 	e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
 	s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
 	s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-COMMON_SRCS += fenv.c
+COMMON_SRCS += fenv.c s_nearbyint.c
 .endif
 .endif
 # end of m68k
@@ -174,7 +174,7 @@ WARNS?=5
 .PATH:	${.CURDIR}/arch/riscv
 
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c
+COMMON_SRCS += fenv.c s_nearbyint.c
 ARCH_SRCS = e_sqrt.S e_sqrtf.S
 ARCH_SRCS += s_copysign.S s_copysignf.S
 ARCH_SRCS += s_fabs.S s_fabsf.S
@@ -186,22 +186,22 @@ ARCH_SRCS += s_fmin.S s_fminf.S
 .elif (${LIBC_MACHINE_ARCH} == "powerpc")
 .PATH:	${.CURDIR}/arch/powerpc
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c
+COMMON_SRCS += fenv.c s_nearbyint.c
 .endif
 
 .elif (${LIBC_MACHINE_CPU} == "mips")
 .PATH:	${.CURDIR}/arch/mips
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c
+COMMON_SRCS += fenv.c s_nearbyint.c
 .endif
 
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3
 .if ${MKSOFTFLOAT} == "no"
-COMMON_SRCS += fenv.c
+COMMON_SRCS += fenv.c s_nearbyint.c
 .endif
 .endif
-# End of long list of CPU tests
+# End of list of CPU tests
 
 WARNS?=5
 



CVS commit: src/lib/libm

2017-07-26 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Jul 26 09:42:12 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
Add some blank lines to separate the different CPU archs,
for a minimal readability improvement.


To generate a diff of this commit:
cvs rdiff -u -r1.191 -r1.192 src/lib/libm/Makefile

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.191 src/lib/libm/Makefile:1.192
--- src/lib/libm/Makefile:1.191	Sat May  6 18:03:24 2017
+++ src/lib/libm/Makefile	Wed Jul 26 09:42:12 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.191 2017/05/06 18:03:24 christos Exp $
+#  $NetBSD: Makefile,v 1.192 2017/07/26 09:42:12 he Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -63,10 +63,12 @@ COMMON_SRCS+= fenv.c
 COMMON_SRCS+= e_sqrtl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${LIBC_MACHINE_ARCH} == "alpha")
+
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
 COMMON_SRCS+= fenv.c
 COPTS+=	-mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
+
 .elif (${LIBC_MACHINE_CPU} == "arm")
 .PATH.c: ${.CURDIR}/arch/arm
 .if ${MKSOFTFLOAT} == "no"
@@ -80,17 +82,21 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .if (${MKSOFTFLOAT} == "no")
 .PATH.S: ${.CURDIR}/arch/arm
 ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
+
 .endif
 .elif (${LIBC_MACHINE_ARCH} == "ia64")
 .PATH: ${.CURDIR}/arch/ia64
 COMMON_SRCS += fenv.c
+
 .elif (${LIBC_MACHINE_ARCH} == "hppa")
 .PATH.c: ${.CURDIR}/arch/hppa
 COMMON_SRCS+= fenv.c s_nexttowardf.c s_nearbyint.c s_rintl.c
+
 .elif (${LIBC_MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
 COMMON_SRCS+= fenv.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
+
 .elif (${LIBC_MACHINE_ARCH} == "sparc64")
 .PATH: ${.CURDIR}/arch/sparc64
 COMMON_SRCS+= fenv.c
@@ -99,6 +105,7 @@ COMMON_SRCS+= s_nexttowardf.c s_nearbyin
 COMMON_SRCS+= s_nexttoward.c
 .endif
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
+
 .elif ((${MACHINE_ARCH} == "i386") || (${MACHINE_ARCH} == "x86_64"))
 
 # XXX consider making this LIBC_MACHINE_ARCH?
@@ -128,6 +135,7 @@ s_${f}.o s_${f}.pico s_${f}.po s_${f}.go
 .if (${MACHINE_ARCH} == "i386")
 SUBDIR=arch/i387
 .endif
+
 .elif (${LIBC_MACHINE_ARCH} == "m68k")
 .if defined(M68060)
 .PATH:	${.CURDIR}/arch/m68060
@@ -150,6 +158,7 @@ COMMON_SRCS += fenv.c
 .endif
 .endif
 # end of m68k
+
 .elif (${LIBC_MACHINE_ARCH} == "vax")
 .PATH:	${.CURDIR}/arch/vax
 
@@ -160,6 +169,7 @@ COMMON_SRCS += fenv.c
 # and emulation code isn't written yet.
 ARCH_SRCS = n_scalbn.S
 WARNS?=5
+
 .elif (${LIBC_MACHINE_CPU} == "riscv")
 .PATH:	${.CURDIR}/arch/riscv
 
@@ -172,22 +182,26 @@ ARCH_SRCS += s_fma.S s_fmaf.S
 ARCH_SRCS += s_fmax.S s_fmaxf.S
 ARCH_SRCS += s_fmin.S s_fminf.S
 .endif
+
 .elif (${LIBC_MACHINE_ARCH} == "powerpc")
 .PATH:	${.CURDIR}/arch/powerpc
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
+
 .elif (${LIBC_MACHINE_CPU} == "mips")
 .PATH:	${.CURDIR}/arch/mips
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
+
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
 .endif
+# End of long list of CPU tests
 
 WARNS?=5
 



CVS commit: src/lib/libm/src

2017-06-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Jun 22 12:43:43 UTC 2017

Modified Files:
src/lib/libm/src: k_rem_pio2.c k_rem_pio2f.c

Log Message:
Correct misleading indentation. NFC

>From GCC8


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libm/src/k_rem_pio2.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/src/k_rem_pio2f.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/src/k_rem_pio2.c
diff -u src/lib/libm/src/k_rem_pio2.c:1.12 src/lib/libm/src/k_rem_pio2.c:1.13
--- src/lib/libm/src/k_rem_pio2.c:1.12	Fri Apr 23 19:17:07 2010
+++ src/lib/libm/src/k_rem_pio2.c	Thu Jun 22 12:43:43 2017
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: k_rem_pio2.c,v 1.12 2010/04/23 19:17:07 drochner Exp $");
+__RCSID("$NetBSD: k_rem_pio2.c,v 1.13 2017/06/22 12:43:43 maya Exp $");
 #endif
 
 /*
@@ -175,7 +175,9 @@ __kernel_rem_pio2(double *x, double *y, 
 
 /* compute q[0],q[1],...q[jk] */
 	for (i=0;i<=jk;i++) {
-	for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+	for(j=0,fw=0.0;j<=jx;j++)
+		fw += x[j]*f[jx+i-j];
+	q[i] = fw;
 	}
 
 	jz = jk;

Index: src/lib/libm/src/k_rem_pio2f.c
diff -u src/lib/libm/src/k_rem_pio2f.c:1.8 src/lib/libm/src/k_rem_pio2f.c:1.9
--- src/lib/libm/src/k_rem_pio2f.c:1.8	Fri Apr 23 19:17:07 2010
+++ src/lib/libm/src/k_rem_pio2f.c	Thu Jun 22 12:43:43 2017
@@ -15,7 +15,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: k_rem_pio2f.c,v 1.8 2010/04/23 19:17:07 drochner Exp $");
+__RCSID("$NetBSD: k_rem_pio2f.c,v 1.9 2017/06/22 12:43:43 maya Exp $");
 #endif
 
 #include "namespace.h"
@@ -68,7 +68,9 @@ __kernel_rem_pio2f(float *x, float *y, i
 
 /* compute q[0],q[1],...q[jk] */
 	for (i=0;i<=jk;i++) {
-	for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+	for(j=0,fw=0.0;j<=jx;j++)
+		fw += x[j]*f[jx+i-j];
+	q[i] = fw;
 	}
 
 	jz = jk;



CVS commit: src/lib/libm

2017-05-13 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat May 13 13:17:11 UTC 2017

Modified Files:
src/lib/libm: shlib_version

Log Message:
Belatedly bump minor.

lots of changes since -7 (libm.so.0.11), including:
new functions: llroundl, lroundl, erfl, erfcl
partial switch to freebsd catrig


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libm/shlib_version

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/shlib_version
diff -u src/lib/libm/shlib_version:1.15 src/lib/libm/shlib_version:1.16
--- src/lib/libm/shlib_version:1.15	Fri Jan 20 22:10:38 2017
+++ src/lib/libm/shlib_version	Sat May 13 13:17:11 2017
@@ -1,8 +1,8 @@
-#	$NetBSD: shlib_version,v 1.15 2017/01/20 22:10:38 maya Exp $
+#	$NetBSD: shlib_version,v 1.16 2017/05/13 13:17:11 maya Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 # things we wish to do on next major version bump:
 # - remove compatibility cabs
 # - hide isinff
 major=0
-minor=11
+minor=12



CVS commit: src/lib/libm/compat

2017-05-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat May 13 02:58:03 UTC 2017

Modified Files:
src/lib/libm/compat: compat_cabs.c compat_cabsf.c

Log Message:
Drop superfluous ; in __warn_references


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/compat/compat_cabs.c \
src/lib/libm/compat/compat_cabsf.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/compat/compat_cabs.c
diff -u src/lib/libm/compat/compat_cabs.c:1.2 src/lib/libm/compat/compat_cabs.c:1.3
--- src/lib/libm/compat/compat_cabs.c:1.2	Fri Aug 10 21:20:35 2007
+++ src/lib/libm/compat/compat_cabs.c	Sat May 13 02:58:03 2017
@@ -7,7 +7,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_cabs.c,v 1.2 2007/08/10 21:20:35 drochner Exp $");
+__RCSID("$NetBSD: compat_cabs.c,v 1.3 2017/05/13 02:58:03 maya Exp $");
 #endif
 
 #include "../src/namespace.h"
@@ -19,7 +19,7 @@ struct complex {
 };
 
 double cabs(struct complex);
-__warn_references(cabs, "warning: reference to compatibility cabs()");
+__warn_references(cabs, "warning: reference to compatibility cabs()")
 
 double
 cabs(struct complex z)
Index: src/lib/libm/compat/compat_cabsf.c
diff -u src/lib/libm/compat/compat_cabsf.c:1.2 src/lib/libm/compat/compat_cabsf.c:1.3
--- src/lib/libm/compat/compat_cabsf.c:1.2	Fri Aug 10 21:20:35 2007
+++ src/lib/libm/compat/compat_cabsf.c	Sat May 13 02:58:03 2017
@@ -7,7 +7,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_cabsf.c,v 1.2 2007/08/10 21:20:35 drochner Exp $");
+__RCSID("$NetBSD: compat_cabsf.c,v 1.3 2017/05/13 02:58:03 maya Exp $");
 #endif
 
 #include "../src/namespace.h"
@@ -19,7 +19,7 @@ struct complex {
 };
 
 float cabsf __P((struct complex));
-__warn_references(cabsf, "warning: reference to compatibility cabsf()");
+__warn_references(cabsf, "warning: reference to compatibility cabsf()")
 
 float
 cabsf(struct complex z)



CVS commit: src/lib/libm/src

2017-05-08 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue May  9 02:04:38 UTC 2017

Modified Files:
src/lib/libm/src: e_asin.c e_asinf.c

Log Message:
Correct misleading indentation. NFC

This isn't a functional difference because huge + x > one is
always true for a small x, and is probably a magical incantation
to raise inexact if x != 0

Found by GCC 8.0


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libm/src/e_asin.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/src/e_asinf.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/src/e_asin.c
diff -u src/lib/libm/src/e_asin.c:1.12 src/lib/libm/src/e_asin.c:1.13
--- src/lib/libm/src/e_asin.c:1.12	Sun May 26 22:01:48 2002
+++ src/lib/libm/src/e_asin.c	Tue May  9 02:04:38 2017
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_asin.c,v 1.12 2002/05/26 22:01:48 wiz Exp $");
+__RCSID("$NetBSD: e_asin.c,v 1.13 2017/05/09 02:04:38 maya Exp $");
 #endif
 
 /* __ieee754_asin(x)
@@ -86,12 +86,13 @@ __ieee754_asin(double x)
 	} else if (ix<0x3fe0) {	/* |x|<0.5 */
 	if(ix<0x3e40) {		/* if |x| < 2**-27 */
 		if(huge+x>one) return x;/* return x with inexact if x!=0*/
-	} else
+	} else {
 		t = x*x;
 		p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5);
 		q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
 		w = p/q;
 		return x+x*w;
+	}
 	}
 	/* 1> |x|>= 0.5 */
 	w = one-fabs(x);

Index: src/lib/libm/src/e_asinf.c
diff -u src/lib/libm/src/e_asinf.c:1.8 src/lib/libm/src/e_asinf.c:1.9
--- src/lib/libm/src/e_asinf.c:1.8	Sun May 26 22:01:48 2002
+++ src/lib/libm/src/e_asinf.c	Tue May  9 02:04:38 2017
@@ -15,7 +15,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_asinf.c,v 1.8 2002/05/26 22:01:48 wiz Exp $");
+__RCSID("$NetBSD: e_asinf.c,v 1.9 2017/05/09 02:04:38 maya Exp $");
 #endif
 
 #include "math.h"
@@ -56,12 +56,13 @@ __ieee754_asinf(float x)
 	} else if (ix<0x3f00) {	/* |x|<0.5 */
 	if(ix<0x3200) {		/* if |x| < 2**-27 */
 		if(huge+x>one) return x;/* return x with inexact if x!=0*/
-	} else
+	} else {
 		t = x*x;
 		p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5);
 		q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
 		w = p/q;
 		return x+x*w;
+	}
 	}
 	/* 1> |x|>= 0.5 */
 	w = one-fabsf(x);



CVS commit: src/lib/libm/arch/arm

2017-05-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May  8 09:25:03 UTC 2017

Modified Files:
src/lib/libm/arch/arm: fenv.c

Log Message:
Complete the namespace dance


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/arch/arm/fenv.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/arch/arm/fenv.c
diff -u src/lib/libm/arch/arm/fenv.c:1.8 src/lib/libm/arch/arm/fenv.c:1.9
--- src/lib/libm/arch/arm/fenv.c:1.8	Mon May  8 08:21:56 2017
+++ src/lib/libm/arch/arm/fenv.c	Mon May  8 09:25:03 2017
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.8 2017/05/08 08:21:56 martin Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.9 2017/05/08 09:25:03 martin Exp $");
 
 #include "namespace.h"
 
@@ -43,6 +43,23 @@ __RCSID("$NetBSD: fenv.c,v 1.8 2017/05/0
 #error This fenv implementation is only for hardfloat.
 #endif
 
+#ifdef __weak_alias
+__weak_alias(feclearexcept,_feclearexcept)
+__weak_alias(fedisableexcept,_fedisableexcept)
+__weak_alias(feenableexcept,_feenableexcept)
+__weak_alias(fegetenv,_fegetenv)
+__weak_alias(fegetexcept,_fegetexcept)
+__weak_alias(fegetexceptflag,_fegetexceptflag)
+__weak_alias(fegetround,_fegetround)
+__weak_alias(feholdexcept,_feholdexcept)
+__weak_alias(feraiseexcept,_feraiseexcept)
+__weak_alias(fesetenv,_fesetenv)
+__weak_alias(fesetexceptflag,_fesetexceptflag)
+__weak_alias(fesetround,_fesetround)
+__weak_alias(fetestexcept,_fetestexcept)
+__weak_alias(feupdateenv,_feupdateenv)
+#endif
+
 #include 
 #include 
 



CVS commit: src/lib/libm/arch/arm

2017-05-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May  8 08:21:56 UTC 2017

Modified Files:
src/lib/libm/arch/arm: fenv.c

Log Message:
Add missing namespace.h include


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libm/arch/arm/fenv.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/arch/arm/fenv.c
diff -u src/lib/libm/arch/arm/fenv.c:1.7 src/lib/libm/arch/arm/fenv.c:1.8
--- src/lib/libm/arch/arm/fenv.c:1.7	Wed Mar 22 23:11:08 2017
+++ src/lib/libm/arch/arm/fenv.c	Mon May  8 08:21:56 2017
@@ -28,7 +28,9 @@
  */
 
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.7 2017/03/22 23:11:08 chs Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.8 2017/05/08 08:21:56 martin Exp $");
+
+#include "namespace.h"
 
 #include 
 #include 



CVS commit: src/lib/libm/complex

2017-05-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  7 22:01:54 UTC 2017

Modified Files:
src/lib/libm/complex: Makefile.inc

Log Message:
Add the imprecise catrigl functions back.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libm/complex/Makefile.inc

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/complex/Makefile.inc
diff -u src/lib/libm/complex/Makefile.inc:1.9 src/lib/libm/complex/Makefile.inc:1.10
--- src/lib/libm/complex/Makefile.inc:1.9	Mon Sep 19 18:05:05 2016
+++ src/lib/libm/complex/Makefile.inc	Sun May  7 18:01:54 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.9 2016/09/19 22:05:05 christos Exp $
+# $NetBSD: Makefile.inc,v 1.10 2017/05/07 22:01:54 christos Exp $
 
 .PATH: ${.CURDIR}/complex
 
@@ -17,6 +17,7 @@ MLINKS+= ${i:Ncatrig*:Ncephes_*:S/.c/.3/
 .endfor
 
 .for i in ${CATRIG_SRCS}
+SRCS+=	${i:S/.c/l.c/}
 MAN+= ${i:S/.c/.3/}
 MLINKS+= ${i:S/.c/.3/} ${i:S/.c/f.3/}
 MLINKS+= ${i:S/.c/.3/} ${i:S/.c/l.3/}



CVS commit: src/lib/libm/complex

2017-05-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  7 21:59:06 UTC 2017

Modified Files:
src/lib/libm/complex: catrigl.c

Log Message:
mention why we don't support this (yet)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/complex/catrigl.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/complex/catrigl.c
diff -u src/lib/libm/complex/catrigl.c:1.1 src/lib/libm/complex/catrigl.c:1.2
--- src/lib/libm/complex/catrigl.c:1.1	Mon Sep 19 18:05:05 2016
+++ src/lib/libm/complex/catrigl.c	Sun May  7 17:59:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: catrigl.c,v 1.1 2016/09/19 22:05:05 christos Exp $	*/
+/*	$NetBSD: catrigl.c,v 1.2 2017/05/07 21:59:06 christos Exp $	*/
 /*-
  * Copyright (c) 2012 Stephen Montgomery-Smith 
  * All rights reserved.
@@ -35,7 +35,7 @@
  * The code for catrig.c contains complete comments.
  */
 #include 
-__RCSID("$NetBSD: catrigl.c,v 1.1 2016/09/19 22:05:05 christos Exp $");
+__RCSID("$NetBSD: catrigl.c,v 1.2 2017/05/07 21:59:06 christos Exp $");
 
 #include "namespace.h"
 #ifdef __weak_alias
@@ -46,11 +46,12 @@ __weak_alias(catanl, _catanl)
 #endif
 
 
+#include 
 #include 
 #include 
-#ifdef __HAVE_LONG_DOUBLE
+#include 
+#ifdef notyet // missing log1pl __HAVE_LONG_DOUBLE
 
-#include "math.h"
 #include "math_private.h"
 
 #undef isinf
@@ -65,9 +66,10 @@ __weak_alias(catanl, _catanl)
 // Ok
 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
 // XXX: Byte order
+#define EXT_EXPBITS	15
 struct ieee_ext {
 	uint64_t ext_frac;
-	uint16_t ext_exp:15;
+	uint16_t ext_exp:EXT_EXPBITS;
 	uint16_t ext_sign:1;
 	uint16_t ext_pad;
 };
@@ -87,14 +89,14 @@ union ieee_ext_u {
 	union ieee_ext_u u; \
 	u.extu_ld = s; \
 	r = u.extu_sign; \
-	r >>= EXT_EXPBITS - 1;
+	r >>= EXT_EXPBITS - 1; \
 } while (/*CONSTCOND*/0)
-#define SET_LDBL_EXPSIGN(r, s) \
+#define SET_LDBL_EXPSIGN(s, r) \
 do { \
 	union ieee_ext_u u; \
 	u.extu_ld = s; \
 	u.extu_exp &= __BITS(0, EXT_EXPBITS - 1); \
-	u.extu_exp |= r << (EXT_EXPBITS - 1); \
+	u.extu_exp |= (r) << (EXT_EXPBITS - 1); \
 	s = u.extu_ld; \
 } while (/*CONSTCOND*/0)
 



CVS commit: src/lib/libm/src

2017-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May  7 11:29:21 UTC 2017

Modified Files:
src/lib/libm/src: s_llrintl.c s_lrintl.c

Log Message:
Limit some rintl usage to #ifdef __HAVE_LONG_DOUBLE.
XXX should probably declare some aliases in the #else case


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/src/s_llrintl.c \
src/lib/libm/src/s_lrintl.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/src/s_llrintl.c
diff -u src/lib/libm/src/s_llrintl.c:1.1 src/lib/libm/src/s_llrintl.c:1.2
--- src/lib/libm/src/s_llrintl.c:1.1	Sat May  6 18:03:24 2017
+++ src/lib/libm/src/s_llrintl.c	Sun May  7 11:29:21 2017
@@ -2,12 +2,15 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: head/lib/msun/src/s_llrintl.c 175309 2008-01-14 02:12:07Z das $");
 #else
-__RCSID("$NetBSD: s_llrintl.c,v 1.1 2017/05/06 18:03:24 christos Exp $");
+__RCSID("$NetBSD: s_llrintl.c,v 1.2 2017/05/07 11:29:21 martin Exp $");
 #endif
 
+#ifdef __HAVE_LONG_DOUBLE
 #define stype		long double
 #define	roundit		rintl
 #define dtype		long long
 #define	fn		llrintl
 
 #include "s_lrint.c"
+#endif
+
Index: src/lib/libm/src/s_lrintl.c
diff -u src/lib/libm/src/s_lrintl.c:1.1 src/lib/libm/src/s_lrintl.c:1.2
--- src/lib/libm/src/s_lrintl.c:1.1	Sat May  6 18:03:24 2017
+++ src/lib/libm/src/s_lrintl.c	Sun May  7 11:29:21 2017
@@ -2,12 +2,14 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: head/lib/msun/src/s_lrintl.c 175309 2008-01-14 02:12:07Z das $");
 #else
-__RCSID("$NetBSD: s_lrintl.c,v 1.1 2017/05/06 18:03:24 christos Exp $");
+__RCSID("$NetBSD: s_lrintl.c,v 1.2 2017/05/07 11:29:21 martin Exp $");
 #endif
 
+#ifdef __HAVE_LONG_DOUBLE
 #define stype		long double
 #define	roundit		rintl
 #define dtype		long
 #define	fn		lrintl
 
 #include "s_lrint.c"
+#endif



CVS commit: src/lib/libm

2017-05-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  6 18:03:25 UTC 2017

Modified Files:
src/lib/libm: Makefile
Added Files:
src/lib/libm/src: s_llrint.c s_llrintf.c s_llrintl.c s_llround.c
s_llroundf.c s_llroundl.c s_lrint.c s_lrintf.c s_lrintl.c
s_lround.c s_lroundf.c s_lroundl.c
Removed Files:
src/lib/libm/src: llrint.c llrintf.c llround.c llroundf.c lrint.c
lrintf.c lround.c lroundf.c

Log Message:
Replace our rounding functions with the ones from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/lib/libm/Makefile
cvs rdiff -u -r1.2 -r0 src/lib/libm/src/llrint.c src/lib/libm/src/llrintf.c \
src/lib/libm/src/llround.c src/lib/libm/src/llroundf.c
cvs rdiff -u -r1.6 -r0 src/lib/libm/src/lrint.c src/lib/libm/src/lrintf.c
cvs rdiff -u -r1.3 -r0 src/lib/libm/src/lround.c src/lib/libm/src/lroundf.c
cvs rdiff -u -r0 -r1.1 src/lib/libm/src/s_llrint.c \
src/lib/libm/src/s_llrintf.c src/lib/libm/src/s_llrintl.c \
src/lib/libm/src/s_llround.c src/lib/libm/src/s_llroundf.c \
src/lib/libm/src/s_llroundl.c src/lib/libm/src/s_lrint.c \
src/lib/libm/src/s_lrintf.c src/lib/libm/src/s_lrintl.c \
src/lib/libm/src/s_lround.c src/lib/libm/src/s_lroundf.c \
src/lib/libm/src/s_lroundl.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.190 src/lib/libm/Makefile:1.191
--- src/lib/libm/Makefile:1.190	Thu Mar 23 14:26:03 2017
+++ src/lib/libm/Makefile	Sat May  6 14:03:24 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.190 2017/03/23 18:26:03 chs Exp $
+#  $NetBSD: Makefile,v 1.191 2017/05/06 18:03:24 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -248,6 +248,10 @@ COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c
 	s_floor.c s_floorf.c s_floorl.c s_frexpf.c \
 	s_ilogb.c s_ilogbf.c s_ilogbl.c \
 	s_isinff.c s_isnanf.c s_lib_version.c s_log1p.c \
+	s_llrint.c s_llrintf.c s_llrintl.c \
+	s_llround.c s_llroundf.c s_llroundl.c \
+	s_lrint.c s_lrintf.c s_lrintl.c \
+	s_lround.c s_lroundf.c s_lroundl.c \
 	s_log1pf.c s_logb.c s_logbf.c s_logbl.c \
 	s_matherr.c s_modff.c s_modfl.c s_nextafter.c s_nextafterl.c \
 	s_nextafterf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c \
@@ -265,8 +269,7 @@ COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c
 	w_log2f.c w_logf.c \
 	w_pow.c w_powf.c w_remainder.c w_remainderf.c w_scalb.c w_scalbf.c \
 	w_sinh.c w_sinhf.c w_sqrt.c w_sqrtf.c w_sqrtl.c \
-	lrint.c lrintf.c llrint.c llrintf.c lround.c lroundf.c llround.c \
-	llroundf.c s_frexp.c s_frexpl.c s_modf.c \
+	s_frexp.c s_frexpl.c s_modf.c \
 	s_fmax.c s_fmaxf.c s_fmaxl.c \
 	s_fmin.c s_fminf.c s_fminl.c s_fdim.c
 

Added files:

Index: src/lib/libm/src/s_llrint.c
diff -u /dev/null src/lib/libm/src/s_llrint.c:1.1
--- /dev/null	Sat May  6 14:03:25 2017
+++ src/lib/libm/src/s_llrint.c	Sat May  6 14:03:24 2017
@@ -0,0 +1,13 @@
+#include 
+#ifdef __FreeBSD__
+__FBSDID("$FreeBSD: head/lib/msun/src/s_llrint.c 140088 2005-01-11 23:12:55Z das $");
+#else
+__RCSID("$NetBSD: s_llrint.c,v 1.1 2017/05/06 18:03:24 christos Exp $");
+#endif
+
+#define stype		double
+#define	roundit		rint
+#define dtype		long long
+#define	fn		llrint
+
+#include "s_lrint.c"
Index: src/lib/libm/src/s_llrintf.c
diff -u /dev/null src/lib/libm/src/s_llrintf.c:1.1
--- /dev/null	Sat May  6 14:03:25 2017
+++ src/lib/libm/src/s_llrintf.c	Sat May  6 14:03:24 2017
@@ -0,0 +1,13 @@
+#include 
+#ifdef __FreeBSD__
+__FBSDID("$FreeBSD: head/lib/msun/src/s_llrintf.c 140088 2005-01-11 23:12:55Z das $");
+#else
+__RCSID("$NetBSD: s_llrintf.c,v 1.1 2017/05/06 18:03:24 christos Exp $");
+#endif
+
+#define stype		float
+#define	roundit		rintf
+#define dtype		long long
+#define	fn		llrintf
+
+#include "s_lrint.c"
Index: src/lib/libm/src/s_llrintl.c
diff -u /dev/null src/lib/libm/src/s_llrintl.c:1.1
--- /dev/null	Sat May  6 14:03:25 2017
+++ src/lib/libm/src/s_llrintl.c	Sat May  6 14:03:24 2017
@@ -0,0 +1,13 @@
+#include 
+#ifdef __FreeBSD__
+__FBSDID("$FreeBSD: head/lib/msun/src/s_llrintl.c 175309 2008-01-14 02:12:07Z das $");
+#else
+__RCSID("$NetBSD: s_llrintl.c,v 1.1 2017/05/06 18:03:24 christos Exp $");
+#endif
+
+#define stype		long double
+#define	roundit		rintl
+#define dtype		long long
+#define	fn		llrintl
+
+#include "s_lrint.c"
Index: src/lib/libm/src/s_llround.c
diff -u /dev/null src/lib/libm/src/s_llround.c:1.1
--- /dev/null	Sat May  6 14:03:25 2017
+++ src/lib/libm/src/s_llround.c	Sat May  6 14:03:24 2017
@@ -0,0 +1,15 @@
+#include 
+#ifdef __FreeBSD__
+__FBSDID("$FreeBSD: head/lib/msun/src/s_llround.c 144771 2005-04-08 00:52:27Z das $");
+#else
+__RCSID("$NetBSD: s_llround.c,v 1.1 2017/05/06 18:03:24 christos Exp $");
+#endif
+
+#define stype		double
+#define	roundit		round
+#define dtype		long long
+#define	DTYPE_MIN	LLONG_MIN
+#define	DTYPE_MAX	LLONG_MAX
+#define	fn		llround
+
+#include "s_lround.c"
Index: src/lib/libm/src

CVS commit: src/lib/libm/src

2017-05-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  6 18:02:52 UTC 2017

Modified Files:
src/lib/libm/src: e_sqrtl.c s_fma.c s_fmaf.c s_fmal.c s_nearbyint.c

Log Message:
add missing namespace.h


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libm/src/e_sqrtl.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libm/src/s_fma.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/src/s_fmaf.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/src/s_fmal.c \
src/lib/libm/src/s_nearbyint.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/src/e_sqrtl.c
diff -u src/lib/libm/src/e_sqrtl.c:1.5 src/lib/libm/src/e_sqrtl.c:1.6
--- src/lib/libm/src/e_sqrtl.c:1.5	Fri Aug 26 04:31:17 2016
+++ src/lib/libm/src/e_sqrtl.c	Sat May  6 14:02:52 2017
@@ -28,8 +28,9 @@
 #if 0
 __FBSDID("$FreeBSD: head/lib/msun/src/e_sqrtl.c 176720 2008-03-02 01:47:58Z das $");
 #endif
-__RCSID("$NetBSD: e_sqrtl.c,v 1.5 2016/08/26 08:31:17 christos Exp $");
+__RCSID("$NetBSD: e_sqrtl.c,v 1.6 2017/05/06 18:02:52 christos Exp $");
 
+#include "namespace.h"
 #include 
 #include 
 

Index: src/lib/libm/src/s_fma.c
diff -u src/lib/libm/src/s_fma.c:1.6 src/lib/libm/src/s_fma.c:1.7
--- src/lib/libm/src/s_fma.c:1.6	Thu Feb 14 04:24:50 2013
+++ src/lib/libm/src/s_fma.c	Sat May  6 14:02:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: s_fma.c,v 1.6 2013/02/14 09:24:50 matt Exp $	*/
+/*	$NetBSD: s_fma.c,v 1.7 2017/05/06 18:02:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005-2011 David Schultz 
@@ -30,9 +30,11 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/msun/src/s_fma.c,v 1.8 2011/10/21 06:30:43 das Exp $");
 #else
-__RCSID("$NetBSD: s_fma.c,v 1.6 2013/02/14 09:24:50 matt Exp $");
+__RCSID("$NetBSD: s_fma.c,v 1.7 2017/05/06 18:02:52 christos Exp $");
 #endif
 
+#include "namespace.h"
+
 #include 
 #include 
 #include 

Index: src/lib/libm/src/s_fmaf.c
diff -u src/lib/libm/src/s_fmaf.c:1.2 src/lib/libm/src/s_fmaf.c:1.3
--- src/lib/libm/src/s_fmaf.c:1.2	Sun Feb 10 20:29:58 2013
+++ src/lib/libm/src/s_fmaf.c	Sat May  6 14:02:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: s_fmaf.c,v 1.2 2013/02/11 01:29:58 christos Exp $	*/
+/*	$NetBSD: s_fmaf.c,v 1.3 2017/05/06 18:02:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005-2011 David Schultz 
@@ -30,9 +30,11 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/msun/src/s_fmaf.c,v 1.3 2011/10/15 04:16:58 das Exp $");
 #else
-__RCSID("$NetBSD: s_fmaf.c,v 1.2 2013/02/11 01:29:58 christos Exp $");
+__RCSID("$NetBSD: s_fmaf.c,v 1.3 2017/05/06 18:02:52 christos Exp $");
 #endif
 
+#include "namespace.h"
+
 #include 
 
 #include "math.h"

Index: src/lib/libm/src/s_fmal.c
diff -u src/lib/libm/src/s_fmal.c:1.3 src/lib/libm/src/s_fmal.c:1.4
--- src/lib/libm/src/s_fmal.c:1.3	Tue Feb 12 16:40:19 2013
+++ src/lib/libm/src/s_fmal.c	Sat May  6 14:02:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: s_fmal.c,v 1.3 2013/02/12 21:40:19 martin Exp $	*/
+/*	$NetBSD: s_fmal.c,v 1.4 2017/05/06 18:02:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 2005-2011 David Schultz 
@@ -30,9 +30,11 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/msun/src/s_fmal.c,v 1.7 2011/10/21 06:30:43 das Exp $");
 #else
-__RCSID("$NetBSD: s_fmal.c,v 1.3 2013/02/12 21:40:19 martin Exp $");
+__RCSID("$NetBSD: s_fmal.c,v 1.4 2017/05/06 18:02:52 christos Exp $");
 #endif
 
+#include "namespace.h"
+
 #include 
 #include 
 #include 
Index: src/lib/libm/src/s_nearbyint.c
diff -u src/lib/libm/src/s_nearbyint.c:1.3 src/lib/libm/src/s_nearbyint.c:1.4
--- src/lib/libm/src/s_nearbyint.c:1.3	Sun Feb 10 21:45:27 2013
+++ src/lib/libm/src/s_nearbyint.c	Sat May  6 14:02:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: s_nearbyint.c,v 1.3 2013/02/11 02:45:27 christos Exp $	*/
+/*	$NetBSD: s_nearbyint.c,v 1.4 2017/05/06 18:02:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004 David Schultz 
@@ -30,9 +30,11 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/msun/src/s_nearbyint.c,v 1.2 2008/01/14 02:12:06 das Exp $");
 #else
-__RCSID("$NetBSD: s_nearbyint.c,v 1.3 2013/02/11 02:45:27 christos Exp $");
+__RCSID("$NetBSD: s_nearbyint.c,v 1.4 2017/05/06 18:02:52 christos Exp $");
 #endif
 
+#include "namespace.h"
+
 #include 
 #include 
 #include 



CVS commit: src/lib/libm

2017-03-23 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu Mar 23 18:26:03 UTC 2017

Modified Files:
src/lib/libm: Makefile

Log Message:
sun2 just has to be different, of course.
it doesn't use the libc softfloat and thus doesn't set MKSOFTFLOAT=yes.
enable the fenv functions here explicitly for now.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/lib/libm/Makefile

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.189 src/lib/libm/Makefile:1.190
--- src/lib/libm/Makefile:1.189	Wed Mar 22 23:11:08 2017
+++ src/lib/libm/Makefile	Thu Mar 23 18:26:03 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.189 2017/03/22 23:11:08 chs Exp $
+#  $NetBSD: Makefile,v 1.190 2017/03/23 18:26:03 chs Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -206,7 +206,7 @@ COPTS+=	-fno-strict-aliasing
 .endif
 CPPFLAGS+=-DLIBM_SCCS
 
-.if ${MKSOFTFLOAT} != "no"
+.if (${MKSOFTFLOAT} != "no" || ${MACHINE_ARCH} == "m68000")
 .PATH:	${.CURDIR}/softfloat
 .include "${.CURDIR}/../libc/libcincludes.mk"
 CPPFLAGS+=	-I${ARCHDIR}/softfloat



CVS commit: src/lib/libm/arch/arm

2017-03-16 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu Mar 16 16:32:12 UTC 2017

Modified Files:
src/lib/libm/arch/arm: lrint.S lrintf.S

Log Message:
lrint() and lrintf() are supposed to use the current rounding mode,
so use vcvtr rather than vcvt.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/arch/arm/lrint.S \
src/lib/libm/arch/arm/lrintf.S

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/arch/arm/lrint.S
diff -u src/lib/libm/arch/arm/lrint.S:1.1 src/lib/libm/arch/arm/lrint.S:1.2
--- src/lib/libm/arch/arm/lrint.S:1.1	Mon Feb 11 12:43:03 2013
+++ src/lib/libm/arch/arm/lrint.S	Thu Mar 16 16:32:12 2017
@@ -29,14 +29,14 @@
 
 #include 
 
-RCSID("$NetBSD: lrint.S,v 1.1 2013/02/11 12:43:03 matt Exp $")
+RCSID("$NetBSD: lrint.S,v 1.2 2017/03/16 16:32:12 chs Exp $")
 
 STRONG_ALIAS(_lrintl, _lrint)
 WEAK_ALIAS(lrintl, _lrintl)
 WEAK_ALIAS(lrint, _lrint)
 
 ENTRY(_lrint)
-	vcvt.s32.f64	s0, d0
+	vcvtr.s32.f64	s0, d0
 	vmov		r0, s0
 	RET
 END(_lrint)
Index: src/lib/libm/arch/arm/lrintf.S
diff -u src/lib/libm/arch/arm/lrintf.S:1.1 src/lib/libm/arch/arm/lrintf.S:1.2
--- src/lib/libm/arch/arm/lrintf.S:1.1	Mon Feb 11 12:43:03 2013
+++ src/lib/libm/arch/arm/lrintf.S	Thu Mar 16 16:32:12 2017
@@ -29,12 +29,12 @@
 
 #include 
 
-RCSID("$NetBSD: lrintf.S,v 1.1 2013/02/11 12:43:03 matt Exp $")
+RCSID("$NetBSD: lrintf.S,v 1.2 2017/03/16 16:32:12 chs Exp $")
 
 WEAK_ALIAS(lrintf, _lrintf)
 
 ENTRY(_lrintf)
-	vcvt.s32.f32	s0, s0
+	vcvtr.s32.f32	s0, s0
 	vmov		r0, s0
 	RET
 END(_lrintf)



CVS commit: src/lib/libm/gen

2017-03-07 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Mar  7 11:15:08 UTC 2017

Modified Files:
src/lib/libm/gen: nan.c

Log Message:
Remove redundant null check before free()
It is guaranteed to be fine also by C99


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/gen/nan.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/gen/nan.c
diff -u src/lib/libm/gen/nan.c:1.2 src/lib/libm/gen/nan.c:1.3
--- src/lib/libm/gen/nan.c:1.2	Mon Apr 28 20:23:01 2008
+++ src/lib/libm/gen/nan.c	Tue Mar  7 11:15:08 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: nan.c,v 1.2 2008/04/28 20:23:01 martin Exp $ */
+/* $NetBSD: nan.c,v 1.3 2017/03/07 11:15:08 maya Exp $ */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint) && !defined(NAN_FUNCTION)
-__RCSID("$NetBSD: nan.c,v 1.2 2008/04/28 20:23:01 martin Exp $");
+__RCSID("$NetBSD: nan.c,v 1.3 2017/03/07 11:15:08 maya Exp $");
 #endif /* LIBM_SCCS and not lint */
 
 #include 
@@ -78,8 +78,7 @@ NAN_FUNCTION(const char *tagp)
 
 	res = NAN_STRTOD(nstr, NULL);
 
-	if (buf != NULL)
-		free(buf);
+	free(buf);
 
 	return res;
 }



CVS commit: src/lib/libm/src

2017-02-26 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Feb 27 06:49:02 UTC 2017

Modified Files:
src/lib/libm/src: lrint.c

Log Message:
the MI lrint() code assumes that rounding is done in at most double precision
but m68k (68881) uses extended precision by default, so put the FPU in
double-precision mode temporarily here.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libm/src/lrint.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/src/lrint.c
diff -u src/lib/libm/src/lrint.c:1.5 src/lib/libm/src/lrint.c:1.6
--- src/lib/libm/src/lrint.c:1.5	Thu Jul  9 06:17:13 2015
+++ src/lib/libm/src/lrint.c	Mon Feb 27 06:49:02 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: lrint.c,v 1.5 2015/07/09 06:17:13 nat Exp $ */
+/* $NetBSD: lrint.c,v 1.6 2017/02/27 06:49:02 chs Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -46,6 +46,15 @@ TWO52[2]={
  -4.5035996273704960e+15, /* 0xC330, 0x */
 };
 
+#ifdef __HAVE_68881__
+#include 
+
+#define get_fpcr(__fpcr) \
+__asm__ __volatile__ ("fmove%.l %!,%0" : "=dm" (__fpcr))
+#define set_fpcr(__fpcr) \
+__asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (__fpcr))
+#endif
+
 RESTYPE
 LRINTNAME(double x)
 {
@@ -68,8 +77,20 @@ LRINTNAME(double x)
 	/* >= 2^52 is already an exact integer */
 	if (e < DBL_FRACBITS) {
 		/* round, using current direction */
+#ifdef __HAVE_68881__
+		int ofpcr, nfpcr;
+
+		/* For m68k hardfloat, use double-precision */
+		get_fpcr(ofpcr);
+		nfpcr = (ofpcr & ~FPCR_PREC) | FPCR_DBL;
+		set_fpcr(nfpcr);
+#endif
 		x += TWO52[s];
 		x -= TWO52[s];
+#ifdef __HAVE_68881__
+		__asm__ __volatile__ ("/* dummy %0 */" : : "f" (x));
+		set_fpcr(ofpcr);
+#endif
 	} else
 		return x;
 



CVS commit: src/lib/libm

2017-02-22 Thread Sean Cole
Module Name:src
Committed By:   scole
Date:   Thu Feb 23 02:05:30 UTC 2017

Modified Files:
src/lib/libm: Makefile
Added Files:
src/lib/libm/arch/ia64: fenv.c

Log Message:
Add fenv for ia64, imported from FreeBSD, compile tested only.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/lib/libm/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libm/arch/ia64/fenv.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.187 src/lib/libm/Makefile:1.188
--- src/lib/libm/Makefile:1.187	Thu Dec  8 18:42:01 2016
+++ src/lib/libm/Makefile	Thu Feb 23 02:05:30 2017
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.187 2016/12/08 18:42:01 christos Exp $
+#  $NetBSD: Makefile,v 1.188 2017/02/23 02:05:30 scole Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -77,6 +77,9 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .PATH.S: ${.CURDIR}/arch/arm
 ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
 .endif
+.elif (${LIBC_MACHINE_ARCH} == "ia64")
+.PATH: ${.CURDIR}/arch/ia64
+COMMON_SRCS += fenv.c
 .elif (${LIBC_MACHINE_ARCH} == "hppa")
 .PATH.c: ${.CURDIR}/arch/hppa
 COMMON_SRCS+= fenv.c s_nexttowardf.c \

Added files:

Index: src/lib/libm/arch/ia64/fenv.c
diff -u /dev/null src/lib/libm/arch/ia64/fenv.c:1.1
--- /dev/null	Thu Feb 23 02:05:30 2017
+++ src/lib/libm/arch/ia64/fenv.c	Thu Feb 23 02:05:30 2017
@@ -0,0 +1,69 @@
+/*	$NetBSD: fenv.c,v 1.1 2017/02/23 02:05:30 scole Exp $	*/
+
+/*-
+ * Copyright (c) 2004 David Schultz 
+ * 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 AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: releng/10.1/lib/msun/ia64/fenv.c 226415 2011-10-16 05:37:56Z das $
+ */
+
+#include 
+__RCSID("$NetBSD: fenv.c,v 1.1 2017/02/23 02:05:30 scole Exp $");
+
+#define	__fenv_static
+#include "fenv.h"
+
+#if defined(__GNUC_GNU_INLINE__) && !defined(__lint__)
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
+
+const fenv_t __fe_dfl_env = 0x0009804c8a70033fULL;
+
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+
+/*
+ * It doesn't pay to inline feupdateenv() because it includes one of
+ * the rare uses of feraiseexcept() where the argument is not a
+ * constant.  Thus, no dead code elimination can occur, resulting in
+ * significant bloat.
+ */
+int
+feupdateenv(const fenv_t *envp)
+{
+	fenv_t fpsr;
+
+	__stfpsr(&fpsr);
+	__ldfpsr(*envp);
+	feraiseexcept((fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+	return (0);
+}



CVS commit: src/lib/libm/src

2017-02-09 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Feb  9 22:11:09 UTC 2017

Modified Files:
src/lib/libm/src: s_expm1.c s_expm1f.c

Log Message:
ifdef out some dead code. improves code readability.
all later users of y first assign another value.

using ifdefs to make potential future code syncs easier, as is done
elsewhere.

suggested by coverity, CID 1300929, 1300930.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libm/src/s_expm1.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libm/src/s_expm1f.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/src/s_expm1.c
diff -u src/lib/libm/src/s_expm1.c:1.12 src/lib/libm/src/s_expm1.c:1.13
--- src/lib/libm/src/s_expm1.c:1.12	Sun May 26 22:01:55 2002
+++ src/lib/libm/src/s_expm1.c	Thu Feb  9 22:11:09 2017
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_expm1.c,v 1.12 2002/05/26 22:01:55 wiz Exp $");
+__RCSID("$NetBSD: s_expm1.c,v 1.13 2017/02/09 22:11:09 maya Exp $");
 #endif
 
 /* expm1(x)
@@ -138,7 +138,9 @@ expm1(double x)
 	c = 0;
 	GET_HIGH_WORD(hx,x);
 	xsb = hx&0x8000;		/* sign bit of x */
+#ifdef DEAD_CODE
 	if(xsb==0) y=x; else y= -x;	/* y = |x| */
+#endif
 	hx &= 0x7fff;		/* high word of |x| */
 
 /* filter out huge and non-finite argument */

Index: src/lib/libm/src/s_expm1f.c
diff -u src/lib/libm/src/s_expm1f.c:1.10 src/lib/libm/src/s_expm1f.c:1.11
--- src/lib/libm/src/s_expm1f.c:1.10	Sun May 26 22:01:55 2002
+++ src/lib/libm/src/s_expm1f.c	Thu Feb  9 22:11:09 2017
@@ -15,7 +15,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_expm1f.c,v 1.10 2002/05/26 22:01:55 wiz Exp $");
+__RCSID("$NetBSD: s_expm1f.c,v 1.11 2017/02/09 22:11:09 maya Exp $");
 #endif
 
 #include "math.h"
@@ -46,7 +46,9 @@ expm1f(float x)
 	c = 0;
 	GET_FLOAT_WORD(hx,x);
 	xsb = hx&0x8000;		/* sign bit of x */
+#ifdef DEAD_CODE
 	if(xsb==0) y=x; else y= -x;	/* y = |x| */
+#endif
 	hx &= 0x7fff;		/* high word of |x| */
 
 /* filter out huge and non-finite argument */



CVS commit: src/lib/libm/src

2017-02-09 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Feb  9 21:23:11 UTC 2017

Modified Files:
src/lib/libm/src: e_j0.c e_j0f.c e_j1.c e_j1f.c

Log Message:
Appease static analyzers by making all code paths which assign
values into p,q sane. Get rid of redundant assignment. Indent
for legibility. NFC.

This doesn't create a functional difference, as all callers
test number >= 0x4000 anyway.

To see this, note the following:
- consistently, hx is the high bits of x, lx is the low bits,
  x is the float.
- & 0x7fff zeroes the sign bit, as does fabs.

A case where it isn't easy to see that there's no functional
change is y1, which does:

ix = hx & 0x7fff (zero signbit of high bits of x)
y = fabs(x) (this has a zeroed signbit but otherwise same as x)
ix >= 0x4000
  pone(y); qone(y)

qone(x) (also pone) do:
  ix = hx & 0x7fff

ix in qone and in the calling function are the same number,
and the comparison applies for both, and ix < 0x4000 isn't
possible.

(Also, no explosions seem to happen when I feed it random numbers)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libm/src/e_j0.c src/lib/libm/src/e_j1.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libm/src/e_j0f.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libm/src/e_j1f.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/src/e_j0.c
diff -u src/lib/libm/src/e_j0.c:1.12 src/lib/libm/src/e_j0.c:1.13
--- src/lib/libm/src/e_j0.c:1.12	Mon Aug 20 16:01:38 2007
+++ src/lib/libm/src/e_j0.c	Thu Feb  9 21:23:11 2017
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_j0.c,v 1.12 2007/08/20 16:01:38 drochner Exp $");
+__RCSID("$NetBSD: e_j0.c,v 1.13 2017/02/09 21:23:11 maya Exp $");
 #endif
 
 /* __ieee754_j0(x), __ieee754_y0(x)
@@ -277,13 +277,12 @@ pzero(double x)
 	double z,r,s;
 	int32_t ix;
 
-	p = q = 0;
 	GET_HIGH_WORD(ix,x);
 	ix &= 0x7fff;
-	if(ix>=0x4020) {p = pR8; q= pS8;}
-	else if(ix>=0x40122E8B){p = pR5; q= pS5;}
-	else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
-	else if(ix>=0x4000){p = pR2; q= pS2;}
+	if(ix>=0x4020) {p = pR8; q= pS8;}
+	else if(ix>=0x40122E8B){p = pR5; q= pS5;}
+	else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
+	else /*if(ix>=0x4000)*/{p = pR2; q= pS2;}
 	z = one/(x*x);
 	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5];
 	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4];
@@ -375,13 +374,12 @@ qzero(double x)
 	double s,r,z;
 	int32_t ix;
 
-	p = q = 0;
 	GET_HIGH_WORD(ix,x);
 	ix &= 0x7fff;
-	if(ix>=0x4020) {p = qR8; q= qS8;}
-	else if(ix>=0x40122E8B){p = qR5; q= qS5;}
-	else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
-	else if(ix>=0x4000){p = qR2; q= qS2;}
+	if(ix>=0x4020) {p = qR8; q= qS8;}
+	else if(ix>=0x40122E8B){p = qR5; q= qS5;}
+	else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
+	else /*if(ix>=0x4000)*/{p = qR2; q= qS2;}
 	z = one/(x*x);
 	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5];
 	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]);
Index: src/lib/libm/src/e_j1.c
diff -u src/lib/libm/src/e_j1.c:1.12 src/lib/libm/src/e_j1.c:1.13
--- src/lib/libm/src/e_j1.c:1.12	Mon Aug 20 16:01:38 2007
+++ src/lib/libm/src/e_j1.c	Thu Feb  9 21:23:11 2017
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_j1.c,v 1.12 2007/08/20 16:01:38 drochner Exp $");
+__RCSID("$NetBSD: e_j1.c,v 1.13 2017/02/09 21:23:11 maya Exp $");
 #endif
 
 /* __ieee754_j1(x), __ieee754_y1(x)
@@ -271,13 +271,12 @@ pone(double x)
 	double z,r,s;
 int32_t ix;
 
-	p = q = 0;
 	GET_HIGH_WORD(ix,x);
 	ix &= 0x7fff;
-if(ix>=0x4020) {p = pr8; q= ps8;}
-else if(ix>=0x40122E8B){p = pr5; q= ps5;}
-else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
-else if(ix>=0x4000){p = pr2; q= ps2;}
+if(ix>=0x4020) {p = pr8; q= ps8;}
+else if(ix>=0x40122E8B){p = pr5; q= ps5;}
+else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
+else /*if(ix>=0x4000)*/{p = pr2; q= ps2;}
 z = one/(x*x);
 r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5];
 s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4];
@@ -370,13 +369,12 @@ qone(double x)
 	double  s,r,z;
 	int32_t ix;
 
-	p = q = 0;
 	GET_HIGH_WORD(ix,x);
 	ix &= 0x7fff;
-	if(ix>=0x4020) {p = qr8; q= qs8;}
-	else if(ix>=0x40122E8B){p = qr5; q= qs5;}
-	else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
-	else if(ix>=0x4000){p = qr2; q= qs2;}
+	if(ix>=0x4020) {p = qr8; q= qs8;}
+	else if(ix>=0x40122E8B){p = qr5; q= qs5;}
+	else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
+	else /*if(ix>=0x4000)*/{p = qr2; q= qs2;}
 	z = one/(x*x);
 	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5];
 	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]);

Index: src/lib/libm/src/e_j0f.c
diff -u src/lib/libm/src/e_j0f.c:1.1

CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 16:06:19 UTC 2017

Modified Files:
src/lib/libm/man: ceil.3

Log Message:
Add comma between two Nm entries in the NAME section.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libm/man/ceil.3

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/man/ceil.3
diff -u src/lib/libm/man/ceil.3:1.20 src/lib/libm/man/ceil.3:1.21
--- src/lib/libm/man/ceil.3:1.20	Tue Nov 12 00:10:29 2013
+++ src/lib/libm/man/ceil.3	Wed Feb  1 16:06:19 2017
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)ceil.3	5.1 (Berkeley) 5/2/91
-.\"	$NetBSD: ceil.3,v 1.20 2013/11/12 00:10:29 joerg Exp $
+.\"	$NetBSD: ceil.3,v 1.21 2017/02/01 16:06:19 abhinav Exp $
 .\"
 .Dd November 12, 2013
 .Dt CEIL 3
@@ -36,7 +36,7 @@
 .Nm ceilf ,
 .Nm ceill ,
 .Nm floor ,
-.Nm floorf
+.Nm floorf ,
 .Nm floorl
 .Nd ceiling and floor
 .Sh LIBRARY



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 15:57:47 UTC 2017

Modified Files:
src/lib/libm/man: modf.3

Log Message:
Add modff and modfl in the NAME section.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/man/modf.3

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/man/modf.3
diff -u src/lib/libm/man/modf.3:1.2 src/lib/libm/man/modf.3:1.3
--- src/lib/libm/man/modf.3:1.2	Tue Mar 15 15:29:19 2016
+++ src/lib/libm/man/modf.3	Wed Feb  1 15:57:47 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: modf.3,v 1.2 2016/03/15 15:29:19 nros Exp $
+.\"	$NetBSD: modf.3,v 1.3 2017/02/01 15:57:47 abhinav Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -37,7 +37,9 @@
 .Dt MODF 3
 .Os
 .Sh NAME
-.Nm modf
+.Nm modf ,
+.Nm modff ,
+.Nm modfl
 .Nd extract signed integral and fractional values from floating-point number
 .Sh LIBRARY
 .Lb libm



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 15:49:02 UTC 2017

Modified Files:
src/lib/libm/man: ieee_test.3

Log Message:
Fix a sentence.
Correct function name in the DESCRIPTION section.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libm/man/ieee_test.3

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/man/ieee_test.3
diff -u src/lib/libm/man/ieee_test.3:1.12 src/lib/libm/man/ieee_test.3:1.13
--- src/lib/libm/man/ieee_test.3:1.12	Tue Sep 13 07:11:43 2011
+++ src/lib/libm/man/ieee_test.3	Wed Feb  1 15:49:02 2017
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
-.\"	$NetBSD: ieee_test.3,v 1.12 2011/09/13 07:11:43 njoly Exp $
+.\"	$NetBSD: ieee_test.3,v 1.13 2017/02/01 15:49:02 abhinav Exp $
 .\"
 .Dd August 3, 2011
 .Dt IEEE_TEST 3
@@ -61,7 +61,7 @@
 .Sh DESCRIPTION
 These functions allow users to test conformance to
 .St -ieee754 .
-Their use is not otherwise recommended.
+Their use is otherwise not recommended.
 .Pp
 .Fn logb x
 returns
@@ -73,7 +73,7 @@ a signed integer converted to double\-pr
 .Fn logb 0
 = -\*(If with a division by zero exception.
 .Pp
-.Fn scalbn x n
+.Fn scalb x n
 returns
 .Fa x Ns \(**(2** Ns Fa n )
 computed by exponent manipulation.



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:51:29 UTC 2017

Modified Files:
src/lib/libm/man: log.3

Log Message:
Also, fix spelling of described.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/man/log.3

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/man/log.3
diff -u src/lib/libm/man/log.3:1.4 src/lib/libm/man/log.3:1.5
--- src/lib/libm/man/log.3:1.4	Wed Feb  1 14:42:28 2017
+++ src/lib/libm/man/log.3	Wed Feb  1 14:51:29 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: log.3,v 1.4 2017/02/01 14:42:28 abhinav Exp $
+.\" $NetBSD: log.3,v 1.5 2017/02/01 14:51:29 abhinav Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -91,7 +91,7 @@ functions return the base 2 logarithm.
 .Sh RETURN VALUES
 Upon successful completion, the functions return the logarithm of
 .Fa x
-as descibed above.
+as described above.
 Otherwise the following may occur:
 .Bl -enum -offset indent
 .It



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:46:51 UTC 2017

Modified Files:
src/lib/libm/man: exp.3

Log Message:
Fix sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libm/man/exp.3

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/man/exp.3
diff -u src/lib/libm/man/exp.3:1.30 src/lib/libm/man/exp.3:1.31
--- src/lib/libm/man/exp.3:1.30	Wed Feb  1 14:37:20 2017
+++ src/lib/libm/man/exp.3	Wed Feb  1 14:46:51 2017
@@ -27,7 +27,7 @@
 .\"
 .\" from: @(#)exp.3	6.12 (Berkeley) 7/31/91
 .\" $FreeBSD: src/lib/msun/man/exp.3,v 1.24 2008/01/18 21:43:00 das Exp $
-.\"	$NetBSD: exp.3,v 1.30 2017/02/01 14:37:20 abhinav Exp $
+.\"	$NetBSD: exp.3,v 1.31 2017/02/01 14:46:51 abhinav Exp $
 .\"
 .Dd September 13, 2011
 .Dt EXP 3
@@ -105,7 +105,7 @@ and cause a reserved operand fault on a
 .Sh STANDARDS
 The
 .Fn exp
-functions conform to
+function conforms to
 .St -ansiC .
 The
 .Fn exp2 ,



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:42:28 UTC 2017

Modified Files:
src/lib/libm/man: log.3

Log Message:
Remove comma after last Nm entry.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/man/log.3

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/man/log.3
diff -u src/lib/libm/man/log.3:1.3 src/lib/libm/man/log.3:1.4
--- src/lib/libm/man/log.3:1.3	Tue Sep 13 08:51:32 2011
+++ src/lib/libm/man/log.3	Wed Feb  1 14:42:28 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: log.3,v 1.3 2011/09/13 08:51:32 wiz Exp $
+.\" $NetBSD: log.3,v 1.4 2017/02/01 14:42:28 abhinav Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -35,7 +35,7 @@
 .Nm log1p ,
 .Nm log1pf
 .Nm log2 ,
-.Nm log2f ,
+.Nm log2f
 .Nd logarithm functions
 .Sh LIBRARY
 .Lb libm



CVS commit: src/lib/libm/man

2017-02-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb  1 14:37:20 UTC 2017

Modified Files:
src/lib/libm/man: exp.3

Log Message:
Remove comma after the last Nm entry.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libm/man/exp.3

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/man/exp.3
diff -u src/lib/libm/man/exp.3:1.29 src/lib/libm/man/exp.3:1.30
--- src/lib/libm/man/exp.3:1.29	Tue Nov  6 21:43:37 2012
+++ src/lib/libm/man/exp.3	Wed Feb  1 14:37:20 2017
@@ -27,7 +27,7 @@
 .\"
 .\" from: @(#)exp.3	6.12 (Berkeley) 7/31/91
 .\" $FreeBSD: src/lib/msun/man/exp.3,v 1.24 2008/01/18 21:43:00 das Exp $
-.\"	$NetBSD: exp.3,v 1.29 2012/11/06 21:43:37 dholland Exp $
+.\"	$NetBSD: exp.3,v 1.30 2017/02/01 14:37:20 abhinav Exp $
 .\"
 .Dd September 13, 2011
 .Dt EXP 3
@@ -40,7 +40,7 @@
 .Nm exp2f ,
 .\" .Nm exp2l ,
 .Nm expm1 ,
-.Nm expm1f ,
+.Nm expm1f
 .Nd exponential functions
 .Sh LIBRARY
 .Lb libm



CVS commit: src/lib/libm

2017-01-20 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Jan 20 22:10:38 UTC 2017

Modified Files:
src/lib/libm: shlib_version

Log Message:
add a wishlist for a major bump. isinff and compatibility cabs.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libm/shlib_version

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/shlib_version
diff -u src/lib/libm/shlib_version:1.14 src/lib/libm/shlib_version:1.15
--- src/lib/libm/shlib_version:1.14	Fri Oct 10 00:48:18 2014
+++ src/lib/libm/shlib_version	Fri Jan 20 22:10:38 2017
@@ -1,5 +1,8 @@
-#	$NetBSD: shlib_version,v 1.14 2014/10/10 00:48:18 christos Exp $
+#	$NetBSD: shlib_version,v 1.15 2017/01/20 22:10:38 maya Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
+# things we wish to do on next major version bump:
+# - remove compatibility cabs
+# - hide isinff
 major=0
 minor=11



CVS commit: src/lib/libm/complex

2017-01-01 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun Jan  1 19:32:14 UTC 2017

Modified Files:
src/lib/libm/complex: csqrt.c csqrtf.c

Log Message:
compare to zero, instead of using signbit, and be more specific in comment.
-0.0 > 0 is also false. no functional change.

while this is mostly a change to be consistent in style (the rest of the
comparisons aren't done with signbit), it is also a micro-optimization.

with our default compile flags, calls to copysign are libm calls (and a
whole function call!!). this generates more efficient code.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/complex/csqrt.c \
src/lib/libm/complex/csqrtf.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/complex/csqrt.c
diff -u src/lib/libm/complex/csqrt.c:1.3 src/lib/libm/complex/csqrt.c:1.4
--- src/lib/libm/complex/csqrt.c:1.3	Sat Dec 31 20:01:15 2016
+++ src/lib/libm/complex/csqrt.c	Sun Jan  1 19:32:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrt.c,v 1.3 2016/12/31 20:01:15 maya Exp $ */
+/* $NetBSD: csqrt.c,v 1.4 2017/01/01 19:32:14 maya Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -41,7 +41,10 @@ csqrt(double complex z)
 	x = creal (z);
 	y = cimag (z);
 
-	/* Input is a real number that isn't on the branch cut */
+	/* 
+	 * input is a real number and imaginary part isn't -0.0.
+	 * negative zero is on the branch cut.
+	 */
 	if ((y == 0.0) && !signbit(y)) {
 		if (x == 0.0) {
 			w = 0.0 + y * I;
@@ -93,9 +96,9 @@ csqrt(double complex z)
 		t = scale * fabs((0.5 * y) / r);
 		r *= scale;
 	}
-	if (signbit(y))
-		w = t - r * I;
-	else
+	if (y > 0)
 		w = t + r * I;
+	else
+		w = t - r * I;
 	return w;
 }
Index: src/lib/libm/complex/csqrtf.c
diff -u src/lib/libm/complex/csqrtf.c:1.3 src/lib/libm/complex/csqrtf.c:1.4
--- src/lib/libm/complex/csqrtf.c:1.3	Sat Dec 31 22:54:56 2016
+++ src/lib/libm/complex/csqrtf.c	Sun Jan  1 19:32:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrtf.c,v 1.3 2016/12/31 22:54:56 maya Exp $ */
+/* $NetBSD: csqrtf.c,v 1.4 2017/01/01 19:32:14 maya Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -41,7 +41,10 @@ csqrtf(float complex z)
 	x = crealf (z);
 	y = cimagf (z);
 
-	/* Input is a real number that isn't on the branch cut */
+	/* 
+	 * input is a real number and imaginary part isn't -0.0.
+	 * negative zero is on the branch cut.
+	 */
 	if ((y == 0.0f) && !signbit(y)) {
 		if (x < 0.0f) {
 			w = 0.0f + sqrtf(-x) * I;
@@ -93,9 +96,9 @@ csqrtf(float complex z)
 		r *= scale;
 	}
 
-	if (signbit(y))
-		w = t - r * I;
-	else
+	if (y > 0)
 		w = t + r * I;
+	else
+		w = t - r * I;
 	return w;
 }



CVS commit: src/lib/libm/complex

2016-12-31 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Dec 31 22:54:56 UTC 2016

Modified Files:
src/lib/libm/complex: csqrtf.c

Log Message:
similar to csqrt, spare ourselves a fabsf call. we already check sign
later on, use this to our advantage.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/complex/csqrtf.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/complex/csqrtf.c
diff -u src/lib/libm/complex/csqrtf.c:1.2 src/lib/libm/complex/csqrtf.c:1.3
--- src/lib/libm/complex/csqrtf.c:1.2	Sat Dec 31 20:01:15 2016
+++ src/lib/libm/complex/csqrtf.c	Sat Dec 31 22:54:56 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrtf.c,v 1.2 2016/12/31 20:01:15 maya Exp $ */
+/* $NetBSD: csqrtf.c,v 1.3 2016/12/31 22:54:56 maya Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -55,12 +55,13 @@ csqrtf(float complex z)
 	}
 
 	if (x == 0.0f) {
-		r = fabsf(y);
-		r = sqrtf(0.5f * r);
-		if (y > 0)
+		if (y > 0) {
+			r = sqrtf(0.5f * y);
 			w = r + r * I;
-		else
+		} else {
+			r = sqrtf(-0.5f * y);
 			w = r - r * I;
+		}
 		return w;
 	}
 



CVS commit: src/lib/libm/complex

2016-12-31 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Dec 31 20:01:15 UTC 2016

Modified Files:
src/lib/libm/complex: csqrt.c csqrtf.c

Log Message:
csqrt has a branch cut on the negative real axis, and this requires
delicacy in order to maintain continuity around it.

we have an initial case to deal with a fairly common case: getting
a real number. Avoid dealing with the branch cut in this case by
checking if the real part is negative.

later, -0.0 < 0 is not met, so instead, test for a negative number
using signbit, so negative zero is also treated as a negative number.

Fixes last part of PR lib/51427: libm issues triggered by py-numpy

ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/complex/csqrt.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/complex/csqrtf.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/complex/csqrt.c
diff -u src/lib/libm/complex/csqrt.c:1.2 src/lib/libm/complex/csqrt.c:1.3
--- src/lib/libm/complex/csqrt.c:1.2	Sat Dec 31 15:33:03 2016
+++ src/lib/libm/complex/csqrt.c	Sat Dec 31 20:01:15 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrt.c,v 1.2 2016/12/31 15:33:03 maya Exp $ */
+/* $NetBSD: csqrt.c,v 1.3 2016/12/31 20:01:15 maya Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -41,7 +41,8 @@ csqrt(double complex z)
 	x = creal (z);
 	y = cimag (z);
 
-	if (y == 0.0) {
+	/* Input is a real number that isn't on the branch cut */
+	if ((y == 0.0) && !signbit(y)) {
 		if (x == 0.0) {
 			w = 0.0 + y * I;
 		} else {
@@ -92,7 +93,7 @@ csqrt(double complex z)
 		t = scale * fabs((0.5 * y) / r);
 		r *= scale;
 	}
-	if (y < 0)
+	if (signbit(y))
 		w = t - r * I;
 	else
 		w = t + r * I;

Index: src/lib/libm/complex/csqrtf.c
diff -u src/lib/libm/complex/csqrtf.c:1.1 src/lib/libm/complex/csqrtf.c:1.2
--- src/lib/libm/complex/csqrtf.c:1.1	Mon Aug 20 16:01:37 2007
+++ src/lib/libm/complex/csqrtf.c	Sat Dec 31 20:01:15 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrtf.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */
+/* $NetBSD: csqrtf.c,v 1.2 2016/12/31 20:01:15 maya Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -41,7 +41,8 @@ csqrtf(float complex z)
 	x = crealf (z);
 	y = cimagf (z);
 
-	if (y == 0.0f) {
+	/* Input is a real number that isn't on the branch cut */
+	if ((y == 0.0f) && !signbit(y)) {
 		if (x < 0.0f) {
 			w = 0.0f + sqrtf(-x) * I;
 			return w;
@@ -91,7 +92,7 @@ csqrtf(float complex z)
 		r *= scale;
 	}
 
-	if (y < 0)
+	if (signbit(y))
 		w = t - r * I;
 	else
 		w = t + r * I;



CVS commit: src/lib/libm/complex

2016-12-31 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Dec 31 15:33:03 UTC 2016

Modified Files:
src/lib/libm/complex: csqrt.c

Log Message:
Spare ourselves a fabs call. We already check the sign later.
w = r + y*I is the same as w = r because this is the y == 0 case.

no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/complex/csqrt.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/complex/csqrt.c
diff -u src/lib/libm/complex/csqrt.c:1.1 src/lib/libm/complex/csqrt.c:1.2
--- src/lib/libm/complex/csqrt.c:1.1	Mon Aug 20 16:01:37 2007
+++ src/lib/libm/complex/csqrt.c	Sat Dec 31 15:33:03 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrt.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */
+/* $NetBSD: csqrt.c,v 1.2 2016/12/31 15:33:03 maya Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -45,23 +45,24 @@ csqrt(double complex z)
 		if (x == 0.0) {
 			w = 0.0 + y * I;
 		} else {
-			r = fabs(x);
-			r = sqrt(r);
 			if (x < 0.0) {
+r = sqrt(-x);
 w = 0.0 + r * I;
 			} else {
-w = r + y * I;
+r = sqrt(x);
+w = r;
 			}
 		}
 		return w;
 	}
 	if (x == 0.0) {
-		r = fabs(y);
-		r = sqrt(0.5 * r);
-		if (y > 0)
+		if (y > 0) {
+			r = sqrt(0.5 * y);
 			w = r + r * I;
-		else
+		} else {
+			r = sqrt(-0.5 * y);
 			w = r - r * I;
+		}
 		return w;
 	}
 	/* Rescale to avoid internal overflow or underflow.  */



CVS commit: src/lib/libm

2016-12-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec  8 18:42:01 UTC 2016

Modified Files:
src/lib/libm: Makefile

Log Message:
more stuff needs -mfpu=vfp


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/lib/libm/Makefile

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.186 src/lib/libm/Makefile:1.187
--- src/lib/libm/Makefile:1.186	Wed Sep 21 10:11:40 2016
+++ src/lib/libm/Makefile	Thu Dec  8 13:42:01 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.186 2016/09/21 14:11:40 christos Exp $
+#  $NetBSD: Makefile,v 1.187 2016/12/08 18:42:01 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -69,7 +69,9 @@ COPTS+=	-mfloat-ieee -mieee-with-inexact
 .PATH.c: ${.CURDIR}/arch/arm
 COMMON_SRCS+= fenv.c s_nexttowardf.c \
 	s_nearbyint.c s_rintl.c
-COPTS.fenv.c+=	-mfpu=vfp
+.for f in fenv.c lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
+COPTS.$f +=	-mfpu=vfp
+.endfor
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .if (${MKSOFTFLOAT} == "no")
 .PATH.S: ${.CURDIR}/arch/arm



CVS commit: src/lib/libm

2016-09-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 21 14:11:40 UTC 2016

Modified Files:
src/lib/libm: Makefile
src/lib/libm/noieee_src: n_asincos.c
Added Files:
src/lib/libm/noieee_src: n_atanhf.c

Log Message:
deal with namespace issues and missing atanhf for vax.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/lib/libm/Makefile
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/noieee_src/n_asincos.c
cvs rdiff -u -r0 -r1.1 src/lib/libm/noieee_src/n_atanhf.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.185 src/lib/libm/Makefile:1.186
--- src/lib/libm/Makefile:1.185	Wed Sep  7 10:41:33 2016
+++ src/lib/libm/Makefile	Wed Sep 21 10:11:40 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.185 2016/09/07 14:41:33 jakllsch Exp $
+#  $NetBSD: Makefile,v 1.186 2016/09/21 14:11:40 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -243,7 +243,8 @@ COPTS.compat_cabs.c=	${${ACTIVE_CC} == "
 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_cosh.c \
+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_lgamma.c n_j0.c n_j1.c n_jn.c n_log.c n_log10.c n_log1p.c \

Index: src/lib/libm/noieee_src/n_asincos.c
diff -u src/lib/libm/noieee_src/n_asincos.c:1.8 src/lib/libm/noieee_src/n_asincos.c:1.9
--- src/lib/libm/noieee_src/n_asincos.c:1.8	Sun Nov 24 09:41:53 2013
+++ src/lib/libm/noieee_src/n_asincos.c	Wed Sep 21 10:11:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: n_asincos.c,v 1.8 2013/11/24 14:41:53 martin Exp $	*/
+/*	$NetBSD: n_asincos.c,v 1.9 2016/09/21 14:11:40 christos Exp $	*/
 /*
  * Copyright (c) 1985, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -27,6 +27,8 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+#include 
+__RCSID("$NetBSD: n_asincos.c,v 1.9 2016/09/21 14:11:40 christos Exp $");
 
 #ifndef lint
 #if 0
@@ -86,8 +88,16 @@ static char sccsid[] = "@(#)asincos.c	8.
  *  1.99 ulps.
  */
 
+#include "namespace.h"
 #include "mathimpl.h"
 
+#ifdef __weak_alias
+__weak_alias(asinf, _asinf)
+#endif
+#ifdef __weak_alias
+__weak_alias(asin, _asin)
+#endif
+
 double
 asin(double x)
 {

Added files:

Index: src/lib/libm/noieee_src/n_atanhf.c
diff -u /dev/null src/lib/libm/noieee_src/n_atanhf.c:1.1
--- /dev/null	Wed Sep 21 10:11:40 2016
+++ src/lib/libm/noieee_src/n_atanhf.c	Wed Sep 21 10:11:40 2016
@@ -0,0 +1,84 @@
+/*  $NetBSD: n_atanhf.c,v 1.1 2016/09/21 14:11:40 christos Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ *	The Regents of the University of California.  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.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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_atanhf.c,v 1.1 2016/09/21 14:11:40 christos Exp $");
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)atanh.c	8.1 (Berkeley) 6/4/93";
+#endif
+#endif /* not lint */
+
+/* ATANH(X)
+ * RETURN THE HYPERBOLIC ARC TANGENT OF X
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 2/7/85, 3/7/85, 8/18/85.
+ *
+ * Required kernel function:
+ *	log1p(x) 	...return log(1+x)
+ *
+ * Method :
+ *	

CVS commit: src/lib/libm/complex

2016-09-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 20 18:25:20 UTC 2016

Modified Files:
src/lib/libm/complex: catrig.c

Log Message:
fix VAX!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/complex/catrig.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/complex/catrig.c
diff -u src/lib/libm/complex/catrig.c:1.1 src/lib/libm/complex/catrig.c:1.2
--- src/lib/libm/complex/catrig.c:1.1	Mon Sep 19 18:05:05 2016
+++ src/lib/libm/complex/catrig.c	Tue Sep 20 14:25:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: catrig.c,v 1.1 2016/09/19 22:05:05 christos Exp $	*/
+/*	$NetBSD: catrig.c,v 1.2 2016/09/20 18:25:20 christos Exp $	*/
 /*-
  * Copyright (c) 2012 Stephen Montgomery-Smith 
  * All rights reserved.
@@ -29,7 +29,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/lib/msun/src/catrig.c 275819 2014-12-16 09:21:56Z ed $");
 #endif
-__RCSID("$NetBSD: catrig.c,v 1.1 2016/09/19 22:05:05 christos Exp $");
+__RCSID("$NetBSD: catrig.c,v 1.2 2016/09/20 18:25:20 christos Exp $");
 
 #include "namespace.h"
 #ifdef __weak_alias
@@ -59,15 +59,24 @@ __weak_alias(catan, _catan)
 static const double
 A_crossover =		10, /* Hull et al suggest 1.5, but 10 works better */
 B_crossover =		0.6417,			/* suggested by Hull et al */
-FOUR_SQRT_MIN =		0x1p-509,		/* >= 4 * sqrt(DBL_MIN) */
-QUARTER_SQRT_MAX =	0x1p509,		/* <= sqrt(DBL_MAX) / 4 */
 m_e =			2.7182818284590452e0,	/*  0x15bf0a8b145769.0p-51 */
 m_ln2 =			6.9314718055994531e-1,	/*  0x162e42fefa39ef.0p-53 */
 pio2_hi =		1.5707963267948966e0,	/*  0x1921fb54442d18.0p-52 */
 RECIP_EPSILON =		1 / DBL_EPSILON,
 SQRT_3_EPSILON =	2.5809568279517849e-8,	/*  0x1bb67ae8584caa.0p-78 */
 SQRT_6_EPSILON =	3.6500241499888571e-8,	/*  0x13988e1409212e.0p-77 */
+#if DBL_MAX_EXP == 1024	/* IEEE */
+FOUR_SQRT_MIN =		0x1p-509,		/* >= 4 * sqrt(DBL_MIN) */
+QUARTER_SQRT_MAX =	0x1p509,		/* <= sqrt(DBL_MAX) / 4 */
 SQRT_MIN =		0x1p-511;		/* >= sqrt(DBL_MIN) */
+#elif DBL_MAX_EXP == 127 /* VAX */
+FOUR_SQRT_MIN =		0x1p-62,		/* >= 4 * sqrt(DBL_MIN) */
+QUARTER_SQRT_MAX =	0x1p62,			/* <= sqrt(DBL_MAX) / 4 */
+SQRT_MIN =		0x1p-64;		/* >= sqrt(DBL_MIN) */
+#else
+	#error "unsupported floating point format"
+#endif
+
 
 static const volatile double
 pio2_lo =		6.1232339957367659e-17;	/*  0x11a62633145c07.0p-106 */



CVS commit: src/lib/libm

2016-09-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 19 22:05:05 UTC 2016

Modified Files:
src/lib/libm/complex: Makefile.inc
src/lib/libm/src: math_private.h
Added Files:
src/lib/libm/complex: catrig.c catrigf.c catrigl.c

Log Message:
Add the complex trig functions from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/complex/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libm/complex/catrig.c \
src/lib/libm/complex/catrigf.c src/lib/libm/complex/catrigl.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libm/src/math_private.h

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/complex/Makefile.inc
diff -u src/lib/libm/complex/Makefile.inc:1.8 src/lib/libm/complex/Makefile.inc:1.9
--- src/lib/libm/complex/Makefile.inc:1.8	Fri Oct 10 08:43:07 2014
+++ src/lib/libm/complex/Makefile.inc	Mon Sep 19 18:05:05 2016
@@ -1,14 +1,25 @@
-# $NetBSD: Makefile.inc,v 1.8 2014/10/10 12:43:07 christos Exp $
+# $NetBSD: Makefile.inc,v 1.9 2016/09/19 22:05:05 christos Exp $
 
 .PATH: ${.CURDIR}/complex
 
-COMPLEX_SRCS = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c catan.c \
+COMPLEX_SRCS = cabs.c carg.c \
 	ccos.c ccosh.c cephes_subr.c cexp.c clog.c conj.c cpow.c cproj.c \
-	cimag.c creal.c csin.c csinh.c csqrt.c ctan.c ctanh.c catanh.c
+	cimag.c creal.c csin.c csinh.c csqrt.c ctan.c ctanh.c \
+	catrig.c
+CATRIG_SRCS = cacos.c cacosh.c casin.c casinh.c catan.c catanh.c
 
+CPPFLAGS+=-I${.CURDIR}/src
 .for i in ${COMPLEX_SRCS}
 SRCS+=	$i ${i:S/.c/f.c/} ${i:S/.c/l.c/}
-MAN+= ${i:Ncephes_*:S/.c/.3/}
-MLINKS+= ${i:Ncephes_*:S/.c/.3/} ${i:Ncephes_*:S/.c/f.3/}
-MLINKS+= ${i:Ncephes_*:S/.c/.3/} ${i:Ncephes_*:S/.c/l.3/}
+MAN+= ${i:Ncatrig*:Ncephes_*:S/.c/.3/}
+MLINKS+= ${i:Ncatrig*:Ncephes_*:S/.c/.3/} ${i:Ncatrig*:Ncephes_*:S/.c/f.3/}
+MLINKS+= ${i:Ncatrig*:Ncephes_*:S/.c/.3/} ${i:Ncatrig*:Ncephes_*:S/.c/l.3/}
 .endfor
+
+.for i in ${CATRIG_SRCS}
+MAN+= ${i:S/.c/.3/}
+MLINKS+= ${i:S/.c/.3/} ${i:S/.c/f.3/}
+MLINKS+= ${i:S/.c/.3/} ${i:S/.c/l.3/}
+.endfor
+
+

Index: src/lib/libm/src/math_private.h
diff -u src/lib/libm/src/math_private.h:1.22 src/lib/libm/src/math_private.h:1.23
--- src/lib/libm/src/math_private.h:1.22	Thu Mar 26 07:59:38 2015
+++ src/lib/libm/src/math_private.h	Mon Sep 19 18:05:05 2016
@@ -11,7 +11,7 @@
 
 /*
  * from: @(#)fdlibm.h 5.1 93/09/24
- * $NetBSD: math_private.h,v 1.22 2015/03/26 11:59:38 justin Exp $
+ * $NetBSD: math_private.h,v 1.23 2016/09/19 22:05:05 christos Exp $
  */
 
 #ifndef _MATH_PRIVATE_H_
@@ -223,6 +223,57 @@ typedef union {
 #define	REAL_PART(z)	((z).parts[0])
 #define	IMAG_PART(z)	((z).parts[1])
 
+/*
+ * Inline functions that can be used to construct complex values.
+ *
+ * The C99 standard intends x+I*y to be used for this, but x+I*y is
+ * currently unusable in general since gcc introduces many overflow,
+ * underflow, sign and efficiency bugs by rewriting I*y as
+ * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product.
+ * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted
+ * to -0.0+I*0.0.
+ *
+ * The C11 standard introduced the macros CMPLX(), CMPLXF() and CMPLXL()
+ * to construct complex values.  Compilers that conform to the C99
+ * standard require the following functions to avoid the above issues.
+ */
+
+#ifndef CMPLXF
+static __inline float complex
+CMPLXF(float x, float y)
+{
+	float_complex z;
+
+	REAL_PART(z) = x;
+	IMAG_PART(z) = y;
+	return (z.z);
+}
+#endif
+
+#ifndef CMPLX
+static __inline double complex
+CMPLX(double x, double y)
+{
+	double_complex z;
+
+	REAL_PART(z) = x;
+	IMAG_PART(z) = y;
+	return (z.z);
+}
+#endif
+
+#ifndef CMPLXL
+static __inline long double complex
+CMPLXL(long double x, long double y)
+{
+	long_double_complex z;
+
+	REAL_PART(z) = x;
+	IMAG_PART(z) = y;
+	return (z.z);
+}
+#endif
+
 #endif	/* _COMPLEX_H */
 
 /* ieee style elementary functions */

Added files:

Index: src/lib/libm/complex/catrig.c
diff -u /dev/null src/lib/libm/complex/catrig.c:1.1
--- /dev/null	Mon Sep 19 18:05:05 2016
+++ src/lib/libm/complex/catrig.c	Mon Sep 19 18:05:05 2016
@@ -0,0 +1,653 @@
+/*	$NetBSD: catrig.c,v 1.1 2016/09/19 22:05:05 christos Exp $	*/
+/*-
+ * Copyright (c) 2012 Stephen Montgomery-Smith 
+ * 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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NO

CVS commit: src/lib/libm

2016-09-07 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Sep  7 14:41:33 UTC 2016

Modified Files:
src/lib/libm: Makefile

Log Message:
Actually get fma(3) and friends into ARM libm.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/lib/libm/Makefile

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.184 src/lib/libm/Makefile:1.185
--- src/lib/libm/Makefile:1.184	Sat Aug 27 09:15:44 2016
+++ src/lib/libm/Makefile	Wed Sep  7 14:41:33 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.184 2016/08/27 09:15:44 christos Exp $
+#  $NetBSD: Makefile,v 1.185 2016/09/07 14:41:33 jakllsch Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -70,6 +70,7 @@ COPTS+=	-mfloat-ieee -mieee-with-inexact
 COMMON_SRCS+= fenv.c s_nexttowardf.c \
 	s_nearbyint.c s_rintl.c
 COPTS.fenv.c+=	-mfpu=vfp
+COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .if (${MKSOFTFLOAT} == "no")
 .PATH.S: ${.CURDIR}/arch/arm
 ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S



CVS commit: src/lib/libm/src

2016-08-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 27 10:03:16 UTC 2016

Modified Files:
src/lib/libm/src: k_standard.c

Log Message:
no need for stdio.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libm/src/k_standard.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/src/k_standard.c
diff -u src/lib/libm/src/k_standard.c:1.21 src/lib/libm/src/k_standard.c:1.22
--- src/lib/libm/src/k_standard.c:1.21	Sat Aug 27 06:00:38 2016
+++ src/lib/libm/src/k_standard.c	Sat Aug 27 06:03:16 2016
@@ -12,13 +12,12 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: k_standard.c,v 1.21 2016/08/27 10:00:38 christos Exp $");
+__RCSID("$NetBSD: k_standard.c,v 1.22 2016/08/27 10:03:16 christos Exp $");
 #endif
 
 #include "math.h"
 #include "math_private.h"
 #include 
-#include 
 
 #ifndef _USE_WRITE
 #include 			/* fputs(), stderr */



CVS commit: src/lib/libm/src

2016-08-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 27 10:00:38 UTC 2016

Modified Files:
src/lib/libm/src: k_standard.c

Log Message:
correct case 23 for -0.0


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libm/src/k_standard.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/src/k_standard.c
diff -u src/lib/libm/src/k_standard.c:1.20 src/lib/libm/src/k_standard.c:1.21
--- src/lib/libm/src/k_standard.c:1.20	Tue Sep  8 01:23:31 2015
+++ src/lib/libm/src/k_standard.c	Sat Aug 27 06:00:38 2016
@@ -12,12 +12,13 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: k_standard.c,v 1.20 2015/09/08 05:23:31 dholland Exp $");
+__RCSID("$NetBSD: k_standard.c,v 1.21 2016/08/27 10:00:38 christos Exp $");
 #endif
 
 #include "math.h"
 #include "math_private.h"
 #include 
+#include 
 
 #ifndef _USE_WRITE
 #include 			/* fputs(), stderr */
@@ -468,8 +469,11 @@ __kernel_standard(double x, double y, in
 		exc.name = type < 100 ? "pow" : "powf";
 		if (_LIB_VERSION == _SVID_)
 		  exc.retval = zero;
-		else
+		else {
 		  exc.retval = HUGE_VAL;
+		  y *= 0.5;
+		  if(signbit(x)&&rint(y)!=y) exc.retval = -HUGE_VAL;
+		}
 		if (_LIB_VERSION == _POSIX_)
 		  errno = EDOM;
 		else if (!matherr(&exc)) {



CVS commit: src/lib/libm/src

2016-08-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 27 10:01:08 UTC 2016

Modified Files:
src/lib/libm/src: e_pow.c e_powf.c

Log Message:
sync with FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libm/src/e_pow.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libm/src/e_powf.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/src/e_pow.c
diff -u src/lib/libm/src/e_pow.c:1.16 src/lib/libm/src/e_pow.c:1.17
--- src/lib/libm/src/e_pow.c:1.16	Fri Apr 23 15:17:07 2010
+++ src/lib/libm/src/e_pow.c	Sat Aug 27 06:01:08 2016
@@ -1,9 +1,8 @@
-/* @(#)e_pow.c 5.1 93/09/24 */
+/* @(#)e_pow.c 1.5 04/04/22 SMI */
 /*
  * 
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
  *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
  * software is freely granted, provided that this notice
  * is preserved.
@@ -12,7 +11,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_pow.c,v 1.16 2010/04/23 19:17:07 drochner Exp $");
+__RCSID("$NetBSD: e_pow.c,v 1.17 2016/08/27 10:01:08 christos Exp $");
 #endif
 
 /* __ieee754_pow(x,y) return x**y
@@ -29,13 +28,13 @@ __RCSID("$NetBSD: e_pow.c,v 1.16 2010/04
  * Special cases:
  *	1.  (anything) ** 0  is 1
  *	2.  (anything) ** 1  is itself
- *	3.  (anything) ** NAN is NAN
+ *	3.  (anything) ** NAN is NAN except 1 ** NAN = 1
  *	4.  NAN ** (anything except 0) is NAN
  *	5.  +-(|x| > 1) **  +INF is +INF
  *	6.  +-(|x| > 1) **  -INF is +0
  *	7.  +-(|x| < 1) **  +INF is +0
  *	8.  +-(|x| < 1) **  -INF is +INF
- *	9.  +-1 ** +-INF is NAN
+ *	9.  +-1 ** +-INF is 1
  *	10. +0 ** (+anything except 0, NAN)   is +0
  *	11. -0 ** (+anything except 0, NAN, odd integer)  is +0
  *	12. +0 ** (-anything except 0, NAN)   is +INF
@@ -113,10 +112,13 @@ __ieee754_pow(double x, double y)
 /* y==zero: x**0 = 1 */
 	if((iy|ly)==0) return one;
 
-/* +-NaN return x+y */
+/* x==1: 1**y = 1, even if y is NaN */
+	if (hx==0x3ff0 && lx == 0) return one;
+
+/* y!=zero: result is NaN if either arg is NaN */
 	if(ix > 0x7ff0 || ((ix==0x7ff0)&&(lx!=0)) ||
 	   iy > 0x7ff0 || ((iy==0x7ff0)&&(ly!=0)))
-		return x+y;
+		return (x+0.0)+(y+0.0);
 
 /* determine if y is an odd int when x < 0
  * yisint = 0	... y is not an integer
@@ -142,7 +144,7 @@ __ieee754_pow(double x, double y)
 	if(ly==0) {
 	if (iy==0x7ff0) {	/* y is +-inf */
 	if(((ix-0x3ff0)|lx)==0)
-		return  y - y;	/* inf**+-1 is NaN */
+		return  one;	/* (-1)**+-inf is 1 */
 	else if (ix >= 0x3ff0)/* (|x|>1)**+-inf = inf,0 */
 		return (hy>=0)? y: zero;
 	else			/* (|x|<1)**-,+inf = inf,0 */
@@ -174,7 +176,11 @@ __ieee754_pow(double x, double y)
 	}
 	}
 
+/* CYGNUS LOCAL + fdlibm-5.3 fix: This used to be
 	n = (hx>>31)+1;
+   but ANSI C says a right shift of a signed negative quantity is
+   implementation defined.  */
+	n = ((u_int32_t)hx>>31)-1;
 
 /* (x<0)**(non-int) is NaN */
 	if((n|yisint)==0) return (x-x)/(x-x);

Index: src/lib/libm/src/e_powf.c
diff -u src/lib/libm/src/e_powf.c:1.15 src/lib/libm/src/e_powf.c:1.16
--- src/lib/libm/src/e_powf.c:1.15	Fri Apr 23 15:17:07 2010
+++ src/lib/libm/src/e_powf.c	Sat Aug 27 06:01:08 2016
@@ -15,15 +15,13 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_powf.c,v 1.15 2010/04/23 19:17:07 drochner Exp $");
+__RCSID("$NetBSD: e_powf.c,v 1.16 2016/08/27 10:01:08 christos Exp $");
 #endif
 
 #include "namespace.h"
 #include "math.h"
 #include "math_private.h"
 
-static const float huge = 1.0e+30, tiny = 1.0e-30;
-
 static const float
 bp[] = {1.0, 1.5,},
 dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
@@ -32,6 +30,8 @@ zero=  0.0,
 one	=  1.0,
 two	=  2.0,
 two24	=  16777216.0,	/* 0x4b80 */
+huge	=  1.0e30,
+tiny=  1.0e-30,
 	/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
 L1  =  6.002384e-01, /* 0x3f1a */
 L2  =  4.2857143283e-01, /* 0x3edb6db7 */
@@ -49,8 +49,8 @@ lg2_h  =  6.93145752e-01, /* 0x3f317200 
 lg2_l  =  1.42860654e-06, /* 0x35bfbe8c */
 ovt =  4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
 cp=  9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
-cp_h  =  9.6179199219e-01, /* 0x3f763800 =head of cp */
-cp_l  =  4.7017383622e-06, /* 0x369dc3a0 =tail of cp_h */
+cp_h  =  9.6191406250e-01, /* 0x3f764000 =12b cp */
+cp_l  = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */
 ivln2=  1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
 ivln2_h  =  1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
 ivln2_l  =  7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
@@ -59,7 +59,7 @@ float
 __ieee754_powf(float x, float y)
 {
 	float z,ax,z_h,z_l,p_h,p_l;
-	f

CVS commit: src/lib/libm

2016-08-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 27 09:15:44 UTC 2016

Modified Files:
src/lib/libm: Makefile

Log Message:
skip buggy assembly for libm_g.a


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/lib/libm/Makefile

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.183 src/lib/libm/Makefile:1.184
--- src/lib/libm/Makefile:1.183	Fri Aug 26 04:33:48 2016
+++ src/lib/libm/Makefile	Sat Aug 27 05:15:44 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.183 2016/08/26 08:33:48 christos Exp $
+#  $NetBSD: Makefile,v 1.184 2016/08/27 09:15:44 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -113,7 +113,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atan2.S 
 # do not pick up the i387 asm version for the following functions;
 # it is incorrect
 .for f in modf ilogb ilogbl ilogbf
-s_${f}.o s_${f}.pico s_${f}.po s_${f}.d: s_${f}.c
+s_${f}.o s_${f}.pico s_${f}.po s_${f}.go s_${f}.d: s_${f}.c
 .endfor
 
 .if (${MACHINE_ARCH} == "i386")



CVS commit: src/lib/libm/gen

2016-08-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Aug 27 02:56:26 UTC 2016

Modified Files:
src/lib/libm/gen: nan.3

Log Message:
strtod, not strod.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/gen/nan.3

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/gen/nan.3
diff -u src/lib/libm/gen/nan.3:1.4 src/lib/libm/gen/nan.3:1.5
--- src/lib/libm/gen/nan.3:1.4	Fri Jun 10 14:10:18 2011
+++ src/lib/libm/gen/nan.3	Sat Aug 27 02:56:26 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: nan.3,v 1.4 2011/06/10 14:10:18 njoly Exp $
+.\"	$NetBSD: nan.3,v 1.5 2016/08/27 02:56:26 dholland Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -49,11 +49,11 @@
 The call
 .Fn nan "\*qn-char-sequence\*q"
 is equivalent to the call
-.Fn strod "\*qNAN(n-char-sequence)\*q" "NULL" .
+.Fn strtod "\*qNAN(n-char-sequence)\*q" "NULL" .
 The call
 .Fn nan "\*q\*q"
 is equivalent to the call
-.Fn strod "\*qNAN()\*q" "NULL" .
+.Fn strtod "\*qNAN()\*q" "NULL" .
 .Pp
 The
 .Fn nanf



CVS commit: src/lib/libm

2016-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug 26 08:33:48 UTC 2016

Modified Files:
src/lib/libm: Makefile

Log Message:
fix double merge.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/lib/libm/Makefile

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.182 src/lib/libm/Makefile:1.183
--- src/lib/libm/Makefile:1.182	Fri Aug 26 04:31:17 2016
+++ src/lib/libm/Makefile	Fri Aug 26 04:33:48 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.182 2016/08/26 08:31:17 christos Exp $
+#  $NetBSD: Makefile,v 1.183 2016/08/26 08:33:48 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -170,12 +170,8 @@ COMMON_SRCS += fenv.c
 .elif (${LIBC_MACHINE_CPU} == "mips")
 .PATH:	${.CURDIR}/arch/mips
 COMMON_SRCS += fenv.c
-.if (${LIBC_MACHINE_CPU} == "sh3")
-.PATH:	${.CURDIR}/arch/sh3
-COMMON_SRCS += fenv.c
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS += fenv.c
 .endif
 



CVS commit: src/lib/libm

2016-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug 26 08:31:17 UTC 2016

Modified Files:
src/lib/libm: Makefile
src/lib/libm/src: e_sqrtl.c

Log Message:
do the FENV test consistently


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/lib/libm/Makefile
cvs rdiff -u -r1.4 -r1.5 src/lib/libm/src/e_sqrtl.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.181 src/lib/libm/Makefile:1.182
--- src/lib/libm/Makefile:1.181	Thu Aug 25 08:15:28 2016
+++ src/lib/libm/Makefile	Fri Aug 26 04:31:17 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.181 2016/08/25 12:15:28 christos Exp $
+#  $NetBSD: Makefile,v 1.182 2016/08/26 08:31:17 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -57,7 +57,6 @@ LINTFLAGS += -g
 .PATH: ${.CURDIR}/arch/aarch64
 ARCH_SRCS = e_sqrt.S e_sqrtf.S s_fabsf.S
 ARCH_SRCS+= s_fma.S s_fmaf.S s_fmax.S s_fmaxf.S s_fmin.S s_fminf.S
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS+= fenv.c
 COMMON_SRCS+= e_sqrtl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
@@ -70,7 +69,6 @@ COPTS+=	-mfloat-ieee -mieee-with-inexact
 .PATH.c: ${.CURDIR}/arch/arm
 COMMON_SRCS+= fenv.c s_nexttowardf.c \
 	s_nearbyint.c s_rintl.c
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COPTS.fenv.c+=	-mfpu=vfp
 .if (${MKSOFTFLOAT} == "no")
 .PATH.S: ${.CURDIR}/arch/arm
@@ -80,17 +78,14 @@ ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S l
 .PATH.c: ${.CURDIR}/arch/hppa
 COMMON_SRCS+= fenv.c s_nexttowardf.c \
 	s_nearbyint.c s_rintl.c
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 .elif (${LIBC_MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
 COMMON_SRCS+= fenv.c
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${LIBC_MACHINE_ARCH} == "sparc64")
 .PATH: ${.CURDIR}/arch/sparc64
 COMMON_SRCS+= fenv.c s_nexttowardf.c \
 	s_nearbyint.c s_rintl.c
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 .ifndef _COMPAT_M32_MK_
 COMMON_SRCS+= s_nexttoward.c
 .endif
@@ -106,7 +101,6 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.c \
 	s_nearbyint.c s_rintl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 
 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
 	e_logf.S e_log10.S e_log10f.S e_log2.S e_log2f.S e_remainder.S \
@@ -143,7 +137,6 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 	e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
 	s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
 	s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS += fenv.c
 .endif
 .endif
@@ -173,11 +166,12 @@ ARCH_SRCS += s_fmin.S s_fminf.S
 .endif
 .elif (${LIBC_MACHINE_ARCH} == "powerpc")
 .PATH:	${.CURDIR}/arch/powerpc
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS += fenv.c
 .elif (${LIBC_MACHINE_CPU} == "mips")
 .PATH:	${.CURDIR}/arch/mips
-COPTS.e_sqrtl.c += -DHAVE_FENV_H
+COMMON_SRCS += fenv.c
+.if (${LIBC_MACHINE_CPU} == "sh3")
+.PATH:	${.CURDIR}/arch/sh3
 COMMON_SRCS += fenv.c
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH:	${.CURDIR}/arch/sh3

Index: src/lib/libm/src/e_sqrtl.c
diff -u src/lib/libm/src/e_sqrtl.c:1.4 src/lib/libm/src/e_sqrtl.c:1.5
--- src/lib/libm/src/e_sqrtl.c:1.4	Fri Nov 22 15:15:06 2013
+++ src/lib/libm/src/e_sqrtl.c	Fri Aug 26 04:31:17 2016
@@ -28,7 +28,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/lib/msun/src/e_sqrtl.c 176720 2008-03-02 01:47:58Z das $");
 #endif
-__RCSID("$NetBSD: e_sqrtl.c,v 1.4 2013/11/22 20:15:06 martin Exp $");
+__RCSID("$NetBSD: e_sqrtl.c,v 1.5 2016/08/26 08:31:17 christos Exp $");
 
 #include 
 #include 
@@ -38,15 +38,14 @@ __RCSID("$NetBSD: e_sqrtl.c,v 1.4 2013/1
 
 #ifdef __HAVE_LONG_DOUBLE
 
-#ifdef HAVE_FENV_H
+#define __TEST_FENV
 #include 
-#endif
 
 #ifdef LDBL_IMPLICIT_NBIT
 #define	LDBL_NBIT	0
 #endif
 
-#ifdef HAVE_FENV_H
+#ifdef __HAVE_FENV
 
 /* Return (x + ulp) for normal positive x. Assumes no overflow. */
 static inline long double
@@ -167,7 +166,7 @@ __ieee754_sqrtl(long double x)
 	return (ux.extu_ld);
 }
 
-#else
+#else /* !__HAVE_FENV */
 
 /*
  * No fenv support:
@@ -179,6 +178,6 @@ __ieee754_sqrtl(long double x)
 	return __ieee754_sqrt((double)x);
 }
 
-#endif
+#endif /* __HAVE_FENV */
 
-#endif
+#endif /* __HAVE_LONG_DOUBLE */



CVS commit: src/lib/libm/src

2016-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug 26 08:20:31 UTC 2016

Modified Files:
src/lib/libm/src: s_ilogb.c s_ilogbf.c s_ilogbl.c

Log Message:
fix sun2 build; only IEEE math platform (and coldfire) without fenv


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libm/src/s_ilogb.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libm/src/s_ilogbf.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/src/s_ilogbl.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/src/s_ilogb.c
diff -u src/lib/libm/src/s_ilogb.c:1.15 src/lib/libm/src/s_ilogb.c:1.16
--- src/lib/libm/src/s_ilogb.c:1.15	Wed Aug 24 06:03:32 2016
+++ src/lib/libm/src/s_ilogb.c	Fri Aug 26 04:20:31 2016
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_ilogb.c,v 1.15 2016/08/24 10:03:32 christos Exp $");
+__RCSID("$NetBSD: s_ilogb.c,v 1.16 2016/08/26 08:20:31 christos Exp $");
 #endif
 
 /* ilogb(double x)
@@ -22,7 +22,11 @@ __RCSID("$NetBSD: s_ilogb.c,v 1.15 2016/
  */
 
 #include 
+#define __TEST_FENV
 #include 
+#ifndef __HAVE_FENV
+#define feraiseexcept(a)
+#endif
 #include "math_private.h"
 
 #ifndef __HAVE_LONG_DOUBLE

Index: src/lib/libm/src/s_ilogbf.c
diff -u src/lib/libm/src/s_ilogbf.c:1.9 src/lib/libm/src/s_ilogbf.c:1.10
--- src/lib/libm/src/s_ilogbf.c:1.9	Wed Aug 24 06:03:32 2016
+++ src/lib/libm/src/s_ilogbf.c	Fri Aug 26 04:20:31 2016
@@ -15,11 +15,15 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_ilogbf.c,v 1.9 2016/08/24 10:03:32 christos Exp $");
+__RCSID("$NetBSD: s_ilogbf.c,v 1.10 2016/08/26 08:20:31 christos Exp $");
 #endif
 
 #include 
+#define __TEST_FENV
 #include 
+#ifndef __HAVE_FENV
+#define feraiseexcept(a)
+#endif
 #include "math_private.h"
 
 int

Index: src/lib/libm/src/s_ilogbl.c
diff -u src/lib/libm/src/s_ilogbl.c:1.3 src/lib/libm/src/s_ilogbl.c:1.4
--- src/lib/libm/src/s_ilogbl.c:1.3	Wed Aug 24 06:03:32 2016
+++ src/lib/libm/src/s_ilogbl.c	Fri Aug 26 04:20:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: s_ilogbl.c,v 1.3 2016/08/24 10:03:32 christos Exp $	*/
+/*	$NetBSD: s_ilogbl.c,v 1.4 2016/08/26 08:20:31 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,13 +30,17 @@
  */
 
 #include 
-__RCSID("$NetBSD: s_ilogbl.c,v 1.3 2016/08/24 10:03:32 christos Exp $");
+__RCSID("$NetBSD: s_ilogbl.c,v 1.4 2016/08/26 08:20:31 christos Exp $");
 
 #include "namespace.h"
 
 #include 
 #include 
+#define __TEST_FENV
 #include 
+#ifndef __HAVE_FENV
+#define feraiseexcept(a)
+#endif
 #include 
 
 #ifdef __HAVE_LONG_DOUBLE



CVS commit: src/lib/libm

2016-08-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 25 12:15:28 UTC 2016

Modified Files:
src/lib/libm: Makefile
Added Files:
src/lib/libm/arch/sh3: fenv.c

Log Message:
more fenv for sh


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/lib/libm/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libm/arch/sh3/fenv.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.180 src/lib/libm/Makefile:1.181
--- src/lib/libm/Makefile:1.180	Wed Aug 24 06:03:32 2016
+++ src/lib/libm/Makefile	Thu Aug 25 08:15:28 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.180 2016/08/24 10:03:32 christos Exp $
+#  $NetBSD: Makefile,v 1.181 2016/08/25 12:15:28 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -179,6 +179,10 @@ COMMON_SRCS += fenv.c
 .PATH:	${.CURDIR}/arch/mips
 COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS += fenv.c
+.elif (${LIBC_MACHINE_CPU} == "sh3")
+.PATH:	${.CURDIR}/arch/sh3
+COPTS.e_sqrtl.c += -DHAVE_FENV_H
+COMMON_SRCS += fenv.c
 .endif
 
 WARNS?=5

Added files:

Index: src/lib/libm/arch/sh3/fenv.c
diff -u /dev/null src/lib/libm/arch/sh3/fenv.c:1.1
--- /dev/null	Thu Aug 25 08:15:28 2016
+++ src/lib/libm/arch/sh3/fenv.c	Thu Aug 25 08:15:28 2016
@@ -0,0 +1,51 @@
+/*	$NetBSD: fenv.c,v 1.1 2016/08/25 12:15:28 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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: fenv.c,v 1.1 2016/08/25 12:15:28 christos Exp $");
+
+#define	__fenv_static
+#include "fenv.h"
+
+#if defined(__GNUC_GNU_INLINE__) && !defined(__lint__)
+#error "This file must be compiled with C99 'inline' semantics"
+#endif
+
+extern inline int feclearexcept(int __excepts);
+extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
+extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+extern inline int feraiseexcept(int __excepts);
+extern inline int fetestexcept(int __excepts);
+extern inline int fegetround(void);
+extern inline int fesetround(int __round);
+extern inline int fegetenv(fenv_t *__envp);
+extern inline int feholdexcept(fenv_t *__envp);
+extern inline int fesetenv(const fenv_t *__envp);
+extern inline int feupdateenv(const fenv_t *__envp);



CVS commit: src/lib/libm

2016-08-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 24 10:03:32 UTC 2016

Modified Files:
src/lib/libm: Makefile
src/lib/libm/src: s_ilogb.c s_ilogbf.c s_ilogbl.c

Log Message:
fix ilogb*


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/lib/libm/Makefile
cvs rdiff -u -r1.14 -r1.15 src/lib/libm/src/s_ilogb.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/src/s_ilogbf.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/src/s_ilogbl.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.179 src/lib/libm/Makefile:1.180
--- src/lib/libm/Makefile:1.179	Wed Aug 24 05:10:57 2016
+++ src/lib/libm/Makefile	Wed Aug 24 06:03:32 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.179 2016/08/24 09:10:57 christos Exp $
+#  $NetBSD: Makefile,v 1.180 2016/08/24 10:03:32 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -113,12 +113,14 @@ ARCH_SRCS = e_acos.S e_asin.S e_atan2.S 
 	e_remainderf.S e_scalb.S e_scalbf.S e_sqrt.S e_sqrtf.S s_atan.S \
 	s_atanf.S s_ceil.S s_ceilf.S s_copysign.S s_copysignf.S s_cos.S \
 	s_cosf.S s_finite.S s_finitef.S s_floor.S s_floorf.S \
-	s_ilogb.S s_ilogbf.S s_ilogbl.S s_log1p.S s_log1pf.S \
-	s_logb.S s_logbf.S s_logbl.S \
+	s_log1p.S s_log1pf.S s_logb.S s_logbf.S s_logbl.S \
 	s_rint.S s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \
 	s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S lrint.S 
-# do not pick up the i387 asm version, it is incorrect
-s_modf.o s_modf.pico s_modf.po s_modf.d: s_modf.c
+# do not pick up the i387 asm version for the following functions;
+# it is incorrect
+.for f in modf ilogb ilogbl ilogbf
+s_${f}.o s_${f}.pico s_${f}.po s_${f}.d: s_${f}.c
+.endfor
 
 .if (${MACHINE_ARCH} == "i386")
 SUBDIR=arch/i387

Index: src/lib/libm/src/s_ilogb.c
diff -u src/lib/libm/src/s_ilogb.c:1.14 src/lib/libm/src/s_ilogb.c:1.15
--- src/lib/libm/src/s_ilogb.c:1.14	Sat Feb  9 17:56:00 2013
+++ src/lib/libm/src/s_ilogb.c	Wed Aug 24 06:03:32 2016
@@ -12,7 +12,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_ilogb.c,v 1.14 2013/02/09 22:56:00 matt Exp $");
+__RCSID("$NetBSD: s_ilogb.c,v 1.15 2016/08/24 10:03:32 christos Exp $");
 #endif
 
 /* ilogb(double x)
@@ -21,7 +21,8 @@ __RCSID("$NetBSD: s_ilogb.c,v 1.14 2013/
  * ilogb(inf/NaN) = 0x7fff (no signal is raised)
  */
 
-#include "math.h"
+#include 
+#include 
 #include "math_private.h"
 
 #ifndef __HAVE_LONG_DOUBLE
@@ -31,22 +32,28 @@ __strong_alias(ilogbl,ilogb)
 int
 ilogb(double x)
 {
-	int32_t hx,lx,ix;
+	int32_t hx, lx, ix;
 
-	GET_HIGH_WORD(hx,x);
+	GET_HIGH_WORD(hx, x);
 	hx &= 0x7fff;
-	if(hx<0x0010) {
-	GET_LOW_WORD(lx,x);
-	if((hx|lx)==0)
-		return FP_ILOGB0;	/* ilogb(0) = 0x8001 */
-	else			/* subnormal x */
-		if(hx==0) {
-		for (ix = -1043; lx>0; lx<<=1) ix -=1;
+	if (hx < 0x0010) {
+		GET_LOW_WORD(lx, x);
+		if ((hx | lx) == 0) {
+			feraiseexcept(FE_INVALID);
+			return FP_ILOGB0;	/* ilogb(0) = 0x8001 */
+		}
+		if (hx == 0) {
+			for (ix = -1043; lx > 0; lx <<= 1) ix -= 1;
 		} else {
-		for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
+			for (ix = -1022, hx <<= 11; hx > 0; hx <<= 1) ix -= 1;
 		}
-	return ix;
+		return ix;
+	}
+
+	if (hx < 0x7ff0) {
+		return (hx >> 20) - 1023;
 	}
-	else if (hx<0x7ff0) return (hx>>20)-1023;
-	else return FP_ILOGBNAN;	/* inf too */
+
+	feraiseexcept(FE_INVALID);
+	return isnan(x) ? FP_ILOGBNAN : INT_MAX;
 }

Index: src/lib/libm/src/s_ilogbf.c
diff -u src/lib/libm/src/s_ilogbf.c:1.8 src/lib/libm/src/s_ilogbf.c:1.9
--- src/lib/libm/src/s_ilogbf.c:1.8	Sat Feb  9 17:56:00 2013
+++ src/lib/libm/src/s_ilogbf.c	Wed Aug 24 06:03:32 2016
@@ -15,26 +15,33 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_ilogbf.c,v 1.8 2013/02/09 22:56:00 matt Exp $");
+__RCSID("$NetBSD: s_ilogbf.c,v 1.9 2016/08/24 10:03:32 christos Exp $");
 #endif
 
-#include "math.h"
+#include 
+#include 
 #include "math_private.h"
 
 int
 ilogbf(float x)
 {
-	int32_t hx,ix;
+	int32_t hx, ix;
 
-	GET_FLOAT_WORD(hx,x);
+	GET_FLOAT_WORD(hx, x);
 	hx &= 0x7fff;
-	if(hx<0x0080) {
-	if(hx==0)
-		return FP_ILOGB0;	/* ilogb(0) = 0x8001 */
-	else			/* subnormal x */
-	for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1;
-	return ix;
+	if (hx < 0x0080) {
+		if (hx == 0) {
+			feraiseexcept(FE_INVALID);
+			return FP_ILOGB0;	/* ilogb(0) = 0x8001 */
+		}
+		for (ix = -126, hx <<= 8; hx > 0; hx <<= 1) ix -= 1;
+		return ix;
 	}
-	else if (hx<0x7f80) return (hx>>23)-127;
-	else return FP_ILOGBNAN;	/* inf too */
+
+	if (hx < 0x7f80) {
+		return (hx >> 23) - 127;
+	}
+
+	feraiseexcept(FE_INVALID);
+	return isnan(x) ? FP_ILOGBNAN : INT_MAX;
 }

Index: src/lib/libm/src/s_ilogbl.c
diff -u src/lib/libm/src/s_ilogbl.c:1.2 src/lib/libm/src/s_ilogbl.c:1.3
--- src/lib/libm/src/s_ilogbl.c:

CVS commit: src/lib/libm

2016-08-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 24 09:10:57 UTC 2016

Modified Files:
src/lib/libm: Makefile

Log Message:
add ilogb.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/lib/libm/Makefile

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.178 src/lib/libm/Makefile:1.179
--- src/lib/libm/Makefile:1.178	Tue Aug 23 06:00:15 2016
+++ src/lib/libm/Makefile	Wed Aug 24 05:10:57 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.178 2016/08/23 10:00:15 christos Exp $
+#  $NetBSD: Makefile,v 1.179 2016/08/24 09:10:57 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -248,7 +248,7 @@ 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_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_fmod.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_tan.c \



CVS commit: src/lib/libm/noieee_src

2016-08-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 24 09:08:50 UTC 2016

Added Files:
src/lib/libm/noieee_src: n_ilogb.c

Log Message:
ilogb for the vax


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libm/noieee_src/n_ilogb.c

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

Added files:

Index: src/lib/libm/noieee_src/n_ilogb.c
diff -u /dev/null src/lib/libm/noieee_src/n_ilogb.c:1.1
--- /dev/null	Wed Aug 24 05:08:50 2016
+++ src/lib/libm/noieee_src/n_ilogb.c	Wed Aug 24 05:08:50 2016
@@ -0,0 +1,54 @@
+/*	$NetBSD: n_ilogb.c,v 1.1 2016/08/24 09:08:50 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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 
+#if defined(LIBM_SCCS) && !defined(lint)
+__RCSID("$NetBSD: n_ilogb.c,v 1.1 2016/08/24 09:08:50 christos Exp $");
+#endif
+
+#include "math.h"
+
+int
+ilogb(double x)
+{
+	if (x == 0)
+		return FP_ILOGB0;
+	if (x != x)
+		return FP_ILOGBNAN;
+	if (!finite(x))
+		return INT_MAX;
+	return (int)logb(x);
+}
+
+int
+ilogbf(float x)
+{
+	return ilogb(x);
+}



CVS commit: src/lib/libm

2016-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 23 10:00:15 UTC 2016

Modified Files:
src/lib/libm: Makefile
Added Files:
src/lib/libm/arch/alpha: fenv.c

Log Message:
fenv.h for alpha


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/lib/libm/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libm/arch/alpha/fenv.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.177 src/lib/libm/Makefile:1.178
--- src/lib/libm/Makefile:1.177	Wed Mar 30 03:44:06 2016
+++ src/lib/libm/Makefile	Tue Aug 23 06:00:15 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.177 2016/03/30 07:44:06 martin Exp $
+#  $NetBSD: Makefile,v 1.178 2016/08/23 10:00:15 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -64,6 +64,7 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${LIBC_MACHINE_ARCH} == "alpha")
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
+COMMON_SRCS+= fenv.c
 COPTS+=	-mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
 .elif (${LIBC_MACHINE_CPU} == "arm")
 .PATH.c: ${.CURDIR}/arch/arm

Added files:

Index: src/lib/libm/arch/alpha/fenv.c
diff -u /dev/null src/lib/libm/arch/alpha/fenv.c:1.1
--- /dev/null	Tue Aug 23 06:00:15 2016
+++ src/lib/libm/arch/alpha/fenv.c	Tue Aug 23 06:00:15 2016
@@ -0,0 +1,150 @@
+/*	$NetBSD: fenv.c,v 1.1 2016/08/23 10:00:15 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2004-2005 David Schultz 
+ * 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 AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: src/lib/msun/alpha/fenv.c,v 1.2 2005/03/16 19:03:44 das Exp $
+ */
+#include 
+__RCSID("$NetBSD: fenv.c,v 1.1 2016/08/23 10:00:15 christos Exp $");
+
+#ifdef __weak_alias
+#define feenableexcept _feenableexcept
+#define fedisableexcept _fedisableexcept
+#define fegetexcept _fegetexcept
+#endif
+#include 
+#include 
+
+const fenv_t __fe_dfl_env = 0x680eULL;
+
+/*
+ * The lower 49 bits of the FPCR are unused by the hardware, so we use
+ * the lower order bits to store the kernel's idea of the FP mask as
+ * described in the Alpha Architecture Manual.
+ */
+int
+fegetenv(fenv_t *envp)
+{
+	struct alpha_fp_except_args p;
+	union __fpcr r;
+
+	/*
+	 * The syscall acts as an implicit exception barrier, so we
+	 * only need to issue an excb after the mf_fpcr to ensure that
+	 * the read is executed before any subsequent FP ops.
+	 */
+	sysarch(ALPHA_FPGETMASK, (char *)&p);
+	__mf_fpcr(&r.__d);
+	*envp = r.__bits | p.mask;
+	__excb();
+	return 0;
+}
+
+int
+feholdexcept(fenv_t *envp)
+{
+	struct alpha_fp_except_args p;
+	union __fpcr r;
+
+	sysarch(ALPHA_FPGETMASK, (char *)&p);
+	__mf_fpcr(&r.__d);
+	*envp = r.__bits | p.mask;
+	r.__bits &= ~((fenv_t)FE_ALL_EXCEPT << _FPUSW_SHIFT);
+	__mt_fpcr(r.__d);
+	if (p.mask & FE_ALL_EXCEPT) {
+		p.mask = 0;
+		sysarch(ALPHA_FPSETMASK, &p);
+	}
+	__excb();
+	return 0;
+}
+
+int
+fesetenv(const fenv_t *envp)
+{
+	struct alpha_fp_except_args p;
+	union __fpcr r;
+
+	p.mask = *envp & FE_ALL_EXCEPT;
+	sysarch(ALPHA_FPSETMASK, &p);
+	r.__bits = *envp & ~FE_ALL_EXCEPT;
+	__mt_fpcr(r.__d);
+	__excb();
+	return 0;
+}
+
+int
+feupdateenv(const fenv_t *envp)
+{
+	struct alpha_fp_except_args p;
+	union __fpcr oldr, newr;
+
+	p.mask = *envp & FE_ALL_EXCEPT;
+	sysarch(ALPHA_FPSETMASK, &p);
+	__mf_fpcr(&oldr.__d);
+	newr.__bits = *envp & ~FE_ALL_EXCEPT;
+	__excb();
+	__mt_fpcr(newr.__d);
+	feraiseexcept((oldr.__bits >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+	return 0; 
+}
+
+#ifdef __weak_alias
+__weak_alias(feenableexcept, _feenableexcept);
+__weak_alias(fedisableexcept, _fedisableexcept);
+__weak_alias(fegetexcept, _fegetex

CVS commit: src/lib/libm/man

2016-08-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Aug 22 07:33:31 UTC 2016

Modified Files:
src/lib/libm/man: ilogb.3

Log Message:
BUGS section is no longer correct
FP_ILOGB0 and FP_ILOGBNAN are both defined in math.h


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libm/man/ilogb.3

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/man/ilogb.3
diff -u src/lib/libm/man/ilogb.3:1.3 src/lib/libm/man/ilogb.3:1.4
--- src/lib/libm/man/ilogb.3:1.3	Tue Aug  2 10:15:03 2011
+++ src/lib/libm/man/ilogb.3	Mon Aug 22 07:33:30 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: ilogb.3,v 1.3 2011/08/02 10:15:03 wiz Exp $
+.\" $NetBSD: ilogb.3,v 1.4 2016/08/22 07:33:30 maya Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 29, 2011
+.Dd August 22, 2016
 .Dt ILOGB 3
 .Os
 .Sh NAME
@@ -102,10 +102,3 @@ a domain error occurs but an unspecified
 .Sh STANDARDS
 The described functions conform to
 .St -isoC-99 .
-.Sh BUGS
-Neither
-.Dv FP_ILOGB0
-nor
-.Dv FP_ILOGBNAN
-is defined currently in
-.Nx .



CVS commit: src/lib/libm

2016-03-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Mar 30 07:44:06 UTC 2016

Modified Files:
src/lib/libm: Makefile

Log Message:
No fenv for m68k with SOFTFLOAT for now - so at least it builds.


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/lib/libm/Makefile

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.176 src/lib/libm/Makefile:1.177
--- src/lib/libm/Makefile:1.176	Thu Mar 17 18:29:59 2016
+++ src/lib/libm/Makefile	Wed Mar 30 07:44:06 2016
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.176 2016/03/17 18:29:59 nros Exp $
+#  $NetBSD: Makefile,v 1.177 2016/03/30 07:44:06 martin Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -140,10 +140,10 @@ ARCH_SRCS = e_acos.S e_asin.S e_atanh.S 
 	e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
 	s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
 	s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-.endif
 COPTS.e_sqrtl.c += -DHAVE_FENV_H
 COMMON_SRCS += fenv.c
 .endif
+.endif
 # end of m68k
 .elif (${LIBC_MACHINE_ARCH} == "vax")
 .PATH:	${.CURDIR}/arch/vax



CVS commit: src/lib/libm/arch/hppa

2016-03-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 20 14:22:46 UTC 2016

Modified Files:
src/lib/libm/arch/hppa: fenv.c

Log Message:
Update {read,write}fpsr to work everywhere


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/arch/hppa/fenv.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/arch/hppa/fenv.c
diff -u src/lib/libm/arch/hppa/fenv.c:1.2 src/lib/libm/arch/hppa/fenv.c:1.3
--- src/lib/libm/arch/hppa/fenv.c:1.2	Tue Jan 13 11:16:06 2015
+++ src/lib/libm/arch/hppa/fenv.c	Sun Mar 20 14:22:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: fenv.c,v 1.2 2015/01/13 11:16:06 martin Exp $	*/
+/*	$NetBSD: fenv.c,v 1.3 2016/03/20 14:22:46 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2004-2005 David Schultz 
@@ -24,7 +24,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  */
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.2 2015/01/13 11:16:06 martin Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.3 2016/03/20 14:22:46 skrll Exp $");
 
 #include 
 #include 
@@ -47,7 +47,7 @@ readfpsr(void)
 {
 	uint32_t rv;
 
-	__asm__	__volatile__ ("fstws	%%fr0, %0" : "=m"(rv));
+	__asm__	__volatile__ ("fstw	%%fr0, 0(%1)" : "=m" (rv) : "r"(&rv));
 	return rv;
 }
 
@@ -55,7 +55,7 @@ readfpsr(void)
 static inline void
 writefpsr(uint32_t val)
 {
-	__asm__	__volatile__("fldws	%0,%%fr0" : : "m"(val));
+	__asm__	__volatile__("fldw	0(%1),%%fr0" : : "m" (val), "r"(&val));
 }
 
 /*



CVS commit: src/lib/libm/man

2016-03-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Mar 17 09:44:56 UTC 2016

Modified Files:
src/lib/libm/man: fabs.3

Log Message:
Fix typo, add whitespace for better formatting, bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libm/man/fabs.3

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/man/fabs.3
diff -u src/lib/libm/man/fabs.3:1.16 src/lib/libm/man/fabs.3:1.17
--- src/lib/libm/man/fabs.3:1.16	Thu Mar 17 00:00:44 2016
+++ src/lib/libm/man/fabs.3	Thu Mar 17 09:44:56 2016
@@ -26,14 +26,14 @@
 .\" SUCH DAMAGE.
 .\"
 .\" from: @(#)fabs.3	5.1 (Berkeley) 5/2/91
-.\"	$NetBSD: fabs.3,v 1.16 2016/03/17 00:00:44 nros Exp $
+.\"	$NetBSD: fabs.3,v 1.17 2016/03/17 09:44:56 wiz Exp $
 .\"
-.Dd May 2, 1991
+.Dd March 17, 2016
 .Dt FABS 3
 .Os
 .Sh NAME
 .Nm fabs ,
-.Nm fabsf,
+.Nm fabsf ,
 .Nm fabsl
 .Nd floating-point absolute value functions
 .Sh LIBRARY
@@ -45,7 +45,7 @@
 .Ft float
 .Fn fabsf "float x"
 .Ft long double
-.Fn fabs "long double x"
+.Fn fabsl "long double x"
 .Sh DESCRIPTION
 The
 .Fn fabs ,



CVS commit: src/lib/libm/man

2016-03-15 Thread Niclas Rosenvik
Module Name:src
Committed By:   nros
Date:   Tue Mar 15 15:29:19 UTC 2016

Modified Files:
src/lib/libm/man: modf.3

Log Message:
Add modfl to the modf manpage, the link to modfl was already there but the
content was missing.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libm/man/modf.3

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/man/modf.3
diff -u src/lib/libm/man/modf.3:1.1 src/lib/libm/man/modf.3:1.2
--- src/lib/libm/man/modf.3:1.1	Mon Jul  3 16:03:56 2006
+++ src/lib/libm/man/modf.3	Tue Mar 15 15:29:19 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: modf.3,v 1.1 2006/07/03 16:03:56 drochner Exp $
+.\"	$NetBSD: modf.3,v 1.2 2016/03/15 15:29:19 nros Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -33,7 +33,7 @@
 .\"
 .\" @(#)modf.3	8.1 (Berkeley) 6/4/93
 .\"
-.Dd March 21, 2006
+.Dd March 7, 2016
 .Dt MODF 3
 .Os
 .Sh NAME
@@ -47,6 +47,8 @@
 .Fn modf "double value" "double *iptr"
 .Ft float
 .Fn modff "float value" "float *iptr"
+.Ft long double
+.Fn modfl "long double value" "long double *iptr"
 .Sh DESCRIPTION
 The
 .Fn modf



CVS commit: src/lib/libm/compiler_rt

2016-02-27 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Feb 27 19:06:56 UTC 2016

Modified Files:
src/lib/libm/compiler_rt: Makefile.inc

Log Message:
Long double complex multiplication and division helpers are needed on
Sparc64 and AArch64.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libm/compiler_rt/Makefile.inc

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/compiler_rt/Makefile.inc
diff -u src/lib/libm/compiler_rt/Makefile.inc:1.9 src/lib/libm/compiler_rt/Makefile.inc:1.10
--- src/lib/libm/compiler_rt/Makefile.inc:1.9	Wed Oct 22 10:33:27 2014
+++ src/lib/libm/compiler_rt/Makefile.inc	Sat Feb 27 19:06:56 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.9 2014/10/22 10:33:27 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.10 2016/02/27 19:06:56 joerg Exp $
 
 COMPILER_RT_SRCDIR=	${NETBSDSRCDIR}/sys/external/bsd/compiler_rt/dist
 
@@ -23,7 +23,7 @@ GENERIC_SRCS+= \
 	divsc3.c \
 	divxc3.c
 
-.if ${MACHINE_CPU} == "powerpc"
+.if ${MACHINE_CPU} == "powerpc" || ${LIBC_MACHINE_CPU:U} == "sparc64" || ${LIBC_MACHINE_CPU:U} == "aarch64"
 GENERIC_SRCS+= \
 	divtc3.c \
 	multc3.c



CVS commit: src/lib/libm/arch/i387

2016-02-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb 17 19:54:11 UTC 2016

Modified Files:
src/lib/libm/arch/i387: fenv.c

Log Message:
PR/50822: David Binderman: Fix copy length.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libm/arch/i387/fenv.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/arch/i387/fenv.c
diff -u src/lib/libm/arch/i387/fenv.c:1.6 src/lib/libm/arch/i387/fenv.c:1.7
--- src/lib/libm/arch/i387/fenv.c:1.6	Sun Nov 10 19:31:51 2013
+++ src/lib/libm/arch/i387/fenv.c	Wed Feb 17 14:54:11 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.6 2013/11/11 00:31:51 joerg Exp $ */
+/* $NetBSD: fenv.c,v 1.7 2016/02/17 19:54:11 christos Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fenv.c,v 1.6 2013/11/11 00:31:51 joerg Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.7 2016/02/17 19:54:11 christos Exp $");
 
 #include 
 #include 
@@ -400,9 +400,8 @@ fesetenv(const fenv_t *envp)
 	__fe_dfl_env.x87.unused1 = env.x87.unused1;
 	__fe_dfl_env.x87.unused2 = env.x87.unused2;
 	__fe_dfl_env.x87.unused3 = env.x87.unused3;
-	memcpy(__fe_dfl_env.x87.others,
-	   env.x87.others,
-	   sizeof(__fe_dfl_env.x87.others) / sizeof(uint32_t));
+	memcpy(__fe_dfl_env.x87.others, env.x87.others,
+	sizeof(__fe_dfl_env.x87.others));
 
 	__fldenv(envp->x87);
 	if (__HAS_SSE)
@@ -436,9 +435,8 @@ feupdateenv(const fenv_t *envp)
 	__fe_dfl_env.x87.unused1 = env.x87.unused1;
 	__fe_dfl_env.x87.unused2 = env.x87.unused2;
 	__fe_dfl_env.x87.unused3 = env.x87.unused3;
-	memcpy(__fe_dfl_env.x87.others,
-	   env.x87.others,
-	   sizeof(__fe_dfl_env.x87.others) / sizeof(uint32_t));
+	memcpy(__fe_dfl_env.x87.others, env.x87.others,
+	sizeof(__fe_dfl_env.x87.others));
 
 	__fnstsw(&status);
 	if (__HAS_SSE)



CVS commit: src/lib/libm/src

2016-01-24 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sun Jan 24 20:34:30 UTC 2016

Modified Files:
src/lib/libm/src: e_hypotf.c

Log Message:
Fix incorrect magic numbers in scaling.  From FreeBSD commit 23397, by
way of Rin Okuyama.  Fixes PR lib/50698.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libm/src/e_hypotf.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/src/e_hypotf.c
diff -u src/lib/libm/src/e_hypotf.c:1.9 src/lib/libm/src/e_hypotf.c:1.10
--- src/lib/libm/src/e_hypotf.c:1.9	Fri Apr 25 22:21:53 2008
+++ src/lib/libm/src/e_hypotf.c	Sun Jan 24 20:34:30 2016
@@ -15,7 +15,7 @@
 
 #include 
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: e_hypotf.c,v 1.9 2008/04/25 22:21:53 christos Exp $");
+__RCSID("$NetBSD: e_hypotf.c,v 1.10 2016/01/24 20:34:30 gson Exp $");
 #endif
 
 #include "math.h"
@@ -43,22 +43,22 @@ __ieee754_hypotf(float x, float y)
 	   if(hb == 0x7f80) w = b;
 	   return w;
 	   }
-	   /* scale a and b by 2**-60 */
-	   ha -= 0x5d80; hb -= 0x5d80;	k += 60;
+	   /* scale a and b by 2**-68 */
+	   ha -= 0x2200; hb -= 0x2200;	k += 68;
 	   SET_FLOAT_WORD(a,ha);
 	   SET_FLOAT_WORD(b,hb);
 	}
 	if(hb < 0x2680) {	/* b < 2**-50 */
 	if(hb <= 0x007f) {	/* subnormal b or 0 */
 	if(hb==0) return a;
-		SET_FLOAT_WORD(t1,0x3f00);	/* t1=2^126 */
+		SET_FLOAT_WORD(t1,0x7e80);	/* t1=2^126 */
 		b *= t1;
 		a *= t1;
 		k -= 126;
-	} else {		/* scale a and b by 2^60 */
-	ha += 0x5d80; 	/* a *= 2^60 */
-		hb += 0x5d80;	/* b *= 2^60 */
-		k -= 60;
+	} else {		/* scale a and b by 2^68 */
+	ha += 0x2200; 	/* a *= 2^68 */
+		hb += 0x2200;	/* b *= 2^68 */
+		k -= 68;
 		SET_FLOAT_WORD(a,ha);
 		SET_FLOAT_WORD(b,hb);
 	}



CVS commit: src/lib/libm/noieee_src

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 21:31:38 UTC 2016

Modified Files:
src/lib/libm/noieee_src: n_fmod.c

Log Message:
modernize.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libm/noieee_src/n_fmod.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/noieee_src/n_fmod.c
diff -u src/lib/libm/noieee_src/n_fmod.c:1.9 src/lib/libm/noieee_src/n_fmod.c:1.10
--- src/lib/libm/noieee_src/n_fmod.c:1.9	Sat Jan 16 16:29:33 2016
+++ src/lib/libm/noieee_src/n_fmod.c	Sat Jan 16 16:31:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: n_fmod.c,v 1.9 2016/01/16 21:29:33 christos Exp $	*/
+/*	$NetBSD: n_fmod.c,v 1.10 2016/01/16 21:31:38 christos Exp $	*/
 /*
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -109,8 +109,9 @@ fmodf(float x, float y)
 }
 
 #ifdef TEST_FMOD
-extern long random();
-extern double fmod();
+#include 
+#include 
+#include 
 
 #define	NTEST	1
 #define	NCASES	3



CVS commit: src/lib/libm/noieee_src

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 21:29:33 UTC 2016

Modified Files:
src/lib/libm/noieee_src: n_fmod.c

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/noieee_src/n_fmod.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/noieee_src/n_fmod.c
diff -u src/lib/libm/noieee_src/n_fmod.c:1.8 src/lib/libm/noieee_src/n_fmod.c:1.9
--- src/lib/libm/noieee_src/n_fmod.c:1.8	Sat Jan 16 14:44:05 2016
+++ src/lib/libm/noieee_src/n_fmod.c	Sat Jan 16 16:29:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: n_fmod.c,v 1.8 2016/01/16 19:44:05 christos Exp $	*/
+/*	$NetBSD: n_fmod.c,v 1.9 2016/01/16 21:29:33 christos Exp $	*/
 /*
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -124,7 +124,7 @@ prf(const char *s, double d)
 		unsigned long long u;
 	} x;
 	x.d = d;
-	printf("%s = %#016.16llx (%24.16e)\n:, s, x.u, x.d);
+	printf("%s = %#016.16llx (%24.16e)\n", s, x.u, x.d);
 }
 
 static void



CVS commit: src/lib/libm/noieee_src

2016-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 16 19:44:05 UTC 2016

Modified Files:
src/lib/libm/noieee_src: n_fmod.c

Log Message:
PR/50660: David Binderman: bad calls to printf, in test part


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libm/noieee_src/n_fmod.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/noieee_src/n_fmod.c
diff -u src/lib/libm/noieee_src/n_fmod.c:1.7 src/lib/libm/noieee_src/n_fmod.c:1.8
--- src/lib/libm/noieee_src/n_fmod.c:1.7	Fri Nov 22 05:59:31 2013
+++ src/lib/libm/noieee_src/n_fmod.c	Sat Jan 16 14:44:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: n_fmod.c,v 1.7 2013/11/22 10:59:31 martin Exp $	*/
+/*	$NetBSD: n_fmod.c,v 1.8 2016/01/16 19:44:05 christos Exp $	*/
 /*
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -116,16 +116,26 @@ extern double fmod();
 #define	NCASES	3
 
 static int nfail = 0;
+static void
+prf(const char *s, double d)
+{
+	union {
+		double d;
+		unsigned long long u;
+	} x;
+	x.d = d;
+	printf("%s = %#016.16llx (%24.16e)\n:, s, x.u, x.d);
+}
 
 static void
 doit(double x, double y)
 {
 	double ro = fmod(x,y),rn = _fmod(x,y);
 	if (ro != rn) {
-		(void)printf(" x= 0x%08.8x %08.8x (%24.16e)\n",x,x);
-		(void)printf(" y= 0x%08.8x %08.8x (%24.16e)\n",y,y);
-		(void)printf(" fmod = 0x%08.8x %08.8x (%24.16e)\n",ro,ro);
-		(void)printf("_fmod = 0x%08.8x %08.8x (%24.16e)\n",rn,rn);
+		prf(" x   ", x);
+		prf(" y   ", y);
+		prf(" fmod", ro);
+		prf("_fmod", rn);
 		(void)printf("\n");
 	}
 }



  1   2   3   4   >