svn commit: branches/uClibc_0_9_29/libm
vapier at uclibc.org
vapier at uclibc.org
Sat Jan 5 17:57:40 UTC 2008
Author: vapier
Date: 2008-01-05 09:57:40 -0800 (Sat, 05 Jan 2008)
New Revision: 20793
Log:
Merge r20629 by vapier from trunk:
import trunc()/truncf() for ISO C requirements, otherwise fortran can hit infinite loops when it generates builtins+trunc() substitutes
Added:
branches/uClibc_0_9_29/libm/s_trunc.c
Modified:
branches/uClibc_0_9_29/libm/Makefile.in
branches/uClibc_0_9_29/libm/float_wrappers.c
Changeset:
Modified: branches/uClibc_0_9_29/libm/Makefile.in
===================================================================
--- branches/uClibc_0_9_29/libm/Makefile.in 2008-01-05 17:57:30 UTC (rev 20792)
+++ branches/uClibc_0_9_29/libm/Makefile.in 2008-01-05 17:57:40 UTC (rev 20793)
@@ -68,8 +68,8 @@
s_ilogb.c s_ldexp.c s_lib_version.c s_lrint.c s_lround.c s_llround.c \
s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c s_round.c \
s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c s_tan.c \
- s_tanh.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c w_cabs.c \
- w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \
+ s_tanh.c s_trunc.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c \
+ w_cabs.c w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \
w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \
w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \
w_sqrt.c fpmacros.c nan.c carg.c s_llrint.c
Modified: branches/uClibc_0_9_29/libm/float_wrappers.c
===================================================================
--- branches/uClibc_0_9_29/libm/float_wrappers.c 2008-01-05 17:57:30 UTC (rev 20792)
+++ branches/uClibc_0_9_29/libm/float_wrappers.c 2008-01-05 17:57:40 UTC (rev 20793)
@@ -26,7 +26,6 @@
#undef L_remquof /*float remquof(float, float, int *);*/
#undef L_scalblnf /*float scalblnf(float, long);*/
#undef L_tgammaf /*float tgammaf(float);*/
-#undef L_truncf /*float truncf(float);*/
/* Implement the following, as defined by SuSv3 */
#if 0
Added: branches/uClibc_0_9_29/libm/s_trunc.c
===================================================================
--- branches/uClibc_0_9_29/libm/s_trunc.c (rev 0)
+++ branches/uClibc_0_9_29/libm/s_trunc.c 2008-01-05 17:57:40 UTC (rev 20793)
@@ -0,0 +1,58 @@
+/* Truncate argument to nearest integral value not larger than the argument.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper at cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#include "math_private.h"
+
+
+libm_hidden_proto(trunc)
+double
+trunc (double x)
+{
+ int32_t i0, j0;
+ u_int32_t i1;
+ int sx;
+
+ EXTRACT_WORDS (i0, i1, x);
+ sx = i0 & 0x80000000;
+ j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ if (j0 < 20)
+ {
+ if (j0 < 0)
+ /* The magnitude of the number is < 1 so the result is +-0. */
+ INSERT_WORDS (x, sx, 0);
+ else
+ INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> j0)), 0);
+ }
+ else if (j0 > 51)
+ {
+ if (j0 == 0x400)
+ /* x is inf or NaN. */
+ return x + x;
+ }
+ else
+ {
+ INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (j0 - 20)));
+ }
+
+ return x;
+}
+libm_hidden_def(trunc)
More information about the uClibc-cvs
mailing list