Commit 538075fe by Paolo Carlini

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
parent 79bedddc
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> 2007-05-11 Benjamin Kosnik <bkoz@redhat.com>
* include/std/stdexcept: Remove extra spacing. * include/std/stdexcept: Remove extra spacing.
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <locale> #include <locale>
#include <bits/c++locale_internal.h> #include <bits/c++locale_internal.h>
#include <cstdlib> #include <cstdlib>
#include <cstring>
namespace std namespace std
{ {
......
...@@ -37,8 +37,10 @@ ...@@ -37,8 +37,10 @@
#include <cerrno> // For errno #include <cerrno> // For errno
#include <cmath> // For isinf, finite, finitef, fabs #include <cmath> // For isinf, finite, finitef, fabs
#include <cstdlib> // For strof, strtold #include <cstdlib> // For strof, strtold
#include <cstring>
#include <locale> #include <locale>
#include <limits> #include <limits>
#include <cstddef>
#ifdef _GLIBCXX_HAVE_IEEEFP_H #ifdef _GLIBCXX_HAVE_IEEEFP_H
#include <ieeefp.h> #include <ieeefp.h>
...@@ -53,7 +55,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -53,7 +55,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale&) const __c_locale&)
{ {
// Assumes __s formatted for "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"); setlocale(LC_ALL, "C");
char* __sanity; char* __sanity;
...@@ -91,8 +96,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -91,8 +96,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
} }
template<> template<>
...@@ -101,7 +106,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -101,7 +106,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __c_locale&) const __c_locale&)
{ {
// Assumes __s formatted for "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"); setlocale(LC_ALL, "C");
char* __sanity; char* __sanity;
...@@ -121,8 +129,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -121,8 +129,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
} }
template<> template<>
...@@ -131,7 +139,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -131,7 +139,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
ios_base::iostate& __err, const __c_locale&) ios_base::iostate& __err, const __c_locale&)
{ {
// Assumes __s formatted for "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"); setlocale(LC_ALL, "C");
#if !__LDBL_HAS_INFINITY__ #if !__LDBL_HAS_INFINITY__
...@@ -167,8 +178,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -167,8 +178,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
} }
void void
......
// Wrapper for underlying C-language localization -*- C++ -*- // 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. // 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
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
#pragma GCC system_header #pragma GCC system_header
#include <clocale> #include <clocale>
#include <cstring> // get std::strlen
#include <cstdio> // get std::vsnprintf or std::vsprintf #include <cstdio> // get std::vsnprintf or std::vsprintf
#include <cstdarg> #include <cstdarg>
#include <cstddef>
#define _GLIBCXX_NUM_CATEGORIES 0 #define _GLIBCXX_NUM_CATEGORIES 0
...@@ -66,10 +66,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -66,10 +66,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
char* __old = std::setlocale(LC_NUMERIC, NULL); char* __old = std::setlocale(LC_NUMERIC, NULL);
char* __sav = NULL; char* __sav = NULL;
if (std::strcmp(__old, "C")) if (__builtin_strcmp(__old, "C"))
{ {
__sav = new char[std::strlen(__old) + 1]; const size_t __len = __builtin_strlen(__old) + 1;
std::strcpy(__sav, __old); __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C"); std::setlocale(LC_NUMERIC, "C");
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <locale> #include <locale>
#include <cstdlib> // For MB_CUR_MAX #include <cstdlib> // For MB_CUR_MAX
#include <climits> // For MB_LEN_MAX #include <climits> // For MB_LEN_MAX
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
......
// std::collate implementation details, generic version -*- C++ -*- // 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 // 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
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com> // Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale> #include <locale>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <locale> #include <locale>
#include <cstdlib> #include <cstdlib>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
......
// std::messages implementation details, generic version -*- C++ -*- // 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 // 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
...@@ -83,7 +84,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -83,7 +84,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__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_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s); this->_S_create_c_locale(this->_M_c_locale_messages, __s);
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <locale> #include <locale>
#include <cstdlib> #include <cstdlib>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
...@@ -46,11 +47,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -46,11 +47,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_put(char* __s, size_t __maxlen, const char* __format, _M_put(char* __s, size_t __maxlen, const char* __format,
const tm* __tm) const 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); setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm); const size_t __len = strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
// Make sure __s is null terminated. // Make sure __s is null terminated.
if (__len == 0) if (__len == 0)
__s[0] = '\0'; __s[0] = '\0';
...@@ -128,11 +132,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -128,11 +132,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format, _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
const tm* __tm) const 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); setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm); const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
// Make sure __s is null terminated. // Make sure __s is null terminated.
if (__len == 0) if (__len == 0)
__s[0] = L'\0'; __s[0] = L'\0';
......
// std::time_get, std::time_put implementation, generic version -*- C++ -*- // 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 // 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
...@@ -62,9 +63,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -62,9 +63,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_t __refs) size_t __refs)
: facet(__refs), _M_data(NULL) : 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]; char* __tmp = new char[__len];
std::memcpy(__tmp, __s, __len); __builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp; _M_name_timepunct = __tmp;
try try
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <bits/c++config.h> #include <bits/c++config.h>
#include <clocale> #include <clocale>
#include <cstdlib> #include <cstdlib>
#include <cstring>
#include <cstddef>
#include <langinfo.h> #include <langinfo.h>
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
......
...@@ -44,11 +44,11 @@ ...@@ -44,11 +44,11 @@
#pragma GCC system_header #pragma GCC system_header
#include <cstring> // get std::strlen
#include <cstdio> // get std::vsnprintf or std::vsprintf #include <cstdio> // get std::vsnprintf or std::vsprintf
#include <clocale> #include <clocale>
#include <libintl.h> // For messages #include <libintl.h> // For messages
#include <cstdarg> #include <cstdarg>
#include <cstddef>
#define _GLIBCXX_C_LOCALE_GNU 1 #define _GLIBCXX_C_LOCALE_GNU 1
...@@ -80,8 +80,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -80,8 +80,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__c_locale __old = __gnu_cxx::__uselocale(__cloc); __c_locale __old = __gnu_cxx::__uselocale(__cloc);
#else #else
char* __old = std::setlocale(LC_ALL, NULL); char* __old = std::setlocale(LC_ALL, NULL);
char* __sav = new char[std::strlen(__old) + 1]; const size_t __len = __builtin_strlen(__old) + 1;
std::strcpy(__sav, __old); char* __sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_ALL, "C"); std::setlocale(LC_ALL, "C");
#endif #endif
......
...@@ -49,11 +49,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -49,11 +49,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__uselocale(__old); __uselocale(__old);
return string(__msg); return string(__msg);
#else #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); setlocale(LC_ALL, _M_name_messages);
const char* __msg = gettext(__dfault.c_str()); const char* __msg = gettext(__dfault.c_str());
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
return string(__msg); return string(__msg);
#endif #endif
} }
...@@ -69,11 +72,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -69,11 +72,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__uselocale(__old); __uselocale(__old);
return _M_convert_from_char(__msg); return _M_convert_from_char(__msg);
# else # 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); setlocale(LC_ALL, _M_name_messages);
char* __msg = gettext(_M_convert_to_char(__dfault)); char* __msg = gettext(_M_convert_to_char(__dfault));
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
return _M_convert_from_char(__msg); return _M_convert_from_char(__msg);
# endif # endif
} }
......
// std::messages implementation details, GNU version -*- C++ -*- // 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 // 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
...@@ -52,9 +53,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -52,9 +53,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_t __refs) size_t __refs)
: facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL) : 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]; char* __tmp = new char[__len];
std::memcpy(__tmp, __s, __len); __builtin_memcpy(__tmp, __s, __len);
_M_name_messages = __tmp; _M_name_messages = __tmp;
// Last to avoid leaking memory if new throws. // Last to avoid leaking memory if new throws.
...@@ -102,11 +103,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -102,11 +103,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
if (this->_M_name_messages != locale::facet::_S_get_c_name()) if (this->_M_name_messages != locale::facet::_S_get_c_name())
delete [] this->_M_name_messages; delete [] this->_M_name_messages;
char* __tmp = new char[std::strlen(__s) + 1]; const size_t __len = __builtin_strlen(__s) + 1;
std::strcpy(__tmp, __s); char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
this->_M_name_messages = __tmp; 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_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s); this->_S_create_c_locale(this->_M_c_locale_messages, __s);
......
...@@ -383,7 +383,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -383,7 +383,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__c_locale __old = __uselocale(__cloc); __c_locale __old = __uselocale(__cloc);
#else #else
// Switch to named locale so that mbsrtowcs will work. // 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); setlocale(LC_ALL, __name);
#endif #endif
...@@ -457,8 +460,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -457,8 +460,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old); __uselocale(__old);
#else #else
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
#endif #endif
__throw_exception_again; __throw_exception_again;
} }
...@@ -478,8 +481,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -478,8 +481,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old); __uselocale(__old);
#else #else
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
#endif #endif
} }
} }
...@@ -525,7 +528,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -525,7 +528,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__c_locale __old = __uselocale(__cloc); __c_locale __old = __uselocale(__cloc);
#else #else
// Switch to named locale so that mbsrtowcs will work. // 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); setlocale(LC_ALL, __name);
#endif #endif
...@@ -600,8 +606,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -600,8 +606,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old); __uselocale(__old);
#else #else
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
#endif #endif
__throw_exception_again; __throw_exception_again;
} }
...@@ -620,8 +626,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -620,8 +626,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old); __uselocale(__old);
#else #else
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
#endif #endif
} }
} }
......
// std::time_get, std::time_put implementation, GNU version -*- C++ -*- // 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 // 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
...@@ -49,11 +50,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -49,11 +50,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const size_t __len = __strftime_l(__s, __maxlen, __format, __tm, const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct); _M_c_locale_timepunct);
#else #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); setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm); const size_t __len = strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
#endif #endif
// Make sure __s is null terminated. // Make sure __s is null terminated.
if (__len == 0) if (__len == 0)
...@@ -202,11 +206,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -202,11 +206,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm, const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct); _M_c_locale_timepunct);
#else #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); setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm); const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __sav);
free(__old); delete [] __sav;
#endif #endif
// Make sure __s is null terminated. // Make sure __s is null terminated.
if (__len == 0) if (__len == 0)
......
// std::time_get, std::time_put implementation, GNU version -*- C++ -*- // 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 // 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
...@@ -59,9 +60,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -59,9 +60,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
_M_name_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]; char* __tmp = new char[__len];
std::memcpy(__tmp, __s, __len); __builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp; _M_name_timepunct = __tmp;
try try
......
// Locale support -*- C++ -*- // 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. // 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
...@@ -48,15 +49,18 @@ ...@@ -48,15 +49,18 @@
ctype<char>::classic_table() throw() ctype<char>::classic_table() throw()
{ {
const ctype_base::mask* __ret; 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"); setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__ret = *__ctype_b_loc(); __ret = *__ctype_b_loc();
#else #else
__ret = __ctype_b; __ret = __ctype_b;
#endif #endif
setlocale(LC_CTYPE, __old); setlocale(LC_CTYPE, __sav);
free(__old); delete [] __sav;
return __ret; return __ret;
} }
#endif #endif
...@@ -71,8 +75,8 @@ ...@@ -71,8 +75,8 @@
_M_table(__table ? __table : _M_c_locale_ctype->__ctype_b), _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
_M_widen_ok(0), _M_narrow_ok(0) _M_widen_ok(0), _M_narrow_ok(0)
{ {
memset(_M_widen, 0, sizeof(_M_widen)); __builtin_memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow)); __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
} }
#else #else
ctype<char>::ctype(__c_locale, const mask* __table, bool __del, ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
...@@ -80,7 +84,10 @@ ...@@ -80,7 +84,10 @@
: facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
_M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0) _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"); setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
_M_toupper = *__ctype_toupper_loc(); _M_toupper = *__ctype_toupper_loc();
...@@ -91,10 +98,10 @@ ...@@ -91,10 +98,10 @@
_M_tolower = __ctype_tolower; _M_tolower = __ctype_tolower;
_M_table = __table ? __table : __ctype_b; _M_table = __table ? __table : __ctype_b;
#endif #endif
setlocale(LC_CTYPE, __old); setlocale(LC_CTYPE, __sav);
free(__old); delete [] __sav;
memset(_M_widen, 0, sizeof(_M_widen)); __builtin_memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow)); __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
} }
#endif #endif
...@@ -107,15 +114,18 @@ ...@@ -107,15 +114,18 @@
_M_table(__table ? __table : _M_c_locale_ctype->__ctype_b), _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
_M_widen_ok(0), _M_narrow_ok(0) _M_widen_ok(0), _M_narrow_ok(0)
{ {
memset(_M_widen, 0, sizeof(_M_widen)); __builtin_memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow)); __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
} }
#else #else
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
_M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0) _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"); setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
_M_toupper = *__ctype_toupper_loc(); _M_toupper = *__ctype_toupper_loc();
...@@ -126,10 +136,10 @@ ...@@ -126,10 +136,10 @@
_M_tolower = __ctype_tolower; _M_tolower = __ctype_tolower;
_M_table = __table ? __table : __ctype_b; _M_table = __table ? __table : __ctype_b;
#endif #endif
setlocale(LC_CTYPE, __old); setlocale(LC_CTYPE, __sav);
free(__old); delete [] __sav;
memset(_M_widen, 0, sizeof(_M_widen)); __builtin_memset(_M_widen, 0, sizeof(_M_widen));
memset(_M_narrow, 0, sizeof(_M_narrow)); __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
} }
#endif #endif
......
// Locale support -*- C++ -*- // 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 // 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
...@@ -42,11 +42,14 @@ ...@@ -42,11 +42,14 @@
ctype<char>::classic_table() throw() ctype<char>::classic_table() throw()
{ {
const ctype_base::mask* __ret; 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"); setlocale(LC_CTYPE, "C");
__ret = *__ctype_b_loc(); __ret = *__ctype_b_loc();
setlocale(LC_CTYPE, __old); setlocale(LC_CTYPE, __sav);
free(__old); delete [] __sav;
return __ret; return __ret;
} }
...@@ -54,26 +57,32 @@ ...@@ -54,26 +57,32 @@
size_t __refs) size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del) : 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"); setlocale(LC_CTYPE, "C");
_M_toupper = *__ctype_toupper_loc(); _M_toupper = *__ctype_toupper_loc();
_M_tolower = *__ctype_tolower_loc(); _M_tolower = *__ctype_tolower_loc();
_M_table = __table ? __table : *__ctype_b_loc(); _M_table = __table ? __table : *__ctype_b_loc();
setlocale(LC_CTYPE, __old); setlocale(LC_CTYPE, __sav);
free(__old); delete [] __sav;
_M_c_locale_ctype = _S_get_c_locale(); _M_c_locale_ctype = _S_get_c_locale();
} }
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del) : 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"); setlocale(LC_CTYPE, "C");
_M_toupper = *__ctype_toupper_loc(); _M_toupper = *__ctype_toupper_loc();
_M_tolower = *__ctype_tolower_loc(); _M_tolower = *__ctype_tolower_loc();
_M_table = __table ? __table : *__ctype_b_loc(); _M_table = __table ? __table : *__ctype_b_loc();
setlocale(LC_CTYPE, __old); setlocale(LC_CTYPE, __sav);
free(__old); delete [] __sav;
_M_c_locale_ctype = _S_get_c_locale(); _M_c_locale_ctype = _S_get_c_locale();
} }
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#pragma GCC system_header #pragma GCC system_header
#include <cstring> // For memmove, memset, memchr
#include <bits/stl_algobase.h> // For copy, fill_n #include <bits/stl_algobase.h> // For copy, fill_n
#include <bits/postypes.h> // For streampos #include <bits/postypes.h> // For streampos
#include <cstdio> // For EOF #include <cstdio> // For EOF
...@@ -186,7 +185,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -186,7 +185,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
char_traits<_CharT>:: char_traits<_CharT>::
move(char_type* __s1, const char_type* __s2, std::size_t __n) move(char_type* __s1, const char_type* __s2, std::size_t __n)
{ {
return static_cast<_CharT*>(std::memmove(__s1, __s2, return static_cast<_CharT*>(__builtin_memmove(__s1, __s2,
__n * sizeof(char_type))); __n * sizeof(char_type)));
} }
...@@ -254,27 +253,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -254,27 +253,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
static int static int
compare(const char_type* __s1, const char_type* __s2, size_t __n) 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 static size_t
length(const char_type* __s) length(const char_type* __s)
{ return strlen(__s); } { return __builtin_strlen(__s); }
static const char_type* static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a) 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* static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n) 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* static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n) 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* static char_type*
assign(char_type* __s, size_t __n, char_type __a) 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 static char_type
to_char_type(const int_type& __c) to_char_type(const int_type& __c)
......
...@@ -457,7 +457,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -457,7 +457,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
codecvt_byname(const char* __s, size_t __refs = 0) codecvt_byname(const char* __s, size_t __refs = 0)
: codecvt<_InternT, _ExternT, _StateT>(__refs) : 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_destroy_c_locale(this->_M_c_locale_codecvt);
this->_S_create_c_locale(this->_M_c_locale_codecvt, __s); this->_S_create_c_locale(this->_M_c_locale_codecvt, __s);
......
...@@ -263,14 +263,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -263,14 +263,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
char* __buf = new char[__blen]; char* __buf = new char[__blen];
if (__remainder) if (__remainder)
std::memcpy(__buf, _M_ext_next, __remainder); __builtin_memcpy(__buf, _M_ext_next, __remainder);
delete [] _M_ext_buf; delete [] _M_ext_buf;
_M_ext_buf = __buf; _M_ext_buf = __buf;
_M_ext_buf_size = __blen; _M_ext_buf_size = __blen;
} }
else if (__remainder) 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_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder; _M_ext_end = _M_ext_buf + __remainder;
...@@ -888,7 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -888,7 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
this->gptr() - this->eback()); this->gptr() - this->eback());
const streamsize __remainder = _M_ext_end - _M_ext_next; const streamsize __remainder = _M_ext_end - _M_ext_next;
if (__remainder) 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_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder; _M_ext_end = _M_ext_buf + __remainder;
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#pragma GCC system_header #pragma GCC system_header
#include <bits/localefwd.h> #include <bits/localefwd.h>
#include <cstring> // For strcmp.
#include <string> #include <string>
#include <ext/atomicity.h> #include <ext/atomicity.h>
...@@ -537,7 +536,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -537,7 +536,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (_M_names[1]) if (_M_names[1])
// We must actually compare all the _M_names: can be all equal! // We must actually compare all the _M_names: can be all equal!
for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i) 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; return __ret;
} }
...@@ -810,7 +809,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -810,7 +809,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
collate_byname(const char* __s, size_t __refs = 0) collate_byname(const char* __s, size_t __refs = 0)
: collate<_CharT>(__refs) : 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_destroy_c_locale(this->_M_c_locale_collate);
this->_S_create_c_locale(this->_M_c_locale_collate, __s); this->_S_create_c_locale(this->_M_c_locale_collate, __s);
......
...@@ -899,7 +899,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -899,7 +899,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
if (_M_widen_ok == 1) if (_M_widen_ok == 1)
{ {
memcpy(__to, __lo, __hi - __lo); __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi; return __hi;
} }
if (!_M_widen_ok) if (!_M_widen_ok)
...@@ -964,7 +964,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -964,7 +964,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
if (__builtin_expect(_M_narrow_ok == 1, true)) if (__builtin_expect(_M_narrow_ok == 1, true))
{ {
memcpy(__to, __lo, __hi - __lo); __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi; return __hi;
} }
if (!_M_narrow_ok) if (!_M_narrow_ok)
...@@ -1101,7 +1101,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1101,7 +1101,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
virtual const char* virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __dest) const 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; return __hi;
} }
...@@ -1154,7 +1154,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1154,7 +1154,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
do_narrow(const char_type* __lo, const char_type* __hi, do_narrow(const char_type* __lo, const char_type* __hi,
char, char* __dest) const char, char* __dest) const
{ {
memcpy(__dest, __lo, __hi - __lo); __builtin_memcpy(__dest, __lo, __hi - __lo);
return __hi; return __hi;
} }
...@@ -1169,7 +1169,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1169,7 +1169,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_widen_ok = 1; _M_widen_ok = 1;
// Set _M_widen_ok to 2 if memcpy can't be used. // 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; _M_widen_ok = 2;
} }
...@@ -1184,7 +1184,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1184,7 +1184,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow); do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
_M_narrow_ok = 1; _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; _M_narrow_ok = 2;
else else
{ {
...@@ -1922,7 +1922,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1922,7 +1922,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
numpunct_byname(const char* __s, size_t __refs = 0) numpunct_byname(const char* __s, size_t __refs = 0)
: numpunct<_CharT>(__refs) : 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; __c_locale __tmp;
this->_S_create_c_locale(__tmp, __s); this->_S_create_c_locale(__tmp, __s);
......
...@@ -1320,7 +1320,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1320,7 +1320,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
moneypunct_byname(const char* __s, size_t __refs = 0) moneypunct_byname(const char* __s, size_t __refs = 0)
: moneypunct<_CharT, _Intl>(__refs) : 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; __c_locale __tmp;
this->_S_create_c_locale(__tmp, __s); this->_S_create_c_locale(__tmp, __s);
......
...@@ -140,8 +140,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -140,8 +140,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
static char_type* static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n) move(char_type* __s1, const char_type* __s2, size_t __n)
{ {
return static_cast<char_type*>(std::memmove(__s1, __s2, return static_cast<char_type*>
__n * sizeof(char_type))); (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)));
} }
static char_type* static char_type*
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#pragma GCC system_header #pragma GCC system_header
#include <cstddef> // For size_t #include <cstddef> // For size_t
#include <cstring> // For memset
#include <string> #include <string>
#include <bits/functexcept.h> // For invalid_argument, out_of_range, #include <bits/functexcept.h> // For invalid_argument, out_of_range,
// overflow_error // overflow_error
...@@ -165,7 +164,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) ...@@ -165,7 +164,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
void void
_M_do_reset() _M_do_reset()
{ std::memset(_M_w, 0, _Nw * sizeof(_WordT)); } { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); }
bool bool
_M_is_equal(const _Base_bitset<_Nw>& __x) const _M_is_equal(const _Base_bitset<_Nw>& __x) const
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <locale> #include <locale>
#include <cstdlib> #include <cstdlib>
#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
......
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/1972 // libstdc++/1972
......
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/2089 // libstdc++/2089
......
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/1972 // libstdc++/1972
......
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/2089 // libstdc++/2089
......
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com> // 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 // 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
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <cstring>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// test copy ctors and assignment operators // test copy ctors and assignment operators
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment