pod_char_traits.h (char_traits<>::move): Use __builtin_memmove.

2007-05-11  Paolo Carlini  <pcarlini@suse.de>

	* include/ext/pod_char_traits.h (char_traits<>::move):
	Use __builtin_memmove.
	* include/bits/locale_classes.h (locale::_Impl::_M_check_same_name,
	collate_byname(const char*, size_t)): Use __builtin_strcmp.
	* include/bits/locale_facets.h: Use __builtin_mem* and
	__builtin_str* everywhere.
	* include/bits/codecvt.h (codecvt_byname(const char*, size_t)):
	Use __builtin_strcmp.
	* include/bits/char_traits.h: Use __builtin_mem* everywhere.
	* include/bits/fstream.tcc (basic_filebuf<>::underflow, imbue):
	Use __builtin_memcpy and __builtin_memmove.
	* include/bits/locale_facets_nonio.h (moneypunct_byname(const char*,
	size_t __refs)): Use __builtin_strcmp.
	* include/std/bitset (bitset<>::_M_do_reset): Use __builtin_memset.
	* config/locale/gnu/c_locale.h: Use __builtin_strlen, __builtin_strcmp,
	and __builtin_memcpy.
	* config/locale/gnu/messages_members.h: Likewise.
	* config/locale/gnu/time_members.h: Likewise.
	* config/locale/generic/c_locale.h: Likewise.
	* config/locale/generic/messages_members.h: Likewise.
	* config/locale/generic/time_members.h: Likewise.
	* config/os/gnu-linux/ctype_noninline.h: Likewise, avoid strdup.
	* config/os/tpf/ctype_noninline.h: Likewise.
	* config/locale/generic/codecvt_members.cc: Include <cstring>. 
	* config/locale/generic/ctype_members.cc: Likewise.
	* config/locale/generic/collate_members.cc: Likewise.
	* config/locale/gnu/c++locale_internal.h: Likewise.
	* config/locale/darwin/ctype_members.cc: Likewise.
	* src/ctype.cc: Likewise.
	* testsuite/19_diagnostics/logic_error/what-1.cc: Likewise.
	* testsuite/19_diagnostics/logic_error/what-2.cc: Likewise.
	* testsuite/19_diagnostics/runtime_error/what-1.cc: Likewise.
	* testsuite/19_diagnostics/runtime_error/what-2.cc: Likewise.
	* testsuite/19_diagnostics/runtime_error/what-3.cc: Likewise.
	* config/locale/gnu/messages_members.cc: Avoid strdup.
	* config/locale/gnu/monetary_members.cc: Likewise.
	* config/locale/gnu/time_members.cc: Likewise.	
	* config/locale/gnu/time_members.cc: Likewise.
	* config/locale/generic/c_locale.cc: Likewise.

From-SVN: r124623
This commit is contained in:
Paolo Carlini 2007-05-11 18:58:08 +00:00
parent 79bedddc8f
commit 538075fe42
33 changed files with 260 additions and 134 deletions

View File

@ -1,18 +1,60 @@
2007-05-11 Paolo Carlini <pcarlini@suse.de>
* include/ext/pod_char_traits.h (char_traits<>::move):
Use __builtin_memmove.
* include/bits/locale_classes.h (locale::_Impl::_M_check_same_name,
collate_byname(const char*, size_t)): Use __builtin_strcmp.
* include/bits/locale_facets.h: Use __builtin_mem* and
__builtin_str* everywhere.
* include/bits/codecvt.h (codecvt_byname(const char*, size_t)):
Use __builtin_strcmp.
* include/bits/char_traits.h: Use __builtin_mem* everywhere.
* include/bits/fstream.tcc (basic_filebuf<>::underflow, imbue):
Use __builtin_memcpy and __builtin_memmove.
* include/bits/locale_facets_nonio.h (moneypunct_byname(const char*,
size_t __refs)): Use __builtin_strcmp.
* include/std/bitset (bitset<>::_M_do_reset): Use __builtin_memset.
* config/locale/gnu/c_locale.h: Use __builtin_strlen, __builtin_strcmp,
and __builtin_memcpy.
* config/locale/gnu/messages_members.h: Likewise.
* config/locale/gnu/time_members.h: Likewise.
* config/locale/generic/c_locale.h: Likewise.
* config/locale/generic/messages_members.h: Likewise.
* config/locale/generic/time_members.h: Likewise.
* config/os/gnu-linux/ctype_noninline.h: Likewise, avoid strdup.
* config/os/tpf/ctype_noninline.h: Likewise.
* config/locale/generic/codecvt_members.cc: Include <cstring>.
* config/locale/generic/ctype_members.cc: Likewise.
* config/locale/generic/collate_members.cc: Likewise.
* config/locale/gnu/c++locale_internal.h: Likewise.
* config/locale/darwin/ctype_members.cc: Likewise.
* src/ctype.cc: Likewise.
* testsuite/19_diagnostics/logic_error/what-1.cc: Likewise.
* testsuite/19_diagnostics/logic_error/what-2.cc: Likewise.
* testsuite/19_diagnostics/runtime_error/what-1.cc: Likewise.
* testsuite/19_diagnostics/runtime_error/what-2.cc: Likewise.
* testsuite/19_diagnostics/runtime_error/what-3.cc: Likewise.
* config/locale/gnu/messages_members.cc: Avoid strdup.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/time_members.cc: Likewise.
* config/locale/gnu/time_members.cc: Likewise.
* config/locale/generic/c_locale.cc: Likewise.
2007-05-11 Benjamin Kosnik <bkoz@redhat.com>
* include/std/stdexcept: Remove extra spacing.
* include/std/stdexcept: Remove extra spacing.
* testsuite/19_diagnostics/stdexceptions.cc: Break into...
* testsuite/19_diagnostics/bad_exception: ...this. Populate.
* testsuite/19_diagnostics/logic_error: ... this.
* testsuite/19_diagnostics/logic_error/what-1.cc: ...this.
* testsuite/19_diagnostics/logic_error/what-2.cc: ...this.
* testsuite/19_diagnostics/runtime_error: ...this.
* testsuite/19_diagnostics/runtime_error/what-1.cc: ...this.
* testsuite/19_diagnostics/runtime_error/what-2.cc: ...this.
* testsuite/19_diagnostics/runtime_error/what-3.cc: ...this.
* testsuite/19_diagnostics/23591_thread-1.c: Move...
* testsuite/19_diagnostics/bad_exception/23591_thread-1.c: ...here.
* testsuite/19_diagnostics/stdexceptions.cc: Break into...
* testsuite/19_diagnostics/bad_exception: ...this. Populate.
* testsuite/19_diagnostics/logic_error: ... this.
* testsuite/19_diagnostics/logic_error/what-1.cc: ...this.
* testsuite/19_diagnostics/logic_error/what-2.cc: ...this.
* testsuite/19_diagnostics/runtime_error: ...this.
* testsuite/19_diagnostics/runtime_error/what-1.cc: ...this.
* testsuite/19_diagnostics/runtime_error/what-2.cc: ...this.
* testsuite/19_diagnostics/runtime_error/what-3.cc: ...this.
* testsuite/19_diagnostics/23591_thread-1.c: Move...
* testsuite/19_diagnostics/bad_exception/23591_thread-1.c: ...here.
2007-05-10 Paolo Carlini <pcarlini@suse.de>

View File

@ -37,6 +37,7 @@
#include <locale>
#include <bits/c++locale_internal.h>
#include <cstdlib>
#include <cstring>
namespace std
{

View File

@ -37,8 +37,10 @@
#include <cerrno> // For errno
#include <cmath> // For isinf, finite, finitef, fabs
#include <cstdlib> // For strof, strtold
#include <cstring>
#include <locale>
#include <limits>
#include <cstddef>
#ifdef _GLIBCXX_HAVE_IEEEFP_H
#include <ieeefp.h>
@ -53,7 +55,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale&)
{
// Assumes __s formatted for "C" locale.
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
@ -91,8 +96,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
}
template<>
@ -101,7 +106,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale&)
{
// Assumes __s formatted for "C" locale.
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
@ -121,8 +129,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
}
template<>
@ -131,7 +139,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
ios_base::iostate& __err, const __c_locale&)
{
// Assumes __s formatted for "C" locale.
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
#if !__LDBL_HAS_INFINITY__
@ -167,8 +178,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
}
void

View File

@ -1,6 +1,6 @@
// Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -45,9 +45,9 @@
#pragma GCC system_header
#include <clocale>
#include <cstring> // get std::strlen
#include <cstdio> // get std::vsnprintf or std::vsprintf
#include <cstdarg>
#include <cstddef>
#define _GLIBCXX_NUM_CATEGORIES 0
@ -66,10 +66,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
char* __old = std::setlocale(LC_NUMERIC, NULL);
char* __sav = NULL;
if (std::strcmp(__old, "C"))
if (__builtin_strcmp(__old, "C"))
{
__sav = new char[std::strlen(__old) + 1];
std::strcpy(__sav, __old);
const size_t __len = __builtin_strlen(__old) + 1;
__sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C");
}

View File

@ -37,6 +37,7 @@
#include <locale>
#include <cstdlib> // For MB_CUR_MAX
#include <climits> // For MB_LEN_MAX
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)

View File

@ -1,6 +1,7 @@
// std::collate implementation details, generic version -*- C++ -*-
// Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -34,6 +35,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)

View File

@ -36,6 +36,7 @@
#include <locale>
#include <cstdlib>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)

View File

@ -1,6 +1,7 @@
// std::messages implementation details, generic version -*- C++ -*-
// Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -83,7 +84,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);

View File

@ -37,6 +37,7 @@
#include <locale>
#include <cstdlib>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)
@ -46,11 +47,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_put(char* __s, size_t __maxlen, const char* __format,
const tm* __tm) const
{
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
// Make sure __s is null terminated.
if (__len == 0)
__s[0] = '\0';
@ -128,11 +132,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
const tm* __tm) const
{
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
// Make sure __s is null terminated.
if (__len == 0)
__s[0] = L'\0';

View File

@ -1,6 +1,7 @@
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -62,9 +63,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_t __refs)
: facet(__refs), _M_data(NULL)
{
const size_t __len = std::strlen(__s) + 1;
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
std::memcpy(__tmp, __s, __len);
__builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp;
try

View File

@ -38,6 +38,8 @@
#include <bits/c++config.h>
#include <clocale>
#include <cstdlib>
#include <cstring>
#include <cstddef>
#include <langinfo.h>
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)

View File

@ -44,11 +44,11 @@
#pragma GCC system_header
#include <cstring> // get std::strlen
#include <cstdio> // get std::vsnprintf or std::vsprintf
#include <clocale>
#include <libintl.h> // For messages
#include <cstdarg>
#include <cstddef>
#define _GLIBCXX_C_LOCALE_GNU 1
@ -80,8 +80,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
#else
char* __old = std::setlocale(LC_ALL, NULL);
char* __sav = new char[std::strlen(__old) + 1];
std::strcpy(__sav, __old);
const size_t __len = __builtin_strlen(__old) + 1;
char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_ALL, "C");
#endif

View File

@ -49,11 +49,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__uselocale(__old);
return string(__msg);
#else
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, _M_name_messages);
const char* __msg = gettext(__dfault.c_str());
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
return string(__msg);
#endif
}
@ -69,11 +72,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__uselocale(__old);
return _M_convert_from_char(__msg);
# else
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, _M_name_messages);
char* __msg = gettext(_M_convert_to_char(__dfault));
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
return _M_convert_from_char(__msg);
# endif
}

View File

@ -1,6 +1,7 @@
// std::messages implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -52,9 +53,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_t __refs)
: facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
{
const size_t __len = std::strlen(__s) + 1;
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
std::memcpy(__tmp, __s, __len);
__builtin_memcpy(__tmp, __s, __len);
_M_name_messages = __tmp;
// Last to avoid leaking memory if new throws.
@ -102,11 +103,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
if (this->_M_name_messages != locale::facet::_S_get_c_name())
delete [] this->_M_name_messages;
char* __tmp = new char[std::strlen(__s) + 1];
std::strcpy(__tmp, __s);
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
this->_M_name_messages = __tmp;
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);

View File

@ -383,7 +383,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__c_locale __old = __uselocale(__cloc);
#else
// Switch to named locale so that mbsrtowcs will work.
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, __name);
#endif
@ -457,8 +460,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
__throw_exception_again;
}
@ -478,8 +481,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
}
}
@ -525,7 +528,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__c_locale __old = __uselocale(__cloc);
#else
// Switch to named locale so that mbsrtowcs will work.
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, __name);
#endif
@ -600,8 +606,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
__throw_exception_again;
}
@ -620,8 +626,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
}
}

View File

@ -1,6 +1,7 @@
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -49,11 +50,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct);
#else
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
// Make sure __s is null terminated.
if (__len == 0)
@ -202,11 +206,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct);
#else
char* __old = strdup(setlocale(LC_ALL, NULL));
char* __old = setlocale(LC_ALL, NULL);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
free(__old);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
// Make sure __s is null terminated.
if (__len == 0)

View File

@ -1,6 +1,7 @@
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -59,9 +60,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
_M_name_timepunct(NULL)
{
const size_t __len = std::strlen(__s) + 1;
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
std::memcpy(__tmp, __s, __len);
__builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp;
try

View File

@ -1,6 +1,7 @@
// Locale support -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -48,15 +49,18 @@
ctype<char>::classic_table() throw()
{
const ctype_base::mask* __ret;
char* __old = strdup(setlocale(LC_CTYPE, NULL));
char* __old = setlocale(LC_CTYPE, NULL);
const size_t __len = __builtin_strlen(__old) + 1;
char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__ret = *__ctype_b_loc();
#else
__ret = __ctype_b;
#endif
setlocale(LC_CTYPE, __old);
free(__old);
setlocale(LC_CTYPE, __sav);
delete [] __sav;
return __ret;
}
#endif
@ -71,8 +75,8 @@
_M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
_M_widen_ok(0), _M_narrow_ok(0)
{
memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow));
__builtin_memset(_M_widen, 0, sizeof(_M_widen));
__builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#else
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
@ -80,7 +84,10 @@
: facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
_M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
{
char* __old=strdup(setlocale(LC_CTYPE, NULL));
char* __old = setlocale(LC_CTYPE, NULL);
const size_t __len = __builtin_strlen(__old) + 1;
char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
_M_toupper = *__ctype_toupper_loc();
@ -91,10 +98,10 @@
_M_tolower = __ctype_tolower;
_M_table = __table ? __table : __ctype_b;
#endif
setlocale(LC_CTYPE, __old);
free(__old);
memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow));
setlocale(LC_CTYPE, __sav);
delete [] __sav;
__builtin_memset(_M_widen, 0, sizeof(_M_widen));
__builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#endif
@ -107,15 +114,18 @@
_M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
_M_widen_ok(0), _M_narrow_ok(0)
{
memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow));
__builtin_memset(_M_widen, 0, sizeof(_M_widen));
__builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#else
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
_M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
{
char* __old=strdup(setlocale(LC_CTYPE, NULL));
char* __old = setlocale(LC_CTYPE, NULL);
const size_t __len = __builtin_strlen(__old) + 1;
char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
_M_toupper = *__ctype_toupper_loc();
@ -126,10 +136,10 @@
_M_tolower = __ctype_tolower;
_M_table = __table ? __table : __ctype_b;
#endif
setlocale(LC_CTYPE, __old);
free(__old);
memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow));
setlocale(LC_CTYPE, __sav);
delete [] __sav;
__builtin_memset(_M_widen, 0, sizeof(_M_widen));
__builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#endif

View File

@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
// Copyright (C) 2004 Free Software Foundation, Inc.
// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
//
// 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
@ -42,11 +42,14 @@
ctype<char>::classic_table() throw()
{
const ctype_base::mask* __ret;
char* __old = strdup(setlocale(LC_CTYPE, NULL));
char* __old = setlocale(LC_CTYPE, NULL);
const size_t __len = __builtin_strlen(__old) + 1;
char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
__ret = *__ctype_b_loc();
setlocale(LC_CTYPE, __old);
free(__old);
setlocale(LC_CTYPE, __sav);
delete [] __sav;
return __ret;
}
@ -54,26 +57,32 @@
size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del)
{
char* __old=strdup(setlocale(LC_CTYPE, NULL));
char* __old = setlocale(LC_CTYPE, NULL);
const size_t __len = __builtin_strlen(__old) + 1;
char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
_M_toupper = *__ctype_toupper_loc();
_M_tolower = *__ctype_tolower_loc();
_M_table = __table ? __table : *__ctype_b_loc();
setlocale(LC_CTYPE, __old);
free(__old);
setlocale(LC_CTYPE, __sav);
delete [] __sav;
_M_c_locale_ctype = _S_get_c_locale();
}
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del)
{
char* __old=strdup(setlocale(LC_CTYPE, NULL));
char* __old = setlocale(LC_CTYPE, NULL);
const size_t __len = __builtin_strlen(__old) + 1;
char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
_M_toupper = *__ctype_toupper_loc();
_M_tolower = *__ctype_tolower_loc();
_M_table = __table ? __table : *__ctype_b_loc();
setlocale(LC_CTYPE, __old);
free(__old);
setlocale(LC_CTYPE, __sav);
delete [] __sav;
_M_c_locale_ctype = _S_get_c_locale();
}

View File

@ -43,7 +43,6 @@
#pragma GCC system_header
#include <cstring> // For memmove, memset, memchr
#include <bits/stl_algobase.h> // For copy, fill_n
#include <bits/postypes.h> // For streampos
#include <cstdio> // For EOF
@ -186,8 +185,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
char_traits<_CharT>::
move(char_type* __s1, const char_type* __s2, std::size_t __n)
{
return static_cast<_CharT*>(std::memmove(__s1, __s2,
__n * sizeof(char_type)));
return static_cast<_CharT*>(__builtin_memmove(__s1, __s2,
__n * sizeof(char_type)));
}
template<typename _CharT>
@ -254,27 +253,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
static int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{ return memcmp(__s1, __s2, __n); }
{ return __builtin_memcmp(__s1, __s2, __n); }
static size_t
length(const char_type* __s)
{ return strlen(__s); }
{ return __builtin_strlen(__s); }
static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{ return static_cast<const char_type*>(memchr(__s, __a, __n)); }
{ return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n)); }
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
{ return static_cast<char_type*>(memmove(__s1, __s2, __n)); }
{ return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n)); }
static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
{ return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); }
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
{ return static_cast<char_type*>(memset(__s, __a, __n)); }
{ return static_cast<char_type*>(__builtin_memset(__s, __a, __n)); }
static char_type
to_char_type(const int_type& __c)

View File

@ -457,7 +457,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
codecvt_byname(const char* __s, size_t __refs = 0)
: codecvt<_InternT, _ExternT, _StateT>(__refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_codecvt);
this->_S_create_c_locale(this->_M_c_locale_codecvt, __s);

View File

@ -263,14 +263,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
char* __buf = new char[__blen];
if (__remainder)
std::memcpy(__buf, _M_ext_next, __remainder);
__builtin_memcpy(__buf, _M_ext_next, __remainder);
delete [] _M_ext_buf;
_M_ext_buf = __buf;
_M_ext_buf_size = __blen;
}
else if (__remainder)
std::memmove(_M_ext_buf, _M_ext_next, __remainder);
__builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;
@ -888,7 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
this->gptr() - this->eback());
const streamsize __remainder = _M_ext_end - _M_ext_next;
if (__remainder)
std::memmove(_M_ext_buf, _M_ext_next, __remainder);
__builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;

View File

@ -44,7 +44,6 @@
#pragma GCC system_header
#include <bits/localefwd.h>
#include <cstring> // For strcmp.
#include <string>
#include <ext/atomicity.h>
@ -537,7 +536,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (_M_names[1])
// We must actually compare all the _M_names: can be all equal!
for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
__ret = std::strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
__ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
return __ret;
}
@ -810,7 +809,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
collate_byname(const char* __s, size_t __refs = 0)
: collate<_CharT>(__refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_collate);
this->_S_create_c_locale(this->_M_c_locale_collate, __s);

View File

@ -899,7 +899,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
if (_M_widen_ok == 1)
{
memcpy(__to, __lo, __hi - __lo);
__builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_widen_ok)
@ -964,7 +964,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
if (__builtin_expect(_M_narrow_ok == 1, true))
{
memcpy(__to, __lo, __hi - __lo);
__builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_narrow_ok)
@ -1101,7 +1101,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __dest) const
{
memcpy(__dest, __lo, __hi - __lo);
__builtin_memcpy(__dest, __lo, __hi - __lo);
return __hi;
}
@ -1154,7 +1154,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
do_narrow(const char_type* __lo, const char_type* __hi,
char, char* __dest) const
{
memcpy(__dest, __lo, __hi - __lo);
__builtin_memcpy(__dest, __lo, __hi - __lo);
return __hi;
}
@ -1169,7 +1169,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_widen_ok = 1;
// Set _M_widen_ok to 2 if memcpy can't be used.
if (memcmp(__tmp, _M_widen, sizeof(_M_widen)))
if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
_M_widen_ok = 2;
}
@ -1184,7 +1184,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
_M_narrow_ok = 1;
if (memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
_M_narrow_ok = 2;
else
{
@ -1922,7 +1922,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
numpunct_byname(const char* __s, size_t __refs = 0)
: numpunct<_CharT>(__refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
__c_locale __tmp;
this->_S_create_c_locale(__tmp, __s);

View File

@ -1320,7 +1320,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
moneypunct_byname(const char* __s, size_t __refs = 0)
: moneypunct<_CharT, _Intl>(__refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
__c_locale __tmp;
this->_S_create_c_locale(__tmp, __s);

View File

@ -140,8 +140,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
{
return static_cast<char_type*>(std::memmove(__s1, __s2,
__n * sizeof(char_type)));
return static_cast<char_type*>
(__builtin_memmove(__s1, __s2, __n * sizeof(char_type)));
}
static char_type*

View File

@ -51,7 +51,6 @@
#pragma GCC system_header
#include <cstddef> // For size_t
#include <cstring> // For memset
#include <string>
#include <bits/functexcept.h> // For invalid_argument, out_of_range,
// overflow_error
@ -165,7 +164,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
void
_M_do_reset()
{ std::memset(_M_w, 0, _Nw * sizeof(_WordT)); }
{ __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); }
bool
_M_is_equal(const _Base_bitset<_Nw>& __x) const

View File

@ -29,6 +29,7 @@
#include <locale>
#include <cstdlib>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)

View File

@ -1,6 +1,7 @@
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -22,6 +23,7 @@
#include <string>
#include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/1972

View File

@ -1,6 +1,7 @@
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -22,6 +23,7 @@
#include <string>
#include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/2089

View File

@ -1,6 +1,7 @@
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -22,6 +23,7 @@
#include <string>
#include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/1972

View File

@ -1,6 +1,7 @@
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -22,6 +23,7 @@
#include <string>
#include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/2089

View File

@ -1,6 +1,7 @@
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// 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
@ -22,6 +23,7 @@
#include <string>
#include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h>
// test copy ctors and assignment operators