public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
@ 2014-09-23 20:33 Jonathan Roelofs
  2014-09-24  1:18 ` Craig Howland
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-09-23 20:33 UTC (permalink / raw)
  To: newlib; +Cc: JF Bastien

[-- Attachment #1: Type: text/plain, Size: 105 bytes --]

Please see the attached patch.

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

[-- Attachment #2: newlib_nexttoward.diff --]
[-- Type: text/plain, Size: 10342 bytes --]

Index: newlib/libc/include/math.h
===================================================================
--- newlib/libc/include/math.h	(revision 439406)
+++ newlib/libc/include/math.h	(working copy)
@@ -420,20 +420,24 @@
 extern long double fmodl _PARAMS((long double, long double));
 extern long double hypotl _PARAMS((long double, long double));
 #endif /* ! defined (__math_68881) */
 #endif /* ! defined (_REENT_ONLY) */
 extern long double copysignl _PARAMS((long double, long double));
 extern long double nanl _PARAMS((const char *));
 extern int ilogbl _PARAMS((long double));
 extern long double asinhl _PARAMS((long double));
 extern long double cbrtl _PARAMS((long double));
 extern long double nextafterl _PARAMS((long double, long double));
+extern float nexttowardf _PARAMS((float, long double));
+extern double nexttoward _PARAMS((double, long double));
+extern long double nexttowardl _PARAMS((long double, long double));
+extern long double logbl _PARAMS((long double));
 extern long double rintl _PARAMS((long double));
 extern long double scalbnl _PARAMS((long double, int));
 extern long double exp2l _PARAMS((long double));
 extern long double scalblnl _PARAMS((long double, long));
 extern long double tgammal _PARAMS((long double));
 extern long double nearbyintl _PARAMS((long double));
 extern long int lrintl _PARAMS((long double));
 extern long long int llrintl _PARAMS((long double));
 extern long double roundl _PARAMS((long double));
 extern long lroundl _PARAMS((long double));
Index: newlib/libm/common/nexttowardl.c
===================================================================
--- newlib/libm/common/nexttowardl.c	(revision 0)
+++ newlib/libm/common/nexttowardl.c	(revision 0)
@@ -0,0 +1,11 @@
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+nexttowardl (long double x, long double y)
+{
+  return nextafter((double)x, (double)y);
+}
+#endif
+
Index: newlib/libm/common/nexttoward.c
===================================================================
--- newlib/libm/common/nexttoward.c	(revision 0)
+++ newlib/libm/common/nexttoward.c	(revision 0)
@@ -0,0 +1,11 @@
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+double
+nexttoward (double x, long double y)
+{
+  return nextafter(x, (double)y);
+}
+#endif
+
Index: newlib/libm/common/logbl.c
===================================================================
--- newlib/libm/common/logbl.c	(revision 0)
+++ newlib/libm/common/logbl.c	(revision 0)
@@ -0,0 +1,11 @@
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+logbl (long double x)
+{
+  return logb((double)x);
+}
+#endif
+
Index: newlib/libm/common/nexttowardf.c
===================================================================
--- newlib/libm/common/nexttowardf.c	(revision 0)
+++ newlib/libm/common/nexttowardf.c	(revision 0)
@@ -0,0 +1,11 @@
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+float
+nexttowardf (float x, long double y)
+{
+  return nextafterf(x, (double)y);
+}
+#endif
+
Index: newlib/libm/common/Makefile.in
===================================================================
--- newlib/libm/common/Makefile.in	(revision 439406)
+++ newlib/libm/common/Makefile.in	(working copy)
@@ -129,21 +129,23 @@
 	lib_a-scalbnl.$(OBJEXT) lib_a-exp2l.$(OBJEXT) \
 	lib_a-scalblnl.$(OBJEXT) lib_a-tgammal.$(OBJEXT) \
 	lib_a-nearbyintl.$(OBJEXT) lib_a-lrintl.$(OBJEXT) \
 	lib_a-llrintl.$(OBJEXT) lib_a-roundl.$(OBJEXT) \
 	lib_a-lroundl.$(OBJEXT) lib_a-llroundl.$(OBJEXT) \
 	lib_a-truncl.$(OBJEXT) lib_a-remquol.$(OBJEXT) \
 	lib_a-fdiml.$(OBJEXT) lib_a-fmaxl.$(OBJEXT) \
 	lib_a-fminl.$(OBJEXT) lib_a-fmal.$(OBJEXT) \
 	lib_a-acoshl.$(OBJEXT) lib_a-atanhl.$(OBJEXT) \
 	lib_a-remainderl.$(OBJEXT) lib_a-lgammal.$(OBJEXT) \
-	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT)
+	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT) \
+	lib_a-logbl.$(OBJEXT) lib_a-nexttoward.$(OBJEXT) \
+	lib_a-nexttowardl.$(OBJEXT) lib_a-nexttowardf.$(OBJEXT)
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@am__objects_4 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@	$(am__objects_3)
 @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \
 @USE_LIBTOOL_FALSE@	$(am__objects_2) $(am__objects_4)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libcommon_la_LIBADD =
 am__objects_5 = s_finite.lo s_copysign.lo s_modf.lo s_scalbn.lo \
 	s_cbrt.lo s_exp10.lo s_expm1.lo s_ilogb.lo s_infconst.lo \
 	s_infinity.lo s_isinf.lo s_isinfd.lo s_isnan.lo s_isnand.lo \
@@ -162,21 +164,21 @@
 	sf_scalbln.lo sf_trunc.lo
 am__objects_7 = atanl.lo cosl.lo sinl.lo tanl.lo tanhl.lo frexpl.lo \
 	modfl.lo ceill.lo fabsl.lo floorl.lo log1pl.lo expm1l.lo \
 	acosl.lo asinl.lo atan2l.lo coshl.lo sinhl.lo expl.lo \
 	ldexpl.lo logl.lo log10l.lo powl.lo sqrtl.lo fmodl.lo \
 	hypotl.lo copysignl.lo nanl.lo ilogbl.lo asinhl.lo cbrtl.lo \
 	nextafterl.lo rintl.lo scalbnl.lo exp2l.lo scalblnl.lo \
 	tgammal.lo nearbyintl.lo lrintl.lo llrintl.lo roundl.lo \
 	lroundl.lo llroundl.lo truncl.lo remquol.lo fdiml.lo fmaxl.lo \
 	fminl.lo fmal.lo acoshl.lo atanhl.lo remainderl.lo lgammal.lo \
-	erfl.lo erfcl.lo
+	erfl.lo erfcl.lo logbl.lo nexttowardf.lo nexttoward.lo nexttowardl.lo
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@am__objects_8 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@	$(am__objects_7)
 @USE_LIBTOOL_TRUE@am_libcommon_la_OBJECTS = $(am__objects_5) \
 @USE_LIBTOOL_TRUE@	$(am__objects_6) $(am__objects_8)
 libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
 libcommon_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(libcommon_la_LDFLAGS) $(LDFLAGS) -o $@
 @USE_LIBTOOL_TRUE@am_libcommon_la_rpath =
 DEFAULT_INCLUDES = -I.@am__isrc@
@@ -348,21 +350,22 @@
 	sf_lrint.c sf_llrint.c \
 	sf_lround.c sf_llround.c sf_nearbyint.c sf_remquo.c sf_round.c \
 	sf_scalbln.c sf_trunc.c
 
 lsrc = atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
 	floorl.c log1pl.c expm1l.c acosl.c asinl.c atan2l.c coshl.c sinhl.c \
 	expl.c ldexpl.c logl.c log10l.c powl.c sqrtl.c fmodl.c hypotl.c \
 	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
 	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \
 	roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \
-	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c \
+	logbl.c nexttowardf.c nexttoward.c nexttowardl.c
 
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcommon.la
 @USE_LIBTOOL_TRUE@libcommon_la_SOURCES = $(src) $(fsrc) \
 @USE_LIBTOOL_TRUE@	$(am__append_1)
 @USE_LIBTOOL_FALSE@noinst_DATA = 
 @USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in
 @USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a
 @USE_LIBTOOL_FALSE@lib_a_SOURCES = $(src) $(fsrc) $(am__append_2)
 @USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS)
@@ -1058,20 +1061,44 @@
 
 lib_a-cbrtl.obj: cbrtl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cbrtl.obj `if test -f 'cbrtl.c'; then $(CYGPATH_W) 'cbrtl.c'; else $(CYGPATH_W) '$(srcdir)/cbrtl.c'; fi`
 
 lib_a-nextafterl.o: nextafterl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nextafterl.o `test -f 'nextafterl.c' || echo '$(srcdir)/'`nextafterl.c
 
 lib_a-nextafterl.obj: nextafterl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nextafterl.obj `if test -f 'nextafterl.c'; then $(CYGPATH_W) 'nextafterl.c'; else $(CYGPATH_W) '$(srcdir)/nextafterl.c'; fi`
 
+lib_a-logbl.o: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.o `test -f 'logbl.c' || echo '$(srcdir)/'`logbl.c
+
+lib_a-logbl.obj: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.obj `if test -f 'logbl.c'; then $(CYGPATH_W) 'logbl.c'; else $(CYGPATH_W) '$(srcdir)/logbll.c'; fi`
+
+lib_a-nexttowardf.o: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.o `test -f 'nexttowardf.c' || echo '$(srcdir)/'`nexttowardf.c
+
+lib_a-nexttowardf.obj: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.obj `if test -f 'nexttowardf.c'; then $(CYGPATH_W) 'nexttowardf.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardfl.c'; fi`
+
+lib_a-nexttoward.o: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.o `test -f 'nexttoward.c' || echo '$(srcdir)/'`nexttoward.c
+
+lib_a-nexttoward.obj: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.obj `if test -f 'nexttoward.c'; then $(CYGPATH_W) 'nexttoward.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardl.c'; fi`
+
+lib_a-nexttowardl.o: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.o `test -f 'nexttowardl.c' || echo '$(srcdir)/'`nexttowardl.c
+
+lib_a-nexttowardl.obj: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.obj `if test -f 'nexttowardl.c'; then $(CYGPATH_W) 'nexttowardl.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardll.c'; fi`
+
 lib_a-rintl.o: rintl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rintl.o `test -f 'rintl.c' || echo '$(srcdir)/'`rintl.c
 
 lib_a-rintl.obj: rintl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rintl.obj `if test -f 'rintl.c'; then $(CYGPATH_W) 'rintl.c'; else $(CYGPATH_W) '$(srcdir)/rintl.c'; fi`
 
 lib_a-scalbnl.o: scalbnl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-scalbnl.o `test -f 'scalbnl.c' || echo '$(srcdir)/'`scalbnl.c
 
 lib_a-scalbnl.obj: scalbnl.c

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-09-23 20:33 [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems Jonathan Roelofs
@ 2014-09-24  1:18 ` Craig Howland
  2014-09-24 16:37   ` Jonathan Roelofs
  0 siblings, 1 reply; 15+ messages in thread
From: Craig Howland @ 2014-09-24  1:18 UTC (permalink / raw)
  To: newlib

On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
> Please see the attached patch.
>
Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.

Operationally, all looks OK, but aesthetically, the use of casting is 
inconsistent.  For example:

+long double
+nexttowardl (long double x, long double y)
+{
+  return nextafter((double)x, (double)y);
+}

The x and y arguments are cast to double to pass to nextafter(), but the return 
value is not cast to long double.  It works OK, but could be confusing.  Are the 
casts intended to highlight the spots where the double/long double equality is 
required?  If so, it would probably be better to either cast in all places where 
it is theoretically needed, or to just leave them out.  The other existing 
functions of this style left all of them out (i.e. no casts from ld to d or d to 
ld)--see, for example, libm/common/nextafterl.c.  I suggest that the precedent 
is the better way.

Craig

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-09-24  1:18 ` Craig Howland
@ 2014-09-24 16:37   ` Jonathan Roelofs
  2014-12-02 18:45     ` JF Bastien
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-09-24 16:37 UTC (permalink / raw)
  To: Craig Howland, newlib

[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]

Craig,

Thanks for the review!

On 9/23/14 7:17 PM, Craig Howland wrote:
> On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
>> Please see the attached patch.
>>
> Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.
Oops. I'm not very familiar with Newlib processes, so please let me know if I'm 
missing other things that you'd normally expect from such an upstream 
submission.... For example, some of my co-workers reminded me to also update 
COPYING.NEWLIB, and add copyright headers to the new files.
>
> Operationally, all looks OK, but aesthetically, the use of casting is
> inconsistent.  For example:
>
> +long double
> +nexttowardl (long double x, long double y)
> +{
> +  return nextafter((double)x, (double)y);
> +}
>
> The x and y arguments are cast to double to pass to nextafter(), but the return
> value is not cast to long double.  It works OK, but could be confusing.  Are the
> casts intended to highlight the spots where the double/long double equality is
> required?
Yeah, that was my intent.
> If so, it would probably be better to either cast in all places where
> it is theoretically needed, or to just leave them out.  The other existing
> functions of this style left all of them out (i.e. no casts from ld to d or d to
> ld)--see, for example, libm/common/nextafterl.c.  I suggest that the precedent
> is the better way.
Agreed, consistency is probably better.

Attached is a new version of this patch with these things addressed, and I've 
added another similar shim for log2l.


Cheers,

Jon
>
> Craig

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

[-- Attachment #2: newlib_nexttoward2.diff --]
[-- Type: text/plain, Size: 30238 bytes --]

diff --git a/src/COPYING.NEWLIB b/src/COPYING.NEWLIB
index 0655d35..1cec9ad 100644
--- a/src/COPYING.NEWLIB
+++ b/src/COPYING.NEWLIB
@@ -934,20 +934,47 @@ 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.
 
+(42) - Mentor Graphics, Inc.
+
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 MENTOR GRAPHICS, INC. ``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 MENTOR GRAPHICS 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.
+
diff --git a/src/ChangeLog b/src/ChangeLog
index 5bea065..f283dc4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,20 +1,24 @@
+2014-09-24  Jonathan Roelofs  <jonathan@codesourcery.com>
+
+	* COPYING.NEWLIB: Add Mentor Graphics copyright.
+
 2014-07-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	* configure.ac: Don't accept isl 0.10.
 	* configure: Regenerate.
 
 2014-05-14  Sandra Loosemore  <sandra@codesourcery.com>
 
 	* configure.ac (target_makefile_frag): Set for nios2-*-elf*.
 	* configure: Regenerated.
 
 2014-04-04  Jeff Johnston  <jjohnstn@redhat.com>
 
 	* COPYING.NEWLIB: Add to current TI license to
         include tirtos addition.
 
 2014-02-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	PR target/59788
 	* ltmain.sh (opt_duplicate_compiler_generated_deps): Enable on
 	*solaris2*.
diff --git a/src/newlib/ChangeLog b/src/newlib/ChangeLog
index a157623..5180ee3 100644
--- a/src/newlib/ChangeLog
+++ b/src/newlib/ChangeLog
@@ -1,20 +1,31 @@
+2014-09-24  Jonathan Roelofs  <jonathan@codesourcery.com>
+
+	* libc/include/math.h: Add nexttowardf,nexttoward,nexttowardl,logbl,and log2l.
+	* libm/common/logbl.c: New File.
+	* libm/common/log2l.c: Likewise.
+	* libm/common/nexttowardf.c: Likewise.
+	* libm/common/nexttoward.c: Likewise.
+	* libm/common/nexttowardl.c: Likewise.
+	* libm/common/Makefile.am: Add dependencies.
+	* libm/common/Makefile.in: Add dependencies.
+
 2014-09-17  Jeff Johnston  <jjohnstn@redhat.com>
 
 	* libc/include/sys/features.h: Add __NEWLIB__ and
 	__NEWLIB_MINOR__ macros.
 
 2014-09-17  Joel Sherrill <joel.sherrill@oarcorp.com>
 	    Thomas Uhle <thomas.uhle@eas.iis.fraunhofer.de>
 
 	* libc/include/string.h: Correct guard for strnlen().
 
 2014-09-15  Jeff Johnston  <jjohnstn@redhat.com>
 
 	* libc/time/month_lengths.c: Fix to define __month_lengths.
 
 2014-09-12  Jeff Johnston  <jjohnstn@redhat.com>
 
 	* libc/time/tzcalc_limits.c: Fix __month_lengths reference.
 
 2014-09-12  Jeff Johnston  <jjohnstn@redhat.com>
 
diff --git a/src/newlib/libc/include/math.h b/src/newlib/libc/include/math.h
index 2da05f1..eda6146 100644
--- a/src/newlib/libc/include/math.h
+++ b/src/newlib/libc/include/math.h
@@ -405,40 +405,45 @@ extern long double acosl _PARAMS((long double));
 extern long double asinl _PARAMS((long double));
 extern long double atan2l _PARAMS((long double, long double));
 extern long double coshl _PARAMS((long double));
 extern long double sinhl _PARAMS((long double));
 extern long double expl _PARAMS((long double));
 extern long double ldexpl _PARAMS((long double, int));
 extern long double logl _PARAMS((long double));
 extern long double log10l _PARAMS((long double));
 extern long double powl _PARAMS((long double, long double));
 extern long double sqrtl _PARAMS((long double));
 extern long double fmodl _PARAMS((long double, long double));
 extern long double hypotl _PARAMS((long double, long double));
 #endif /* ! defined (__math_68881) */
 #endif /* ! defined (_REENT_ONLY) */
 extern long double copysignl _PARAMS((long double, long double));
 extern long double nanl _PARAMS((const char *));
 extern int ilogbl _PARAMS((long double));
 extern long double asinhl _PARAMS((long double));
 extern long double cbrtl _PARAMS((long double));
 extern long double nextafterl _PARAMS((long double, long double));
+extern float nexttowardf _PARAMS((float, long double));
+extern double nexttoward _PARAMS((double, long double));
+extern long double nexttowardl _PARAMS((long double, long double));
+extern long double logbl _PARAMS((long double));
+extern long double log2l _PARAMS((long double));
 extern long double rintl _PARAMS((long double));
 extern long double scalbnl _PARAMS((long double, int));
 extern long double exp2l _PARAMS((long double));
 extern long double scalblnl _PARAMS((long double, long));
 extern long double tgammal _PARAMS((long double));
 extern long double nearbyintl _PARAMS((long double));
 extern long int lrintl _PARAMS((long double));
 extern long long int llrintl _PARAMS((long double));
 extern long double roundl _PARAMS((long double));
 extern long lroundl _PARAMS((long double));
 extern _LONG_LONG_TYPE int llroundl _PARAMS((long double));
 extern long double truncl _PARAMS((long double));
 extern long double remquol _PARAMS((long double, long double, int *));
 extern long double fdiml _PARAMS((long double, long double));
 extern long double fmaxl _PARAMS((long double, long double));
 extern long double fminl _PARAMS((long double, long double));
 extern long double fmal _PARAMS((long double, long double, long double));
 #ifndef _REENT_ONLY
 extern long double acoshl _PARAMS((long double));
 extern long double atanhl _PARAMS((long double));
diff --git a/src/newlib/libm/common/Makefile.am b/src/newlib/libm/common/Makefile.am
index ed556ef..b370b2e 100644
--- a/src/newlib/libm/common/Makefile.am
+++ b/src/newlib/libm/common/Makefile.am
@@ -13,41 +13,43 @@ src = 	s_finite.c s_copysign.c s_modf.c s_scalbn.c \
 	s_lrint.c s_llrint.c \
 	s_lround.c s_llround.c s_nearbyint.c s_remquo.c s_round.c s_scalbln.c \
 	s_signbit.c s_trunc.c
 
 fsrc =	sf_finite.c sf_copysign.c sf_modf.c sf_scalbn.c \
 	sf_cbrt.c sf_exp10.c sf_expm1.c sf_ilogb.c \
 	sf_infinity.c sf_isinf.c sf_isinff.c sf_isnan.c sf_isnanf.c \
 	sf_log1p.c sf_nan.c sf_nextafter.c sf_pow10.c \
 	sf_rint.c sf_logb.c sf_log2.c \
 	sf_fdim.c sf_fma.c sf_fmax.c sf_fmin.c sf_fpclassify.c \
 	sf_lrint.c sf_llrint.c \
 	sf_lround.c sf_llround.c sf_nearbyint.c sf_remquo.c sf_round.c \
 	sf_scalbln.c sf_trunc.c
 
 lsrc =	atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
 	floorl.c log1pl.c expm1l.c acosl.c asinl.c atan2l.c coshl.c sinhl.c \
 	expl.c ldexpl.c logl.c log10l.c powl.c sqrtl.c fmodl.c hypotl.c \
 	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
 	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \
 	roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \
-	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c \
+	logbl.c nexttowardf.c nexttoward.c nexttowardl.c log2l.c
+
 
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 
 if USE_LIBTOOL
 noinst_LTLIBRARIES = libcommon.la
 libcommon_la_SOURCES = $(src) $(fsrc)
 if HAVE_LONG_DOUBLE
 libcommon_la_SOURCES += $(lsrc)
 endif # HAVE_LONG_DOUBLE
 noinst_DATA = objectlist.awk.in
 else
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(src) $(fsrc)
 if HAVE_LONG_DOUBLE
 lib_a_SOURCES += $(lsrc)
 endif # HAVE_LONG_DOUBLE
 lib_a_CFLAGS = $(AM_CFLAGS)
 noinst_DATA =
 endif # USE_LIBTOOL
 
diff --git a/src/newlib/libm/common/Makefile.in b/src/newlib/libm/common/Makefile.in
index 12b5a30..7964531 100644
--- a/src/newlib/libm/common/Makefile.in
+++ b/src/newlib/libm/common/Makefile.in
@@ -119,74 +119,79 @@ am__objects_3 = lib_a-atanl.$(OBJEXT) lib_a-cosl.$(OBJEXT) \
 	lib_a-acosl.$(OBJEXT) lib_a-asinl.$(OBJEXT) \
 	lib_a-atan2l.$(OBJEXT) lib_a-coshl.$(OBJEXT) \
 	lib_a-sinhl.$(OBJEXT) lib_a-expl.$(OBJEXT) \
 	lib_a-ldexpl.$(OBJEXT) lib_a-logl.$(OBJEXT) \
 	lib_a-log10l.$(OBJEXT) lib_a-powl.$(OBJEXT) \
 	lib_a-sqrtl.$(OBJEXT) lib_a-fmodl.$(OBJEXT) \
 	lib_a-hypotl.$(OBJEXT) lib_a-copysignl.$(OBJEXT) \
 	lib_a-nanl.$(OBJEXT) lib_a-ilogbl.$(OBJEXT) \
 	lib_a-asinhl.$(OBJEXT) lib_a-cbrtl.$(OBJEXT) \
 	lib_a-nextafterl.$(OBJEXT) lib_a-rintl.$(OBJEXT) \
 	lib_a-scalbnl.$(OBJEXT) lib_a-exp2l.$(OBJEXT) \
 	lib_a-scalblnl.$(OBJEXT) lib_a-tgammal.$(OBJEXT) \
 	lib_a-nearbyintl.$(OBJEXT) lib_a-lrintl.$(OBJEXT) \
 	lib_a-llrintl.$(OBJEXT) lib_a-roundl.$(OBJEXT) \
 	lib_a-lroundl.$(OBJEXT) lib_a-llroundl.$(OBJEXT) \
 	lib_a-truncl.$(OBJEXT) lib_a-remquol.$(OBJEXT) \
 	lib_a-fdiml.$(OBJEXT) lib_a-fmaxl.$(OBJEXT) \
 	lib_a-fminl.$(OBJEXT) lib_a-fmal.$(OBJEXT) \
 	lib_a-acoshl.$(OBJEXT) lib_a-atanhl.$(OBJEXT) \
 	lib_a-remainderl.$(OBJEXT) lib_a-lgammal.$(OBJEXT) \
-	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT)
+	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT) \
+	lib_a-logbl.$(OBJEXT) lib_a-nexttoward.$(OBJEXT) \
+	lib_a-nexttowardl.$(OBJEXT) lib_a-nexttowardf.$(OBJEXT) \
+	lib_a-log2l.$(OBJEXT)
+
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@am__objects_4 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@	$(am__objects_3)
 @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \
 @USE_LIBTOOL_FALSE@	$(am__objects_2) $(am__objects_4)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libcommon_la_LIBADD =
 am__objects_5 = s_finite.lo s_copysign.lo s_modf.lo s_scalbn.lo \
 	s_cbrt.lo s_exp10.lo s_expm1.lo s_ilogb.lo s_infconst.lo \
 	s_infinity.lo s_isinf.lo s_isinfd.lo s_isnan.lo s_isnand.lo \
 	s_log1p.lo s_nan.lo s_nextafter.lo s_pow10.lo s_rint.lo \
 	s_logb.lo s_log2.lo s_matherr.lo s_lib_ver.lo s_fdim.lo \
 	s_fma.lo s_fmax.lo s_fmin.lo s_fpclassify.lo s_lrint.lo \
 	s_llrint.lo s_lround.lo s_llround.lo s_nearbyint.lo \
 	s_remquo.lo s_round.lo s_scalbln.lo s_signbit.lo s_trunc.lo
 am__objects_6 = sf_finite.lo sf_copysign.lo sf_modf.lo sf_scalbn.lo \
 	sf_cbrt.lo sf_exp10.lo sf_expm1.lo sf_ilogb.lo sf_infinity.lo \
 	sf_isinf.lo sf_isinff.lo sf_isnan.lo sf_isnanf.lo sf_log1p.lo \
 	sf_nan.lo sf_nextafter.lo sf_pow10.lo sf_rint.lo sf_logb.lo \
 	sf_log2.lo sf_fdim.lo sf_fma.lo sf_fmax.lo sf_fmin.lo \
 	sf_fpclassify.lo sf_lrint.lo sf_llrint.lo sf_lround.lo \
 	sf_llround.lo sf_nearbyint.lo sf_remquo.lo sf_round.lo \
 	sf_scalbln.lo sf_trunc.lo
 am__objects_7 = atanl.lo cosl.lo sinl.lo tanl.lo tanhl.lo frexpl.lo \
 	modfl.lo ceill.lo fabsl.lo floorl.lo log1pl.lo expm1l.lo \
 	acosl.lo asinl.lo atan2l.lo coshl.lo sinhl.lo expl.lo \
 	ldexpl.lo logl.lo log10l.lo powl.lo sqrtl.lo fmodl.lo \
 	hypotl.lo copysignl.lo nanl.lo ilogbl.lo asinhl.lo cbrtl.lo \
 	nextafterl.lo rintl.lo scalbnl.lo exp2l.lo scalblnl.lo \
 	tgammal.lo nearbyintl.lo lrintl.lo llrintl.lo roundl.lo \
 	lroundl.lo llroundl.lo truncl.lo remquol.lo fdiml.lo fmaxl.lo \
 	fminl.lo fmal.lo acoshl.lo atanhl.lo remainderl.lo lgammal.lo \
-	erfl.lo erfcl.lo
+	erfl.lo erfcl.lo logbl.lo nexttowardf.lo nexttoward.lo nexttowardl.lo \
+	log2l.lo
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@am__objects_8 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@	$(am__objects_7)
 @USE_LIBTOOL_TRUE@am_libcommon_la_OBJECTS = $(am__objects_5) \
 @USE_LIBTOOL_TRUE@	$(am__objects_6) $(am__objects_8)
 libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
 libcommon_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(libcommon_la_LDFLAGS) $(LDFLAGS) -o $@
 @USE_LIBTOOL_TRUE@am_libcommon_la_rpath =
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp =
 am__depfiles_maybe =
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
@@ -338,41 +343,42 @@ src = s_finite.c s_copysign.c s_modf.c s_scalbn.c \
 	s_lrint.c s_llrint.c \
 	s_lround.c s_llround.c s_nearbyint.c s_remquo.c s_round.c s_scalbln.c \
 	s_signbit.c s_trunc.c
 
 fsrc = sf_finite.c sf_copysign.c sf_modf.c sf_scalbn.c \
 	sf_cbrt.c sf_exp10.c sf_expm1.c sf_ilogb.c \
 	sf_infinity.c sf_isinf.c sf_isinff.c sf_isnan.c sf_isnanf.c \
 	sf_log1p.c sf_nan.c sf_nextafter.c sf_pow10.c \
 	sf_rint.c sf_logb.c sf_log2.c \
 	sf_fdim.c sf_fma.c sf_fmax.c sf_fmin.c sf_fpclassify.c \
 	sf_lrint.c sf_llrint.c \
 	sf_lround.c sf_llround.c sf_nearbyint.c sf_remquo.c sf_round.c \
 	sf_scalbln.c sf_trunc.c
 
 lsrc = atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
 	floorl.c log1pl.c expm1l.c acosl.c asinl.c atan2l.c coshl.c sinhl.c \
 	expl.c ldexpl.c logl.c log10l.c powl.c sqrtl.c fmodl.c hypotl.c \
 	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
 	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \
 	roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \
-	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c \
+	logbl.c nexttowardf.c nexttoward.c nexttowardl.c log2l.c
 
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcommon.la
 @USE_LIBTOOL_TRUE@libcommon_la_SOURCES = $(src) $(fsrc) \
 @USE_LIBTOOL_TRUE@	$(am__append_1)
 @USE_LIBTOOL_FALSE@noinst_DATA = 
 @USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in
 @USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a
 @USE_LIBTOOL_FALSE@lib_a_SOURCES = $(src) $(fsrc) $(am__append_2)
 @USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS)
 chobj = s_cbrt.def s_copysign.def s_exp10.def s_expm1.def s_ilogb.def \
 	s_infinity.def s_isnan.def s_log1p.def s_matherr.def s_modf.def \
 	s_nan.def s_nextafter.def s_pow10.def s_scalbn.def \
 	s_fdim.def s_fma.def s_fmax.def s_fmin.def \
 	s_logb.def s_log2.def s_lrint.def s_lround.def s_nearbyint.def \
 	s_remquo.def s_rint.def s_round.def s_signbit.def s_trunc.def \
 	isgreater.def
 
 SUFFIXES = .def
 CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
@@ -1048,40 +1054,70 @@ lib_a-ilogbl.obj: ilogbl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ilogbl.obj `if test -f 'ilogbl.c'; then $(CYGPATH_W) 'ilogbl.c'; else $(CYGPATH_W) '$(srcdir)/ilogbl.c'; fi`
 
 lib_a-asinhl.o: asinhl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asinhl.o `test -f 'asinhl.c' || echo '$(srcdir)/'`asinhl.c
 
 lib_a-asinhl.obj: asinhl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-asinhl.obj `if test -f 'asinhl.c'; then $(CYGPATH_W) 'asinhl.c'; else $(CYGPATH_W) '$(srcdir)/asinhl.c'; fi`
 
 lib_a-cbrtl.o: cbrtl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cbrtl.o `test -f 'cbrtl.c' || echo '$(srcdir)/'`cbrtl.c
 
 lib_a-cbrtl.obj: cbrtl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cbrtl.obj `if test -f 'cbrtl.c'; then $(CYGPATH_W) 'cbrtl.c'; else $(CYGPATH_W) '$(srcdir)/cbrtl.c'; fi`
 
 lib_a-nextafterl.o: nextafterl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nextafterl.o `test -f 'nextafterl.c' || echo '$(srcdir)/'`nextafterl.c
 
 lib_a-nextafterl.obj: nextafterl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nextafterl.obj `if test -f 'nextafterl.c'; then $(CYGPATH_W) 'nextafterl.c'; else $(CYGPATH_W) '$(srcdir)/nextafterl.c'; fi`
 
+lib_a-logbl.o: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.o `test -f 'logbl.c' || echo '$(srcdir)/'`logbl.c
+
+lib_a-logbl.obj: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.obj `if test -f 'logbl.c'; then $(CYGPATH_W) 'logbl.c'; else $(CYGPATH_W) '$(srcdir)/logbll.c'; fi`
+
+lib_a-log2l.o: log2l.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-log2l.o `test -f 'log2l.c' || echo '$(srcdir)/'`log2l.c
+
+lib_a-log2l.obj: log2l.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-log2l.obj `if test -f 'log2l.c'; then $(CYGPATH_W) 'log2l.c'; else $(CYGPATH_W) '$(srcdir)/log2ll.c'; fi`
+
+lib_a-nexttowardf.o: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.o `test -f 'nexttowardf.c' || echo '$(srcdir)/'`nexttowardf.c
+
+lib_a-nexttowardf.obj: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.obj `if test -f 'nexttowardf.c'; then $(CYGPATH_W) 'nexttowardf.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardfl.c'; fi`
+
+lib_a-nexttoward.o: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.o `test -f 'nexttoward.c' || echo '$(srcdir)/'`nexttoward.c
+
+lib_a-nexttoward.obj: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.obj `if test -f 'nexttoward.c'; then $(CYGPATH_W) 'nexttoward.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardl.c'; fi`
+
+lib_a-nexttowardl.o: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.o `test -f 'nexttowardl.c' || echo '$(srcdir)/'`nexttowardl.c
+
+lib_a-nexttowardl.obj: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.obj `if test -f 'nexttowardl.c'; then $(CYGPATH_W) 'nexttowardl.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardll.c'; fi`
+
 lib_a-rintl.o: rintl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rintl.o `test -f 'rintl.c' || echo '$(srcdir)/'`rintl.c
 
 lib_a-rintl.obj: rintl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rintl.obj `if test -f 'rintl.c'; then $(CYGPATH_W) 'rintl.c'; else $(CYGPATH_W) '$(srcdir)/rintl.c'; fi`
 
 lib_a-scalbnl.o: scalbnl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-scalbnl.o `test -f 'scalbnl.c' || echo '$(srcdir)/'`scalbnl.c
 
 lib_a-scalbnl.obj: scalbnl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-scalbnl.obj `if test -f 'scalbnl.c'; then $(CYGPATH_W) 'scalbnl.c'; else $(CYGPATH_W) '$(srcdir)/scalbnl.c'; fi`
 
 lib_a-exp2l.o: exp2l.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-exp2l.o `test -f 'exp2l.c' || echo '$(srcdir)/'`exp2l.c
 
 lib_a-exp2l.obj: exp2l.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-exp2l.obj `if test -f 'exp2l.c'; then $(CYGPATH_W) 'exp2l.c'; else $(CYGPATH_W) '$(srcdir)/exp2l.c'; fi`
 
 lib_a-scalblnl.o: scalblnl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-scalblnl.o `test -f 'scalblnl.c' || echo '$(srcdir)/'`scalblnl.c
diff --git a/src/newlib/libm/common/log2l.c b/src/newlib/libm/common/log2l.c
new file mode 100644
index 0000000..e92e9eb
--- /dev/null
+++ b/src/newlib/libm/common/log2l.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+log2l (long double x)
+{
+  return log2(x);
+}
+#endif
+
diff --git a/src/newlib/libm/common/logbl.c b/src/newlib/libm/common/logbl.c
new file mode 100644
index 0000000..56c1cf5
--- /dev/null
+++ b/src/newlib/libm/common/logbl.c
@@ -0,0 +1,22 @@
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+logbl (long double x)
+{
+  return logb(x);
+}
+#endif
+
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+logbl (long double x)
+{
+  return logb((double)x);
+}
+#endif
+
diff --git a/src/newlib/libm/common/nexttoward.c b/src/newlib/libm/common/nexttoward.c
new file mode 100644
index 0000000..92093e9
--- /dev/null
+++ b/src/newlib/libm/common/nexttoward.c
@@ -0,0 +1,49 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+double
+nexttoward (double x, long double y)
+{
+  return nextafter(x, y);
+}
+#endif
+
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+double
+nexttoward (double x, long double y)
+{
+  return nextafter(x, (double)y);
+}
+#endif
+
diff --git a/src/newlib/libm/common/nexttowardf.c b/src/newlib/libm/common/nexttowardf.c
new file mode 100644
index 0000000..3fca64f
--- /dev/null
+++ b/src/newlib/libm/common/nexttowardf.c
@@ -0,0 +1,49 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+float
+nexttowardf (float x, long double y)
+{
+  return nextafterf(x, y);
+}
+#endif
+
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+float
+nexttowardf (float x, long double y)
+{
+  return nextafterf(x, (double)y);
+}
+#endif
+
diff --git a/src/newlib/libm/common/nexttowardl.c b/src/newlib/libm/common/nexttowardl.c
new file mode 100644
index 0000000..fbfd498
--- /dev/null
+++ b/src/newlib/libm/common/nexttowardl.c
@@ -0,0 +1,49 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+nexttowardl (long double x, long double y)
+{
+  return nextafter(x, y);
+}
+#endif
+
+#include <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+nexttowardl (long double x, long double y)
+{
+  return nextafter((double)x, (double)y);
+}
+#endif
+

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-09-24 16:37   ` Jonathan Roelofs
@ 2014-12-02 18:45     ` JF Bastien
  2014-12-02 18:55       ` Jonathan Roelofs
  0 siblings, 1 reply; 15+ messages in thread
From: JF Bastien @ 2014-12-02 18:45 UTC (permalink / raw)
  To: Jonathan Roelofs; +Cc: Craig Howland, newlib

Is this change ready to land?

On Wed, Sep 24, 2014 at 9:38 AM, Jonathan Roelofs
<jonathan@codesourcery.com> wrote:
> Craig,
>
> Thanks for the review!
>
> On 9/23/14 7:17 PM, Craig Howland wrote:
>>
>> On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
>>>
>>> Please see the attached patch.
>>>
>> Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.
>
> Oops. I'm not very familiar with Newlib processes, so please let me know if
> I'm missing other things that you'd normally expect from such an upstream
> submission.... For example, some of my co-workers reminded me to also update
> COPYING.NEWLIB, and add copyright headers to the new files.
>>
>>
>> Operationally, all looks OK, but aesthetically, the use of casting is
>> inconsistent.  For example:
>>
>> +long double
>> +nexttowardl (long double x, long double y)
>> +{
>> +  return nextafter((double)x, (double)y);
>> +}
>>
>> The x and y arguments are cast to double to pass to nextafter(), but the
>> return
>> value is not cast to long double.  It works OK, but could be confusing.
>> Are the
>> casts intended to highlight the spots where the double/long double
>> equality is
>> required?
>
> Yeah, that was my intent.
>>
>> If so, it would probably be better to either cast in all places where
>> it is theoretically needed, or to just leave them out.  The other existing
>> functions of this style left all of them out (i.e. no casts from ld to d
>> or d to
>> ld)--see, for example, libm/common/nextafterl.c.  I suggest that the
>> precedent
>> is the better way.
>
> Agreed, consistency is probably better.
>
> Attached is a new version of this patch with these things addressed, and
> I've added another similar shim for log2l.
>
>
> Cheers,
>
> Jon
>>
>>
>> Craig
>
>
> --
> Jon Roelofs
> jonathan@codesourcery.com
> CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-02 18:45     ` JF Bastien
@ 2014-12-02 18:55       ` Jonathan Roelofs
  2014-12-02 23:45         ` Jonathan Roelofs
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-12-02 18:55 UTC (permalink / raw)
  To: JF Bastien; +Cc: Craig Howland, newlib

JF,

No. I've been told by one of my coworkers that nexttowardf cannot be implemented 
correctly on top of nextafterf. For that one we'll need a different 
implementation, perhaps we can copy the one in musl?... I'm not sure if the 
license is compatible with doing that.

Everything in this patch aside from the nexttowardf implementation is ready to 
go as far as I'm concerned. Craig, how about on your end?


Cheers,

Jon

On 12/2/14 11:45 AM, JF Bastien wrote:
> Is this change ready to land?
>
> On Wed, Sep 24, 2014 at 9:38 AM, Jonathan Roelofs
> <jonathan@codesourcery.com> wrote:
>> Craig,
>>
>> Thanks for the review!
>>
>> On 9/23/14 7:17 PM, Craig Howland wrote:
>>>
>>> On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
>>>>
>>>> Please see the attached patch.
>>>>
>>> Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.
>>
>> Oops. I'm not very familiar with Newlib processes, so please let me know if
>> I'm missing other things that you'd normally expect from such an upstream
>> submission.... For example, some of my co-workers reminded me to also update
>> COPYING.NEWLIB, and add copyright headers to the new files.
>>>
>>>
>>> Operationally, all looks OK, but aesthetically, the use of casting is
>>> inconsistent.  For example:
>>>
>>> +long double
>>> +nexttowardl (long double x, long double y)
>>> +{
>>> +  return nextafter((double)x, (double)y);
>>> +}
>>>
>>> The x and y arguments are cast to double to pass to nextafter(), but the
>>> return
>>> value is not cast to long double.  It works OK, but could be confusing.
>>> Are the
>>> casts intended to highlight the spots where the double/long double
>>> equality is
>>> required?
>>
>> Yeah, that was my intent.
>>>
>>> If so, it would probably be better to either cast in all places where
>>> it is theoretically needed, or to just leave them out.  The other existing
>>> functions of this style left all of them out (i.e. no casts from ld to d
>>> or d to
>>> ld)--see, for example, libm/common/nextafterl.c.  I suggest that the
>>> precedent
>>> is the better way.
>>
>> Agreed, consistency is probably better.
>>
>> Attached is a new version of this patch with these things addressed, and
>> I've added another similar shim for log2l.
>>
>>
>> Cheers,
>>
>> Jon
>>>
>>>
>>> Craig
>>
>>
>> --
>> Jon Roelofs
>> jonathan@codesourcery.com
>> CodeSourcery / Mentor Embedded

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-02 18:55       ` Jonathan Roelofs
@ 2014-12-02 23:45         ` Jonathan Roelofs
       [not found]           ` <547E523B.6060703@codesourcery.com>
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-12-02 23:45 UTC (permalink / raw)
  To: JF Bastien; +Cc: Craig Howland, newlib

Here's a rebased version with the broken nexttowardf replaced by the one from musl.


Cheers,

Jon

On 12/2/14 11:55 AM, Jonathan Roelofs wrote:
> JF,
>
> No. I've been told by one of my coworkers that nexttowardf cannot be implemented
> correctly on top of nextafterf. For that one we'll need a different
> implementation, perhaps we can copy the one in musl?... I'm not sure if the
> license is compatible with doing that.
>
> Everything in this patch aside from the nexttowardf implementation is ready to
> go as far as I'm concerned. Craig, how about on your end?
>
>
> Cheers,
>
> Jon
>
> On 12/2/14 11:45 AM, JF Bastien wrote:
>> Is this change ready to land?
>>
>> On Wed, Sep 24, 2014 at 9:38 AM, Jonathan Roelofs
>> <jonathan@codesourcery.com> wrote:
>>> Craig,
>>>
>>> Thanks for the review!
>>>
>>> On 9/23/14 7:17 PM, Craig Howland wrote:
>>>>
>>>> On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
>>>>>
>>>>> Please see the attached patch.
>>>>>
>>>> Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.
>>>
>>> Oops. I'm not very familiar with Newlib processes, so please let me know if
>>> I'm missing other things that you'd normally expect from such an upstream
>>> submission.... For example, some of my co-workers reminded me to also update
>>> COPYING.NEWLIB, and add copyright headers to the new files.
>>>>
>>>>
>>>> Operationally, all looks OK, but aesthetically, the use of casting is
>>>> inconsistent.  For example:
>>>>
>>>> +long double
>>>> +nexttowardl (long double x, long double y)
>>>> +{
>>>> +  return nextafter((double)x, (double)y);
>>>> +}
>>>>
>>>> The x and y arguments are cast to double to pass to nextafter(), but the
>>>> return
>>>> value is not cast to long double.  It works OK, but could be confusing.
>>>> Are the
>>>> casts intended to highlight the spots where the double/long double
>>>> equality is
>>>> required?
>>>
>>> Yeah, that was my intent.
>>>>
>>>> If so, it would probably be better to either cast in all places where
>>>> it is theoretically needed, or to just leave them out.  The other existing
>>>> functions of this style left all of them out (i.e. no casts from ld to d
>>>> or d to
>>>> ld)--see, for example, libm/common/nextafterl.c.  I suggest that the
>>>> precedent
>>>> is the better way.
>>>
>>> Agreed, consistency is probably better.
>>>
>>> Attached is a new version of this patch with these things addressed, and
>>> I've added another similar shim for log2l.
>>>
>>>
>>> Cheers,
>>>
>>> Jon
>>>>
>>>>
>>>> Craig
>>>
>>>
>>> --
>>> Jon Roelofs
>>> jonathan@codesourcery.com
>>> CodeSourcery / Mentor Embedded
>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
       [not found]           ` <547E523B.6060703@codesourcery.com>
@ 2014-12-03 15:10             ` Jonathan Roelofs
  2014-12-09 14:34               ` Jonathan Roelofs
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-12-03 15:10 UTC (permalink / raw)
  To: JF Bastien; +Cc: Craig Howland, newlib

[-- Attachment #1: Type: text/plain, Size: 3153 bytes --]

Sigh, trying again with less context in the diff. Apparently the mailer daemon 
doesn't like big patches.


Jon

On 12/2/14 4:58 PM, Jonathan Roelofs wrote:
> JF reminds me that I forgot to attach the patch... oops.
>
> Jon
>
> On 12/2/14 4:45 PM, Jonathan Roelofs wrote:
>> Here's a rebased version with the broken nexttowardf replaced by the one from
>> musl.
>>
>>
>> Cheers,
>>
>> Jon
>>
>> On 12/2/14 11:55 AM, Jonathan Roelofs wrote:
>>> JF,
>>>
>>> No. I've been told by one of my coworkers that nexttowardf cannot be implemented
>>> correctly on top of nextafterf. For that one we'll need a different
>>> implementation, perhaps we can copy the one in musl?... I'm not sure if the
>>> license is compatible with doing that.
>>>
>>> Everything in this patch aside from the nexttowardf implementation is ready to
>>> go as far as I'm concerned. Craig, how about on your end?
>>>
>>>
>>> Cheers,
>>>
>>> Jon
>>>
>>> On 12/2/14 11:45 AM, JF Bastien wrote:
>>>> Is this change ready to land?
>>>>
>>>> On Wed, Sep 24, 2014 at 9:38 AM, Jonathan Roelofs
>>>> <jonathan@codesourcery.com> wrote:
>>>>> Craig,
>>>>>
>>>>> Thanks for the review!
>>>>>
>>>>> On 9/23/14 7:17 PM, Craig Howland wrote:
>>>>>>
>>>>>> On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
>>>>>>>
>>>>>>> Please see the attached patch.
>>>>>>>
>>>>>> Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.
>>>>>
>>>>> Oops. I'm not very familiar with Newlib processes, so please let me know if
>>>>> I'm missing other things that you'd normally expect from such an upstream
>>>>> submission.... For example, some of my co-workers reminded me to also update
>>>>> COPYING.NEWLIB, and add copyright headers to the new files.
>>>>>>
>>>>>>
>>>>>> Operationally, all looks OK, but aesthetically, the use of casting is
>>>>>> inconsistent.  For example:
>>>>>>
>>>>>> +long double
>>>>>> +nexttowardl (long double x, long double y)
>>>>>> +{
>>>>>> +  return nextafter((double)x, (double)y);
>>>>>> +}
>>>>>>
>>>>>> The x and y arguments are cast to double to pass to nextafter(), but the
>>>>>> return
>>>>>> value is not cast to long double.  It works OK, but could be confusing.
>>>>>> Are the
>>>>>> casts intended to highlight the spots where the double/long double
>>>>>> equality is
>>>>>> required?
>>>>>
>>>>> Yeah, that was my intent.
>>>>>>
>>>>>> If so, it would probably be better to either cast in all places where
>>>>>> it is theoretically needed, or to just leave them out.  The other existing
>>>>>> functions of this style left all of them out (i.e. no casts from ld to d
>>>>>> or d to
>>>>>> ld)--see, for example, libm/common/nextafterl.c.  I suggest that the
>>>>>> precedent
>>>>>> is the better way.
>>>>>
>>>>> Agreed, consistency is probably better.
>>>>>
>>>>> Attached is a new version of this patch with these things addressed, and
>>>>> I've added another similar shim for log2l.
>>>>>
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Jon
>>>>>>
>>>>>>
>>>>>> Craig
>>>>>
>>>>>
>>>>> --
>>>>> Jon Roelofs
>>>>> jonathan@codesourcery.com
>>>>> CodeSourcery / Mentor Embedded
>>>
>>
>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

[-- Attachment #2: newlib_nexttoward4.diff --]
[-- Type: text/plain, Size: 17319 bytes --]

diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index cf69c05..cdce050 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,15 @@
+2014-12-02  Jonathan Roelofs  <jonathan@codesourcery.com>
+
+	* libc/include/math.h: Add log2l,logbl,nexttowardf,
+	nexttoward,nexttowardl
+	* libm/common/Makefile.am: Reference new files
+	* libm/common/Makefile.in: Reference new files
+	* libm/common/log2l.c: New File
+	* libm/common/logbl.c: Likewise
+	* libm/common/nexttowardf.c: Likewise
+	* libm/common/nexttoward.c: Likewise
+	* libm/common/nexttowardl.c: Likewise
+
 2014-11-28  Matthew Fortune  <matthew.fortune@imgtec.com>
 
 	* libc/include/machine/setjmp.h [__mips__]: Remove __mips_fpr == 64
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 6717cb3..d16ce30 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -423,6 +423,11 @@ extern int ilogbl _PARAMS((long double));
 extern long double asinhl _PARAMS((long double));
 extern long double cbrtl _PARAMS((long double));
 extern long double nextafterl _PARAMS((long double, long double));
+extern float nexttowardf _PARAMS((float, long double));
+extern double nexttoward _PARAMS((double, long double));
+extern long double nexttowardl _PARAMS((long double, long double));
+extern long double logbl _PARAMS((long double));
+extern long double log2l _PARAMS((long double));
 extern long double rintl _PARAMS((long double));
 extern long double scalbnl _PARAMS((long double, int));
 extern long double exp2l _PARAMS((long double));
diff --git a/newlib/libm/common/Makefile.am b/newlib/libm/common/Makefile.am
index ed556ef..b370b2e 100644
--- a/newlib/libm/common/Makefile.am
+++ b/newlib/libm/common/Makefile.am
@@ -30,7 +30,9 @@ lsrc =	atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
 	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
 	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \
 	roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \
-	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c \
+	logbl.c nexttowardf.c nexttoward.c nexttowardl.c log2l.c
+
 
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 
diff --git a/newlib/libm/common/Makefile.in b/newlib/libm/common/Makefile.in
index 12b5a30..7964531 100644
--- a/newlib/libm/common/Makefile.in
+++ b/newlib/libm/common/Makefile.in
@@ -136,7 +136,11 @@ am__objects_3 = lib_a-atanl.$(OBJEXT) lib_a-cosl.$(OBJEXT) \
 	lib_a-fminl.$(OBJEXT) lib_a-fmal.$(OBJEXT) \
 	lib_a-acoshl.$(OBJEXT) lib_a-atanhl.$(OBJEXT) \
 	lib_a-remainderl.$(OBJEXT) lib_a-lgammal.$(OBJEXT) \
-	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT)
+	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT) \
+	lib_a-logbl.$(OBJEXT) lib_a-nexttoward.$(OBJEXT) \
+	lib_a-nexttowardl.$(OBJEXT) lib_a-nexttowardf.$(OBJEXT) \
+	lib_a-log2l.$(OBJEXT)
+
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@am__objects_4 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@	$(am__objects_3)
 @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \
@@ -169,7 +173,8 @@ am__objects_7 = atanl.lo cosl.lo sinl.lo tanl.lo tanhl.lo frexpl.lo \
 	tgammal.lo nearbyintl.lo lrintl.lo llrintl.lo roundl.lo \
 	lroundl.lo llroundl.lo truncl.lo remquol.lo fdiml.lo fmaxl.lo \
 	fminl.lo fmal.lo acoshl.lo atanhl.lo remainderl.lo lgammal.lo \
-	erfl.lo erfcl.lo
+	erfl.lo erfcl.lo logbl.lo nexttowardf.lo nexttoward.lo nexttowardl.lo \
+	log2l.lo
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@am__objects_8 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@	$(am__objects_7)
 @USE_LIBTOOL_TRUE@am_libcommon_la_OBJECTS = $(am__objects_5) \
@@ -355,7 +360,8 @@ lsrc = atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
 	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
 	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \
 	roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \
-	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c \
+	logbl.c nexttowardf.c nexttoward.c nexttowardl.c log2l.c
 
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcommon.la
@@ -1065,6 +1071,36 @@ lib_a-nextafterl.o: nextafterl.c
 lib_a-nextafterl.obj: nextafterl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nextafterl.obj `if test -f 'nextafterl.c'; then $(CYGPATH_W) 'nextafterl.c'; else $(CYGPATH_W) '$(srcdir)/nextafterl.c'; fi`
 
+lib_a-logbl.o: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.o `test -f 'logbl.c' || echo '$(srcdir)/'`logbl.c
+
+lib_a-logbl.obj: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.obj `if test -f 'logbl.c'; then $(CYGPATH_W) 'logbl.c'; else $(CYGPATH_W) '$(srcdir)/logbll.c'; fi`
+
+lib_a-log2l.o: log2l.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-log2l.o `test -f 'log2l.c' || echo '$(srcdir)/'`log2l.c
+
+lib_a-log2l.obj: log2l.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-log2l.obj `if test -f 'log2l.c'; then $(CYGPATH_W) 'log2l.c'; else $(CYGPATH_W) '$(srcdir)/log2ll.c'; fi`
+
+lib_a-nexttowardf.o: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.o `test -f 'nexttowardf.c' || echo '$(srcdir)/'`nexttowardf.c
+
+lib_a-nexttowardf.obj: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.obj `if test -f 'nexttowardf.c'; then $(CYGPATH_W) 'nexttowardf.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardfl.c'; fi`
+
+lib_a-nexttoward.o: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.o `test -f 'nexttoward.c' || echo '$(srcdir)/'`nexttoward.c
+
+lib_a-nexttoward.obj: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.obj `if test -f 'nexttoward.c'; then $(CYGPATH_W) 'nexttoward.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardl.c'; fi`
+
+lib_a-nexttowardl.o: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.o `test -f 'nexttowardl.c' || echo '$(srcdir)/'`nexttowardl.c
+
+lib_a-nexttowardl.obj: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.obj `if test -f 'nexttowardl.c'; then $(CYGPATH_W) 'nexttowardl.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardll.c'; fi`
+
 lib_a-rintl.o: rintl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rintl.o `test -f 'rintl.c' || echo '$(srcdir)/'`rintl.c
 
diff --git a/newlib/libm/common/log2l.c b/newlib/libm/common/log2l.c
new file mode 100644
index 0000000..e92e9eb
--- /dev/null
+++ b/newlib/libm/common/log2l.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+log2l (long double x)
+{
+  return log2(x);
+}
+#endif
+
diff --git a/newlib/libm/common/logbl.c b/newlib/libm/common/logbl.c
new file mode 100644
index 0000000..59d24a2
--- /dev/null
+++ b/newlib/libm/common/logbl.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+logbl (long double x)
+{
+  return logb(x);
+}
+#endif
+
diff --git a/newlib/libm/common/nexttoward.c b/newlib/libm/common/nexttoward.c
new file mode 100644
index 0000000..71dd71d
--- /dev/null
+++ b/newlib/libm/common/nexttoward.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+double
+nexttoward (double x, long double y)
+{
+  return nextafter(x, y);
+}
+#endif
+
diff --git a/newlib/libm/common/nexttowardf.c b/newlib/libm/common/nexttowardf.c
new file mode 100644
index 0000000..87cabc2
--- /dev/null
+++ b/newlib/libm/common/nexttowardf.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2005-2014 Rich Felker, et al.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <math.h>
+#include <inttypes.h>
+#include "local.h"
+
+#define FORCE_EVAL(x) do {                   \
+ if (sizeof(x) == sizeof(float)) {           \
+   volatile float __x;                       \
+   __x = (x);                                \
+ } else if (sizeof(x) == sizeof(double)) {   \
+   volatile double __x;                      \
+   __x = (x);                                \
+ } else {                                    \
+   volatile long double __x;                 \
+   __x = (x);                                \
+ }                                           \
+} while(0)
+
+union fshape {
+  float value;
+  uint32_t bits;
+};
+
+float
+nexttowardf (float x, long double y)
+{
+  union fshape ux;
+  uint32_t e;
+
+  if (isnan(x) || isnan(y))
+    return x + y;
+  if (x == y)
+    return y;
+  ux.value = x;
+  if (x == 0) {
+    ux.bits = 1;
+    if (signbit(y))
+      ux.bits |= 0x80000000;
+  } else if (x < y) {
+    if (signbit(x))
+      ux.bits--;
+    else
+      ux.bits++;
+  } else {
+    if (signbit(x))
+      ux.bits++;
+    else
+      ux.bits--;
+  }
+  e = ux.bits & 0x7f800000;
+  /* raise overflow if ux.value is infinite and x is finite */
+  if (e == 0x7f800000)
+    FORCE_EVAL(x+x);
+  /* raise underflow if ux.value is subnormal or zero */
+  if (e == 0)
+    FORCE_EVAL(x*x + ux.value*ux.value);
+  return ux.value;
+}
diff --git a/newlib/libm/common/nexttowardl.c b/newlib/libm/common/nexttowardl.c
new file mode 100644
index 0000000..59af4ce
--- /dev/null
+++ b/newlib/libm/common/nexttowardl.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+nexttowardl (long double x, long double y)
+{
+  return nextafter(x, y);
+}
+#endif
+

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-03 15:10             ` Jonathan Roelofs
@ 2014-12-09 14:34               ` Jonathan Roelofs
  2014-12-09 22:15                 ` Jeff Johnston
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-12-09 14:34 UTC (permalink / raw)
  To: JF Bastien; +Cc: Craig Howland, newlib

Ping


Cheers,

Jon

On 12/3/14 8:10 AM, Jonathan Roelofs wrote:
> Sigh, trying again with less context in the diff. Apparently the mailer daemon
> doesn't like big patches.
>
>
> Jon
>
> On 12/2/14 4:58 PM, Jonathan Roelofs wrote:
>> JF reminds me that I forgot to attach the patch... oops.
>>
>> Jon
>>
>> On 12/2/14 4:45 PM, Jonathan Roelofs wrote:
>>> Here's a rebased version with the broken nexttowardf replaced by the one from
>>> musl.
>>>
>>>
>>> Cheers,
>>>
>>> Jon
>>>
>>> On 12/2/14 11:55 AM, Jonathan Roelofs wrote:
>>>> JF,
>>>>
>>>> No. I've been told by one of my coworkers that nexttowardf cannot be
>>>> implemented
>>>> correctly on top of nextafterf. For that one we'll need a different
>>>> implementation, perhaps we can copy the one in musl?... I'm not sure if the
>>>> license is compatible with doing that.
>>>>
>>>> Everything in this patch aside from the nexttowardf implementation is ready to
>>>> go as far as I'm concerned. Craig, how about on your end?
>>>>
>>>>
>>>> Cheers,
>>>>
>>>> Jon
>>>>
>>>> On 12/2/14 11:45 AM, JF Bastien wrote:
>>>>> Is this change ready to land?
>>>>>
>>>>> On Wed, Sep 24, 2014 at 9:38 AM, Jonathan Roelofs
>>>>> <jonathan@codesourcery.com> wrote:
>>>>>> Craig,
>>>>>>
>>>>>> Thanks for the review!
>>>>>>
>>>>>> On 9/23/14 7:17 PM, Craig Howland wrote:
>>>>>>>
>>>>>>> On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
>>>>>>>>
>>>>>>>> Please see the attached patch.
>>>>>>>>
>>>>>>> Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.
>>>>>>
>>>>>> Oops. I'm not very familiar with Newlib processes, so please let me know if
>>>>>> I'm missing other things that you'd normally expect from such an upstream
>>>>>> submission.... For example, some of my co-workers reminded me to also update
>>>>>> COPYING.NEWLIB, and add copyright headers to the new files.
>>>>>>>
>>>>>>>
>>>>>>> Operationally, all looks OK, but aesthetically, the use of casting is
>>>>>>> inconsistent.  For example:
>>>>>>>
>>>>>>> +long double
>>>>>>> +nexttowardl (long double x, long double y)
>>>>>>> +{
>>>>>>> +  return nextafter((double)x, (double)y);
>>>>>>> +}
>>>>>>>
>>>>>>> The x and y arguments are cast to double to pass to nextafter(), but the
>>>>>>> return
>>>>>>> value is not cast to long double.  It works OK, but could be confusing.
>>>>>>> Are the
>>>>>>> casts intended to highlight the spots where the double/long double
>>>>>>> equality is
>>>>>>> required?
>>>>>>
>>>>>> Yeah, that was my intent.
>>>>>>>
>>>>>>> If so, it would probably be better to either cast in all places where
>>>>>>> it is theoretically needed, or to just leave them out.  The other existing
>>>>>>> functions of this style left all of them out (i.e. no casts from ld to d
>>>>>>> or d to
>>>>>>> ld)--see, for example, libm/common/nextafterl.c.  I suggest that the
>>>>>>> precedent
>>>>>>> is the better way.
>>>>>>
>>>>>> Agreed, consistency is probably better.
>>>>>>
>>>>>> Attached is a new version of this patch with these things addressed, and
>>>>>> I've added another similar shim for log2l.
>>>>>>
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Jon
>>>>>>>
>>>>>>>
>>>>>>> Craig
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Jon Roelofs
>>>>>> jonathan@codesourcery.com
>>>>>> CodeSourcery / Mentor Embedded
>>>>
>>>
>>
>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-09 14:34               ` Jonathan Roelofs
@ 2014-12-09 22:15                 ` Jeff Johnston
  2014-12-09 22:38                   ` Jonathan Roelofs
  0 siblings, 1 reply; 15+ messages in thread
From: Jeff Johnston @ 2014-12-09 22:15 UTC (permalink / raw)
  To: Jonathan Roelofs; +Cc: JF Bastien, Craig Howland, newlib

Just a couple comments.  

1. The FORCE_EVAL macro looks for
double or long double, even though it is only used for floats in nexttowardf
By any chance was this macro in a header that you brought into
the code and if so, would it not be better to put the general-purpose
macro in local.h?  Otherwise, I would just suggest removing the double/long double
parts that are extraneous in this instance and clutter the code.

If you took it from a header, please confirm the license was the same as
nexttowardf() which is fine btw for inclusion into newlib.

2. You have put the nexttowardf function prototype in the math.h section where
_LDBL_EQ_DOUBLE is true but the code itself doesn't use the flag as
it doesn't rely on long double internals.

-- Jeff J.

----- Original Message -----
From: "Jonathan Roelofs" <jonathan@codesourcery.com>
To: "JF Bastien" <jfb@chromium.org>
Cc: "Craig Howland" <howland@lgsinnovations.com>, newlib@sourceware.org
Sent: Tuesday, December 9, 2014 9:34:37 AM
Subject: Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems

Ping


Cheers,

Jon

On 12/3/14 8:10 AM, Jonathan Roelofs wrote:
> Sigh, trying again with less context in the diff. Apparently the mailer daemon
> doesn't like big patches.
>
>
> Jon
>
> On 12/2/14 4:58 PM, Jonathan Roelofs wrote:
>> JF reminds me that I forgot to attach the patch... oops.
>>
>> Jon
>>
>> On 12/2/14 4:45 PM, Jonathan Roelofs wrote:
>>> Here's a rebased version with the broken nexttowardf replaced by the one from
>>> musl.
>>>
>>>
>>> Cheers,
>>>
>>> Jon
>>>
>>> On 12/2/14 11:55 AM, Jonathan Roelofs wrote:
>>>> JF,
>>>>
>>>> No. I've been told by one of my coworkers that nexttowardf cannot be
>>>> implemented
>>>> correctly on top of nextafterf. For that one we'll need a different
>>>> implementation, perhaps we can copy the one in musl?... I'm not sure if the
>>>> license is compatible with doing that.
>>>>
>>>> Everything in this patch aside from the nexttowardf implementation is ready to
>>>> go as far as I'm concerned. Craig, how about on your end?
>>>>
>>>>
>>>> Cheers,
>>>>
>>>> Jon
>>>>
>>>> On 12/2/14 11:45 AM, JF Bastien wrote:
>>>>> Is this change ready to land?
>>>>>
>>>>> On Wed, Sep 24, 2014 at 9:38 AM, Jonathan Roelofs
>>>>> <jonathan@codesourcery.com> wrote:
>>>>>> Craig,
>>>>>>
>>>>>> Thanks for the review!
>>>>>>
>>>>>> On 9/23/14 7:17 PM, Craig Howland wrote:
>>>>>>>
>>>>>>> On 09/23/2014 04:33 PM, Jonathan Roelofs wrote:
>>>>>>>>
>>>>>>>> Please see the attached patch.
>>>>>>>>
>>>>>>> Needs a ChangeLog entry.  Missing the patch for libm/common/Makefile.am.
>>>>>>
>>>>>> Oops. I'm not very familiar with Newlib processes, so please let me know if
>>>>>> I'm missing other things that you'd normally expect from such an upstream
>>>>>> submission.... For example, some of my co-workers reminded me to also update
>>>>>> COPYING.NEWLIB, and add copyright headers to the new files.
>>>>>>>
>>>>>>>
>>>>>>> Operationally, all looks OK, but aesthetically, the use of casting is
>>>>>>> inconsistent.  For example:
>>>>>>>
>>>>>>> +long double
>>>>>>> +nexttowardl (long double x, long double y)
>>>>>>> +{
>>>>>>> +  return nextafter((double)x, (double)y);
>>>>>>> +}
>>>>>>>
>>>>>>> The x and y arguments are cast to double to pass to nextafter(), but the
>>>>>>> return
>>>>>>> value is not cast to long double.  It works OK, but could be confusing.
>>>>>>> Are the
>>>>>>> casts intended to highlight the spots where the double/long double
>>>>>>> equality is
>>>>>>> required?
>>>>>>
>>>>>> Yeah, that was my intent.
>>>>>>>
>>>>>>> If so, it would probably be better to either cast in all places where
>>>>>>> it is theoretically needed, or to just leave them out.  The other existing
>>>>>>> functions of this style left all of them out (i.e. no casts from ld to d
>>>>>>> or d to
>>>>>>> ld)--see, for example, libm/common/nextafterl.c.  I suggest that the
>>>>>>> precedent
>>>>>>> is the better way.
>>>>>>
>>>>>> Agreed, consistency is probably better.
>>>>>>
>>>>>> Attached is a new version of this patch with these things addressed, and
>>>>>> I've added another similar shim for log2l.
>>>>>>
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Jon
>>>>>>>
>>>>>>>
>>>>>>> Craig
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Jon Roelofs
>>>>>> jonathan@codesourcery.com
>>>>>> CodeSourcery / Mentor Embedded
>>>>
>>>
>>
>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-09 22:15                 ` Jeff Johnston
@ 2014-12-09 22:38                   ` Jonathan Roelofs
  2014-12-09 23:36                     ` Jeff Johnston
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-12-09 22:38 UTC (permalink / raw)
  To: Jeff Johnston; +Cc: JF Bastien, Craig Howland, newlib



On 12/9/14 3:15 PM, Jeff Johnston wrote:
> Just a couple comments.
>
> 1. The FORCE_EVAL macro looks for
> double or long double, even though it is only used for floats in nexttowardf
> By any chance was this macro in a header that you brought into
> the code and if so, would it not be better to put the general-purpose
> macro in local.h?  Otherwise, I would just suggest removing the double/long double
> parts that are extraneous in this instance and clutter the code.
FORCE_EVAL did come from a header, and yeah, local.h probably is a better place 
for it.
>
> If you took it from a header, please confirm the license was the same as
> nexttowardf() which is fine btw for inclusion into newlib.
That header has this at the top of it:

  * ====================================================
  * Copyright (C) 1993 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.
  * ====================================================

>
> 2. You have put the nexttowardf function prototype in the math.h section where
> _LDBL_EQ_DOUBLE is true but the code itself doesn't use the flag as
> it doesn't rely on long double internals.
Oh, right. Good point. I'll take it out of _LDBL_EQ_DOUBLE.

Jon
>
> -- Jeff J.
>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-09 22:38                   ` Jonathan Roelofs
@ 2014-12-09 23:36                     ` Jeff Johnston
  2014-12-10  1:05                       ` Craig Howland
  2014-12-10 19:28                       ` Jonathan Roelofs
  0 siblings, 2 replies; 15+ messages in thread
From: Jeff Johnston @ 2014-12-09 23:36 UTC (permalink / raw)
  To: Jonathan Roelofs; +Cc: Newlib Mailing List

----- Original Message -----
> From: "Jonathan Roelofs" <jonathan@codesourcery.com>
> To: "Jeff Johnston" <jjohnstn@redhat.com>
> Cc: "JF Bastien" <jfb@chromium.org>, "Craig Howland" <howland@lgsinnovations.com>, newlib@sourceware.org
> Sent: Tuesday, December 9, 2014 5:38:40 PM
> Subject: Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
> 
> 
> 
> On 12/9/14 3:15 PM, Jeff Johnston wrote:
> > Just a couple comments.
> >
> > 1. The FORCE_EVAL macro looks for
> > double or long double, even though it is only used for floats in
> > nexttowardf
> > By any chance was this macro in a header that you brought into
> > the code and if so, would it not be better to put the general-purpose
> > macro in local.h?  Otherwise, I would just suggest removing the double/long
> > double
> > parts that are extraneous in this instance and clutter the code.
> FORCE_EVAL did come from a header, and yeah, local.h probably is a better
> place
> for it.
> >
> > If you took it from a header, please confirm the license was the same as
> > nexttowardf() which is fine btw for inclusion into newlib.
> That header has this at the top of it:
> 
>   * ====================================================
>   * Copyright (C) 1993 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.
>   * ====================================================
> 

In that case, just do the volatile assignment manually instead of adding a
second license.

> >
> > 2. You have put the nexttowardf function prototype in the math.h section
> > where
> > _LDBL_EQ_DOUBLE is true but the code itself doesn't use the flag as
> > it doesn't rely on long double internals.
> Oh, right. Good point. I'll take it out of _LDBL_EQ_DOUBLE.
> 
> Jon
> >
> > -- Jeff J.
> >
> 
> --
> Jon Roelofs
> jonathan@codesourcery.com
> CodeSourcery / Mentor Embedded
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-09 23:36                     ` Jeff Johnston
@ 2014-12-10  1:05                       ` Craig Howland
  2014-12-10 19:28                       ` Jonathan Roelofs
  1 sibling, 0 replies; 15+ messages in thread
From: Craig Howland @ 2014-12-10  1:05 UTC (permalink / raw)
  To: newlib

(Sorry, I was out for a bit and am just starting to catch up on this thread.)
On 12/09/2014 06:36 PM, Jeff Johnston wrote:
> ----- Original Message -----
>> From: "Jonathan Roelofs" <jonathan@codesourcery.com>
>> To: "Jeff Johnston" <jjohnstn@redhat.com>
>> Cc: "JF Bastien" <jfb@chromium.org>, "Craig Howland" <howland@lgsinnovations.com>, newlib@sourceware.org
>> Sent: Tuesday, December 9, 2014 5:38:40 PM
>> Subject: Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
>>
>>
>>
>> On 12/9/14 3:15 PM, Jeff Johnston wrote:
>> ... 
>>> 2. You have put the nexttowardf function prototype in the math.h section
>>> where
>>> _LDBL_EQ_DOUBLE is true but the code itself doesn't use the flag as
>>> it doesn't rely on long double internals.
>> Oh, right. Good point. I'll take it out of _LDBL_EQ_DOUBLE.
Actually, it probably strictly does belong in the _LDBL_EQ_DOUBLE section, as it 
uses isnan().  isnan(), in turn, calls __fpclassify(), which only will work 100% 
properly when ldbl==double (i.e., it does not work for all inputs when 
ldbl>double).  I suppose that for the restricted case of fpclassify() being used 
for isnan(), it should work OK when ldbl>double, as the compiler would convert 
the NAN properly to double for the __fpclassifyd() call.  But doing this would 
be a dangerous precedent, implying that fpclassify was OK with unrestricted long 
double.  Thoughts, Jeff?
Craig

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-09 23:36                     ` Jeff Johnston
  2014-12-10  1:05                       ` Craig Howland
@ 2014-12-10 19:28                       ` Jonathan Roelofs
       [not found]                         ` <CABdywOdrYKmuOx-k1GzwVF9VakYw41YYeNs74yLuk8=myS+qCA@mail.gmail.com>
  1 sibling, 1 reply; 15+ messages in thread
From: Jonathan Roelofs @ 2014-12-10 19:28 UTC (permalink / raw)
  To: Jeff Johnston; +Cc: Newlib Mailing List

[-- Attachment #1: Type: text/plain, Size: 2284 bytes --]

Drop the FORCE_EVAL macro, and wrap nexttowardf in _LDBL_EQ_DBL as per Craig's 
suggestion.

Jon

On 12/9/14 4:36 PM, Jeff Johnston wrote:
> ----- Original Message -----
>> From: "Jonathan Roelofs" <jonathan@codesourcery.com>
>> To: "Jeff Johnston" <jjohnstn@redhat.com>
>> Cc: "JF Bastien" <jfb@chromium.org>, "Craig Howland" <howland@lgsinnovations.com>, newlib@sourceware.org
>> Sent: Tuesday, December 9, 2014 5:38:40 PM
>> Subject: Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
>>
>>
>>
>> On 12/9/14 3:15 PM, Jeff Johnston wrote:
>>> Just a couple comments.
>>>
>>> 1. The FORCE_EVAL macro looks for
>>> double or long double, even though it is only used for floats in
>>> nexttowardf
>>> By any chance was this macro in a header that you brought into
>>> the code and if so, would it not be better to put the general-purpose
>>> macro in local.h?  Otherwise, I would just suggest removing the double/long
>>> double
>>> parts that are extraneous in this instance and clutter the code.
>> FORCE_EVAL did come from a header, and yeah, local.h probably is a better
>> place
>> for it.
>>>
>>> If you took it from a header, please confirm the license was the same as
>>> nexttowardf() which is fine btw for inclusion into newlib.
>> That header has this at the top of it:
>>
>>    * ====================================================
>>    * Copyright (C) 1993 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.
>>    * ====================================================
>>
>
> In that case, just do the volatile assignment manually instead of adding a
> second license.
>
>>>
>>> 2. You have put the nexttowardf function prototype in the math.h section
>>> where
>>> _LDBL_EQ_DOUBLE is true but the code itself doesn't use the flag as
>>> it doesn't rely on long double internals.
>> Oh, right. Good point. I'll take it out of _LDBL_EQ_DOUBLE.
>>
>> Jon
>>>
>>> -- Jeff J.
>>>
>>
>> --
>> Jon Roelofs
>> jonathan@codesourcery.com
>> CodeSourcery / Mentor Embedded
>>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

[-- Attachment #2: newlib_nexttoward5.diff --]
[-- Type: text/plain, Size: 17319 bytes --]

diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index cf69c05..cdce050 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,15 @@
+2014-12-02  Jonathan Roelofs  <jonathan@codesourcery.com>
+
+	* libc/include/math.h: Add log2l,logbl,nexttowardf,
+	nexttoward,nexttowardl
+	* libm/common/Makefile.am: Reference new files
+	* libm/common/Makefile.in: Reference new files
+	* libm/common/log2l.c: New File
+	* libm/common/logbl.c: Likewise
+	* libm/common/nexttowardf.c: Likewise
+	* libm/common/nexttoward.c: Likewise
+	* libm/common/nexttowardl.c: Likewise
+
 2014-11-28  Matthew Fortune  <matthew.fortune@imgtec.com>
 
 	* libc/include/machine/setjmp.h [__mips__]: Remove __mips_fpr == 64
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 6717cb3..d16ce30 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -423,6 +423,11 @@ extern int ilogbl _PARAMS((long double));
 extern long double asinhl _PARAMS((long double));
 extern long double cbrtl _PARAMS((long double));
 extern long double nextafterl _PARAMS((long double, long double));
+extern float nexttowardf _PARAMS((float, long double));
+extern double nexttoward _PARAMS((double, long double));
+extern long double nexttowardl _PARAMS((long double, long double));
+extern long double logbl _PARAMS((long double));
+extern long double log2l _PARAMS((long double));
 extern long double rintl _PARAMS((long double));
 extern long double scalbnl _PARAMS((long double, int));
 extern long double exp2l _PARAMS((long double));
diff --git a/newlib/libm/common/Makefile.am b/newlib/libm/common/Makefile.am
index ed556ef..b370b2e 100644
--- a/newlib/libm/common/Makefile.am
+++ b/newlib/libm/common/Makefile.am
@@ -30,7 +30,9 @@ lsrc =	atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
 	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
 	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \
 	roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \
-	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c \
+	logbl.c nexttowardf.c nexttoward.c nexttowardl.c log2l.c
+
 
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 
diff --git a/newlib/libm/common/Makefile.in b/newlib/libm/common/Makefile.in
index 12b5a30..7964531 100644
--- a/newlib/libm/common/Makefile.in
+++ b/newlib/libm/common/Makefile.in
@@ -136,7 +136,11 @@ am__objects_3 = lib_a-atanl.$(OBJEXT) lib_a-cosl.$(OBJEXT) \
 	lib_a-fminl.$(OBJEXT) lib_a-fmal.$(OBJEXT) \
 	lib_a-acoshl.$(OBJEXT) lib_a-atanhl.$(OBJEXT) \
 	lib_a-remainderl.$(OBJEXT) lib_a-lgammal.$(OBJEXT) \
-	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT)
+	lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT) \
+	lib_a-logbl.$(OBJEXT) lib_a-nexttoward.$(OBJEXT) \
+	lib_a-nexttowardl.$(OBJEXT) lib_a-nexttowardf.$(OBJEXT) \
+	lib_a-log2l.$(OBJEXT)
+
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@am__objects_4 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@	$(am__objects_3)
 @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \
@@ -169,7 +173,8 @@ am__objects_7 = atanl.lo cosl.lo sinl.lo tanl.lo tanhl.lo frexpl.lo \
 	tgammal.lo nearbyintl.lo lrintl.lo llrintl.lo roundl.lo \
 	lroundl.lo llroundl.lo truncl.lo remquol.lo fdiml.lo fmaxl.lo \
 	fminl.lo fmal.lo acoshl.lo atanhl.lo remainderl.lo lgammal.lo \
-	erfl.lo erfcl.lo
+	erfl.lo erfcl.lo logbl.lo nexttowardf.lo nexttoward.lo nexttowardl.lo \
+	log2l.lo
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@am__objects_8 =  \
 @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@	$(am__objects_7)
 @USE_LIBTOOL_TRUE@am_libcommon_la_OBJECTS = $(am__objects_5) \
@@ -355,7 +360,8 @@ lsrc = atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
 	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
 	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \
 	roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \
-	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+	fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c \
+	logbl.c nexttowardf.c nexttoward.c nexttowardl.c log2l.c
 
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcommon.la
@@ -1065,6 +1071,36 @@ lib_a-nextafterl.o: nextafterl.c
 lib_a-nextafterl.obj: nextafterl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nextafterl.obj `if test -f 'nextafterl.c'; then $(CYGPATH_W) 'nextafterl.c'; else $(CYGPATH_W) '$(srcdir)/nextafterl.c'; fi`
 
+lib_a-logbl.o: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.o `test -f 'logbl.c' || echo '$(srcdir)/'`logbl.c
+
+lib_a-logbl.obj: logbl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-logbl.obj `if test -f 'logbl.c'; then $(CYGPATH_W) 'logbl.c'; else $(CYGPATH_W) '$(srcdir)/logbll.c'; fi`
+
+lib_a-log2l.o: log2l.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-log2l.o `test -f 'log2l.c' || echo '$(srcdir)/'`log2l.c
+
+lib_a-log2l.obj: log2l.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-log2l.obj `if test -f 'log2l.c'; then $(CYGPATH_W) 'log2l.c'; else $(CYGPATH_W) '$(srcdir)/log2ll.c'; fi`
+
+lib_a-nexttowardf.o: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.o `test -f 'nexttowardf.c' || echo '$(srcdir)/'`nexttowardf.c
+
+lib_a-nexttowardf.obj: nexttowardf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardf.obj `if test -f 'nexttowardf.c'; then $(CYGPATH_W) 'nexttowardf.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardfl.c'; fi`
+
+lib_a-nexttoward.o: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.o `test -f 'nexttoward.c' || echo '$(srcdir)/'`nexttoward.c
+
+lib_a-nexttoward.obj: nexttoward.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttoward.obj `if test -f 'nexttoward.c'; then $(CYGPATH_W) 'nexttoward.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardl.c'; fi`
+
+lib_a-nexttowardl.o: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.o `test -f 'nexttowardl.c' || echo '$(srcdir)/'`nexttowardl.c
+
+lib_a-nexttowardl.obj: nexttowardl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nexttowardl.obj `if test -f 'nexttowardl.c'; then $(CYGPATH_W) 'nexttowardl.c'; else $(CYGPATH_W) '$(srcdir)/nexttowardll.c'; fi`
+
 lib_a-rintl.o: rintl.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rintl.o `test -f 'rintl.c' || echo '$(srcdir)/'`rintl.c
 
diff --git a/newlib/libm/common/log2l.c b/newlib/libm/common/log2l.c
new file mode 100644
index 0000000..e92e9eb
--- /dev/null
+++ b/newlib/libm/common/log2l.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+log2l (long double x)
+{
+  return log2(x);
+}
+#endif
+
diff --git a/newlib/libm/common/logbl.c b/newlib/libm/common/logbl.c
new file mode 100644
index 0000000..59d24a2
--- /dev/null
+++ b/newlib/libm/common/logbl.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+logbl (long double x)
+{
+  return logb(x);
+}
+#endif
+
diff --git a/newlib/libm/common/nexttoward.c b/newlib/libm/common/nexttoward.c
new file mode 100644
index 0000000..71dd71d
--- /dev/null
+++ b/newlib/libm/common/nexttoward.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+double
+nexttoward (double x, long double y)
+{
+  return nextafter(x, y);
+}
+#endif
+
diff --git a/newlib/libm/common/nexttowardf.c b/newlib/libm/common/nexttowardf.c
new file mode 100644
index 0000000..87cabc2
--- /dev/null
+++ b/newlib/libm/common/nexttowardf.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2005-2014 Rich Felker, et al.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <math.h>
+#include <inttypes.h>
+#include "local.h"
+
+#define FORCE_EVAL(x) do {                   \
+ if (sizeof(x) == sizeof(float)) {           \
+   volatile float __x;                       \
+   __x = (x);                                \
+ } else if (sizeof(x) == sizeof(double)) {   \
+   volatile double __x;                      \
+   __x = (x);                                \
+ } else {                                    \
+   volatile long double __x;                 \
+   __x = (x);                                \
+ }                                           \
+} while(0)
+
+union fshape {
+  float value;
+  uint32_t bits;
+};
+
+float
+nexttowardf (float x, long double y)
+{
+  union fshape ux;
+  uint32_t e;
+
+  if (isnan(x) || isnan(y))
+    return x + y;
+  if (x == y)
+    return y;
+  ux.value = x;
+  if (x == 0) {
+    ux.bits = 1;
+    if (signbit(y))
+      ux.bits |= 0x80000000;
+  } else if (x < y) {
+    if (signbit(x))
+      ux.bits--;
+    else
+      ux.bits++;
+  } else {
+    if (signbit(x))
+      ux.bits++;
+    else
+      ux.bits--;
+  }
+  e = ux.bits & 0x7f800000;
+  /* raise overflow if ux.value is infinite and x is finite */
+  if (e == 0x7f800000)
+    FORCE_EVAL(x+x);
+  /* raise underflow if ux.value is subnormal or zero */
+  if (e == 0)
+    FORCE_EVAL(x*x + ux.value*ux.value);
+  return ux.value;
+}
diff --git a/newlib/libm/common/nexttowardl.c b/newlib/libm/common/nexttowardl.c
new file mode 100644
index 0000000..59af4ce
--- /dev/null
+++ b/newlib/libm/common/nexttowardl.c
@@ -0,0 +1,38 @@
+/*
+Copyright (c) 2014 Mentor Graphics, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * 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.
+    * Neither the name of Mentor Graphics 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 CODESOURCERY, INC. ``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 CODESOURCERY 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 <math.h>
+#include "local.h"
+
+#ifdef _LDBL_EQ_DBL
+long double
+nexttowardl (long double x, long double y)
+{
+  return nextafter(x, y);
+}
+#endif
+

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
       [not found]                           ` <5488BF5C.4040200@codesourcery.com>
@ 2014-12-15 20:52                             ` Jeff Johnston
  2014-12-15 21:07                               ` Jonathan Roelofs
  0 siblings, 1 reply; 15+ messages in thread
From: Jeff Johnston @ 2014-12-15 20:52 UTC (permalink / raw)
  To: Jonathan Roelofs; +Cc: Newlib Mailing List

Patch committed.

-- Jeff J.

----- Original Message -----
From: "Jonathan Roelofs" <jonathan@codesourcery.com>
To: "JF Bastien" <jfb@chromium.org>, "Jeff Johnston" <jjohnstn@redhat.com>, "Craig Howland" <howland@LGSInnovations.com>
Sent: Wednesday, December 10, 2014 4:47:08 PM
Subject: Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems

Apparently patch management is hard.  Here's what I meant to send.

Jon

On 12/10/14 2:43 PM, JF Bastien wrote:
> FORCE_EVAL is still in newlib/libm/common/nexttowardf.c?
>
> On Wed, Dec 10, 2014 at 11:28 AM, Jonathan Roelofs <
> jonathan@codesourcery.com> wrote:
>
>> Drop the FORCE_EVAL macro, and wrap nexttowardf in _LDBL_EQ_DBL as per
>> Craig's suggestion.
>>
>> Jon
>>
>>
>> On 12/9/14 4:36 PM, Jeff Johnston wrote:
>>
>>> ----- Original Message -----
>>>
>>>> From: "Jonathan Roelofs" <jonathan@codesourcery.com>
>>>> To: "Jeff Johnston" <jjohnstn@redhat.com>
>>>> Cc: "JF Bastien" <jfb@chromium.org>, "Craig Howland" <
>>>> howland@lgsinnovations.com>, newlib@sourceware.org
>>>> Sent: Tuesday, December 9, 2014 5:38:40 PM
>>>> Subject: Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL
>>>> systems
>>>>
>>>>
>>>>
>>>> On 12/9/14 3:15 PM, Jeff Johnston wrote:
>>>>
>>>>> Just a couple comments.
>>>>>
>>>>> 1. The FORCE_EVAL macro looks for
>>>>> double or long double, even though it is only used for floats in
>>>>> nexttowardf
>>>>> By any chance was this macro in a header that you brought into
>>>>> the code and if so, would it not be better to put the general-purpose
>>>>> macro in local.h?  Otherwise, I would just suggest removing the
>>>>> double/long
>>>>> double
>>>>> parts that are extraneous in this instance and clutter the code.
>>>>>
>>>> FORCE_EVAL did come from a header, and yeah, local.h probably is a better
>>>> place
>>>> for it.
>>>>
>>>>>
>>>>> If you took it from a header, please confirm the license was the same as
>>>>> nexttowardf() which is fine btw for inclusion into newlib.
>>>>>
>>>> That header has this at the top of it:
>>>>
>>>>     * ====================================================
>>>>     * Copyright (C) 1993 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.
>>>>     * ====================================================
>>>>
>>>>
>>> In that case, just do the volatile assignment manually instead of adding a
>>> second license.
>>>
>>>
>>>>> 2. You have put the nexttowardf function prototype in the math.h section
>>>>> where
>>>>> _LDBL_EQ_DOUBLE is true but the code itself doesn't use the flag as
>>>>> it doesn't rely on long double internals.
>>>>>
>>>> Oh, right. Good point. I'll take it out of _LDBL_EQ_DOUBLE.
>>>>
>>>> Jon
>>>>
>>>>>
>>>>> -- Jeff J.
>>>>>
>>>>>
>>>> --
>>>> Jon Roelofs
>>>> jonathan@codesourcery.com
>>>> CodeSourcery / Mentor Embedded
>>>>
>>>>
>> --
>> Jon Roelofs
>> jonathan@codesourcery.com
>> CodeSourcery / Mentor Embedded
>>
>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
  2014-12-15 20:52                             ` Jeff Johnston
@ 2014-12-15 21:07                               ` Jonathan Roelofs
  0 siblings, 0 replies; 15+ messages in thread
From: Jonathan Roelofs @ 2014-12-15 21:07 UTC (permalink / raw)
  To: Jeff Johnston; +Cc: Newlib Mailing List, JF Bastien

Thanks!

On 12/15/14 1:51 PM, Jeff Johnston wrote:
> Patch committed.
>
> -- Jeff J.
>
> ----- Original Message -----
> From: "Jonathan Roelofs" <jonathan@codesourcery.com>
> To: "JF Bastien" <jfb@chromium.org>, "Jeff Johnston" <jjohnstn@redhat.com>, "Craig Howland" <howland@LGSInnovations.com>
> Sent: Wednesday, December 10, 2014 4:47:08 PM
> Subject: Re: [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems
>
> Apparently patch management is hard.  Here's what I meant to send.
>
> Jon
>

-- 
Jon Roelofs
jonathan@codesourcery.com
CodeSourcery / Mentor Embedded

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-12-15 21:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-23 20:33 [libcxx+newlib] nexttoward{f,l,} shims for _LDBL_EQ_DBL systems Jonathan Roelofs
2014-09-24  1:18 ` Craig Howland
2014-09-24 16:37   ` Jonathan Roelofs
2014-12-02 18:45     ` JF Bastien
2014-12-02 18:55       ` Jonathan Roelofs
2014-12-02 23:45         ` Jonathan Roelofs
     [not found]           ` <547E523B.6060703@codesourcery.com>
2014-12-03 15:10             ` Jonathan Roelofs
2014-12-09 14:34               ` Jonathan Roelofs
2014-12-09 22:15                 ` Jeff Johnston
2014-12-09 22:38                   ` Jonathan Roelofs
2014-12-09 23:36                     ` Jeff Johnston
2014-12-10  1:05                       ` Craig Howland
2014-12-10 19:28                       ` Jonathan Roelofs
     [not found]                         ` <CABdywOdrYKmuOx-k1GzwVF9VakYw41YYeNs74yLuk8=myS+qCA@mail.gmail.com>
     [not found]                           ` <5488BF5C.4040200@codesourcery.com>
2014-12-15 20:52                             ` Jeff Johnston
2014-12-15 21:07                               ` Jonathan Roelofs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).