This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to valarray
- From: Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Pierre Chanial <p dot chanial at imperial dot ac dot uk>, libstdc++ at gcc dot gnu dot org
- Date: 30 Jan 2006 17:32:58 -0600
- Subject: PATCH to valarray
During a discussion with Pierre, it appeared that the valarray code is
quite old by now :-)
In particular, now that we have __is_pod<>, we should probably use it.
This change should be considered for GCC-4.1 too.
Other issues are still under investigation.
Tested on an i686-pc-linux-gnu. Applied to mainline.
-- Gaby
2006-01-30 Gabriel Dos Reis <gdr@integrable-solutions.net>
* include/bits/valarray_array.h (__valarray_default_construct):
Replace use __is_fundamental with __is_pod.
(__valarray_fill_construct): Likewise.
(__valarray_copy_construct): Likewise.
(__valarray_destroy_elements): Likewise.
(__valarray_copy): Likewise.
*** include/bits/valarray_array.h (revision 110414)
--- include/bits/valarray_array.h (local)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 98,105 ****
inline void
__valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
{
! _Array_default_ctor<_Tp, __is_fundamental<_Tp>::__value>::
! _S_do_it(__b, __e);
}
// Turn a raw-memory into an array of _Tp filled with __t
--- 98,104 ----
inline void
__valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
{
! _Array_default_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e);
}
// Turn a raw-memory into an array of _Tp filled with __t
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 134,141 ****
__valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e,
const _Tp __t)
{
! _Array_init_ctor<_Tp, __is_fundamental<_Tp>::__value>::
! _S_do_it(__b, __e, __t);
}
//
--- 133,139 ----
__valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e,
const _Tp __t)
{
! _Array_init_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e, __t);
}
//
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 171,178 ****
const _Tp* __restrict__ __e,
_Tp* __restrict__ __o)
{
! _Array_copy_ctor<_Tp, __is_fundamental<_Tp>::__value>::
! _S_do_it(__b, __e, __o);
}
// copy-construct raw array [__o, *) from strided array __a[<__n : __s>]
--- 169,175 ----
const _Tp* __restrict__ __e,
_Tp* __restrict__ __o)
{
! _Array_copy_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e, __o);
}
// copy-construct raw array [__o, *) from strided array __a[<__n : __s>]
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 181,187 ****
__valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n,
size_t __s, _Tp* __restrict__ __o)
{
! if (__is_fundamental<_Tp>::__value)
while (__n--)
{
*__o++ = *__a;
--- 178,184 ----
__valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n,
size_t __s, _Tp* __restrict__ __o)
{
! if (__is_pod<_Tp>::__value)
while (__n--)
{
*__o++ = *__a;
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 202,208 ****
const size_t* __restrict__ __i,
_Tp* __restrict__ __o, size_t __n)
{
! if (__is_fundamental<_Tp>::__value)
while (__n--)
*__o++ = __a[*__i++];
else
--- 199,205 ----
const size_t* __restrict__ __i,
_Tp* __restrict__ __o, size_t __n)
{
! if (__is_pod<_Tp>::__value)
while (__n--)
*__o++ = __a[*__i++];
else
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 215,221 ****
inline void
__valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
{
! if (!__is_fundamental<_Tp>::__value)
while (__b != __e)
{
__b->~_Tp();
--- 212,218 ----
inline void
__valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
{
! if (!__is_pod<_Tp>::__value)
while (__b != __e)
{
__b->~_Tp();
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 279,286 ****
__valarray_copy(const _Tp* __restrict__ __a, size_t __n,
_Tp* __restrict__ __b)
{
! _Array_copier<_Tp, __is_fundamental<_Tp>::__value>::
! _S_do_it(__a, __n, __b);
}
// Copy strided array __a[<__n : __s>] in plain __b[<__n>]
--- 276,282 ----
__valarray_copy(const _Tp* __restrict__ __a, size_t __n,
_Tp* __restrict__ __b)
{
! _Array_copier<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__a, __n, __b);
}
// Copy strided array __a[<__n : __s>] in plain __b[<__n>]