2014-12-15 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
			
			
This commit is contained in:
		| @@ -1,3 +1,15 @@ | |||||||
|  | 2014-12-15  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-12-15  Yaakov Selkowitz  <yselkowi@redhat.com> | 2014-12-15  Yaakov Selkowitz  <yselkowi@redhat.com> | ||||||
|  |  | ||||||
| 	* libc/include/stdio.h (__SNLK): Define. | 	* libc/include/stdio.h (__SNLK): Define. | ||||||
|   | |||||||
| @@ -423,6 +423,11 @@ extern int ilogbl _PARAMS((long double)); | |||||||
| extern long double asinhl _PARAMS((long double)); | extern long double asinhl _PARAMS((long double)); | ||||||
| extern long double cbrtl _PARAMS((long double)); | extern long double cbrtl _PARAMS((long double)); | ||||||
| extern long double nextafterl _PARAMS((long double, 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 rintl _PARAMS((long double)); | ||||||
| extern long double scalbnl _PARAMS((long double, int)); | extern long double scalbnl _PARAMS((long double, int)); | ||||||
| extern long double exp2l _PARAMS((long double)); | extern long double exp2l _PARAMS((long double)); | ||||||
|   | |||||||
| @@ -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 \ | 	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 \ | 	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 \ | 	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 | libcommon_la_LDFLAGS = -Xcompiler -nostdlib | ||||||
|  |  | ||||||
|   | |||||||
| @@ -136,7 +136,10 @@ am__objects_3 = lib_a-atanl.$(OBJEXT) lib_a-cosl.$(OBJEXT) \ | |||||||
| 	lib_a-fminl.$(OBJEXT) lib_a-fmal.$(OBJEXT) \ | 	lib_a-fminl.$(OBJEXT) lib_a-fmal.$(OBJEXT) \ | ||||||
| 	lib_a-acoshl.$(OBJEXT) lib_a-atanhl.$(OBJEXT) \ | 	lib_a-acoshl.$(OBJEXT) lib_a-atanhl.$(OBJEXT) \ | ||||||
| 	lib_a-remainderl.$(OBJEXT) lib_a-lgammal.$(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-nexttowardf.$(OBJEXT) \ | ||||||
|  | 	lib_a-nexttoward.$(OBJEXT) lib_a-nexttowardl.$(OBJEXT) \ | ||||||
|  | 	lib_a-log2l.$(OBJEXT) | ||||||
| @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@am__objects_4 =  \ | @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@am__objects_4 =  \ | ||||||
| @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@	$(am__objects_3) | @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@	$(am__objects_3) | ||||||
| @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ | @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ | ||||||
| @@ -169,7 +172,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 \ | 	tgammal.lo nearbyintl.lo lrintl.lo llrintl.lo roundl.lo \ | ||||||
| 	lroundl.lo llroundl.lo truncl.lo remquol.lo fdiml.lo fmaxl.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 \ | 	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_8 =  \ | ||||||
| @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@	$(am__objects_7) | @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@	$(am__objects_7) | ||||||
| @USE_LIBTOOL_TRUE@am_libcommon_la_OBJECTS = $(am__objects_5) \ | @USE_LIBTOOL_TRUE@am_libcommon_la_OBJECTS = $(am__objects_5) \ | ||||||
| @@ -355,7 +359,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 \ | 	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 \ | 	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 \ | 	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 | libcommon_la_LDFLAGS = -Xcompiler -nostdlib | ||||||
| @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcommon.la | @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcommon.la | ||||||
| @@ -1203,6 +1208,36 @@ lib_a-erfcl.o: erfcl.c | |||||||
| lib_a-erfcl.obj: erfcl.c | lib_a-erfcl.obj: erfcl.c | ||||||
| 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-erfcl.obj `if test -f 'erfcl.c'; then $(CYGPATH_W) 'erfcl.c'; else $(CYGPATH_W) '$(srcdir)/erfcl.c'; fi` | 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-erfcl.obj `if test -f 'erfcl.c'; then $(CYGPATH_W) 'erfcl.c'; else $(CYGPATH_W) '$(srcdir)/erfcl.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)/logbl.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)/nexttowardf.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)/nexttoward.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)/nexttowardl.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)/log2l.c'; fi` | ||||||
|  |  | ||||||
| mostlyclean-libtool: | mostlyclean-libtool: | ||||||
| 	-rm -f *.lo | 	-rm -f *.lo | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										38
									
								
								newlib/libm/common/log2l.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								newlib/libm/common/log2l.c
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||||
|  |  | ||||||
							
								
								
									
										38
									
								
								newlib/libm/common/logbl.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								newlib/libm/common/logbl.c
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||||
|  |  | ||||||
							
								
								
									
										38
									
								
								newlib/libm/common/nexttoward.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								newlib/libm/common/nexttoward.c
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||||
|  |  | ||||||
							
								
								
									
										78
									
								
								newlib/libm/common/nexttowardf.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								newlib/libm/common/nexttowardf.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | |||||||
|  | /* | ||||||
|  |  * 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" | ||||||
|  |  | ||||||
|  | union fshape { | ||||||
|  |   float value; | ||||||
|  |   uint32_t bits; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | // This is only necessary because the implementation of isnan only works | ||||||
|  | // properly when long double == double. | ||||||
|  | // See: https://sourceware.org/ml/newlib/2014/msg00684.html | ||||||
|  | #ifdef _LDBL_EQ_DOUBLE | ||||||
|  |  | ||||||
|  | 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) { | ||||||
|  |     volatile float force_eval; | ||||||
|  |     force_eval = x + x; | ||||||
|  |   } | ||||||
|  |   /* raise underflow if ux.value is subnormal or zero */ | ||||||
|  |   if (e == 0) { | ||||||
|  |     volatile float force_eval; | ||||||
|  |     force_eval = x*x + ux.value*ux.value; | ||||||
|  |   } | ||||||
|  |   return ux.value; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #endif // _LDBL_EQ_DOUBLE | ||||||
							
								
								
									
										38
									
								
								newlib/libm/common/nexttowardl.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								newlib/libm/common/nexttowardl.c
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user