cmath.cc: Remove.
* src/cmath.cc: Remove. * src/Makefile.am (c_base_headers): Add bits/cmath.tcc. (sources): Remove cmath.cc * src/Makefile.in: Regenerate. * include/c/bits/std_cmath.h (__cmath_power<>): Declare. (__cmath_abs<>): New function. (abs, fabs): Use __cmath_abs when no direct support is available. (__pow_helper<>): New function. (pow): Define here. Use __pow_helper<>. * include/c/bits/cmath.tcc: New file. From-SVN: r37901
This commit is contained in:
parent
29ced803f0
commit
a30dbb3960
|
@ -1,3 +1,18 @@
|
||||||
|
2000-12-01 Gabriel Dos Reis <gdr@codesourcery.com>
|
||||||
|
|
||||||
|
* src/cmath.cc: Remove.
|
||||||
|
* src/Makefile.am (c_base_headers): Add bits/cmath.tcc.
|
||||||
|
(sources): Remove cmath.cc
|
||||||
|
* src/Makefile.in: Regenerate.
|
||||||
|
|
||||||
|
* include/c/bits/std_cmath.h (__cmath_power<>): Declare.
|
||||||
|
(__cmath_abs<>): New function.
|
||||||
|
(abs, fabs): Use __cmath_abs when no direct support is available.
|
||||||
|
(__pow_helper<>): New function.
|
||||||
|
(pow): Define here. Use __pow_helper<>.
|
||||||
|
|
||||||
|
* include/c/bits/cmath.tcc: New file.
|
||||||
|
|
||||||
2000-11-29 Benjamin Kosnik <bkoz@redhat.com>
|
2000-11-29 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
Fixes for build directories with colons, AIX build problems.
|
Fixes for build directories with colons, AIX build problems.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// -*- C++ -*- C math library.
|
// -*- C++ -*- C math library.
|
||||||
|
|
||||||
// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
// Copyright (C) 2000 Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
// software; you can redistribute it and/or modify it under the
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -27,59 +27,27 @@
|
||||||
// invalidate any other reasons why the executable file might be covered by
|
// invalidate any other reasons why the executable file might be covered by
|
||||||
// the GNU General Public License.
|
// the GNU General Public License.
|
||||||
|
|
||||||
//
|
// This file was written by Gabriel Dos Reis <gdr@codesourcery.com>
|
||||||
// ISO C++ 14882: 26.5 C library
|
|
||||||
// Code for signatures not found in the C library
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <bits/std_cmath.h>
|
#ifndef _CPP_BITS_CMATH_TCC
|
||||||
|
#define _CPP_BITS_CMATH_TCC 1
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
export template<typename _Tp>
|
||||||
namespace {
|
_Tp
|
||||||
template <typename T>
|
__cmath_power(_Tp __x, unsigned int __n)
|
||||||
inline T pow_helper(T x, unsigned int y)
|
|
||||||
{
|
{
|
||||||
T z = y&1? x : 1;
|
_Tp __y = __n % 2 ? __x : 1;
|
||||||
while(y >>= 1)
|
|
||||||
|
while (__n >>= 1)
|
||||||
{
|
{
|
||||||
x *= x;
|
__x = __x * __x;
|
||||||
if(y & 1) z *= x;
|
if (__n % 2)
|
||||||
|
__y = __y * __x;
|
||||||
}
|
}
|
||||||
return z;
|
|
||||||
|
return __y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
|
||||||
pow(float x, int y)
|
|
||||||
{
|
|
||||||
if(y < 0)
|
|
||||||
return 1.0f/pow_helper(x, -y);
|
|
||||||
else
|
|
||||||
return pow_helper(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
pow(double x, int y)
|
|
||||||
{
|
|
||||||
if(y < 0)
|
|
||||||
return 1.0/pow_helper(x, -y);
|
|
||||||
else
|
|
||||||
return pow_helper(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
long double
|
|
||||||
pow(long double x, int y)
|
|
||||||
{
|
|
||||||
if(y < 0)
|
|
||||||
return 1.0l/pow_helper(x, -y);
|
|
||||||
else
|
|
||||||
return pow_helper(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // std
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -44,6 +44,17 @@
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
|
// Forward declaration of a helper function. This really should be
|
||||||
|
// an `exported' forward declaration.
|
||||||
|
template<typename _Tp> _Tp __cmath_power(_Tp, unsigned int);
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
inline _Tp
|
||||||
|
__cmath_abs(_Tp __x)
|
||||||
|
{
|
||||||
|
return __x < _Tp() ? -__x : __x;
|
||||||
|
}
|
||||||
|
|
||||||
inline long
|
inline long
|
||||||
abs(long __i) { return ::labs(__i); }
|
abs(long __i) { return ::labs(__i); }
|
||||||
|
|
||||||
|
@ -58,7 +69,7 @@ namespace std
|
||||||
abs(float __x) { return ::fabsf(__x); }
|
abs(float __x) { return ::fabsf(__x); }
|
||||||
#else
|
#else
|
||||||
inline float
|
inline float
|
||||||
abs(float __x) { return ::fabs(static_cast<double>(__x)); }
|
abs(float __x) { return __cmath_abs(__x); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE_ACOSF
|
#if _GLIBCPP_HAVE_ACOSF
|
||||||
|
@ -137,7 +148,7 @@ namespace std
|
||||||
fabs(float __x) { return ::fabsf(__x); }
|
fabs(float __x) { return ::fabsf(__x); }
|
||||||
#else
|
#else
|
||||||
inline float
|
inline float
|
||||||
fabs(float __x) { return ::fabs(static_cast<double>(__x)); }
|
fabs(float __x) { return __cmath_abs(__x); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE_FLOORF
|
#if _GLIBCPP_HAVE_FLOORF
|
||||||
|
@ -204,6 +215,15 @@ namespace std
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
inline _Tp
|
||||||
|
__pow_helper(_Tp __x, int __n)
|
||||||
|
{
|
||||||
|
return __n < 0
|
||||||
|
? _Tp(1)/__cmath_power(__x, -__n)
|
||||||
|
: __cmath_power(__x, __n);
|
||||||
|
}
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE_POWF
|
#if _GLIBCPP_HAVE_POWF
|
||||||
inline float
|
inline float
|
||||||
pow(float __x, float __y) { return ::powf(__x, __y); }
|
pow(float __x, float __y) { return ::powf(__x, __y); }
|
||||||
|
@ -213,8 +233,11 @@ namespace std
|
||||||
{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
|
{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float
|
inline float
|
||||||
pow(float, int);
|
pow(float __x, int __n)
|
||||||
|
{
|
||||||
|
return __pow_helper(__x, __n);
|
||||||
|
}
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE___BUILTIN_SINF
|
#if _GLIBCPP_HAVE___BUILTIN_SINF
|
||||||
inline float
|
inline float
|
||||||
|
@ -315,8 +338,11 @@ namespace std
|
||||||
|
|
||||||
extern "C" double pow(double __x, double __y);
|
extern "C" double pow(double __x, double __y);
|
||||||
|
|
||||||
double
|
inline double
|
||||||
pow(double __x, int __i);
|
pow(double __x, int __i)
|
||||||
|
{
|
||||||
|
return __pow_helper(__x, __i);
|
||||||
|
}
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE___BUILTIN_SIN
|
#if _GLIBCPP_HAVE___BUILTIN_SIN
|
||||||
inline double
|
inline double
|
||||||
|
@ -347,7 +373,7 @@ namespace std
|
||||||
abs(long double __x) { return ::fabsl(__x); }
|
abs(long double __x) { return ::fabsl(__x); }
|
||||||
#else
|
#else
|
||||||
inline long double
|
inline long double
|
||||||
abs(long double __x) { return fabs(static_cast<double>(__x)); }
|
abs(long double __x) { return __cmath_abs(__x); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE_ACOSL
|
#if _GLIBCPP_HAVE_ACOSL
|
||||||
|
@ -426,7 +452,7 @@ namespace std
|
||||||
fabs(long double __x) { return ::fabsl(__x); }
|
fabs(long double __x) { return ::fabsl(__x); }
|
||||||
#else
|
#else
|
||||||
inline long double
|
inline long double
|
||||||
fabs(long double __x) { return ::fabs(static_cast<double>(__x)); }
|
fabs(long double __x) { return __cmath_abs(__x); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE_FLOORL
|
#if _GLIBCPP_HAVE_FLOORL
|
||||||
|
@ -503,8 +529,11 @@ namespace std
|
||||||
{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
|
{ return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long double
|
inline long double
|
||||||
pow(long double, int);
|
pow(long double __x, int __n)
|
||||||
|
{
|
||||||
|
return __pow_helper(__x, __n);
|
||||||
|
}
|
||||||
|
|
||||||
#if _GLIBCPP_HAVE___BUILTIN_SINL
|
#if _GLIBCPP_HAVE___BUILTIN_SINL
|
||||||
inline long double
|
inline long double
|
||||||
|
@ -551,18 +580,13 @@ namespace std
|
||||||
inline long double
|
inline long double
|
||||||
tanh(long double __x) { return ::tanh(static_cast<double>(__x)); }
|
tanh(long double __x) { return ::tanh(static_cast<double>(__x)); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
} // std
|
} // std
|
||||||
|
|
||||||
|
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
|
||||||
|
# define export
|
||||||
|
# include <bits/cmath.tcc>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
## USA.
|
## USA.
|
||||||
|
|
||||||
## $Id: Makefile.am,v 1.53 2000/11/29 01:09:09 gdr Exp $
|
## $Id: Makefile.am,v 1.54 2000/11/29 21:30:30 bkoz Exp $
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = 1.3 gnits
|
AUTOMAKE_OPTIONS = 1.3 gnits
|
||||||
MAINT_CHARSET = latin1
|
MAINT_CHARSET = latin1
|
||||||
|
@ -135,7 +135,7 @@ c_base_headers = \
|
||||||
bits/std_cmath.h bits/std_csetjmp.h bits/std_csignal.h \
|
bits/std_cmath.h bits/std_csetjmp.h bits/std_csignal.h \
|
||||||
bits/std_cstdarg.h bits/std_cstddef.h bits/std_cstdio.h \
|
bits/std_cstdarg.h bits/std_cstddef.h bits/std_cstdio.h \
|
||||||
bits/std_cstdlib.h bits/std_cstring.h bits/std_ctime.h \
|
bits/std_cstdlib.h bits/std_cstring.h bits/std_ctime.h \
|
||||||
bits/std_cwchar.h bits/std_cwctype.h
|
bits/std_cwchar.h bits/std_cwctype.h bits/cmath.tcc
|
||||||
|
|
||||||
if GLIBCPP_USE_CSHADOW
|
if GLIBCPP_USE_CSHADOW
|
||||||
c_shadow_headers = \
|
c_shadow_headers = \
|
||||||
|
@ -174,7 +174,6 @@ build_headers = \
|
||||||
|
|
||||||
sources = \
|
sources = \
|
||||||
limitsMEMBERS.cc \
|
limitsMEMBERS.cc \
|
||||||
cmath.cc \
|
|
||||||
complex.cc complexf.cc complexl.cc complex_io.cc \
|
complex.cc complexf.cc complexl.cc complex_io.cc \
|
||||||
stdexcept.cc bitset.cc \
|
stdexcept.cc bitset.cc \
|
||||||
c++io.cc ios.cc stdstreams.cc strstream.cc \
|
c++io.cc ios.cc stdstreams.cc strstream.cc \
|
||||||
|
|
|
@ -156,7 +156,7 @@ backward_headers = backward/complex.h backward/iomanip.h backward/istream.h b
|
||||||
ext_headers = ext/ropeimpl.h ext/stl_rope.h ext/stl_bvector.h ext/stl_hashtable.h ext/stl_hash_fun.h ext/hash_map ext/hash_set ext/rope ext/slist ext/tree ext/bvector
|
ext_headers = ext/ropeimpl.h ext/stl_rope.h ext/stl_bvector.h ext/stl_hashtable.h ext/stl_hash_fun.h ext/hash_map ext/hash_set ext/rope ext/slist ext/tree ext/bvector
|
||||||
|
|
||||||
|
|
||||||
c_base_headers = bits/std_cassert.h bits/std_cctype.h bits/std_cerrno.h bits/std_cfloat.h bits/std_climits.h bits/std_clocale.h bits/std_cmath.h bits/std_csetjmp.h bits/std_csignal.h bits/std_cstdarg.h bits/std_cstddef.h bits/std_cstdio.h bits/std_cstdlib.h bits/std_cstring.h bits/std_ctime.h bits/std_cwchar.h bits/std_cwctype.h
|
c_base_headers = bits/std_cassert.h bits/std_cctype.h bits/std_cerrno.h bits/std_cfloat.h bits/std_climits.h bits/std_clocale.h bits/std_cmath.h bits/std_csetjmp.h bits/std_csignal.h bits/std_cstdarg.h bits/std_cstddef.h bits/std_cstdio.h bits/std_cstdlib.h bits/std_cstring.h bits/std_ctime.h bits/std_cwchar.h bits/std_cwctype.h bits/cmath.tcc
|
||||||
|
|
||||||
@GLIBCPP_USE_CSHADOW_TRUE@c_shadow_headers = assert.h ctype.h errno.h float.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdio.h stdlib.h string.h time.h wchar.h wctype.h fcntl.h libio.h iolibio.h libioP.h pthread.h iconv.h features.h langinfo.h bits/wrap_libio.h bits/wrap_iolibio.h bits/wrap_libioP.h bits/wrap_iconv.h bits/wrap_fcntl.h bits/wrap_pthread.h bits/wrap_features.h bits/wrap_langinfo.h sys/cdefs.h
|
@GLIBCPP_USE_CSHADOW_TRUE@c_shadow_headers = assert.h ctype.h errno.h float.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdio.h stdlib.h string.h time.h wchar.h wctype.h fcntl.h libio.h iolibio.h libioP.h pthread.h iconv.h features.h langinfo.h bits/wrap_libio.h bits/wrap_iolibio.h bits/wrap_libioP.h bits/wrap_iconv.h bits/wrap_fcntl.h bits/wrap_pthread.h bits/wrap_features.h bits/wrap_langinfo.h sys/cdefs.h
|
||||||
@GLIBCPP_USE_CSHADOW_FALSE@c_shadow_headers =
|
@GLIBCPP_USE_CSHADOW_FALSE@c_shadow_headers =
|
||||||
|
@ -169,7 +169,7 @@ std_headers = algorithm bitset complex deque fstream functional iomanip ios i
|
||||||
build_headers = bits/std_limits.h bits/c++config.h bits/c++io.h bits/c++threads.h bits/atomicity.h bits/os_defines.h bits/ctype_base.h bits/ctype_noninline.h bits/ctype_inline.h
|
build_headers = bits/std_limits.h bits/c++config.h bits/c++io.h bits/c++threads.h bits/atomicity.h bits/os_defines.h bits/ctype_base.h bits/ctype_noninline.h bits/ctype_inline.h
|
||||||
|
|
||||||
|
|
||||||
sources = limitsMEMBERS.cc cmath.cc complex.cc complexf.cc complexl.cc complex_io.cc stdexcept.cc bitset.cc c++io.cc ios.cc stdstreams.cc strstream.cc locale.cc localename.cc codecvt.cc locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc
|
sources = limitsMEMBERS.cc complex.cc complexf.cc complexl.cc complex_io.cc stdexcept.cc bitset.cc c++io.cc ios.cc stdstreams.cc strstream.cc locale.cc localename.cc codecvt.cc locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc
|
||||||
|
|
||||||
|
|
||||||
wstring_sources = wstring-inst.cc
|
wstring_sources = wstring-inst.cc
|
||||||
|
@ -254,7 +254,7 @@ libinst_string_la_OBJECTS = libinst-string.la.lo
|
||||||
libinst_wstring_la_LDFLAGS =
|
libinst_wstring_la_LDFLAGS =
|
||||||
libinst_wstring_la_LIBADD =
|
libinst_wstring_la_LIBADD =
|
||||||
libinst_wstring_la_OBJECTS = wstring-inst.lo
|
libinst_wstring_la_OBJECTS = wstring-inst.lo
|
||||||
libstdc___la_OBJECTS = limitsMEMBERS.lo cmath.lo complex.lo complexf.lo \
|
libstdc___la_OBJECTS = limitsMEMBERS.lo complex.lo complexf.lo \
|
||||||
complexl.lo complex_io.lo stdexcept.lo bitset.lo c++io.lo ios.lo \
|
complexl.lo complex_io.lo stdexcept.lo bitset.lo c++io.lo ios.lo \
|
||||||
stdstreams.lo strstream.lo locale.lo localename.lo codecvt.lo \
|
stdstreams.lo strstream.lo locale.lo localename.lo codecvt.lo \
|
||||||
locale-inst.lo stl-inst.lo misc-inst.lo valarray-inst.lo string-inst.lo
|
locale-inst.lo stl-inst.lo misc-inst.lo valarray-inst.lo string-inst.lo
|
||||||
|
|
Loading…
Reference in New Issue