diff options
Diffstat (limited to 'contrib/libstdc++/config')
103 files changed, 3862 insertions, 2336 deletions
diff --git a/contrib/libstdc++/config/allocator/bitmap_allocator_base.h b/contrib/libstdc++/config/allocator/bitmap_allocator_base.h new file mode 100644 index 0000000..bf84ae0 --- /dev/null +++ b/contrib/libstdc++/config/allocator/bitmap_allocator_base.h @@ -0,0 +1,37 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _CXX_ALLOCATOR_H +#define _CXX_ALLOCATOR_H 1 + +// Define bitmap_allocator as the base class to std::allocator. +#include <ext/bitmap_allocator.h> +#define ___glibcxx_base_allocator __gnu_cxx::bitmap_allocator + +#endif diff --git a/contrib/libstdc++/config/allocator/malloc_allocator_base.h b/contrib/libstdc++/config/allocator/malloc_allocator_base.h new file mode 100644 index 0000000..4a82ec3 --- /dev/null +++ b/contrib/libstdc++/config/allocator/malloc_allocator_base.h @@ -0,0 +1,37 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _CXX_ALLOCATOR_H +#define _CXX_ALLOCATOR_H 1 + +// Define new_allocator as the base class to std::allocator. +#include <ext/malloc_allocator.h> +#define ___glibcxx_base_allocator __gnu_cxx::malloc_allocator + +#endif diff --git a/contrib/libstdc++/config/allocator/mt_allocator_base.h b/contrib/libstdc++/config/allocator/mt_allocator_base.h new file mode 100644 index 0000000..52b4421 --- /dev/null +++ b/contrib/libstdc++/config/allocator/mt_allocator_base.h @@ -0,0 +1,37 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _CXX_ALLOCATOR_H +#define _CXX_ALLOCATOR_H 1 + +// Define mt_allocator as the base class to std::allocator. +#include <ext/mt_allocator.h> +#define ___glibcxx_base_allocator __gnu_cxx::__mt_alloc + +#endif diff --git a/contrib/libstdc++/config/allocator/new_allocator_base.h b/contrib/libstdc++/config/allocator/new_allocator_base.h new file mode 100644 index 0000000..442f89c --- /dev/null +++ b/contrib/libstdc++/config/allocator/new_allocator_base.h @@ -0,0 +1,37 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _CXX_ALLOCATOR_H +#define _CXX_ALLOCATOR_H 1 + +// Define new_allocator as the base class to std::allocator. +#include <ext/new_allocator.h> +#define ___glibcxx_base_allocator __gnu_cxx::new_allocator + +#endif diff --git a/contrib/libstdc++/config/allocator/pool_allocator_base.h b/contrib/libstdc++/config/allocator/pool_allocator_base.h new file mode 100644 index 0000000..77c74b2 --- /dev/null +++ b/contrib/libstdc++/config/allocator/pool_allocator_base.h @@ -0,0 +1,37 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _CXX_ALLOCATOR_H +#define _CXX_ALLOCATOR_H 1 + +// Define new_allocator as the base class to std::allocator. +#include <ext/pool_allocator.h> +#define ___glibcxx_base_allocator __gnu_cxx::__pool_alloc + +#endif diff --git a/contrib/libstdc++/config/cpu/alpha/atomicity.h b/contrib/libstdc++/config/cpu/alpha/atomicity.h index 895d87a..4eb311b 100644 --- a/contrib/libstdc++/config/cpu/alpha/atomicity.h +++ b/contrib/libstdc++/config/cpu/alpha/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: Alpha version -*- C++ -*- -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2003, 2004 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 @@ -27,23 +27,22 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> /* @@@ With gas we can play nice .subsection games to get the non-predicted branch pointing forward. But Digital assemblers don't understand those directives. This isn't a terribly important issue, so just ignore it. */ -typedef int _Atomic_word; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_cxx { - register int __result, __tmp; - - __asm__ __volatile__ ( + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + register int __result, __tmp; + + __asm__ __volatile__ ( "\n$Lxadd_%=:\n\t" "ldl_l %0,%3\n\t" "addl %0,%4,%1\n\t" @@ -53,16 +52,16 @@ __exchange_and_add (volatile _Atomic_word* __mem, int __val) : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem) : "m" (*__mem), "r"(__val)); - return __result; -} + return __result; + } -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) -{ - register _Atomic_word __result; + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + register _Atomic_word __result; - __asm__ __volatile__ ( + __asm__ __volatile__ ( "\n$Ladd_%=:\n\t" "ldl_l %0,%2\n\t" "addl %0,%3,%0\n\t" @@ -71,6 +70,6 @@ __atomic_add (volatile _Atomic_word* __mem, int __val) "mb" : "=&r"(__result), "=m"(*__mem) : "m" (*__mem), "r"(__val)); -} + } +} // namespace __gnu_cxx -#endif /* atomicity.h */ diff --git a/contrib/libstdc++/config/cpu/cris/atomic_word.h b/contrib/libstdc++/config/cpu/cris/atomic_word.h new file mode 100644 index 0000000..dd2cf6b --- /dev/null +++ b/contrib/libstdc++/config/cpu/cris/atomic_word.h @@ -0,0 +1,36 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +// This entity must not cross a page boundary. +typedef int _Atomic_word __attribute__ ((__aligned__ (4))); + +#endif diff --git a/contrib/libstdc++/config/cpu/cris/atomicity.h b/contrib/libstdc++/config/cpu/cris/atomicity.h index 55c374f..3162f6a 100644 --- a/contrib/libstdc++/config/cpu/cris/atomicity.h +++ b/contrib/libstdc++/config/cpu/cris/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: CRIS version -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003, 2004 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 @@ -27,21 +27,18 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> -// This entity must not cross a page boundary. -typedef int _Atomic_word __attribute__ ((__aligned__ (4))); - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (_Atomic_word* __mem, int __val) +namespace __gnu_cxx { - int __tmp; - _Atomic_word __result; + _Atomic_word + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + int __tmp; + _Atomic_word __result; #if (__CRIS_arch_version >= 10) - __asm__ __volatile__ (" clearf \n" + __asm__ __volatile__ (" clearf \n" "0: \n" " move.d %4,%2 \n" " move.d [%3],%0 \n" @@ -52,9 +49,11 @@ __exchange_and_add (_Atomic_word* __mem, int __val) " clearf \n" : "=&r" (__result), "=m" (*__mem), "=&r" (__tmp) : "r" (__mem), "g" (__val), "m" (*__mem) + /* The memory clobber must stay, regardless of + current uses of this function. */ : "memory"); #else - __asm__ __volatile__ (" move $ccr,$r9 \n" + __asm__ __volatile__ (" move $ccr,$r9 \n" " di \n" " move.d %4,%2 \n" " move.d [%3],%0 \n" @@ -63,17 +62,16 @@ __exchange_and_add (_Atomic_word* __mem, int __val) " move $r9,$ccr \n" : "=&r" (__result), "=m" (*__mem), "=&r" (__tmp) : "r" (__mem), "g" (__val), "m" (*__mem) - : "memory", "r9"); + : "r9", + /* The memory clobber must stay, regardless of + current uses of this function. */ + "memory"); #endif - return __result; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (_Atomic_word* __mem, int __val) -{ - __exchange_and_add (__mem, __val); -} + return __result; + } -#endif /* atomicity.h */ + void + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __exchange_and_add(__mem, __val); } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/generic/atomic_word.h b/contrib/libstdc++/config/cpu/generic/atomic_word.h new file mode 100644 index 0000000..b46adc2 --- /dev/null +++ b/contrib/libstdc++/config/cpu/generic/atomic_word.h @@ -0,0 +1,35 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +typedef int _Atomic_word; + +#endif diff --git a/contrib/libstdc++/config/cpu/generic/atomicity.h b/contrib/libstdc++/config/cpu/generic/atomicity.h index 829a77c..f30005a 100644 --- a/contrib/libstdc++/config/cpu/generic/atomicity.h +++ b/contrib/libstdc++/config/cpu/generic/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: Generic version -*- C++ -*- -// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 1999, 2001, 2002, 2003, 2004 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 @@ -27,51 +27,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> +#include <bits/concurrence.h> -#include <bits/gthr.h> - -#define _GLIBCPP_NEED_GENERIC_MUTEX - -typedef int _Atomic_word; - -namespace __gnu_cxx -{ - extern __gthread_mutex_t _Atomic_add_mutex; - -#ifndef __GTHREAD_MUTEX_INIT - extern __gthread_once_t _Atomic_add_mutex_once; - extern void __gthread_atomic_add_mutex_once(); -#endif -} - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_internal { -#ifndef __GTHREAD_MUTEX_INIT - __gthread_once (&__gnu_cxx::_Atomic_add_mutex_once, - __gnu_cxx::__gthread_atomic_add_mutex_once); -#endif + __glibcxx_mutex_define_initialized(atomic_mutex); +} // namespace __gnu_internal - _Atomic_word __result; - - __gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex); - - __result = *__mem; - *__mem += __val; - - __gthread_mutex_unlock (&__gnu_cxx::_Atomic_add_mutex); - return __result; -} - - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_cxx { - (void) __exchange_and_add (__mem, __val); -} - -#endif /* atomicity.h */ + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + __glibcxx_mutex_lock(__gnu_internal::atomic_mutex); + _Atomic_word __result; + __result = *__mem; + *__mem += __val; + __glibcxx_mutex_unlock(__gnu_internal::atomic_mutex); + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __exchange_and_add(__mem, __val); } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/hppa/atomicity.h b/contrib/libstdc++/config/cpu/hppa/atomicity.h index d99ac34..48c8283 100644 --- a/contrib/libstdc++/config/cpu/hppa/atomicity.h +++ b/contrib/libstdc++/config/cpu/hppa/atomicity.h @@ -1,90 +1,95 @@ -/* Low-level functions for atomic operations. PA-RISC version. -*- C++ -*- - Copyright 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. +// Low-level functions for atomic operations: PA-RISC version -*- C++ -*- - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. +// Copyright (C) 2002, 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. -typedef int _Atomic_word; +#include <bits/c++config.h> +#include <bits/atomicity.h> -template <int __inst> -struct __Atomicity_lock +namespace __gnu_cxx { - static volatile int _S_atomicity_lock; -}; + template<int _Inst> + struct _Atomicity_lock + { + static volatile int _S_atomicity_lock; + }; + + template<int _Inst> + volatile int + _Atomicity_lock<_Inst>::_S_atomicity_lock __attribute__ ((aligned (16))) = 1; -template <int __inst> -volatile int -__Atomicity_lock<__inst>::_S_atomicity_lock __attribute__ ((aligned (16))) = 1; + // Because of the lack of weak support when using the hpux som + // linker, we explicitly instantiate the atomicity lock. + template volatile int _Atomicity_lock<0>::_S_atomicity_lock; -/* Because of the lack of weak support when using the hpux - som linker, we explicitly instantiate the atomicity lock - in src/misc-inst.cc when _GLIBCPP_INST_ATOMICITY_LOCK - is defined. */ -#ifndef _GLIBCPP_INST_ATOMICITY_LOCK -template volatile int __Atomicity_lock<0>::_S_atomicity_lock; -#endif - -static inline int -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word* __mem, int __val) -{ - _Atomic_word result; - int tmp; - volatile int& lock = __Atomicity_lock<0>::_S_atomicity_lock; - - __asm__ __volatile__ ("ldcw 0(%1),%0\n\t" - "cmpib,<>,n 0,%0,.+20\n\t" - "ldw 0(%1),%0\n\t" - "cmpib,= 0,%0,.-4\n\t" - "nop\n\t" - "b,n .-20" - : "=&r" (tmp) - : "r" (&lock)); - - result = *__mem; - *__mem = result + __val; - /* Reset lock with PA 2.0 "ordered" store. */ - __asm__ __volatile__ ("stw,ma %1,0(%0)" - : : "r" (&lock), "r" (tmp) : "memory"); - return result; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (_Atomic_word* __mem, int __val) -{ - int tmp; - volatile int& lock = __Atomicity_lock<0>::_S_atomicity_lock; - - __asm__ __volatile__ ("ldcw 0(%1),%0\n\t" - "cmpib,<>,n 0,%0,.+20\n\t" - "ldw 0(%1),%0\n\t" - "cmpib,= 0,%0,.-4\n\t" - "nop\n\t" - "b,n .-20" - : "=&r" (tmp) - : "r" (&lock)); - - *__mem += __val; - /* Reset lock with PA 2.0 "ordered" store. */ - __asm__ __volatile__ ("stw,ma %1,0(%0)" - : : "r" (&lock), "r" (tmp) : "memory"); -} - -#endif + int + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word result; + int tmp; + volatile int& lock = _Atomicity_lock<0>::_S_atomicity_lock; + + __asm__ __volatile__ ("ldcw 0(%1),%0\n\t" + "cmpib,<>,n 0,%0,.+20\n\t" + "ldw 0(%1),%0\n\t" + "cmpib,= 0,%0,.-4\n\t" + "nop\n\t" + "b,n .-20" + : "=&r" (tmp) + : "r" (&lock)); + + result = *__mem; + *__mem = result + __val; + /* Reset lock with PA 2.0 "ordered" store. */ + __asm__ __volatile__ ("stw,ma %1,0(%0)" + : : "r" (&lock), "r" (tmp) : "memory"); + return result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + int tmp; + volatile int& lock = _Atomicity_lock<0>::_S_atomicity_lock; + + __asm__ __volatile__ ("ldcw 0(%1),%0\n\t" + "cmpib,<>,n 0,%0,.+20\n\t" + "ldw 0(%1),%0\n\t" + "cmpib,= 0,%0,.-4\n\t" + "nop\n\t" + "b,n .-20" + : "=&r" (tmp) + : "r" (&lock)); + + *__mem += __val; + /* Reset lock with PA 2.0 "ordered" store. */ + __asm__ __volatile__ ("stw,ma %1,0(%0)" + : : "r" (&lock), "r" (tmp) : "memory"); + } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/i386/atomicity.h b/contrib/libstdc++/config/cpu/i386/atomicity.h index d619dbb..92c03d5 100644 --- a/contrib/libstdc++/config/cpu/i386/atomicity.h +++ b/contrib/libstdc++/config/cpu/i386/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: x86, x >= 3 version -*- C++ -*- -// Copyright (C) 2003 Free Software Foundation, Inc. +// Copyright (C) 2003, 2004 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 @@ -27,49 +27,48 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> -typedef int _Atomic_word; - -template <int __inst> -struct __Atomicity_lock -{ - static volatile _Atomic_word _S_atomicity_lock; -}; - -template <int __inst> -volatile _Atomic_word __Atomicity_lock<__inst>::_S_atomicity_lock = 0; - -template volatile _Atomic_word __Atomicity_lock<0>::_S_atomicity_lock; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - register _Atomic_word __result, __tmp = 1; - - /* obtain the atomic exchange/add spin lock */ - do { - __asm__ __volatile__ ("xchg{l} {%0,%1|%1,%0}" - : "+m" (__Atomicity_lock<0>::_S_atomicity_lock), - "+r" (__tmp)); - } while (__tmp); - - __result = *__mem; - *__mem += __val; - - /* release spin lock */ - __Atomicity_lock<0>::_S_atomicity_lock = 0; - - return __result; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_cxx { - __exchange_and_add (__mem, __val); -} - -#endif /* atomicity.h */ + template<int __inst> + struct _Atomicity_lock + { + static volatile _Atomic_word _S_atomicity_lock; + }; + + template<int __inst> + volatile _Atomic_word _Atomicity_lock<__inst>::_S_atomicity_lock = 0; + + template volatile _Atomic_word _Atomicity_lock<0>::_S_atomicity_lock; + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + register _Atomic_word __result, __tmp = 1; + + // Obtain the atomic exchange/add spin lock. + do + { + __asm__ __volatile__ ("xchg{l} {%0,%1|%1,%0}" + : "=m" (_Atomicity_lock<0>::_S_atomicity_lock), + "+r" (__tmp) + : "m" (_Atomicity_lock<0>::_S_atomicity_lock)); + } + while (__tmp); + + __result = *__mem; + *__mem += __val; + + // Release spin lock. + _Atomicity_lock<0>::_S_atomicity_lock = 0; + + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __exchange_and_add(__mem, __val); } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/i486/atomicity.h b/contrib/libstdc++/config/cpu/i486/atomicity.h index 7c65fab..5700bf3 100644 --- a/contrib/libstdc++/config/cpu/i486/atomicity.h +++ b/contrib/libstdc++/config/cpu/i486/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: x86, x >= 4 version -*- C++ -*- -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2004 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 @@ -27,31 +27,27 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> -typedef int _Atomic_word; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - register _Atomic_word __result; - __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}" - : "=r" (__result), "+m" (*__mem) - : "0" (__val) - : "memory"); - return __result; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_cxx { - __asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}" - : "+m" (*__mem) : "ir" (__val) : "memory"); -} - -#endif /* atomicity.h */ - + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + register _Atomic_word __result; + __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}" + : "=r" (__result), "=m" (*__mem) + : "0" (__val), "m" (*__mem)); + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + __asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}" + : "=m" (*__mem) : "ir" (__val), "m" (*__mem)); + } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/ia64/atomicity.h b/contrib/libstdc++/config/cpu/ia64/atomicity.h index e28e149..0c3ab33 100644 --- a/contrib/libstdc++/config/cpu/ia64/atomicity.h +++ b/contrib/libstdc++/config/cpu/ia64/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: IA64 version -*- C++ -*- -// Copyright (C) 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2003, 2004 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 @@ -27,25 +27,18 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 - +#include <bits/atomicity.h> #include <ia64intrin.h> -typedef int _Atomic_word; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - return __sync_fetch_and_add (__mem, __val); -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_cxx { - __sync_fetch_and_add (__mem, __val); + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { return __sync_fetch_and_add(__mem, __val); } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __sync_fetch_and_add(__mem, __val); } } - -#endif /* atomicity.h */ diff --git a/contrib/libstdc++/config/cpu/m68k/atomicity.h b/contrib/libstdc++/config/cpu/m68k/atomicity.h index c80e2e3..0e58f3c 100644 --- a/contrib/libstdc++/config/cpu/m68k/atomicity.h +++ b/contrib/libstdc++/config/cpu/m68k/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: m68k version -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -27,111 +27,107 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 - -typedef int _Atomic_word; +#include <bits/atomicity.h> +namespace __gnu_cxx +{ #if ( defined(__mc68020__) || defined(__mc68030__) \ || defined(__mc68040__) || defined(__mc68060__) ) \ && !defined(__mcpu32__) -// These variants support compare-and-swap. - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - register _Atomic_word __result = *__mem; - register _Atomic_word __temp; - __asm__ __volatile__ ("1: move%.l %0,%1\n\t" - "add%.l %2,%1\n\t" - "cas%.l %0,%1,%3\n\t" - "jne 1b" - : "=d" (__result), "=&d" (__temp) - : "d" (__val), "m" (*__mem), "0" (__result) - : "memory"); - return __result; -} + // These variants support compare-and-swap. + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + register _Atomic_word __result = *__mem; + register _Atomic_word __temp; + __asm__ __volatile__ ("1: move%.l %0,%1\n\t" + "add%.l %3,%1\n\t" + "cas%.l %0,%1,%2\n\t" + "jne 1b" + : "=d" (__result), "=&d" (__temp), "=m" (*__mem) + : "d" (__val), "0" (__result), "m" (*__mem)); + return __result; + } #elif defined(__rtems__) - /* - * TAS/JBNE is unsafe on systems with strict priority-based scheduling. - * Disable interrupts, which we can do only from supervisor mode. - */ -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - _Atomic_word __result; - short __level, __tmpsr; - __asm__ __volatile__ ("move%.w %%sr,%0\n\tor%.l %0,%1\n\tmove%.w %1,%%sr" - : "=d"(__level), "=d"(__tmpsr) : "1"(0x700)); - - __result = *__mem; - *__mem = __result + __val; - - __asm__ __volatile__ ("move%.w %0,%%sr" : : "d"(__level)); - - return __result; -} + // TAS/JBNE is unsafe on systems with strict priority-based scheduling. + // Disable interrupts, which we can do only from supervisor mode. + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __result; + short __level, __tmpsr; + __asm__ __volatile__ ("move%.w %%sr,%0\n\tor%.l %0,%1\n\tmove%.w %1,%%sr" + : "=d"(__level), "=d"(__tmpsr) : "1"(0x700)); + + __result = *__mem; + *__mem = __result + __val; + __asm__ __volatile__ ("move%.w %0,%%sr" : : "d"(__level)); + + return __result; + } #else - -template <int __inst> -struct __Atomicity_lock -{ - static volatile unsigned char _S_atomicity_lock; -}; - -template <int __inst> -volatile unsigned char __Atomicity_lock<__inst>::_S_atomicity_lock = 0; - -template volatile unsigned char __Atomicity_lock<0>::_S_atomicity_lock; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - _Atomic_word __result; - -// bset with no immediate addressing -#if defined(__mcf5200__) || defined(__mcf5300__) || defined(__mcf5400__) - __asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b" - : /* no outputs */ - : "a"(&__Atomicity_lock<0>::_S_atomicity_lock) - : "cc", "memory"); - -// bset with immediate addressing -#elif defined(__mc68000__) - __asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b" - : "+m"(__Atomicity_lock<0>::_S_atomicity_lock) - : /* none */ - : "cc"); - -#else // 680x0, cpu32, 5400 support test-and-set. - __asm__ __volatile__("1: tas %0\n\tjbne 1b" - : "+m"(__Atomicity_lock<0>::_S_atomicity_lock) - : /* none */ - : "cc"); + + template<int __inst> + struct _Atomicity_lock + { + static volatile unsigned char _S_atomicity_lock; + }; + + template<int __inst> + volatile unsigned char _Atomicity_lock<__inst>::_S_atomicity_lock = 0; + + template volatile unsigned char _Atomicity_lock<0>::_S_atomicity_lock; + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __result; + + // bset with no immediate addressing (not SMP-safe) +#if defined(__mcf5200__) || defined(__mcf5300__) + __asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b" + : /* no outputs */ + : "a"(&_Atomicity_lock<0>::_S_atomicity_lock) + : "cc", "memory"); + + // CPU32 and MCF5400 support test-and-set (SMP-safe). +#elif defined(__mcpu32__) || defined(__mcf5400__) + __asm__ __volatile__("1: tas %0\n\tjbne 1b" + : "+m"(_Atomicity_lock<0>::_S_atomicity_lock) + : /* none */ + : "cc"); + + // Use bset with immediate addressing for 68000/68010 (not SMP-safe) + // NOTE: TAS is available on the 68000, but unsupported by some Amiga + // memory controllers. +#else + __asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b" + : "+m"(_Atomicity_lock<0>::_S_atomicity_lock) + : /* none */ + : "cc"); #endif - - __result = *__mem; - *__mem = __result + __val; - - __Atomicity_lock<0>::_S_atomicity_lock = 0; - - return __result; -} - + + __result = *__mem; + *__mem = __result + __val; + + _Atomicity_lock<0>::_S_atomicity_lock = 0; + + return __result; + } + #endif /* TAS / BSET */ -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) -{ - // Careful: using add.l with a memory destination is not - // architecturally guaranteed to be atomic. - (void) __exchange_and_add (__mem, __val); -} - -#endif /* _BITS_ATOMICITY_H */ + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + // Careful: using add.l with a memory destination is not + // architecturally guaranteed to be atomic. + __exchange_and_add(__mem, __val); + } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/mips/atomicity.h b/contrib/libstdc++/config/cpu/mips/atomicity.h index 7bacabd..0871342 100644 --- a/contrib/libstdc++/config/cpu/mips/atomicity.h +++ b/contrib/libstdc++/config/cpu/mips/atomicity.h @@ -1,6 +1,6 @@ -// Low-level functions for atomic operations. +// Low-level functions for atomic operations: MIPS version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -27,55 +27,55 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> -typedef int _Atomic_word; - -static inline int -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) +namespace __gnu_cxx { - int __result, __tmp; - - __asm__ __volatile__ - ("/* Inline exchange & add */\n\t" - "1:\n\t" - ".set push\n\t" - ".set mips2\n\t" - "ll %0,%3\n\t" - "addu %1,%4,%0\n\t" - "sc %1,%2\n\t" - ".set pop\n\t" - "beqz %1,1b\n\t" - "/* End exchange & add */" - : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem) - : "m" (*__mem), "r"(__val) - : "memory"); - - return __result; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word *__mem, int __val) -{ - int __result; - - __asm__ __volatile__ - ("/* Inline atomic add */\n\t" - "1:\n\t" - ".set push\n\t" - ".set mips2\n\t" - "ll %0,%2\n\t" - "addu %0,%3,%0\n\t" - "sc %0,%1\n\t" - ".set pop\n\t" - "beqz %0,1b\n\t" - "/* End atomic add */" - : "=&r"(__result), "=m"(*__mem) - : "m" (*__mem), "r"(__val) - : "memory"); -} - -#endif /* atomicity.h */ + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __result, __tmp; + + __asm__ __volatile__ + ("/* Inline exchange & add */\n\t" + "1:\n\t" + ".set push\n\t" +#if _MIPS_SIM == _ABIO32 + ".set mips2\n\t" +#endif + "ll %0,%3\n\t" + "addu %1,%4,%0\n\t" + "sc %1,%2\n\t" + ".set pop\n\t" + "beqz %1,1b\n\t" + "/* End exchange & add */" + : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem) + : "m" (*__mem), "r"(__val)); + + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __result; + + __asm__ __volatile__ + ("/* Inline atomic add */\n\t" + "1:\n\t" + ".set push\n\t" +#if _MIPS_SIM == _ABIO32 + ".set mips2\n\t" +#endif + "ll %0,%2\n\t" + "addu %0,%3,%0\n\t" + "sc %0,%1\n\t" + ".set pop\n\t" + "beqz %0,1b\n\t" + "/* End atomic add */" + : "=&r"(__result), "=m"(*__mem) + : "m" (*__mem), "r"(__val)); + } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/powerpc/atomicity.h b/contrib/libstdc++/config/cpu/powerpc/atomicity.h index b5370fc..7314944 100644 --- a/contrib/libstdc++/config/cpu/powerpc/atomicity.h +++ b/contrib/libstdc++/config/cpu/powerpc/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: PowerPC version -*- C++ -*- -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2003, 2004 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 @@ -27,8 +27,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> #ifdef __PPC405__ #define _STWCX "sync \n\tstwcx. " @@ -36,43 +35,42 @@ #define _STWCX "stwcx. " #endif -typedef int _Atomic_word; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word* __mem, int __val) -{ - _Atomic_word __tmp, __res; - __asm__ __volatile__ ( - "/* Inline exchange & add */\n" - "0:\t" - "lwarx %0,0,%2 \n\t" - "add%I3 %1,%0,%3 \n\t" - _STWCX " %1,0,%2 \n\t" - "bne- 0b \n\t" - "/* End exchange & add */" - : "=&b"(__res), "=&r"(__tmp) - : "r" (__mem), "Ir"(__val) - : "cr0", "memory"); - return __res; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word *__mem, int __val) +namespace __gnu_cxx { - _Atomic_word __tmp; - __asm__ __volatile__ ( - "/* Inline atomic add */\n" - "0:\t" - "lwarx %0,0,%1 \n\t" - "add%I2 %0,%0,%2 \n\t" - _STWCX " %0,0,%1 \n\t" - "bne- 0b \n\t" - "/* End atomic add */" - : "=&b"(__tmp) - : "r" (__mem), "Ir"(__val) - : "cr0", "memory"); -} - -#endif /* atomicity.h */ + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __tmp, __res; + __asm__ __volatile__ ( + "/* Inline exchange & add */\n" + "0:\t" + "lwarx %0,0,%3 \n\t" + "add%I4 %1,%0,%4 \n\t" + _STWCX " %1,0,%3 \n\t" + "bne- 0b \n\t" + "/* End exchange & add */" + : "=&b"(__res), "=&r"(__tmp), "=m" (*__mem) + : "r" (__mem), "Ir"(__val), "m" (*__mem) + : "cr0"); + return __res; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __tmp; + __asm__ __volatile__ ( + "/* Inline atomic add */\n" + "0:\t" + "lwarx %0,0,%2 \n\t" + "add%I3 %0,%0,%3 \n\t" + _STWCX " %0,0,%2 \n\t" + "bne- 0b \n\t" + "/* End atomic add */" + : "=&b"(__tmp), "=m" (*__mem) + : "r" (__mem), "Ir"(__val), "m" (*__mem) + : "cr0"); + } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/s390/atomicity.h b/contrib/libstdc++/config/cpu/s390/atomicity.h index 331c29a..b979e3a 100644 --- a/contrib/libstdc++/config/cpu/s390/atomicity.h +++ b/contrib/libstdc++/config/cpu/s390/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: S/390 version -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003, 2004 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 @@ -27,34 +27,28 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> -typedef int _Atomic_word; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - register _Atomic_word __old_val, __new_val; - - __asm__ __volatile__ (" l %0,0(%2)\n" - "0: lr %1,%0\n" - " ar %1,%3\n" - " cs %0,%1,0(%2)\n" - " jl 0b" - : "=&d" (__old_val), "=&d" (__new_val) - : "a" (__mem), "d" (__val) : "cc", "memory" ); - return __old_val; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word *__mem, int __val) +namespace __gnu_cxx { - __exchange_and_add (__mem, __val); -} - -#endif /* atomicity.h */ - - + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + register _Atomic_word __old_val, __new_val; + + __asm__ __volatile__ (" l %0,0(%3)\n" + "0: lr %1,%0\n" + " ar %1,%4\n" + " cs %0,%1,0(%3)\n" + " jl 0b" + : "=&d" (__old_val), "=&d" (__new_val), "=m" (*__mem) + : "a" (__mem), "d" (__val), "m" (*__mem) : "cc"); + return __old_val; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __exchange_and_add(__mem, __val); } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/cpu/sparc/atomic_word.h b/contrib/libstdc++/config/cpu/sparc/atomic_word.h new file mode 100644 index 0000000..941fddd --- /dev/null +++ b/contrib/libstdc++/config/cpu/sparc/atomic_word.h @@ -0,0 +1,39 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +#ifdef __arch64__ + typedef long _Atomic_word; +#else + typedef int _Atomic_word; +#endif + +#endif diff --git a/contrib/libstdc++/config/cpu/sparc/atomicity.h b/contrib/libstdc++/config/cpu/sparc/atomicity.h index 23804db..a39153b 100644 --- a/contrib/libstdc++/config/cpu/sparc/atomicity.h +++ b/contrib/libstdc++/config/cpu/sparc/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: Sparc version -*- C++ -*- -// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2002, 2004 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 @@ -27,105 +27,99 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> -#ifdef __arch64__ - -typedef long _Atomic_word; - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - _Atomic_word __tmp1, __tmp2; - - __asm__ __volatile__("1: ldx [%2], %0\n\t" - " add %0, %3, %1\n\t" - " casx [%2], %0, %1\n\t" - " sub %0, %1, %0\n\t" - " brnz,pn %0, 1b\n\t" - " nop" - : "=&r" (__tmp1), "=&r" (__tmp2) - : "r" (__mem), "r" (__val) - : "memory"); - return __tmp2; -} - -static inline void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) +namespace __gnu_cxx { - _Atomic_word __tmp1, __tmp2; - - __asm__ __volatile__("1: ldx [%2], %0\n\t" - " add %0, %3, %1\n\t" - " casx [%2], %0, %1\n\t" - " sub %0, %1, %0\n\t" - " brnz,pn %0, 1b\n\t" - " nop" - : "=&r" (__tmp1), "=&r" (__tmp2) - : "r" (__mem), "r" (__val) - : "memory"); -} - +#ifdef __arch64__ + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __tmp1, __tmp2; + _Atomic_word __val_extended = __val; + + __asm__ __volatile__("1: ldx [%3], %0\n\t" + " add %0, %4, %1\n\t" + " casx [%3], %0, %1\n\t" + " sub %0, %1, %0\n\t" + " brnz,pn %0, 1b\n\t" + " nop" + : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem) + : "r" (__mem), "r" (__val_extended), "m" (*__mem)); + return __tmp2; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __tmp1, __tmp2; + _Atomic_word __val_extended = __val; + + __asm__ __volatile__("1: ldx [%3], %0\n\t" + " add %0, %4, %1\n\t" + " casx [%3], %0, %1\n\t" + " sub %0, %1, %0\n\t" + " brnz,pn %0, 1b\n\t" + " nop" + : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem) + : "r" (__mem), "r" (__val_extended), "m" (*__mem)); + } + #else /* __arch32__ */ -typedef int _Atomic_word; - -template <int __inst> -struct __Atomicity_lock -{ - static unsigned char _S_atomicity_lock; -}; - -template <int __inst> -unsigned char __Atomicity_lock<__inst>::_S_atomicity_lock = 0; - -template unsigned char __Atomicity_lock<0>::_S_atomicity_lock; - -static int -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word* __mem, int __val) -{ - _Atomic_word __result, __tmp; - - __asm__ __volatile__("1: ldstub [%1], %0\n\t" - " cmp %0, 0\n\t" - " bne 1b\n\t" - " nop" - : "=&r" (__tmp) - : "r" (&__Atomicity_lock<0>::_S_atomicity_lock) - : "memory"); - __result = *__mem; - *__mem += __val; - __asm__ __volatile__("stb %%g0, [%0]" - : /* no outputs */ - : "r" (&__Atomicity_lock<0>::_S_atomicity_lock) - : "memory"); - return __result; -} - -static void -__attribute__ ((__unused__)) -__atomic_add (volatile _Atomic_word* __mem, int __val) -{ - _Atomic_word __tmp; - - __asm__ __volatile__("1: ldstub [%1], %0\n\t" - " cmp %0, 0\n\t" - " bne 1b\n\t" - " nop" - : "=&r" (__tmp) - : "r" (&__Atomicity_lock<0>::_S_atomicity_lock) - : "memory"); - *__mem += __val; - __asm__ __volatile__("stb %%g0, [%0]" - : /* no outputs */ - : "r" (&__Atomicity_lock<0>::_S_atomicity_lock) - : "memory"); -} - + template<int __inst> + struct _Atomicity_lock + { + static unsigned char _S_atomicity_lock; + }; + + template<int __inst> + unsigned char _Atomicity_lock<__inst>::_S_atomicity_lock = 0; + + template unsigned char _Atomicity_lock<0>::_S_atomicity_lock; + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __result, __tmp; + + __asm__ __volatile__("1: ldstub [%1], %0\n\t" + " cmp %0, 0\n\t" + " bne 1b\n\t" + " nop" + : "=&r" (__tmp) + : "r" (&_Atomicity_lock<0>::_S_atomicity_lock) + : "memory"); + __result = *__mem; + *__mem += __val; + __asm__ __volatile__("stb %%g0, [%0]" + : /* no outputs */ + : "r" (&_Atomicity_lock<0>::_S_atomicity_lock) + : "memory"); + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) + { + _Atomic_word __tmp; + + __asm__ __volatile__("1: ldstub [%1], %0\n\t" + " cmp %0, 0\n\t" + " bne 1b\n\t" + " nop" + : "=&r" (__tmp) + : "r" (&_Atomicity_lock<0>::_S_atomicity_lock) + : "memory"); + *__mem += __val; + __asm__ __volatile__("stb %%g0, [%0]" + : /* no outputs */ + : "r" (&_Atomicity_lock<0>::_S_atomicity_lock) + : "memory"); + } #endif /* __arch32__ */ - -#endif /* atomicity.h */ +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/io/basic_file_stdio.cc b/contrib/libstdc++/config/io/basic_file_stdio.cc index 5393a14..a3ed839 100644 --- a/contrib/libstdc++/config/io/basic_file_stdio.cc +++ b/contrib/libstdc++/config/io/basic_file_stdio.cc @@ -1,6 +1,6 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004 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 @@ -33,87 +33,156 @@ #include <bits/basic_file.h> #include <fcntl.h> +#include <errno.h> + +#ifdef _GLIBCXX_HAVE_POLL +#include <poll.h> +#endif + +// Pick up ioctl on Solaris 2.8 +#ifdef _GLIBCXX_HAVE_UNISTD_H #include <unistd.h> +#endif -#ifdef _GLIBCPP_HAVE_SYS_IOCTL_H -#define BSD_COMP /* Get FIONREAD on Solaris2. */ +// Pick up FIONREAD on Solaris 2 +#ifdef _GLIBCXX_HAVE_SYS_IOCTL_H +#define BSD_COMP #include <sys/ioctl.h> #endif // Pick up FIONREAD on Solaris 2.5. -#ifdef _GLIBCPP_HAVE_SYS_FILIO_H +#ifdef _GLIBCXX_HAVE_SYS_FILIO_H #include <sys/filio.h> #endif -#ifdef _GLIBCPP_HAVE_POLL -#include <poll.h> +#ifdef _GLIBCXX_HAVE_SYS_UIO_H +#include <sys/uio.h> #endif -#if defined(_GLIBCPP_HAVE_S_ISREG) || defined(_GLIBCPP_HAVE_S_IFREG) +#if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) # include <sys/stat.h> -# ifdef _GLIBCPP_HAVE_S_ISREG -# define _GLIBCPP_ISREG(x) S_ISREG(x) +# ifdef _GLIBCXX_HAVE_S_ISREG +# define _GLIBCXX_ISREG(x) S_ISREG(x) # else -# define _GLIBCPP_ISREG(x) (((x) & S_IFMT) == S_IFREG) +# define _GLIBCXX_ISREG(x) (((x) & S_IFMT) == S_IFREG) # endif #endif -namespace std -{ - // Definitions for __basic_file<char>. - __basic_file<char>::__basic_file(__c_lock* /*__lock*/) - : _M_cfile(NULL), _M_cfile_created(false) { } +#include <limits> // For <off_t>::max() and min() - __basic_file<char>::~__basic_file() - { this->close(); } - - void - __basic_file<char>::_M_open_mode(ios_base::openmode __mode, int& __p_mode, - int&, char* __c_mode) - { - bool __testb = __mode & ios_base::binary; - bool __testi = __mode & ios_base::in; - bool __testo = __mode & ios_base::out; - bool __testt = __mode & ios_base::trunc; - bool __testa = __mode & ios_base::app; - - // Set __c_mode for use in fopen. - // Set __p_mode for use in open. - if (!__testi && __testo && !__testt && !__testa) - { - strcpy(__c_mode, "w"); - __p_mode = (O_WRONLY | O_CREAT); - } - if (!__testi && __testo && !__testt && __testa) +namespace __gnu_internal +{ + // Map ios_base::openmode flags to a string for use in fopen(). + // Table of valid combinations as given in [lib.filebuf.members]/2. + static const char* + fopen_mode(std::ios_base::openmode mode) + { + enum { - strcpy(__c_mode, "a"); - __p_mode |= O_WRONLY | O_CREAT | O_APPEND; - } - if (!__testi && __testo && __testt && !__testa) + in = std::ios_base::in, + out = std::ios_base::out, + trunc = std::ios_base::trunc, + app = std::ios_base::app, + binary = std::ios_base::binary + }; + + switch (mode & (in|out|trunc|app|binary)) { - strcpy(__c_mode, "w"); - __p_mode |= O_WRONLY | O_CREAT | O_TRUNC; + case ( out ): return "w"; + case ( out |app ): return "a"; + case ( out|trunc ): return "w"; + case (in ): return "r"; + case (in|out ): return "r+"; + case (in|out|trunc ): return "w+"; + + case ( out |binary): return "wb"; + case ( out |app|binary): return "ab"; + case ( out|trunc |binary): return "wb"; + case (in |binary): return "rb"; + case (in|out |binary): return "r+b"; + case (in|out|trunc |binary): return "w+b"; + + default: return 0; // invalid } + } - if (__testi && !__testo && !__testt && !__testa) - { - strcpy(__c_mode, "r"); - __p_mode |= O_RDONLY; - } - if (__testi && __testo && !__testt && !__testa) + // Wrapper handling partial write. + static std::streamsize + xwrite(int __fd, const char* __s, std::streamsize __n) + { + std::streamsize __nleft = __n; + + for (;;) { - strcpy(__c_mode, "r+"); - __p_mode |= O_RDWR | O_CREAT; + const std::streamsize __ret = write(__fd, __s, __nleft); + if (__ret == -1L && errno == EINTR) + continue; + if (__ret == -1L) + break; + + __nleft -= __ret; + if (__nleft == 0) + break; + + __s += __ret; } - if (__testi && __testo && __testt && !__testa) + + return __n - __nleft; + } + +#ifdef _GLIBCXX_HAVE_WRITEV + // Wrapper handling partial writev. + static std::streamsize + xwritev(int __fd, const char* __s1, std::streamsize __n1, + const char* __s2, std::streamsize __n2) + { + std::streamsize __nleft = __n1 + __n2; + std::streamsize __n1_left = __n1; + + struct iovec __iov[2]; + __iov[1].iov_base = const_cast<char*>(__s2); + __iov[1].iov_len = __n2; + + for (;;) { - strcpy(__c_mode, "w+"); - __p_mode |= O_RDWR | O_CREAT | O_TRUNC; + __iov[0].iov_base = const_cast<char*>(__s1); + __iov[0].iov_len = __n1_left; + + const std::streamsize __ret = writev(__fd, __iov, 2); + if (__ret == -1L && errno == EINTR) + continue; + if (__ret == -1L) + break; + + __nleft -= __ret; + if (__nleft == 0) + break; + + const std::streamsize __off = __ret - __n1_left; + if (__off >= 0) + { + __nleft -= xwrite(__fd, __s2 + __off, __n2 - __off); + break; + } + + __s1 += __ret; + __n1_left -= __ret; } - if (__testb) - strcat(__c_mode, "b"); + + return __n1 + __n2 - __nleft; } - +#endif +} // namespace __gnu_internal + +namespace std +{ + // Definitions for __basic_file<char>. + __basic_file<char>::__basic_file(__c_lock* /*__lock*/) + : _M_cfile(NULL), _M_cfile_created(false) { } + + __basic_file<char>::~__basic_file() + { this->close(); } + __basic_file<char>* __basic_file<char>::sys_open(__c_file* __file, ios_base::openmode) { @@ -122,56 +191,41 @@ namespace std { _M_cfile = __file; _M_cfile_created = false; + this->sync(); __ret = this; } return __ret; } __basic_file<char>* - __basic_file<char>::sys_open(int __fd, ios_base::openmode __mode, - bool __del) + __basic_file<char>::sys_open(int __fd, ios_base::openmode __mode) { __basic_file* __ret = NULL; - int __p_mode = 0; - int __rw_mode = 0; - char __c_mode[4]; - - _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode); - if (!this->is_open() && (_M_cfile = fdopen(__fd, __c_mode))) + const char* __c_mode = __gnu_internal::fopen_mode(__mode); + if (__c_mode && !this->is_open() && (_M_cfile = fdopen(__fd, __c_mode))) { - // Iff __del is true, then close will fclose the fd. - _M_cfile_created = __del; - + char* __buf = NULL; + _M_cfile_created = true; if (__fd == 0) - setvbuf(_M_cfile, reinterpret_cast<char*>(NULL), _IONBF, 0); - + setvbuf(_M_cfile, __buf, _IONBF, 0); __ret = this; } return __ret; } - - int - __basic_file<char>::sys_getc() - { return getc(_M_cfile); } - - int - __basic_file<char>::sys_ungetc(int __c) - { return ungetc(__c, _M_cfile); } __basic_file<char>* __basic_file<char>::open(const char* __name, ios_base::openmode __mode, int /*__prot*/) { __basic_file* __ret = NULL; - int __p_mode = 0; - int __rw_mode = 0; - char __c_mode[4]; - - _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode); - - if (!this->is_open()) + const char* __c_mode = __gnu_internal::fopen_mode(__mode); + if (__c_mode && !this->is_open()) { +#ifdef _GLIBCXX_USE_LFS + if ((_M_cfile = fopen64(__name, __c_mode))) +#else if ((_M_cfile = fopen(__name, __c_mode))) +#endif { _M_cfile_created = true; __ret = this; @@ -186,69 +240,92 @@ namespace std int __basic_file<char>::fd() - { return fileno(_M_cfile) ; } + { return fileno(_M_cfile); } + + __c_file* + __basic_file<char>::file() + { return _M_cfile; } __basic_file<char>* __basic_file<char>::close() { - __basic_file* __retval = static_cast<__basic_file*>(NULL); + __basic_file* __ret = static_cast<__basic_file*>(NULL); if (this->is_open()) { if (_M_cfile_created) fclose(_M_cfile); else - fflush(_M_cfile); + this->sync(); _M_cfile = 0; - __retval = this; + __ret = this; } - return __retval; + return __ret; } streamsize __basic_file<char>::xsgetn(char* __s, streamsize __n) - { return fread(__s, 1, __n, _M_cfile); } - + { + streamsize __ret; + do + __ret = read(this->fd(), __s, __n); + while (__ret == -1L && errno == EINTR); + return __ret; + } + streamsize __basic_file<char>::xsputn(const char* __s, streamsize __n) - { return fwrite(__s, 1, __n, _M_cfile); } - - streamoff - __basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way, - ios_base::openmode /*__mode*/) - { - if (!fseek(_M_cfile, __off, __way)) - return ftell(_M_cfile); - else - // Fseek failed. - return -1L; + { return __gnu_internal::xwrite(this->fd(), __s, __n); } + + streamsize + __basic_file<char>::xsputn_2(const char* __s1, streamsize __n1, + const char* __s2, streamsize __n2) + { + streamsize __ret = 0; +#ifdef _GLIBCXX_HAVE_WRITEV + __ret = __gnu_internal::xwritev(this->fd(), __s1, __n1, __s2, __n2); +#else + if (__n1) + __ret = __gnu_internal::xwrite(this->fd(), __s1, __n1); + + if (__ret == __n1) + __ret += __gnu_internal::xwrite(this->fd(), __s2, __n2); +#endif + return __ret; } streamoff - __basic_file<char>::seekpos(streamoff __pos, ios_base::openmode /*__mode*/) - { - if (!fseek(_M_cfile, __pos, ios_base::beg)) - return ftell(_M_cfile); - else - // Fseek failed. + __basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way) + { +#ifdef _GLIBCXX_USE_LFS + return lseek64(this->fd(), __off, __way); +#else + if (__off > std::numeric_limits<off_t>::max() + || __off < std::numeric_limits<off_t>::min()) return -1L; + return lseek(this->fd(), __off, __way); +#endif } - + int __basic_file<char>::sync() { return fflush(_M_cfile); } streamsize - __basic_file<char>::showmanyc_helper() + __basic_file<char>::showmanyc() { #ifdef FIONREAD // Pipes and sockets. +#ifdef _GLIBCXX_FIONREAD_TAKES_OFF_T + off_t __num = 0; +#else int __num = 0; +#endif int __r = ioctl(this->fd(), FIONREAD, &__num); if (!__r && __num >= 0) return __num; #endif -#ifdef _GLIBCPP_HAVE_POLL +#ifdef _GLIBCXX_HAVE_POLL // Cheap test. struct pollfd __pfd[1]; __pfd[0].fd = this->fd(); @@ -257,12 +334,12 @@ namespace std return 0; #endif -#if defined(_GLIBCPP_HAVE_S_ISREG) || defined(_GLIBCPP_HAVE_S_IFREG) +#if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) // Regular files. struct stat __buffer; int __ret = fstat(this->fd(), &__buffer); - if (!__ret && _GLIBCPP_ISREG(__buffer.st_mode)) - return __buffer.st_size - ftell(_M_cfile); + if (!__ret && _GLIBCXX_ISREG(__buffer.st_mode)) + return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur); #endif return 0; } diff --git a/contrib/libstdc++/config/io/basic_file_stdio.h b/contrib/libstdc++/config/io/basic_file_stdio.h index cefd38f..6aa031b 100644 --- a/contrib/libstdc++/config/io/basic_file_stdio.h +++ b/contrib/libstdc++/config/io/basic_file_stdio.h @@ -1,6 +1,6 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004 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 @@ -36,8 +36,8 @@ * You should not attempt to use it directly. */ -#ifndef _CPP_BASIC_FILE -#define _CPP_BASIC_FILE 1 +#ifndef _BASIC_FILE_STDIO_H +#define _BASIC_FILE_STDIO_H 1 #pragma GCC system_header @@ -56,16 +56,13 @@ namespace std { // Underlying data source/sink. __c_file* _M_cfile; + // True iff we opened _M_cfile, and thus must close it ourselves. bool _M_cfile_created; public: __basic_file(__c_lock* __lock = 0); - - void - _M_open_mode(ios_base::openmode __mode, int& __p_mode, int& __rw_mode, - char* __c_mode); - + __basic_file* open(const char* __name, ios_base::openmode __mode, int __prot = 0664); @@ -73,13 +70,7 @@ namespace std sys_open(__c_file* __file, ios_base::openmode); __basic_file* - sys_open(int __fd, ios_base::openmode __mode, bool __del); - - int - sys_getc(); - - int - sys_ungetc(int); + sys_open(int __fd, ios_base::openmode __mode); __basic_file* close(); @@ -90,28 +81,30 @@ namespace std int fd(); + __c_file* + file(); + ~__basic_file(); streamsize xsputn(const char* __s, streamsize __n); streamsize - xsgetn(char* __s, streamsize __n); + xsputn_2(const char* __s1, streamsize __n1, + const char* __s2, streamsize __n2); - streamoff - seekoff(streamoff __off, ios_base::seekdir __way, - ios_base::openmode __mode = ios_base::in | ios_base::out); + streamsize + xsgetn(char* __s, streamsize __n); streamoff - seekpos(streamoff __pos, - ios_base::openmode __mode = ios_base::in | ios_base::out); + seekoff(streamoff __off, ios_base::seekdir __way); int sync(); streamsize - showmanyc_helper(); + showmanyc(); }; } // namespace std -#endif // _CPP_BASIC_FILE +#endif diff --git a/contrib/libstdc++/config/io/c_io_stdio.h b/contrib/libstdc++/config/io/c_io_stdio.h index 0d11d14..c9ae432 100644 --- a/contrib/libstdc++/config/io/c_io_stdio.h +++ b/contrib/libstdc++/config/io/c_io_stdio.h @@ -1,6 +1,6 @@ // underlying io library -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003 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 @@ -29,8 +29,8 @@ // c_io_stdio.h - Defines for using "C" stdio.h -#ifndef _CPP_IO_STDIO_H -#define _CPP_IO_STDIO_H 1 +#ifndef _C_IO_STDIO_H +#define _C_IO_STDIO_H 1 #include <cstdio> #include <cstddef> @@ -38,20 +38,12 @@ namespace std { -// for fpos.h - typedef long streamoff; - typedef ptrdiff_t streamsize; // Signed integral type -#if _GLIBCPP_USE_WCHAR_T - typedef ptrdiff_t wstreamsize; -#endif - typedef fpos_t __c_streampos; - typedef __gthread_mutex_t __c_lock; -// for basic_file.h + // for basic_file.h typedef FILE __c_file; -// for ios_base.h + // for ios_base.h struct __ios_flags { typedef short __int_type; @@ -90,4 +82,4 @@ namespace std }; } -#endif // _CPP_IO_STDIO_H +#endif diff --git a/contrib/libstdc++/config/linker-map.gnu b/contrib/libstdc++/config/linker-map.gnu index 301867f..02fb094 100644 --- a/contrib/libstdc++/config/linker-map.gnu +++ b/contrib/libstdc++/config/linker-map.gnu @@ -1,6 +1,6 @@ -## Linker script for GNU ld 2.11.94+ only. +## Linker script for GNU ld 2.13.91+ only. ## -## Copyright (C) 2002, 2003 Free Software Foundation, Inc. +## Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. ## ## This file is part of the libstdc++ version 3 distribution. ## @@ -20,384 +20,253 @@ ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, ## USA. -GLIBCPP_3.2 { +GLIBCXX_3.4 { global: # Names inside the 'extern' block are demangled names. - # All but the last are terminated with a semicolon. extern "C++" { - std::[A-Za]*; - std::ba[a-r]*; - std::basic_[a-h]*; - std::basic_ifstream*; - std::basic_istringstream*; - std::basic_istream*; - std::basic_iostream*; - std::basic_[j-r]*; - std::basic_streambuf*; - std::basic_stringbuf*; - std::basic_stringstream*; - std::basic_[t-z]*; - std::ba[t-z]*; - std::b[b-z]*; - std::c[a-n]*; - std::co[a-c]*; - std::codecvt_byname*; - std::codecvt::[A-Za-b]*; - std::codecvt::[A-Zd-z]*; - std::codecvt_c; - std::codecvt_w; - std::co[e-z]*; - std::c[p-z]*; - std::c_[a-z]*; - std::[A-Zd-k]*; + std::[A-Za-h]*; + std::i[a-n]*; + std::ios_base::[A-Ha-z]*; + std::ios_base::_M_grow_words*; + std::ios_base::_M_init*; + std::ios_base::Init::[A-Za-z]*; + std::ios_base::[J-Za-z]*; + std::i[p-z]*; + std::[A-Zj-k]*; std::length_error*; std::logic_error*; std::locale::[A-Za-e]*; std::locale::facet::[A-Za-z]*; - std::locale::facet::_M*; - std::locale::facet::_S_c_locale; + std::locale::facet::_S_get_c_locale*; std::locale::facet::_S_clone_c_locale*; std::locale::facet::_S_create_c_locale*; std::locale::facet::_S_destroy_c_locale*; - std::locale::[A-Zg-z]*; - std::locale::_[A-Ra-z]*; - std::locale::_S_classic; - std::locale::_S_global; - std::locale::_S_num_categories; + std::locale::[A-Zg-h]*; + std::locale::id::[A-Za-z]*; + std::locale::id::_M_id*; + std::locale::[A-Zj-z]*; + std::locale::_[A-Ha-z]*; + std::locale::_Impl::[A-Za-z]*; + std::locale::_Impl::_M_[A-Za-z]*; + std::locale::_[J-Ra-z]*; std::locale::_S_normalize_category*; std::locale::_[T-Za-z]*; - std::[A-Zm]*; - std::n[a-t]*; - std::num_put_[cw]; - std::numeric*; - std::numpunct*; - std::num_get*; - std::num_get_[cw]; - std::n[v-z]*; - std::ostrstream*; - std::overflow_error*; - std::out_of_range*; - std::[A-Zp-z]*; + std::[A-Zm-z]*; + std::_List_node_base::hook*; + std::_List_node_base::swap*; + std::_List_node_base::unhook*; + std::_List_node_base::reverse*; + std::_List_node_base::transfer*; std::__throw_*; - std::__numeric_limits_base*; std::__timepunct*; - std::_S_bit_count; - std::_S_first_one + std::__numeric_limits_base*; + std::__num_base::_S_format_float*; + std::__num_base::_S_format_int*; + std::__num_base::_S_atoms_in; + std::__num_base::_S_atoms_out; + std::__moneypunct_cache*; + std::__numpunct_cache*; + std::__timepunct_cache*; + __gnu_debug::_Safe_iterator_base*; + __gnu_debug::_Safe_sequence_base*; + __gnu_debug::_Error_formatter*; + __gnu_norm::_List_node_base::hook*; + __gnu_norm::_List_node_base::swap*; + __gnu_norm::_List_node_base::unhook*; + __gnu_norm::_List_node_base::reverse*; + __gnu_norm::_List_node_base::transfer* }; # Names not in an 'extern' block are mangled names. - _ZSt7getline*; - _ZStrs*; - _ZNSo*; - _ZNKSt9basic_ios*; - _ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE15_M_cache_facetsERKSt6locale; - _ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE[A-Z]*; - _ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE[0-9][A-Za-z]*; - _ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE[0-9][0-9][A-Za-z]*; - - _ZNSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEEC*; - _ZNSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEED*; - _ZNSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEEC*; - _ZNSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEED*; - - _ZNKSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE6do_put*; - - _ZNKSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE3put*; - _ZNSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE2idE; - - _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE14_M_convert_intI[lmxy]EES3_S3_RSt8ios_basecccT_; - - _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE14_M_convert_intI[lmxy]EES3_S3_RSt8ios_basewccT_; - - _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE16_M_convert_floatI[de]EES3_S3_RSt8ios_baseccT_; - - _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE16_M_convert_floatI[de]EES3_S3_RSt8ios_basewcT_; - - _ZNKSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE12_M_widen_int*; - - _ZNKSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE14_M_widen_float*; - - _ZNKSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE9_M_insert*; - - _ZSt9use_facetISt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEEERKT_RKSt6locale; - - # __num_base - _ZNSt10__num_base13_S_format_intERKSt8ios_basePccc; - _ZNSt10__num_base15_S_format_floatERKSt8ios_basePcc[il]; - _ZNSt10__num_base8_S_atomsE; - - # std::string minus binary operator plus - _ZNKSs*; - _ZNKSb*; - _ZNSs[A-Za-z]*; - _ZNSs[0-9][A-Za-z]*; - _ZNSs[0-9][0-9][A-Za-z]*; - _ZNSs[0-9]_[A-Ra-z]*; - _ZNSs[0-9][0-9]_[A-Ra-z]*; - _ZNSs12_S_empty_repEv; - _ZNSs20_S_empty_rep_storageE; - _ZNSbIwSt11char_traitsIwESaIwEE20_S_empty_rep_storageE; - _ZNSs12_S_constructE*; - _ZNSs13_S_copy_charsE*; - _ZNSbIwSt11char_traitsIwESaIwEE[A-Ra-z]*; - _ZNSbIwSt11char_traitsIwESaIwEE[0-9][A-Ra-z]*; - _ZNSbIwSt11char_traitsIwESaIwEE[0-9][0-9][A-Ra-z]*; - _ZNSbIwSt11char_traitsIwESaIwEE[0-9]_[A-Ra-z]*; - _ZNSbIwSt11char_traitsIwESaIwEE[0-9][0-9]_[A-Ra-z]*; - _ZNSbIwSt11char_traitsIwESaIwEE13_S_copy_chars*; - _ZNSbIwSt11char_traitsIwESaIwEE12_S_constructE[jm]wRKS1_; - _ZNSbIwSt11char_traitsIwESaIwEE12_S_empty_repEv; - _ZSt24__uninitialized_copy_auxIN9*; - _ZSt26__uninitialized_fill_n_aux*; - _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_; - _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ES3_RKS6_; - _ZStplIwSt11char_traitsIwESaIwEESbIT_T0_T1_EPKS3_RKS6_; - _ZStplIwSt11char_traitsIwESaIwEESbIT_T0_T1_ES3_RKS6_; - - # std::__basic_file minus showmanyc_helper - _ZNSt12__basic_fileIcED*; - _ZNSt12__basic_fileIcEC*; - _ZNSt12__basic_fileIcE8sys_open*; - _ZNSt12__basic_fileIcE8sys_getc*; - _ZNSt12__basic_fileIcE10sys_ungetc*; - _ZNSt12__basic_fileIcE7seekpos*; - _ZNSt12__basic_fileIcE7seekoff*; - _ZNSt12__basic_fileIcE6xsputn*; - _ZNSt12__basic_fileIcE6xsgetn*; - _ZNSt12__basic_fileIcE5close*; - _ZNSt12__basic_fileIcE4sync*; - _ZNSt12__basic_fileIcE4open*; - _ZNSt12__basic_fileIcE2fd*; - _ZNSt12__basic_fileIcE12_M_open_modeE*; - _ZNKSt12__basic_fileIcE7is_open*; - - # std::locale destructors - _ZNSt6localeD*; - - # std::locale::facet destructors - _ZNSt6locale5facetD*; - - # std::codecvt<char> members. - _ZNKSt7codecvtIcc11__mbstate_tE*; - # std::codecvt<char>::~codecvt - _ZNSt7codecvtIcc11__mbstate_tED*; - # std::codecvt<char>::codecvt(size_t), where size_t variable. - _ZNSt7codecvtIcc11__mbstate_tEC[12]E[jm]; - # std::codecvt<char>::id - _ZNSt7codecvtIcc11__mbstate_tE2idE; - - # std::codecvt<wchar_t> members. - _ZNKSt7codecvtIwc11__mbstate_tE*; - # std::codecvt<wchar_t>::~codecvt - _ZNSt7codecvtIwc11__mbstate_tED*; - # std::codecvt<wchar_t>::codecvt(size_t), where size_t variable. - _ZNSt7codecvtIwc11__mbstate_tEC[12]E[jm]; - # std::codecvt<wchar_t>::id - _ZNSt7codecvtIwc11__mbstate_tE2idE; - - # std::use_facet<codecvt> - _ZSt9use_facetISt7codecvtIcc11__mbstate_tEERKT_RKSt6locale; - _ZSt9use_facetISt7codecvtIwc11__mbstate_tEERKT_RKSt6locale; - - # std::has_facet* - _ZSt9has_facet*; - # std::__default_alloc_template - _ZNSt24__default_alloc_templateILb1ELi0EE10deallocate*; - _ZNSt24__default_alloc_templateILb1ELi0EE8allocate*; - _ZNSt24__default_alloc_templateILb1ELi0EE12_S_free_listE; - _ZNSt24__default_alloc_templateILb1ELi0EE22_S_node_allocator_lockE; - _ZNSt24__default_alloc_templateILb1ELi0EE9_S_refillE*; - - # std::__default_alloc_template to be removed in the future - _ZNSt24__default_alloc_templateILb1ELi0EE10reallocateEPv*; - _ZNSt24__default_alloc_templateILb1ELi0EE11_S_round_upE*; - _ZNSt24__default_alloc_templateILb1ELi0EE14_S_chunk_allocE*; - _ZNSt24__default_alloc_templateILb1ELi0EE17_S_freelist_indexE*; - _ZNSt24__default_alloc_templateILb1ELi0EE11_S_end_freeE; - _ZNSt24__default_alloc_templateILb1ELi0EE12_S_heap_sizeE; - _ZNSt24__default_alloc_templateILb1ELi0EE13_S_start_freeE; - _ZNSt24__default_alloc_templateILb1ELi0EE5_Lock*; - - # operator new(unsigned) - _Znwj; - # operator new(unsigned, std::nothrow_t const&) - _ZnwjRKSt9nothrow_t; - # operator new(unsigned long) - _Znwm; - # operator new(unsigned long, std::nothrow_t const&) - _ZnwmRKSt9nothrow_t; + # operator new(size_t) + _Znw[jm]; + # operator new(size_t, std::nothrow_t const&) + _Znw[jm]RKSt9nothrow_t; # operator delete(void*) _ZdlPv; # operator delete(void*, std::nothrow_t const&) _ZdlPvRKSt9nothrow_t; - # operator new[](unsigned) - _Znaj; - # operator new[](unsigned, std::nothrow_t const&) - _ZnajRKSt9nothrow_t; - # operator new[](unsigned long) - _Znam; - # operator new[](unsigned long, std::nothrow_t const&) - _ZnamRKSt9nothrow_t; + # operator new[](size_t) + _Zna[jm]; + # operator new[](size_t, std::nothrow_t const&) + _Zna[jm]RKSt9nothrow_t; # operator delete[](void*) _ZdaPv; # operator delete[](void*, std::nothrow_t const&) _ZdaPvRKSt9nothrow_t; - # vtable + # std::locale destructors + _ZNSt6localeD*; + + # std::locale::facet destructors + _ZNSt6locale5facetD*; + + # std::locale::_Impl constructors, destructors + _ZNSt6locale5_ImplC*; + _ZNSt6locale5_ImplD*; + + # std::ios_base, std::ios_base::Init destructors + _ZNSt8ios_baseD*; + _ZNSt8ios_base4InitD*; + + # bool has_facet + _ZSt9has_facet*; + + # _Rb_tree + _ZSt18_Rb_tree_decrementPKSt18_Rb_tree_node_base; + _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base; + _ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base; + _ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base; + _ZSt20_Rb_tree_black_countPKSt18_Rb_tree_node_baseS1_; + _ZSt20_Rb_tree_rotate_leftPSt18_Rb_tree_node_baseRS0_; + _ZSt21_Rb_tree_rotate_rightPSt18_Rb_tree_node_baseRS0_; + _ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_; + _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_; + + # std::__codecvt_abstract_base* + _ZNStSt23__codecvt_abstract_base*; + + # std::__basic_file + _ZNKSt12__basic_fileIcE7is_openEv; + _ZNSt12__basic_fileIcE2fdEv; + _ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei; + _ZNSt12__basic_fileIcE4syncEv; + _ZNSt12__basic_fileIcE5closeEv; + _ZNSt12__basic_fileIcE6xsgetn*; + _ZNSt12__basic_fileIcE6xsputn*; + _ZNSt12__basic_fileIcE7seekoff*; + _ZNSt12__basic_fileIcE8sys_openE*St13_Ios_Openmode; + _ZNSt12__basic_fileIcE8sys_openEiSt13_Ios_Openmode; + _ZNSt12__basic_fileIcE8xsputn_2*; + _ZNSt12__basic_fileIcE9showmanycEv; + _ZNSt12__basic_fileIcEC*; + _ZNSt12__basic_fileIcED*; + + # virtual table + _ZTVNSt8ios_base7failureE; + _ZTVNSt6locale5facetE; _ZTVS[a-z]; _ZTVSt[0-9][A-Za-z]*; _ZTVSt[0-9][0-9][A-Za-z]*; - _ZTTS[a-z]; - _ZTTSt[0-9][A-Za-z]*; - _ZTTSt[0-9][0-9][A-Za-z]*; - _ZTVN9__gnu_cxx*; - _ZTVNSt6locale5facetE; _ZTVSt11__timepunctI[cw]E; - _ZTVNSt8ios_base7failureE; _ZTVSt23__codecvt_abstract_baseI[cw]c11__mbstate_tE; _ZTVSt21__ctype_abstract_baseI[cw]E; - # XXX - _ZTVN10__cxxabi*; + # VTT structure + _ZTTS[a-z]; + _ZTTSt[0-9][A-Za-z]*; + _ZTTSt[0-9][0-9][A-Za-z]*; - # typeinfo - _ZTI[a-z]; - _ZTIP[a-z]; - _ZTIPK[a-z]; + # typeinfo structure _ZTIS[a-z]; + _ZTINSt8ios_base7failureE; + _ZTINSt6locale5facetE; _ZTISt[0-9][A-Za-z]*; _ZTISt[0-9][0-9][A-Za-z]*; - _ZTS[a-z]; + _ZTISt11__timepunctI[cw]E; + _ZTISt10__num_base; + _ZTISt21__ctype_abstract_baseI[cw]E; + _ZTISt23__codecvt_abstract_baseI[cw]c11__mbstate_tE; + _ZTIN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEE; + _ZTIN9__gnu_cxx13stdio_filebufI[cw]St11char_traitsI[cw]EEE; + + # typeinfo name + _ZTSNSt8ios_base7failureE; + _ZTSNSt6locale5facetE; _ZTSS[a-z]; - _ZTSP[a-z]; - _ZTSPK[a-z]; _ZTSSt[0-9][A-Za-z]*; _ZTSSt[0-9][0-9][A-Za-z]*; - _ZTSN9__gnu_cxx*; - _ZTIN9__gnu_cxx*; - _ZTINSt8ios_base7failureE; - _ZTSNSt8ios_base7failureE; - _ZTINSt6locale5facetE; - _ZTSNSt6locale5facetE; - _ZTISt11__timepunctI[cw]E; _ZTSSt11__timepunctI[cw]E; _ZTSSt10__num_base; - _ZTISt10__num_base; _ZTSSt21__ctype_abstract_baseI[cw]E; - _ZTISt21__ctype_abstract_baseI[cw]E; - _ZTISt23__codecvt_abstract_baseI[cw]c11__mbstate_tE; _ZTSSt23__codecvt_abstract_baseI[cw]c11__mbstate_tE; - - # XXX - _ZTIN10__cxxabi*; - _ZTSN10__cxxabi*; + _ZTSN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEE; + _ZTSN9__gnu_cxx13stdio_filebufI[cw]St11char_traitsI[cw]EEE; # function-scope static objects requires a guard variable. - _ZGV*; + _ZGVNSt*; # virtual function thunks - _ZTh*; - _ZTv*; - _ZTc*; + _ZThn8_NS*; + _ZThn16_NS*; + _ZTv0_n12_NS*; + _ZTv0_n24_NS*; # std::__convert_to_v _ZSt14__convert_to_v*; + # stub functions from libmath + sinf; + sinl; + sinhf; + sinhl; + cosf; + cosl; + coshf; + coshl; + tanf; + tanl; + tanhf; + tanhl; + atan2f; + atan2l; + expf; + expl; + hypotf; + hypotl; + hypot; + logf; + logl; + log10f; + log10l; + powf; + powl; + sqrtf; + sqrtl; + copysignf; + __signbit; + __signbitf; + __signbitl; + + # __gnu_cxx::stdio_sync_filebuf + _ZTVN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEE; + + # __gnu_cxx::__atomic_add + # __gnu_cxx::__exchange_and_add + _ZN9__gnu_cxx12__atomic_add*; + _ZN9__gnu_cxx18__exchange_and_add*; + + # DO NOT DELETE THIS LINE. Port-specific symbols, if any, will be here. + local: *; }; -# Symbols added after GLIBCPP_3.2 -GLIBCPP_3.2.1 { - - _ZNSt7codecvtIcc11__mbstate_tEC1EP15__locale_structj; - _ZNSt7codecvtIcc11__mbstate_tEC2EP15__locale_structj; - _ZNSt7codecvtIwc11__mbstate_tEC1EP15__locale_structj; - _ZNSt7codecvtIwc11__mbstate_tEC2EP15__locale_structj; - - _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ERKS6_S8_; - _ZStplIwSt11char_traitsIwESaIwEESbIT_T0_T1_ERKS6_S8_; - - # stub functions from libmath - sinf; - sinl; - sinhf; - sinhl; - cosf; - cosl; - coshf; - coshl; - tanf; - tanl; - tanhf; - tanhl; - atan2f; - atan2l; - expf; - expl; - hypotf; - hypotl; - hypot; - logf; - logl; - log10f; - log10l; - powf; - powl; - sqrtf; - sqrtl; - copysignf; - nan; - __signbit; - __signbitf; - __signbitl; - -} GLIBCPP_3.2; - -GLIBCPP_3.2.2 { - - _ZNSt24__default_alloc_templateILb1ELi0EE12_S_force_newE; - -} GLIBCPP_3.2.1; - -GLIBCPP_3.2.3 { +GLIBCXX_3.4.1 { + + _ZNSt12__basic_fileIcE4fileEv; + +} GLIBCXX_3.4; + +GLIBCXX_3.4.2 { - global: + _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EE4fileEv; - extern "C++" - { - # Needed only when generic cpu's atomicity.h is in use. - __gnu_cxx::_Atomic_add_mutex; - __gnu_cxx::_Atomic_add_mutex_once; - __gnu_cxx::__gthread_atomic_add_mutex_once; - - std::__num_base::_S_atoms_in; - std::__num_base::_S_atoms_out - }; - - _ZNKSt7num_putI[wc]St19ostreambuf_iteratorI[wc]St11char_traitsI[wc]EEE6_M_pad*; - - _ZNKSt7num_putI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEE14_M_convert_intI[yxml]EES3_S3_RSt8ios_base[cw]T_; - - _ZNKSt7num_putI[wc]St19ostreambuf_iteratorI[wc]St11char_traitsI[wc]EEE14_M_group_float*; - - _ZNKSt7num_putI[wc]St19ostreambuf_iteratorI[wc]St11char_traitsI[wc]EEE12_M_group_int*; - - # __basic_file::showmanyc_helper - _ZNSt12__basic_fileIcE16showmanyc_helperEv; - -} GLIBCPP_3.2.2; + _ZN9__gnu_cxx11__pool_base9_M_refillE[jm]; + _ZN9__gnu_cxx11__pool_base16_M_get_free_listE[jm]; + _ZN9__gnu_cxx11__pool_base12_M_get_mutexEv; +} GLIBCXX_3.4.1; # Symbols in the support library (libsupc++) have their own tag. -CXXABI_1.2 { +CXXABI_1.3 { global: __cxa_allocate_exception; @@ -411,6 +280,9 @@ CXXABI_1.2 { __cxa_free_exception; __cxa_get_globals; __cxa_get_globals_fast; + __cxa_guard_abort; + __cxa_guard_acquire; + __cxa_guard_release; __cxa_pure_virtual; __cxa_rethrow; __cxa_throw; @@ -428,38 +300,72 @@ CXXABI_1.2 { __gxx_personality_sj0; __dynamic_cast; + # *_type_info classes, ctor and dtor + _ZN10__cxxabiv117__array_type_info*; + _ZN10__cxxabiv117__class_type_info*; + _ZN10__cxxabiv116__enum_type_info*; + _ZN10__cxxabiv120__function_type_info*; + _ZN10__cxxabiv123__fundamental_type_info*; + _ZN10__cxxabiv117__pbase_type_info*; + _ZN10__cxxabiv129__pointer_to_member_type_info*; + _ZN10__cxxabiv119__pointer_type_info*; + _ZN10__cxxabiv120__si_class_type_info*; + _ZN10__cxxabiv121__vmi_class_type_info*; + + # *_type_info classes, member functions + _ZNK10__cxxabiv117__class_type_info*; + _ZNK10__cxxabiv120__function_type_info*; + _ZNK10__cxxabiv117__pbase_type_info*; + _ZNK10__cxxabiv129__pointer_to_member_type_info*; + _ZNK10__cxxabiv119__pointer_type_info*; + _ZNK10__cxxabiv120__si_class_type_info*; + _ZNK10__cxxabiv121__vmi_class_type_info*; + + # virtual table + _ZTVN10__cxxabiv117__array_type_infoE; + _ZTVN10__cxxabiv117__class_type_infoE; + _ZTVN10__cxxabiv116__enum_type_infoE; + _ZTVN10__cxxabiv120__function_type_infoE; + _ZTVN10__cxxabiv123__fundamental_type_infoE; + _ZTVN10__cxxabiv117__pbase_type_infoE; + _ZTVN10__cxxabiv129__pointer_to_member_type_infoE; + _ZTVN10__cxxabiv119__pointer_type_infoE; + _ZTVN10__cxxabiv120__si_class_type_infoE; + _ZTVN10__cxxabiv121__vmi_class_type_infoE; + + # typeinfo structure (and some names) + _ZTI[a-z]; + _ZTIP[a-z]; + _ZTIPK[a-z]; + _ZTIN10__cxxabiv117__array_type_infoE; + _ZTIN10__cxxabiv117__class_type_infoE; + _ZTIN10__cxxabiv116__enum_type_infoE; + _ZTIN10__cxxabiv120__function_type_infoE; + _ZTIN10__cxxabiv123__fundamental_type_infoE; + _ZTIN10__cxxabiv117__pbase_type_infoE; + _ZTIN10__cxxabiv129__pointer_to_member_type_infoE; + _ZTIN10__cxxabiv119__pointer_type_infoE; + _ZTIN10__cxxabiv120__si_class_type_infoE; + _ZTIN10__cxxabiv121__vmi_class_type_infoE; + + # typeinfo name + _ZTS[a-z]; + _ZTSP[a-z]; + _ZTSPK[a-z]; + _ZTSN10__cxxabiv117__array_type_infoE; + _ZTSN10__cxxabiv117__class_type_infoE; + _ZTSN10__cxxabiv116__enum_type_infoE; + _ZTSN10__cxxabiv120__function_type_infoE; + _ZTSN10__cxxabiv123__fundamental_type_infoE; + _ZTSN10__cxxabiv117__pbase_type_infoE; + _ZTSN10__cxxabiv129__pointer_to_member_type_infoE; + _ZTSN10__cxxabiv119__pointer_type_infoE; + _ZTSN10__cxxabiv120__si_class_type_infoE; + _ZTSN10__cxxabiv121__vmi_class_type_infoE; + # __gnu_cxx::_verbose_terminate_handler() _ZN9__gnu_cxx27__verbose_terminate_handlerEv; - # XXX Should not be exported. - __cxa_dyn_string_append_char; - __cxa_dyn_string_append_cstr; - __cxa_dyn_string_append; - __cxa_dyn_string_clear; - __cxa_dyn_string_copy_cstr; - __cxa_dyn_string_copy; - __cxa_dyn_string_delete; - __cxa_dyn_string_eq; - __cxa_dyn_string_init; - __cxa_dyn_string_insert_char; - __cxa_dyn_string_insert_cstr; - __cxa_dyn_string_insert; - __cxa_dyn_string_new; - __cxa_dyn_string_prepend_cstr; - __cxa_dyn_string_prepend; - __cxa_dyn_string_release; - __cxa_dyn_string_resize; - __cxa_dyn_string_substring; - local: *; }; - -# Symbols added after CXXABI_1.2 -CXXABI_1.2.1 { - - __cxa_guard_acquire; - __cxa_guard_release; - __cxa_guard_abort; - -} CXXABI_1.2; diff --git a/contrib/libstdc++/config/locale/generic/c_locale.cc b/contrib/libstdc++/config/locale/generic/c_locale.cc index 23f7912..730c366 100644 --- a/contrib/libstdc++/config/locale/generic/c_locale.cc +++ b/contrib/libstdc++/config/locale/generic/c_locale.cc @@ -1,6 +1,6 @@ // Wrapper for underlying C-language localization -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -33,9 +33,12 @@ // Written by Benjamin Kosnik <bkoz@redhat.com> +#include <cerrno> // For errno +#include <cmath> // For isinf, finite, finitef, fabs +#include <cstdlib> // For strof, strtold #include <locale> -#ifdef _GLIBCPP_HAVE_IEEEFP_H +#ifdef _GLIBCXX_HAVE_IEEEFP_H #include <ieeefp.h> #endif @@ -44,78 +47,8 @@ namespace std // Specializations for all types used in num_get. template<> void - __convert_to_v(const char* __s, long& __v, ios_base::iostate& __err, - const __c_locale&, int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - long __l = strtol(__s, &__sanity, __base); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __l; - else - __err |= ios_base::failbit; - } - } - - template<> - void - __convert_to_v(const char* __s, unsigned long& __v, - ios_base::iostate& __err, const __c_locale&, int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - unsigned long __ul = strtoul(__s, &__sanity, __base); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __ul; - else - __err |= ios_base::failbit; - } - } - -#ifdef _GLIBCPP_USE_LONG_LONG - template<> - void - __convert_to_v(const char* __s, long long& __v, ios_base::iostate& __err, - const __c_locale&, int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - long long __ll = strtoll(__s, &__sanity, __base); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __ll; - else - __err |= ios_base::failbit; - } - } - - template<> - void - __convert_to_v(const char* __s, unsigned long long& __v, - ios_base::iostate& __err, const __c_locale&, int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - unsigned long long __ull = strtoull(__s, &__sanity, __base); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __ull; - else - __err |= ios_base::failbit; - } - } -#endif - - template<> - void __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, - const __c_locale&, int) + const __c_locale&) { if (!(__err & ios_base::failbit)) { @@ -124,18 +57,18 @@ namespace std setlocale(LC_ALL, "C"); char* __sanity; errno = 0; -#if defined(_GLIBCPP_USE_C99) +#if defined(_GLIBCXX_USE_C99) float __f = strtof(__s, &__sanity); #else double __d = strtod(__s, &__sanity); float __f = static_cast<float>(__d); -#ifdef _GLIBCPP_HAVE_FINITEF +#ifdef _GLIBCXX_HAVE_FINITEF if (!finitef (__f)) errno = ERANGE; -#elif defined (_GLIBCPP_HAVE_FINITE) +#elif defined (_GLIBCXX_HAVE_FINITE) if (!finite (static_cast<double> (__f))) errno = ERANGE; -#elif defined (_GLIBCPP_HAVE_ISINF) +#elif defined (_GLIBCXX_HAVE_ISINF) if (isinf (static_cast<double> (__f))) errno = ERANGE; #else @@ -143,7 +76,7 @@ namespace std errno = ERANGE; #endif #endif - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) + if (__sanity != __s && errno != ERANGE) __v = __f; else __err |= ios_base::failbit; @@ -155,7 +88,7 @@ namespace std template<> void __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err, - const __c_locale&, int) + const __c_locale&) { if (!(__err & ios_base::failbit)) { @@ -165,7 +98,7 @@ namespace std char* __sanity; errno = 0; double __d = strtod(__s, &__sanity); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) + if (__sanity != __s && errno != ERANGE) __v = __d; else __err |= ios_base::failbit; @@ -177,18 +110,18 @@ namespace std template<> void __convert_to_v(const char* __s, long double& __v, - ios_base::iostate& __err, const __c_locale&, int) + ios_base::iostate& __err, const __c_locale&) { if (!(__err & ios_base::failbit)) { // Assumes __s formatted for "C" locale. char* __old = strdup(setlocale(LC_ALL, NULL)); setlocale(LC_ALL, "C"); -#if defined(_GLIBCPP_USE_C99) +#if defined(_GLIBCXX_USE_C99) char* __sanity; errno = 0; long double __ld = strtold(__s, &__sanity); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) + if (__sanity != __s && errno != ERANGE) __v = __ld; #else typedef char_traits<char>::int_type int_type; @@ -197,7 +130,7 @@ namespace std int __p = sscanf(__s, "%Lf", &__ld); if (errno == ERANGE) __p = 0; -#ifdef _GLIBCPP_HAVE_FINITEL +#ifdef _GLIBCXX_HAVE_FINITEL if ((__p == 1) && !finitel (__ld)) __p = 0; #endif @@ -212,9 +145,16 @@ namespace std } void - locale::facet::_S_create_c_locale(__c_locale& __cloc, const char*, + locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, __c_locale) - { __cloc = NULL; } + { + // Currently, the generic model only supports the "C" locale. + // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html + __cloc = NULL; + if (strcmp(__s, "C")) + __throw_runtime_error(__N("locale::facet::_S_create_c_locale " + "name not valid")); + } void locale::facet::_S_destroy_c_locale(__c_locale& __cloc) @@ -223,9 +163,11 @@ namespace std __c_locale locale::facet::_S_clone_c_locale(__c_locale&) { return __c_locale(); } +} // namespace std - const char* locale::_S_categories[_S_categories_size - + _S_extra_categories_size] = +namespace __gnu_cxx +{ + const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] = { "LC_CTYPE", "LC_NUMERIC", @@ -234,4 +176,9 @@ namespace std "LC_MONETARY", "LC_MESSAGES" }; +} + +namespace std +{ + const char* const* const locale::_S_categories = __gnu_cxx::category_names; } // namespace std diff --git a/contrib/libstdc++/config/locale/generic/c_locale.h b/contrib/libstdc++/config/locale/generic/c_locale.h index 1f2accb..9fadcc4 100644 --- a/contrib/libstdc++/config/locale/generic/c_locale.h +++ b/contrib/libstdc++/config/locale/generic/c_locale.h @@ -1,6 +1,6 @@ // Wrapper for underlying C-language localization -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -33,14 +33,16 @@ // Written by Benjamin Kosnik <bkoz@redhat.com> -#ifndef _CPP_BITS_C_LOCALE_H -#define _CPP_BITS_C_LOCALE_H 1 +#ifndef _C_LOCALE_H +#define _C_LOCALE_H 1 #pragma GCC system_header #include <clocale> +#include <cstring> // get std::strlen +#include <cstdio> // get std::snprintf or std::sprintf -#define _GLIBCPP_NUM_CATEGORIES 0 +#define _GLIBCXX_NUM_CATEGORIES 0 namespace std { @@ -53,30 +55,29 @@ namespace std template<typename _Tv> int __convert_from_v(char* __out, - const int __attribute__ ((__unused__)) __size, + const int __size __attribute__((__unused__)), const char* __fmt, _Tv __v, const __c_locale&, int __prec = -1) { - char* __old = setlocale(LC_ALL, NULL); - char* __sav = static_cast<char*>(malloc(strlen(__old) + 1)); - if (__sav) - strcpy(__sav, __old); - setlocale(LC_ALL, "C"); + char* __old = std::setlocale(LC_ALL, NULL); + char* __sav = new char[std::strlen(__old) + 1]; + std::strcpy(__sav, __old); + std::setlocale(LC_ALL, "C"); int __ret; -#ifdef _GLIBCPP_USE_C99 +#ifdef _GLIBCXX_USE_C99 if (__prec >= 0) - __ret = snprintf(__out, __size, __fmt, __prec, __v); + __ret = std::snprintf(__out, __size, __fmt, __prec, __v); else - __ret = snprintf(__out, __size, __fmt, __v); + __ret = std::snprintf(__out, __size, __fmt, __v); #else if (__prec >= 0) - __ret = sprintf(__out, __fmt, __prec, __v); + __ret = std::sprintf(__out, __fmt, __prec, __v); else - __ret = sprintf(__out, __fmt, __v); + __ret = std::sprintf(__out, __fmt, __v); #endif - setlocale(LC_ALL, __sav); - free(__sav); + std::setlocale(LC_ALL, __sav); + delete [] __sav; return __ret; } } diff --git a/contrib/libstdc++/config/locale/generic/codecvt_members.cc b/contrib/libstdc++/config/locale/generic/codecvt_members.cc index ff65dff..8bdc227 100644 --- a/contrib/libstdc++/config/locale/generic/codecvt_members.cc +++ b/contrib/libstdc++/config/locale/generic/codecvt_members.cc @@ -38,7 +38,7 @@ namespace std { // Specializations. -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T codecvt_base::result codecvt<wchar_t, char, mbstate_t>:: do_out(state_type& __state, const intern_type* __from, @@ -46,25 +46,61 @@ namespace std extern_type* __to, extern_type* __to_end, extern_type*& __to_next) const { - result __ret = error; - size_t __len = min(__from_end - __from, __to_end - __to); - size_t __conv = wcsrtombs(__to, &__from, __len, &__state); + result __ret = ok; + // The conversion must be done using a temporary destination buffer + // since it is not possible to pass the size of the buffer to wcrtomb + state_type __tmp_state(__state); - if (__conv == __len) - { - __from_next = __from; - __to_next = __to + __conv; - __ret = ok; - } - else if (__conv > 0 && __conv < __len) + // The conversion must be done by calling wcrtomb in a loop rather + // than using wcsrtombs because wcsrtombs assumes that the input is + // zero-terminated. + + // Either we can upper bound the total number of external characters to + // something smaller than __to_end - __to or the conversion must be done + // using a temporary destination buffer since it is not possible to + // pass the size of the buffer to wcrtomb + if (MB_CUR_MAX * (__from_end - __from) - (__to_end - __to) <= 0) + while (__from < __from_end) + { + const size_t __conv = wcrtomb(__to, *__from, &__tmp_state); + if (__conv == static_cast<size_t>(-1)) + { + __ret = error; + break; + } + __state = __tmp_state; + __to += __conv; + __from++; + } + else { - __from_next = __from; - __to_next = __to + __conv; - __ret = partial; + extern_type __buf[MB_LEN_MAX]; + while (__from < __from_end && __to < __to_end) + { + const size_t __conv = wcrtomb(__buf, *__from, &__tmp_state); + if (__conv == static_cast<size_t>(-1)) + { + __ret = error; + break; + } + else if (__conv > static_cast<size_t>(__to_end - __to)) + { + __ret = partial; + break; + } + + memcpy(__to, __buf, __conv); + __state = __tmp_state; + __to += __conv; + __from++; + } } - else - __ret = error; - + + if (__ret == ok && __from < __from_end) + __ret = partial; + + __from_next = __from; + __to_next = __to; return __ret; } @@ -75,25 +111,106 @@ namespace std intern_type* __to, intern_type* __to_end, intern_type*& __to_next) const { - result __ret = error; - size_t __len = min(__from_end - __from, __to_end - __to); - size_t __conv = mbsrtowcs(__to, &__from, __len, &__state); + result __ret = ok; + // This temporary state object is neccessary so __state won't be modified + // if [__from, __from_end) is a partial multibyte character. + state_type __tmp_state(__state); - if (__conv == __len) + // Conversion must be done by calling mbrtowc in a loop rather than + // by calling mbsrtowcs because mbsrtowcs assumes that the input + // sequence is zero-terminated. + while (__from < __from_end && __to < __to_end) { - __from_next = __from; - __to_next = __to + __conv; - __ret = ok; + size_t __conv = mbrtowc(__to, __from, __from_end - __from, + &__tmp_state); + if (__conv == static_cast<size_t>(-1)) + { + __ret = error; + break; + } + else if (__conv == static_cast<size_t>(-2)) + { + // It is unclear what to return in this case (see DR 382). + __ret = partial; + break; + } + else if (__conv == 0) + { + // XXX Probably wrong for stateful encodings + __conv = 1; + *__to = L'\0'; + } + + __state = __tmp_state; + __to++; + __from += __conv; } - else if (__conv > 0 && __conv < __len) + + // It is not clear that __from < __from_end implies __ret != ok + // (see DR 382). + if (__ret == ok && __from < __from_end) + __ret = partial; + + __from_next = __from; + __to_next = __to; + return __ret; + } + + int + codecvt<wchar_t, char, mbstate_t>:: + do_encoding() const throw() + { + // XXX This implementation assumes that the encoding is + // stateless and is either single-byte or variable-width. + int __ret = 0; + if (MB_CUR_MAX == 1) + __ret = 1; + return __ret; + } + + int + codecvt<wchar_t, char, mbstate_t>:: + do_max_length() const throw() + { + // XXX Probably wrong for stateful encodings. + int __ret = MB_CUR_MAX; + return __ret; + } + + int + codecvt<wchar_t, char, mbstate_t>:: + do_length(state_type& __state, const extern_type* __from, + const extern_type* __end, size_t __max) const + { + int __ret = 0; + state_type __tmp_state(__state); + + while (__from < __end && __max) { - __from_next = __from; - __to_next = __to + __conv; - __ret = partial; + size_t __conv = mbrtowc(NULL, __from, __end - __from, &__tmp_state); + if (__conv == static_cast<size_t>(-1)) + { + // Invalid source character + break; + } + else if (__conv == static_cast<size_t>(-2)) + { + // Remainder of input does not form a complete destination + // character. + break; + } + else if (__conv == 0) + { + // XXX Probably wrong for stateful encodings + __conv = 1; + } + + __state = __tmp_state; + __from += __conv; + __ret += __conv; + __max--; } - else - __ret = error; - + return __ret; } #endif diff --git a/contrib/libstdc++/config/locale/generic/collate_members.cc b/contrib/libstdc++/config/locale/generic/collate_members.cc index 93767d9..9547f71 100644 --- a/contrib/libstdc++/config/locale/generic/collate_members.cc +++ b/contrib/libstdc++/config/locale/generic/collate_members.cc @@ -53,7 +53,7 @@ namespace std size_t __n) const { return strxfrm(__to, __from, __n); } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> int collate<wchar_t>::_M_compare(const wchar_t* __one, diff --git a/contrib/libstdc++/config/locale/generic/ctype_members.cc b/contrib/libstdc++/config/locale/generic/ctype_members.cc index 71e810a..af994cb 100644 --- a/contrib/libstdc++/config/locale/generic/ctype_members.cc +++ b/contrib/libstdc++/config/locale/generic/ctype_members.cc @@ -1,6 +1,6 @@ // std::ctype implementation details, generic version -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -43,11 +43,14 @@ namespace std ctype_byname<char>::ctype_byname(const char* __s, size_t __refs) : ctype<char>(0, false, __refs) { - _S_destroy_c_locale(_M_c_locale_ctype); - _S_create_c_locale(_M_c_locale_ctype, __s); + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_ctype); + this->_S_create_c_locale(this->_M_c_locale_ctype, __s); + } } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T ctype<wchar_t>::__wmask_type ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const { @@ -128,13 +131,16 @@ namespace std do_is(mask __m, char_type __c) const { bool __ret = false; - const size_t __bitmasksize = 10; + // Generically, 15 (instead of 10) since we don't know the numerical + // encoding of the various categories in /usr/include/ctype.h. + const size_t __bitmasksize = 15; for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) - { - const mask __bit = static_cast<mask>(1 << __bitcur); - if (__m & __bit) - __ret |= iswctype(__c, _M_convert_to_wmask(__bit)); - } + if (__m & _M_bit[__bitcur] + && iswctype(__c, _M_wmask[__bitcur])) + { + __ret = true; + break; + } return __ret; } @@ -144,14 +150,13 @@ namespace std { for (;__lo < __hi; ++__vec, ++__lo) { - const size_t __bitmasksize = 10; + // Generically, 15 (instead of 10) since we don't know the numerical + // encoding of the various categories in /usr/include/ctype.h. + const size_t __bitmasksize = 15; mask __m = 0; for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) - { - const mask __bit = static_cast<mask>(1 << __bitcur); - if (iswctype(*__lo, _M_convert_to_wmask(__bit))) - __m |= __bit; - } + if (iswctype(*__lo, _M_wmask[__bitcur])) + __m |= _M_bit[__bitcur]; *__vec = __m; } return __hi; @@ -178,15 +183,18 @@ namespace std wchar_t ctype<wchar_t>:: do_widen(char __c) const - { return btowc(__c); } + { return _M_widen[static_cast<unsigned char>(__c)]; } const char* ctype<wchar_t>:: do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const { - mbstate_t __state; - memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t)); - mbsrtowcs(__dest, &__lo, __hi - __lo, &__state); + while (__lo < __hi) + { + *__dest = _M_widen[static_cast<unsigned char>(*__lo)]; + ++__lo; + ++__dest; + } return __hi; } @@ -194,7 +202,9 @@ namespace std ctype<wchar_t>:: do_narrow(wchar_t __wc, char __dfault) const { - int __c = wctob(__wc); + if (__wc >= 0 && __wc < 128 && _M_narrow_ok) + return _M_narrow[__wc]; + const int __c = wctob(__wc); return (__c == EOF ? __dfault : static_cast<char>(__c)); } @@ -203,24 +213,55 @@ namespace std do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault, char* __dest) const { - size_t __offset = 0; - while (true) + if (_M_narrow_ok) + while (__lo < __hi) + { + if (*__lo >= 0 && *__lo < 128) + *__dest = _M_narrow[*__lo]; + else + { + const int __c = wctob(*__lo); + *__dest = (__c == EOF ? __dfault : static_cast<char>(__c)); + } + ++__lo; + ++__dest; + } + else + while (__lo < __hi) + { + const int __c = wctob(*__lo); + *__dest = (__c == EOF ? __dfault : static_cast<char>(__c)); + ++__lo; + ++__dest; + } + return __hi; + } + + void + ctype<wchar_t>::_M_initialize_ctype() + { + wint_t __i; + for (__i = 0; __i < 128; ++__i) { - const wchar_t* __start = __lo + __offset; - size_t __len = __hi - __start; - - mbstate_t __state; - memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t)); - size_t __con = wcsrtombs(__dest + __offset, &__start, __len, &__state); - if (__con != __len && __start != 0) - { - __offset = __start - __lo; - __dest[__offset++] = __dfault; - } - else + const int __c = wctob(__i); + if (__c == EOF) break; + else + _M_narrow[__i] = static_cast<char>(__c); } - return __hi; + if (__i == 128) + _M_narrow_ok = true; + else + _M_narrow_ok = false; + for (size_t __i = 0; + __i < sizeof(_M_widen) / sizeof(wint_t); ++__i) + _M_widen[__i] = btowc(__i); + + for (size_t __i = 0; __i <= 15; ++__i) + { + _M_bit[__i] = static_cast<mask>(1 << __i); + _M_wmask[__i] = _M_convert_to_wmask(_M_bit[__i]); + } } -#endif // _GLIBCPP_USE_WCHAR_T +#endif // _GLIBCXX_USE_WCHAR_T } diff --git a/contrib/libstdc++/config/locale/generic/messages_members.cc b/contrib/libstdc++/config/locale/generic/messages_members.cc index f38f82b..6edca38 100644 --- a/contrib/libstdc++/config/locale/generic/messages_members.cc +++ b/contrib/libstdc++/config/locale/generic/messages_members.cc @@ -43,7 +43,7 @@ namespace std messages<char>::do_get(catalog, int, int, const string& __dfault) const { return __dfault; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> wstring messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const diff --git a/contrib/libstdc++/config/locale/generic/messages_members.h b/contrib/libstdc++/config/locale/generic/messages_members.h index c1c8e4d..4a2ff4a 100644 --- a/contrib/libstdc++/config/locale/generic/messages_members.h +++ b/contrib/libstdc++/config/locale/generic/messages_members.h @@ -1,6 +1,6 @@ // std::messages implementation details, generic version -*- C++ -*- -// Copyright (C) 2001, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003, 2004 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 @@ -36,13 +36,13 @@ // Non-virtual member functions. template<typename _CharT> messages<_CharT>::messages(size_t __refs) - : locale::facet(__refs) - { _M_c_locale_messages = _S_c_locale; } + : facet(__refs) + { _M_c_locale_messages = _S_get_c_locale(); } template<typename _CharT> messages<_CharT>::messages(__c_locale, const char*, size_t __refs) - : locale::facet(__refs) - { _M_c_locale_messages = _S_c_locale; } + : facet(__refs) + { _M_c_locale_messages = _S_get_c_locale(); } template<typename _CharT> typename messages<_CharT>::catalog @@ -76,6 +76,9 @@ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { - _S_destroy_c_locale(_M_c_locale_messages); - _S_create_c_locale(_M_c_locale_messages, __s); + if (std::strcmp(__s, "C") != 0 && std::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); + } } diff --git a/contrib/libstdc++/config/locale/generic/monetary_members.cc b/contrib/libstdc++/config/locale/generic/monetary_members.cc index 1921f46..957a326 100644 --- a/contrib/libstdc++/config/locale/generic/monetary_members.cc +++ b/contrib/libstdc++/config/locale/generic/monetary_members.cc @@ -1,6 +1,6 @@ // std::moneypunct implementation details, generic version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -47,58 +47,92 @@ namespace std void moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*) { - // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + // "C" locale. + if (!_M_data) + _M_data = new __moneypunct_cache<char, true>; + + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } template<> void moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*) { - // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + // "C" locale. + if (!_M_data) + _M_data = new __moneypunct_cache<char, false>; + + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } template<> moneypunct<char, true>::~moneypunct() - { } + { delete _M_data; } template<> moneypunct<char, false>::~moneypunct() - { } + { delete _M_data; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, const char*) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t, true>; + + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } template<> @@ -107,23 +141,37 @@ namespace std const char*) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t, false>; + + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } template<> moneypunct<wchar_t, true>::~moneypunct() - { } + { delete _M_data; } template<> moneypunct<wchar_t, false>::~moneypunct() - { } + { delete _M_data; } #endif } diff --git a/contrib/libstdc++/config/locale/generic/numeric_members.cc b/contrib/libstdc++/config/locale/generic/numeric_members.cc index f942e04..e2afed9 100644 --- a/contrib/libstdc++/config/locale/generic/numeric_members.cc +++ b/contrib/libstdc++/config/locale/generic/numeric_members.cc @@ -1,6 +1,6 @@ // std::numpunct implementation details, generic version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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,32 +42,70 @@ namespace std numpunct<char>::_M_initialize_numpunct(__c_locale) { // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_truename = "true"; - _M_falsename = "false"; + if (!_M_data) + _M_data = new __numpunct_cache<char>; + + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + + for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) + _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i]; + + for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) + _M_data->_M_atoms_in[__i] = __num_base::_S_atoms_in[__i]; + + _M_data->_M_truename = "true"; + _M_data->_M_truename_size = strlen(_M_data->_M_truename); + _M_data->_M_falsename = "false"; + _M_data->_M_falsename_size = strlen(_M_data->_M_falsename); } template<> numpunct<char>::~numpunct() - { } + { delete _M_data; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void numpunct<wchar_t>::_M_initialize_numpunct(__c_locale) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_truename = L"true"; - _M_falsename = L"false"; + if (!_M_data) + _M_data = new __numpunct_cache<wchar_t>; + + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + + // Use ctype::widen code without the facet... + unsigned char uc; + for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) + { + uc = static_cast<unsigned char>(__num_base::_S_atoms_out[__i]); + _M_data->_M_atoms_out[__i] = btowc(uc); + } + + for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) + { + uc = static_cast<unsigned char>(__num_base::_S_atoms_in[__i]); + _M_data->_M_atoms_in[__i] = btowc(uc); + } + + _M_data->_M_truename = L"true"; + _M_data->_M_truename_size = wcslen(_M_data->_M_truename); + _M_data->_M_falsename = L"false"; + _M_data->_M_falsename_size = wcslen(_M_data->_M_falsename); } template<> numpunct<wchar_t>::~numpunct() - { } + { delete _M_data; } #endif } diff --git a/contrib/libstdc++/config/locale/generic/time_members.cc b/contrib/libstdc++/config/locale/generic/time_members.cc index df43f03..6e2f755 100644 --- a/contrib/libstdc++/config/locale/generic/time_members.cc +++ b/contrib/libstdc++/config/locale/generic/time_members.cc @@ -1,6 +1,6 @@ // std::time_get, std::time_put implementation, generic version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -55,65 +55,68 @@ namespace std void __timepunct<char>::_M_initialize_timepunct(__c_locale) { - // "C" locale - _M_date_format = "%m/%d/%y"; - _M_date_era_format = "%m/%d/%y"; - _M_time_format = "%H:%M:%S"; - _M_time_era_format = "%H:%M:%S"; - _M_date_time_format = ""; - _M_date_time_era_format = ""; - _M_am = "AM"; - _M_pm = "PM"; - _M_am_pm_format = ""; + // "C" locale. + if (!_M_data) + _M_data = new __timepunct_cache<char>; + + _M_data->_M_date_format = "%m/%d/%y"; + _M_data->_M_date_era_format = "%m/%d/%y"; + _M_data->_M_time_format = "%H:%M:%S"; + _M_data->_M_time_era_format = "%H:%M:%S"; + _M_data->_M_date_time_format = ""; + _M_data->_M_date_time_era_format = ""; + _M_data->_M_am = "AM"; + _M_data->_M_pm = "PM"; + _M_data->_M_am_pm_format = ""; // Day names, starting with "C"'s Sunday. - _M_day1 = "Sunday"; - _M_day2 = "Monday"; - _M_day3 = "Tuesday"; - _M_day4 = "Wednesday"; - _M_day5 = "Thursday"; - _M_day6 = "Friday"; - _M_day7 = "Saturday"; + _M_data->_M_day1 = "Sunday"; + _M_data->_M_day2 = "Monday"; + _M_data->_M_day3 = "Tuesday"; + _M_data->_M_day4 = "Wednesday"; + _M_data->_M_day5 = "Thursday"; + _M_data->_M_day6 = "Friday"; + _M_data->_M_day7 = "Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = "Sun"; - _M_day_a2 = "Mon"; - _M_day_a3 = "Tue"; - _M_day_a4 = "Wed"; - _M_day_a5 = "Thu"; - _M_day_a6 = "Fri"; - _M_day_a7 = "Sat"; + _M_data->_M_aday1 = "Sun"; + _M_data->_M_aday2 = "Mon"; + _M_data->_M_aday3 = "Tue"; + _M_data->_M_aday4 = "Wed"; + _M_data->_M_aday5 = "Thu"; + _M_data->_M_aday6 = "Fri"; + _M_data->_M_aday7 = "Sat"; // Month names, starting with "C"'s January. - _M_month01 = "January"; - _M_month02 = "February"; - _M_month03 = "March"; - _M_month04 = "April"; - _M_month05 = "May"; - _M_month06 = "June"; - _M_month07 = "July"; - _M_month08 = "August"; - _M_month09 = "September"; - _M_month10 = "October"; - _M_month11 = "November"; - _M_month12 = "December"; + _M_data->_M_month01 = "January"; + _M_data->_M_month02 = "February"; + _M_data->_M_month03 = "March"; + _M_data->_M_month04 = "April"; + _M_data->_M_month05 = "May"; + _M_data->_M_month06 = "June"; + _M_data->_M_month07 = "July"; + _M_data->_M_month08 = "August"; + _M_data->_M_month09 = "September"; + _M_data->_M_month10 = "October"; + _M_data->_M_month11 = "November"; + _M_data->_M_month12 = "December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = "Jan"; - _M_month_a02 = "Feb"; - _M_month_a03 = "Mar"; - _M_month_a04 = "Apr"; - _M_month_a05 = "May"; - _M_month_a06 = "Jun"; - _M_month_a07 = "July"; - _M_month_a08 = "Aug"; - _M_month_a09 = "Sep"; - _M_month_a10 = "Oct"; - _M_month_a11 = "Nov"; - _M_month_a12 = "Dec"; + _M_data->_M_amonth01 = "Jan"; + _M_data->_M_amonth02 = "Feb"; + _M_data->_M_amonth03 = "Mar"; + _M_data->_M_amonth04 = "Apr"; + _M_data->_M_amonth05 = "May"; + _M_data->_M_amonth06 = "Jun"; + _M_data->_M_amonth07 = "Jul"; + _M_data->_M_amonth08 = "Aug"; + _M_data->_M_amonth09 = "Sep"; + _M_data->_M_amonth10 = "Oct"; + _M_data->_M_amonth11 = "Nov"; + _M_data->_M_amonth12 = "Dec"; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void __timepunct<wchar_t>:: @@ -131,62 +134,65 @@ namespace std void __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale) { - // "C" locale - _M_date_format = L"%m/%d/%y"; - _M_date_era_format = L"%m/%d/%y"; - _M_time_format = L"%H:%M:%S"; - _M_time_era_format = L"%H:%M:%S"; - _M_date_time_format = L""; - _M_date_time_era_format = L""; - _M_am = L"AM"; - _M_pm = L"PM"; - _M_am_pm_format = L""; + // "C" locale. + if (!_M_data) + _M_data = new __timepunct_cache<wchar_t>; + + _M_data->_M_date_format = L"%m/%d/%y"; + _M_data->_M_date_era_format = L"%m/%d/%y"; + _M_data->_M_time_format = L"%H:%M:%S"; + _M_data->_M_time_era_format = L"%H:%M:%S"; + _M_data->_M_date_time_format = L""; + _M_data->_M_date_time_era_format = L""; + _M_data->_M_am = L"AM"; + _M_data->_M_pm = L"PM"; + _M_data->_M_am_pm_format = L""; // Day names, starting with "C"'s Sunday. - _M_day1 = L"Sunday"; - _M_day2 = L"Monday"; - _M_day3 = L"Tuesday"; - _M_day4 = L"Wednesday"; - _M_day5 = L"Thursday"; - _M_day6 = L"Friday"; - _M_day7 = L"Saturday"; + _M_data->_M_day1 = L"Sunday"; + _M_data->_M_day2 = L"Monday"; + _M_data->_M_day3 = L"Tuesday"; + _M_data->_M_day4 = L"Wednesday"; + _M_data->_M_day5 = L"Thursday"; + _M_data->_M_day6 = L"Friday"; + _M_data->_M_day7 = L"Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = L"Sun"; - _M_day_a2 = L"Mon"; - _M_day_a3 = L"Tue"; - _M_day_a4 = L"Wed"; - _M_day_a5 = L"Thu"; - _M_day_a6 = L"Fri"; - _M_day_a7 = L"Sat"; + _M_data->_M_aday1 = L"Sun"; + _M_data->_M_aday2 = L"Mon"; + _M_data->_M_aday3 = L"Tue"; + _M_data->_M_aday4 = L"Wed"; + _M_data->_M_aday5 = L"Thu"; + _M_data->_M_aday6 = L"Fri"; + _M_data->_M_aday7 = L"Sat"; // Month names, starting with "C"'s January. - _M_month01 = L"January"; - _M_month02 = L"February"; - _M_month03 = L"March"; - _M_month04 = L"April"; - _M_month05 = L"May"; - _M_month06 = L"June"; - _M_month07 = L"July"; - _M_month08 = L"August"; - _M_month09 = L"September"; - _M_month10 = L"October"; - _M_month11 = L"November"; - _M_month12 = L"December"; + _M_data->_M_month01 = L"January"; + _M_data->_M_month02 = L"February"; + _M_data->_M_month03 = L"March"; + _M_data->_M_month04 = L"April"; + _M_data->_M_month05 = L"May"; + _M_data->_M_month06 = L"June"; + _M_data->_M_month07 = L"July"; + _M_data->_M_month08 = L"August"; + _M_data->_M_month09 = L"September"; + _M_data->_M_month10 = L"October"; + _M_data->_M_month11 = L"November"; + _M_data->_M_month12 = L"December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = L"Jan"; - _M_month_a02 = L"Feb"; - _M_month_a03 = L"Mar"; - _M_month_a04 = L"Apr"; - _M_month_a05 = L"May"; - _M_month_a06 = L"Jun"; - _M_month_a07 = L"July"; - _M_month_a08 = L"Aug"; - _M_month_a09 = L"Sep"; - _M_month_a10 = L"Oct"; - _M_month_a11 = L"Nov"; - _M_month_a12 = L"Dec"; + _M_data->_M_amonth01 = L"Jan"; + _M_data->_M_amonth02 = L"Feb"; + _M_data->_M_amonth03 = L"Mar"; + _M_data->_M_amonth04 = L"Apr"; + _M_data->_M_amonth05 = L"May"; + _M_data->_M_amonth06 = L"Jun"; + _M_data->_M_amonth07 = L"Jul"; + _M_data->_M_amonth08 = L"Aug"; + _M_data->_M_amonth09 = L"Sep"; + _M_data->_M_amonth10 = L"Oct"; + _M_data->_M_amonth11 = L"Nov"; + _M_data->_M_amonth12 = L"Dec"; } #endif } diff --git a/contrib/libstdc++/config/locale/generic/time_members.h b/contrib/libstdc++/config/locale/generic/time_members.h index 03c31d1..9801300 100644 --- a/contrib/libstdc++/config/locale/generic/time_members.h +++ b/contrib/libstdc++/config/locale/generic/time_members.h @@ -36,26 +36,36 @@ template<typename _CharT> __timepunct<_CharT>::__timepunct(size_t __refs) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL) { - _M_name_timepunct = _S_c_name; + _M_name_timepunct = _S_get_c_name(); + _M_initialize_timepunct(); + } + + template<typename _CharT> + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) + : facet(__refs), _M_data(__cache) + { + _M_name_timepunct = _S_get_c_name(); _M_initialize_timepunct(); } template<typename _CharT> __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, size_t __refs) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL) { - _M_name_timepunct = new char[strlen(__s) + 1]; - strcpy(_M_name_timepunct, __s); + char* __tmp = new char[std::strlen(__s) + 1]; + std::strcpy(__tmp, __s); + _M_name_timepunct = __tmp; _M_initialize_timepunct(__cloc); } template<typename _CharT> __timepunct<_CharT>::~__timepunct() { - if (_S_c_name != _M_name_timepunct) + if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; + delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } diff --git a/contrib/libstdc++/config/locale/gnu/c++locale_internal.h b/contrib/libstdc++/config/locale/gnu/c++locale_internal.h index cfb89b5..8aa5b56 100644 --- a/contrib/libstdc++/config/locale/gnu/c++locale_internal.h +++ b/contrib/libstdc++/config/locale/gnu/c++locale_internal.h @@ -1,6 +1,6 @@ // Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*- -// Copyright (C) 2002 Free Software Foundation, Inc. +// Copyright (C) 2002, 2004 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 @@ -40,10 +40,6 @@ extern "C" __typeof(strftime_l) __strftime_l; extern "C" __typeof(strtod_l) __strtod_l; extern "C" __typeof(strtof_l) __strtof_l; extern "C" __typeof(strtold_l) __strtold_l; -extern "C" __typeof(strtol_l) __strtol_l; -extern "C" __typeof(strtoll_l) __strtoll_l; -extern "C" __typeof(strtoul_l) __strtoul_l; -extern "C" __typeof(strtoull_l) __strtoull_l; extern "C" __typeof(strxfrm_l) __strxfrm_l; extern "C" __typeof(towlower_l) __towlower_l; extern "C" __typeof(towupper_l) __towupper_l; diff --git a/contrib/libstdc++/config/locale/gnu/c_locale.cc b/contrib/libstdc++/config/locale/gnu/c_locale.cc index 065e10a..bf975b9 100644 --- a/contrib/libstdc++/config/locale/gnu/c_locale.cc +++ b/contrib/libstdc++/config/locale/gnu/c_locale.cc @@ -33,6 +33,7 @@ // Written by Benjamin Kosnik <bkoz@redhat.com> +#include <cerrno> // For errno #include <locale> #include <stdexcept> #include <langinfo.h> @@ -42,88 +43,15 @@ namespace std { template<> void - __convert_to_v(const char* __s, long& __v, ios_base::iostate& __err, - const __c_locale& __cloc, int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - long __l = __strtol_l(__s, &__sanity, __base, __cloc); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __l; - else - __err |= ios_base::failbit; - } - } - - template<> - void - __convert_to_v(const char* __s, unsigned long& __v, - ios_base::iostate& __err, const __c_locale& __cloc, - int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - unsigned long __ul = __strtoul_l(__s, &__sanity, __base, __cloc); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __ul; - else - __err |= ios_base::failbit; - } - } - -#ifdef _GLIBCPP_USE_LONG_LONG - template<> - void - __convert_to_v(const char* __s, long long& __v, ios_base::iostate& __err, - const __c_locale& __cloc, int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - long long __ll = __strtoll_l(__s, &__sanity, __base, __cloc); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __ll; - else - __err |= ios_base::failbit; - } - } - - template<> - void - __convert_to_v(const char* __s, unsigned long long& __v, - ios_base::iostate& __err, const __c_locale& __cloc, - int __base) - { - if (!(__err & ios_base::failbit)) - { - char* __sanity; - errno = 0; - unsigned long long __ull = __strtoull_l(__s, &__sanity, __base, - __cloc); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) - __v = __ull; - else - __err |= ios_base::failbit; - } - } -#endif - - template<> - void __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, - const __c_locale& __cloc, int) + const __c_locale& __cloc) { if (!(__err & ios_base::failbit)) { char* __sanity; errno = 0; float __f = __strtof_l(__s, &__sanity, __cloc); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) + if (__sanity != __s && errno != ERANGE) __v = __f; else __err |= ios_base::failbit; @@ -133,14 +61,14 @@ namespace std template<> void __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err, - const __c_locale& __cloc, int) + const __c_locale& __cloc) { if (!(__err & ios_base::failbit)) { char* __sanity; errno = 0; double __d = __strtod_l(__s, &__sanity, __cloc); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) + if (__sanity != __s && errno != ERANGE) __v = __d; else __err |= ios_base::failbit; @@ -150,14 +78,14 @@ namespace std template<> void __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err, - const __c_locale& __cloc, int) + const __c_locale& __cloc) { if (!(__err & ios_base::failbit)) { char* __sanity; errno = 0; long double __ld = __strtold_l(__s, &__sanity, __cloc); - if (__sanity != __s && *__sanity == '\0' && errno != ERANGE) + if (__sanity != __s && errno != ERANGE) __v = __ld; else __err |= ios_base::failbit; @@ -172,23 +100,26 @@ namespace std if (!__cloc) { // This named locale is not supported by the underlying OS. - __throw_runtime_error("attempt to create locale from unknown name"); + __throw_runtime_error(__N("locale::facet::_S_create_c_locale " + "name not valid")); } } void locale::facet::_S_destroy_c_locale(__c_locale& __cloc) { - if (_S_c_locale != __cloc) + if (_S_get_c_locale() != __cloc) __freelocale(__cloc); } __c_locale locale::facet::_S_clone_c_locale(__c_locale& __cloc) { return __duplocale(__cloc); } +} // namespace std - const char* locale::_S_categories[_S_categories_size - + _S_extra_categories_size] = +namespace __gnu_cxx +{ + const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] = { "LC_CTYPE", "LC_NUMERIC", @@ -203,4 +134,9 @@ namespace std "LC_MEASUREMENT", "LC_IDENTIFICATION" }; +} + +namespace std +{ + const char* const* const locale::_S_categories = __gnu_cxx::category_names; } // namespace std diff --git a/contrib/libstdc++/config/locale/gnu/c_locale.h b/contrib/libstdc++/config/locale/gnu/c_locale.h index 37df3fa..fe899cf 100644 --- a/contrib/libstdc++/config/locale/gnu/c_locale.h +++ b/contrib/libstdc++/config/locale/gnu/c_locale.h @@ -1,6 +1,6 @@ // Wrapper for underlying C-language localization -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -33,19 +33,21 @@ // Written by Benjamin Kosnik <bkoz@redhat.com> -#ifndef _CPP_BITS_C_LOCALE_H -#define _CPP_BITS_C_LOCALE_H 1 +#ifndef _C_LOCALE_H +#define _C_LOCALE_H 1 #pragma GCC system_header +#include <cstring> // get std::strlen +#include <cstdio> // get std::snprintf or std::sprintf #include <clocale> #include <langinfo.h> // For codecvt #include <iconv.h> // For codecvt using iconv, iconv_t #include <libintl.h> // For messages -#define _GLIBCPP_C_LOCALE_GNU 1 +#define _GLIBCXX_C_LOCALE_GNU 1 -#define _GLIBCPP_NUM_CATEGORIES 6 +#define _GLIBCXX_NUM_CATEGORIES 6 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) namespace __gnu_cxx @@ -72,31 +74,30 @@ namespace std #else _Tv __v, const __c_locale&, int __prec = -1) { - char* __old = setlocale(LC_ALL, NULL); - char* __sav = static_cast<char*>(malloc(strlen(__old) + 1)); - if (__sav) - strcpy(__sav, __old); - setlocale(LC_ALL, "C"); + char* __old = std::setlocale(LC_ALL, NULL); + char* __sav = new char[std::strlen(__old) + 1]; + std::strcpy(__sav, __old); + std::setlocale(LC_ALL, "C"); #endif int __ret; -#ifdef _GLIBCPP_USE_C99 +#ifdef _GLIBCXX_USE_C99 if (__prec >= 0) - __ret = snprintf(__out, __size, __fmt, __prec, __v); + __ret = std::snprintf(__out, __size, __fmt, __prec, __v); else - __ret = snprintf(__out, __size, __fmt, __v); + __ret = std::snprintf(__out, __size, __fmt, __v); #else if (__prec >= 0) - __ret = sprintf(__out, __fmt, __prec, __v); + __ret = std::sprintf(__out, __fmt, __prec, __v); else - __ret = sprintf(__out, __fmt, __v); + __ret = std::sprintf(__out, __fmt, __v); #endif #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __gnu_cxx::__uselocale(__old); #else - setlocale(LC_ALL, __sav); - free(__sav); + std::setlocale(LC_ALL, __sav); + delete [] __sav; #endif return __ret; } diff --git a/contrib/libstdc++/config/locale/gnu/codecvt_members.cc b/contrib/libstdc++/config/locale/gnu/codecvt_members.cc index c3d3e34..3a3e324 100644 --- a/contrib/libstdc++/config/locale/gnu/codecvt_members.cc +++ b/contrib/libstdc++/config/locale/gnu/codecvt_members.cc @@ -39,7 +39,7 @@ namespace std { // Specializations. -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T codecvt_base::result codecvt<wchar_t, char, mbstate_t>:: do_out(state_type& __state, const intern_type* __from, @@ -47,31 +47,71 @@ namespace std extern_type* __to, extern_type* __to_end, extern_type*& __to_next) const { - result __ret = error; - size_t __len = min(__from_end - __from, __to_end - __to); + result __ret = ok; + state_type __tmp_state(__state); + #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __c_locale __old = __uselocale(_S_c_locale); + __c_locale __old = __uselocale(_M_c_locale_codecvt); #endif - size_t __conv = wcsrtombs(__to, &__from, __len, &__state); + + // wcsnrtombs is *very* fast but stops if encounters NUL characters: + // in case we fall back to wcrtomb and then continue, in a loop. + // NB: wcsnrtombs is a GNU extension + for (__from_next = __from, __to_next = __to; + __from_next < __from_end && __to_next < __to_end + && __ret == ok;) + { + const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0', + __from_end - __from_next); + if (!__from_chunk_end) + __from_chunk_end = __from_end; + + __from = __from_next; + const size_t __conv = wcsnrtombs(__to_next, &__from_next, + __from_chunk_end - __from_next, + __to_end - __to_next, &__state); + if (__conv == static_cast<size_t>(-1)) + { + // In case of error, in order to stop at the exact place we + // have to start again from the beginning with a series of + // wcrtomb. + for (; __from < __from_next; ++__from) + __to_next += wcrtomb(__to_next, *__from, &__tmp_state); + __state = __tmp_state; + __ret = error; + } + else if (__from_next && __from_next < __from_chunk_end) + { + __to_next += __conv; + __ret = partial; + } + else + { + __from_next = __from_chunk_end; + __to_next += __conv; + } + + if (__from_next < __from_end && __ret == ok) + { + extern_type __buf[MB_LEN_MAX]; + __tmp_state = __state; + const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state); + if (__conv > static_cast<size_t>(__to_end - __to_next)) + __ret = partial; + else + { + memcpy(__to_next, __buf, __conv); + __state = __tmp_state; + __to_next += __conv; + ++__from_next; + } + } + } + #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); #endif - if (__conv == __len) - { - __from_next = __from; - __to_next = __to + __conv; - __ret = ok; - } - else if (__conv > 0 && __conv < __len) - { - __from_next = __from; - __to_next = __to + __conv; - __ret = partial; - } - else - __ret = error; - return __ret; } @@ -82,31 +122,184 @@ namespace std intern_type* __to, intern_type* __to_end, intern_type*& __to_next) const { - result __ret = error; - size_t __len = min(__from_end - __from, __to_end - __to); + result __ret = ok; + state_type __tmp_state(__state); + #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __c_locale __old = __uselocale(_S_c_locale); + __c_locale __old = __uselocale(_M_c_locale_codecvt); #endif - size_t __conv = mbsrtowcs(__to, &__from, __len, &__state); + + // mbsnrtowcs is *very* fast but stops if encounters NUL characters: + // in case we store a L'\0' and then continue, in a loop. + // NB: mbsnrtowcs is a GNU extension + for (__from_next = __from, __to_next = __to; + __from_next < __from_end && __to_next < __to_end + && __ret == ok;) + { + const extern_type* __from_chunk_end; + __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0', + __from_end + - __from_next)); + if (!__from_chunk_end) + __from_chunk_end = __from_end; + + __from = __from_next; + size_t __conv = mbsnrtowcs(__to_next, &__from_next, + __from_chunk_end - __from_next, + __to_end - __to_next, &__state); + if (__conv == static_cast<size_t>(-1)) + { + // In case of error, in order to stop at the exact place we + // have to start again from the beginning with a series of + // mbrtowc. + for (;; ++__to_next, __from += __conv) + { + __conv = mbrtowc(__to_next, __from, __from_end - __from, + &__tmp_state); + if (__conv == static_cast<size_t>(-1) + || __conv == static_cast<size_t>(-2)) + break; + } + __from_next = __from; + __state = __tmp_state; + __ret = error; + } + else if (__from_next && __from_next < __from_chunk_end) + { + // It is unclear what to return in this case (see DR 382). + __to_next += __conv; + __ret = partial; + } + else + { + __from_next = __from_chunk_end; + __to_next += __conv; + } + + if (__from_next < __from_end && __ret == ok) + { + if (__to_next < __to_end) + { + // XXX Probably wrong for stateful encodings + __tmp_state = __state; + ++__from_next; + *__to_next++ = L'\0'; + } + else + __ret = partial; + } + } + #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); #endif - if (__conv == __len) - { - __from_next = __from; - __to_next = __to + __conv; - __ret = ok; - } - else if (__conv > 0 && __conv < __len) + return __ret; + } + + int + codecvt<wchar_t, char, mbstate_t>:: + do_encoding() const throw() + { + // XXX This implementation assumes that the encoding is + // stateless and is either single-byte or variable-width. + int __ret = 0; +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __c_locale __old = __uselocale(_M_c_locale_codecvt); +#endif + if (MB_CUR_MAX == 1) + __ret = 1; +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __uselocale(__old); +#endif + return __ret; + } + + int + codecvt<wchar_t, char, mbstate_t>:: + do_max_length() const throw() + { +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __c_locale __old = __uselocale(_M_c_locale_codecvt); +#endif + // XXX Probably wrong for stateful encodings. + int __ret = MB_CUR_MAX; +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __uselocale(__old); +#endif + return __ret; + } + + int + codecvt<wchar_t, char, mbstate_t>:: + do_length(state_type& __state, const extern_type* __from, + const extern_type* __end, size_t __max) const + { + int __ret = 0; + state_type __tmp_state(__state); + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __c_locale __old = __uselocale(_M_c_locale_codecvt); +#endif + + // mbsnrtowcs is *very* fast but stops if encounters NUL characters: + // in case we advance past it and then continue, in a loop. + // NB: mbsnrtowcs is a GNU extension + + // A dummy internal buffer is needed in order for mbsnrtocws to consider + // its fourth parameter (it wouldn't with NULL as first parameter). + wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t) + * __max)); + while (__from < __end && __max) { - __from_next = __from; - __to_next = __to + __conv; - __ret = partial; - } - else - __ret = error; + const extern_type* __from_chunk_end; + __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0', + __end + - __from)); + if (!__from_chunk_end) + __from_chunk_end = __end; + + const extern_type* __tmp_from = __from; + size_t __conv = mbsnrtowcs(__to, &__from, + __from_chunk_end - __from, + __max, &__state); + if (__conv == static_cast<size_t>(-1)) + { + // In case of error, in order to stop at the exact place we + // have to start again from the beginning with a series of + // mbrtowc. + for (__from = __tmp_from;; __from += __conv) + { + __conv = mbrtowc(NULL, __from, __end - __from, + &__tmp_state); + if (__conv == static_cast<size_t>(-1) + || __conv == static_cast<size_t>(-2)) + break; + } + __state = __tmp_state; + __ret += __from - __tmp_from; + break; + } + if (!__from) + __from = __from_chunk_end; + __ret += __from - __tmp_from; + __max -= __conv; + + if (__from < __end && __max) + { + // XXX Probably wrong for stateful encodings + __tmp_state = __state; + ++__from; + ++__ret; + --__max; + } + } + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __uselocale(__old); +#endif + return __ret; } #endif diff --git a/contrib/libstdc++/config/locale/gnu/collate_members.cc b/contrib/libstdc++/config/locale/gnu/collate_members.cc index 1ac2094..573aa65 100644 --- a/contrib/libstdc++/config/locale/gnu/collate_members.cc +++ b/contrib/libstdc++/config/locale/gnu/collate_members.cc @@ -54,7 +54,7 @@ namespace std size_t __n) const { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> int collate<wchar_t>::_M_compare(const wchar_t* __one, diff --git a/contrib/libstdc++/config/locale/gnu/ctype_members.cc b/contrib/libstdc++/config/locale/gnu/ctype_members.cc index ee4cc0a..7c53c15 100644 --- a/contrib/libstdc++/config/locale/gnu/ctype_members.cc +++ b/contrib/libstdc++/config/locale/gnu/ctype_members.cc @@ -1,6 +1,6 @@ // std::ctype implementation details, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -43,15 +43,18 @@ namespace std template<> ctype_byname<char>::ctype_byname(const char* __s, size_t __refs) : ctype<char>(0, false, __refs) - { - _S_destroy_c_locale(_M_c_locale_ctype); - _S_create_c_locale(_M_c_locale_ctype, __s); - _M_toupper = _M_c_locale_ctype->__ctype_toupper; - _M_tolower = _M_c_locale_ctype->__ctype_tolower; - _M_table = _M_c_locale_ctype->__ctype_b; + { + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_ctype); + this->_S_create_c_locale(this->_M_c_locale_ctype, __s); + this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper; + this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower; + this->_M_table = this->_M_c_locale_ctype->__ctype_b; + } } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T ctype<wchar_t>::__wmask_type ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const { @@ -95,7 +98,7 @@ namespace std __ret = 0; } return __ret; - }; + } wchar_t ctype<wchar_t>::do_toupper(wchar_t __c) const @@ -136,12 +139,12 @@ namespace std bool __ret = false; const size_t __bitmasksize = 11; for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) - { - const mask __bit = static_cast<mask>(_ISbit(__bitcur)); - if (__m & __bit) - __ret |= __iswctype_l(__c, _M_convert_to_wmask(__bit), - _M_c_locale_ctype); - } + if (__m & _M_bit[__bitcur] + && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype)) + { + __ret = true; + break; + } return __ret; } @@ -149,19 +152,15 @@ namespace std ctype<wchar_t>:: do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const { - for (;__lo < __hi; ++__vec, ++__lo) + for (; __lo < __hi; ++__vec, ++__lo) { // Highest bitmask in ctype_base == 10, but extra in "C" // library for blank. const size_t __bitmasksize = 11; mask __m = 0; for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) - { - const mask __bit = static_cast<mask>(_ISbit(__bitcur)); - if (__iswctype_l(*__lo, _M_convert_to_wmask(__bit), - _M_c_locale_ctype)) - __m |= __bit; - } + if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype)) + __m |= _M_bit[__bitcur]; *__vec = __m; } return __hi; @@ -188,41 +187,31 @@ namespace std wchar_t ctype<wchar_t>:: do_widen(char __c) const - { -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __c_locale __old = __uselocale(_M_c_locale_ctype); -#endif - wchar_t __ret = btowc(__c); -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __uselocale(__old); -#endif - return __ret; - } + { return _M_widen[static_cast<unsigned char>(__c)]; } const char* ctype<wchar_t>:: do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const { -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __c_locale __old = __uselocale(_M_c_locale_ctype); -#endif - mbstate_t __state; - memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t)); - mbsrtowcs(__dest, &__lo, __hi - __lo, &__state); -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __uselocale(__old); -#endif + while (__lo < __hi) + { + *__dest = _M_widen[static_cast<unsigned char>(*__lo)]; + ++__lo; + ++__dest; + } return __hi; } char ctype<wchar_t>:: do_narrow(wchar_t __wc, char __dfault) const - { + { + if (__wc >= 0 && __wc < 128 && _M_narrow_ok) + return _M_narrow[__wc]; #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __c_locale __old = __uselocale(_M_c_locale_ctype); #endif - int __c = wctob(__wc); + const int __c = wctob(__wc); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); #endif @@ -237,27 +226,64 @@ namespace std #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __c_locale __old = __uselocale(_M_c_locale_ctype); #endif - size_t __offset = 0; - while (true) + if (_M_narrow_ok) + while (__lo < __hi) + { + if (*__lo >= 0 && *__lo < 128) + *__dest = _M_narrow[*__lo]; + else + { + const int __c = wctob(*__lo); + *__dest = (__c == EOF ? __dfault : static_cast<char>(__c)); + } + ++__lo; + ++__dest; + } + else + while (__lo < __hi) + { + const int __c = wctob(*__lo); + *__dest = (__c == EOF ? __dfault : static_cast<char>(__c)); + ++__lo; + ++__dest; + } +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __uselocale(__old); +#endif + return __hi; + } + + void + ctype<wchar_t>::_M_initialize_ctype() + { +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __c_locale __old = __uselocale(_M_c_locale_ctype); +#endif + wint_t __i; + for (__i = 0; __i < 128; ++__i) { - const wchar_t* __start = __lo + __offset; - size_t __len = __hi - __start; - - mbstate_t __state; - memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t)); - size_t __con = wcsrtombs(__dest + __offset, &__start, __len, &__state); - if (__con != __len && __start != 0) - { - __offset = __start - __lo; - __dest[__offset++] = __dfault; - } - else + const int __c = wctob(__i); + if (__c == EOF) break; + else + _M_narrow[__i] = static_cast<char>(__c); + } + if (__i == 128) + _M_narrow_ok = true; + else + _M_narrow_ok = false; + for (size_t __j = 0; + __j < sizeof(_M_widen) / sizeof(wint_t); ++__j) + _M_widen[__j] = btowc(__j); + + for (size_t __k = 0; __k <= 11; ++__k) + { + _M_bit[__k] = static_cast<mask>(_ISbit(__k)); + _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]); } #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); #endif - return __hi; } -#endif // _GLIBCPP_USE_WCHAR_T +#endif // _GLIBCXX_USE_WCHAR_T } diff --git a/contrib/libstdc++/config/locale/gnu/messages_members.cc b/contrib/libstdc++/config/locale/gnu/messages_members.cc index fad01df..1aa9c06 100644 --- a/contrib/libstdc++/config/locale/gnu/messages_members.cc +++ b/contrib/libstdc++/config/locale/gnu/messages_members.cc @@ -58,7 +58,7 @@ namespace std #endif } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> wstring messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const diff --git a/contrib/libstdc++/config/locale/gnu/messages_members.h b/contrib/libstdc++/config/locale/gnu/messages_members.h index d98d8d1..a7cd1cd 100644 --- a/contrib/libstdc++/config/locale/gnu/messages_members.h +++ b/contrib/libstdc++/config/locale/gnu/messages_members.h @@ -1,6 +1,6 @@ // std::messages implementation details, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -36,24 +36,19 @@ // Non-virtual member functions. template<typename _CharT> messages<_CharT>::messages(size_t __refs) - : locale::facet(__refs) - { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - _M_name_messages = _S_c_name; -#endif - _M_c_locale_messages = _S_c_locale; - } + : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), + _M_name_messages(_S_get_c_name()) + { } template<typename _CharT> - messages<_CharT>::messages(__c_locale __cloc, - const char* __s, size_t __refs) - : locale::facet(__refs) + messages<_CharT>::messages(__c_locale __cloc, const char* __s, + size_t __refs) + : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)), + _M_name_messages(__s) { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - _M_name_messages = new char[strlen(__s) + 1]; - strcpy(_M_name_messages, __s); -#endif - _M_c_locale_messages = _S_clone_c_locale(__cloc); + char* __tmp = new char[std::strlen(__s) + 1]; + std::strcpy(__tmp, __s); + _M_name_messages = __tmp; } template<typename _CharT> @@ -69,10 +64,8 @@ template<typename _CharT> messages<_CharT>::~messages() { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - if (_S_c_name != _M_name_messages) + if (_M_name_messages != _S_get_c_name()) delete [] _M_name_messages; -#endif _S_destroy_c_locale(_M_c_locale_messages); } @@ -97,12 +90,15 @@ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - if (_S_c_name != _M_name_messages) - delete [] _M_name_messages; - _M_name_messages = new char[strlen(__s) + 1]; - strcpy(_M_name_messages, __s); -#endif - _S_destroy_c_locale(_M_c_locale_messages); - _S_create_c_locale(_M_c_locale_messages, __s); + 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); + this->_M_name_messages = __tmp; + + if (std::strcmp(__s, "C") != 0 && std::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); + } } diff --git a/contrib/libstdc++/config/locale/gnu/monetary_members.cc b/contrib/libstdc++/config/locale/gnu/monetary_members.cc index b3ef13b..38d9c39 100644 --- a/contrib/libstdc++/config/locale/gnu/monetary_members.cc +++ b/contrib/libstdc++/config/locale/gnu/monetary_members.cc @@ -1,6 +1,6 @@ // std::moneypunct implementation details, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -63,22 +63,21 @@ namespace std case 0: case 1: // 1 The sign precedes the value and symbol. + __ret.field[0] = sign; if (__space) { // Pattern starts with sign. if (__precedes) { __ret.field[1] = symbol; - __ret.field[2] = space; __ret.field[3] = value; } else { __ret.field[1] = value; - __ret.field[2] = space; __ret.field[3] = symbol; } - __ret.field[0] = sign; + __ret.field[2] = space; } else { @@ -93,7 +92,6 @@ namespace std __ret.field[1] = value; __ret.field[2] = symbol; } - __ret.field[0] = sign; __ret.field[3] = none; } break; @@ -105,15 +103,14 @@ namespace std if (__precedes) { __ret.field[0] = symbol; - __ret.field[1] = space; __ret.field[2] = value; } else { __ret.field[0] = value; - __ret.field[1] = space; __ret.field[2] = symbol; } + __ret.field[1] = space; __ret.field[3] = sign; } else @@ -135,78 +132,70 @@ namespace std break; case 3: // 3 The sign immediately precedes the symbol. - if (__space) + if (__precedes) { - // Have space. - if (__precedes) + __ret.field[0] = sign; + __ret.field[1] = symbol; + if (__space) { - __ret.field[0] = sign; - __ret.field[1] = symbol; __ret.field[2] = space; __ret.field[3] = value; } else { - __ret.field[0] = value; - __ret.field[1] = space; - __ret.field[2] = sign; - __ret.field[3] = symbol; + __ret.field[2] = value; + __ret.field[3] = none; } } else { - // Have none. - if (__precedes) + __ret.field[0] = value; + if (__space) { - __ret.field[0] = sign; - __ret.field[1] = symbol; - __ret.field[2] = value; + __ret.field[1] = space; + __ret.field[2] = sign; + __ret.field[3] = symbol; } else { - __ret.field[0] = value; __ret.field[1] = sign; __ret.field[2] = symbol; + __ret.field[3] = none; } - __ret.field[3] = none; } break; case 4: - // 4 The sign immediately follows the symbol. - if (__space) + // 4 The sign immediately follows the symbol. + if (__precedes) { - // Have space. - if (__precedes) + __ret.field[0] = symbol; + __ret.field[1] = sign; + if (__space) { - __ret.field[0] = symbol; - __ret.field[1] = sign; __ret.field[2] = space; __ret.field[3] = value; } else { - __ret.field[0] = value; - __ret.field[1] = space; - __ret.field[2] = symbol; - __ret.field[3] = sign; + __ret.field[2] = value; + __ret.field[3] = none; } } else { - // Have none. - if (__precedes) + __ret.field[0] = value; + if (__space) { - __ret.field[0] = symbol; - __ret.field[1] = sign; - __ret.field[2] = value; + __ret.field[1] = space; + __ret.field[2] = symbol; + __ret.field[3] = sign; } else { - __ret.field[0] = value; __ret.field[1] = symbol; __ret.field[2] = sign; + __ret.field[3] = none; } - __ret.field[3] = none; } break; default: @@ -220,43 +209,63 @@ namespace std moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc, const char*) { + if (!_M_data) + _M_data = new __moneypunct_cache<char, true>; + if (!__cloc) { // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } else { // Named locale. - _M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, __cloc)); - _M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); - _M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, + __cloc)); + _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, + __cloc)); + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); + _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign); char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); if (!__nposn) - _M_negative_sign = "()"; + _M_data->_M_negative_sign = "()"; else - _M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); + _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, + __cloc); + _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign); // _Intl == true - _M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); - _M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, __cloc)); + _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); + _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol); + _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, + __cloc)); char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); } } @@ -265,55 +274,74 @@ namespace std moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc, const char*) { + if (!_M_data) + _M_data = new __moneypunct_cache<char, false>; + if (!__cloc) { // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; - _M_curr_symbol = ""; - _M_positive_sign = ""; - _M_negative_sign = ""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; } else { // Named locale. - _M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, __cloc)); - _M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); - _M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT, + __cloc)); + _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, + __cloc)); + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); + _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign); char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); if (!__nposn) - _M_negative_sign = "()"; + _M_data->_M_negative_sign = "()"; else - _M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); + _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, + __cloc); + _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign); // _Intl == false - _M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); - _M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); + _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); + _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol); + _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); } } template<> moneypunct<char, true>::~moneypunct() - { } + { delete _M_data; } template<> moneypunct<char, false>::~moneypunct() - { } + { delete _M_data; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc, @@ -323,18 +351,33 @@ namespace std const char* __name) #endif { + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t, true>; + if (!__cloc) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + // Use ctype::widen code without the facet... + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } else { @@ -347,64 +390,93 @@ namespace std setlocale(LC_ALL, __name); #endif - _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w); + union __s_and_w { const char *__s; unsigned int __w; } __u; + __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc); + _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w); - _M_thousands_sep = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w); - _M_grouping = __nl_langinfo_l(GROUPING, __cloc); + __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc); + _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w); + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); - mbstate_t __state; - size_t __len = strlen(__cpossign); - if (__len) + wchar_t* __wcs_ps = 0; + wchar_t* __wcs_ns = 0; + const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); + try { - ++__len; - memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__cpossign, __len, &__state); - _M_positive_sign = __wcs; - } - else - _M_positive_sign = L""; - - char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); - __len = strlen(__cnegsign); - if (!__nposn) - _M_negative_sign = L"()"; - else if (__len) - { - ++__len; - memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__cnegsign, __len, &__state); - _M_negative_sign = __wcs; + mbstate_t __state; + size_t __len = strlen(__cpossign); + if (__len) + { + ++__len; + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ps = new wchar_t[__len]; + mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state); + _M_data->_M_positive_sign = __wcs_ps; + } + else + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign); + + __len = strlen(__cnegsign); + if (!__nposn) + _M_data->_M_negative_sign = L"()"; + else if (__len) + { + ++__len; + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ns = new wchar_t[__len]; + mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state); + _M_data->_M_negative_sign = __wcs_ns; + } + else + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign); + + // _Intl == true. + __len = strlen(__ccurr); + if (__len) + { + ++__len; + memset(&__state, 0, sizeof(mbstate_t)); + wchar_t* __wcs = new wchar_t[__len]; + mbsrtowcs(__wcs, &__ccurr, __len, &__state); + _M_data->_M_curr_symbol = __wcs; + } + else + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); } - else - _M_negative_sign = L""; - - // _Intl == true. - __len = strlen(__ccurr); - if (__len) + catch (...) { - ++__len; - memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__ccurr, __len, &__state); - _M_curr_symbol = __wcs; - } - else - _M_curr_symbol = L""; - - _M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, __cloc)); + delete _M_data; + _M_data = 0; + delete __wcs_ps; + delete __wcs_ns; +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __uselocale(__old); +#else + setlocale(LC_ALL, __old); + free(__old); +#endif + __throw_exception_again; + } + + _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, + __cloc)); char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); @@ -416,26 +488,41 @@ namespace std } template<> - void - moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc, -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - const char*) + void + moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc, +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + const char*) #else - const char* __name) + const char* __name) #endif - { - if (!__cloc) + { + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t, false>; + + if (!__cloc) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; - _M_curr_symbol = L""; - _M_positive_sign = L""; - _M_negative_sign = L""; - _M_frac_digits = 0; - _M_pos_format = money_base::_S_default_pattern; - _M_neg_format = money_base::_S_default_pattern; + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = 0; + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = 0; + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = 0; + _M_data->_M_frac_digits = 0; + _M_data->_M_pos_format = money_base::_S_default_pattern; + _M_data->_M_neg_format = money_base::_S_default_pattern; + + // Use ctype::widen code without the facet... + unsigned char uc; + for (size_t __i = 0; __i < money_base::_S_end; ++__i) + { + uc = static_cast<unsigned char>(money_base::_S_atoms[__i]); + _M_data->_M_atoms[__i] = btowc(uc); + } } else { @@ -448,64 +535,93 @@ namespace std setlocale(LC_ALL, __name); #endif - _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w); - _M_thousands_sep = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w); - _M_grouping = __nl_langinfo_l(GROUPING, __cloc); + union __s_and_w { const char *__s; unsigned int __w; } __u; + __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc); + _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w); + + __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc); + _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w); + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); - mbstate_t __state; - size_t __len; - __len = strlen(__cpossign); - if (__len) - { - ++__len; - memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__cpossign, __len, &__state); - _M_positive_sign = __wcs; + wchar_t* __wcs_ps = 0; + wchar_t* __wcs_ns = 0; + const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); + try + { + mbstate_t __state; + size_t __len; + __len = strlen(__cpossign); + if (__len) + { + ++__len; + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ps = new wchar_t[__len]; + mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state); + _M_data->_M_positive_sign = __wcs_ps; + } + else + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign); + + __len = strlen(__cnegsign); + if (!__nposn) + _M_data->_M_negative_sign = L"()"; + else if (__len) + { + ++__len; + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ns = new wchar_t[__len]; + mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state); + _M_data->_M_negative_sign = __wcs_ns; + } + else + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign); + + // _Intl == true. + __len = strlen(__ccurr); + if (__len) + { + ++__len; + memset(&__state, 0, sizeof(mbstate_t)); + wchar_t* __wcs = new wchar_t[__len]; + mbsrtowcs(__wcs, &__ccurr, __len, &__state); + _M_data->_M_curr_symbol = __wcs; + } + else + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); } - else - _M_positive_sign = L""; - - char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); - __len = strlen(__cnegsign); - if (!__nposn) - _M_negative_sign = L"()"; - else if (__len) - { - ++__len; - memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__cnegsign, __len, &__state); - _M_negative_sign = __wcs; - } - else - _M_negative_sign = L""; - - // _Intl == true. - __len = strlen(__ccurr); - if (__len) + catch (...) { - ++__len; - memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__ccurr, __len, &__state); - _M_curr_symbol = __wcs; + delete _M_data; + _M_data = 0; + delete __wcs_ps; + delete __wcs_ns; +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __uselocale(__old); +#else + setlocale(LC_ALL, __old); + free(__old); +#endif + __throw_exception_again; } - else - _M_curr_symbol = L""; - _M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); + _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc)); - _M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc)); - _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __uselocale(__old); @@ -519,23 +635,27 @@ namespace std template<> moneypunct<wchar_t, true>::~moneypunct() { - if (wcslen(_M_positive_sign)) - delete [] _M_positive_sign; - if (wcslen(_M_negative_sign) && (wcscmp(_M_negative_sign, L"()") != 0)) - delete [] _M_negative_sign; - if (wcslen(_M_curr_symbol)) - delete [] _M_curr_symbol; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && wcscmp(_M_data->_M_negative_sign, L"()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; } template<> moneypunct<wchar_t, false>::~moneypunct() { - if (wcslen(_M_positive_sign)) - delete [] _M_positive_sign; - if (wcslen(_M_negative_sign) && (wcscmp(_M_negative_sign, L"()") != 0)) - delete [] _M_negative_sign; - if (wcslen(_M_curr_symbol)) - delete [] _M_curr_symbol; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && wcscmp(_M_data->_M_negative_sign, L"()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; } #endif } diff --git a/contrib/libstdc++/config/locale/gnu/numeric_members.cc b/contrib/libstdc++/config/locale/gnu/numeric_members.cc index 1aa0529..20f51c1 100644 --- a/contrib/libstdc++/config/locale/gnu/numeric_members.cc +++ b/contrib/libstdc++/config/locale/gnu/numeric_members.cc @@ -1,6 +1,6 @@ // std::numpunct implementation details, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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,66 +42,120 @@ namespace std void numpunct<char>::_M_initialize_numpunct(__c_locale __cloc) { + if (!_M_data) + _M_data = new __numpunct_cache<char>; + if (!__cloc) { // "C" locale - _M_decimal_point = '.'; - _M_thousands_sep = ','; - _M_grouping = ""; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + + for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) + _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i]; + + for (size_t __j = 0; __j < __num_base::_S_iend; ++__j) + _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j]; } else { // Named locale. - _M_decimal_point = *(__nl_langinfo_l(RADIXCHAR, __cloc)); - _M_thousands_sep = *(__nl_langinfo_l(THOUSEP, __cloc)); - // Check for NUL, which implies no grouping. - if (_M_thousands_sep == '\0') - _M_grouping = ""; + _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT, + __cloc)); + _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP, + __cloc)); + + // Check for NULL, which implies no grouping. + if (_M_data->_M_thousands_sep == '\0') + _M_data->_M_grouping = ""; else - _M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); } + // NB: There is no way to extact this info from posix locales. // _M_truename = __nl_langinfo_l(YESSTR, __cloc); - _M_truename = "true"; + _M_data->_M_truename = "true"; + _M_data->_M_truename_size = strlen(_M_data->_M_truename); // _M_falsename = __nl_langinfo_l(NOSTR, __cloc); - _M_falsename = "false"; + _M_data->_M_falsename = "false"; + _M_data->_M_falsename_size = strlen(_M_data->_M_falsename); } template<> numpunct<char>::~numpunct() - { } + { delete _M_data; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc) { + if (!_M_data) + _M_data = new __numpunct_cache<wchar_t>; + if (!__cloc) { // "C" locale - _M_decimal_point = L'.'; - _M_thousands_sep = L','; - _M_grouping = ""; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + + _M_data->_M_decimal_point = L'.'; + _M_data->_M_thousands_sep = L','; + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __c_locale __old = __uselocale(_S_get_c_locale()); +#endif + // Use ctype::widen code without the facet... + unsigned char uc; + for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) + { + uc = static_cast<unsigned char>(__num_base::_S_atoms_out[__i]); + _M_data->_M_atoms_out[__i] = btowc(uc); + } + + for (size_t __j = 0; __j < __num_base::_S_iend; ++__j) + { + uc = static_cast<unsigned char>(__num_base::_S_atoms_in[__j]); + _M_data->_M_atoms_in[__j] = btowc(uc); + } +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __uselocale(__old); +#endif } else { // Named locale. - _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w); - _M_thousands_sep = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w); - if (_M_thousands_sep == L'\0') - _M_grouping = ""; + union __s_and_w { const char *__s; unsigned int __w; } __u; + __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc); + _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w); + + __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc); + _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w); + + if (_M_data->_M_thousands_sep == L'\0') + _M_data->_M_grouping = ""; else - _M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); } + // NB: There is no way to extact this info from posix locales. // _M_truename = __nl_langinfo_l(YESSTR, __cloc); - _M_truename = L"true"; + _M_data->_M_truename = L"true"; + _M_data->_M_truename_size = wcslen(_M_data->_M_truename); // _M_falsename = __nl_langinfo_l(NOSTR, __cloc); - _M_falsename = L"false"; + _M_data->_M_falsename = L"false"; + _M_data->_M_falsename_size = wcslen(_M_data->_M_falsename); } template<> numpunct<wchar_t>::~numpunct() - { } + { delete _M_data; } #endif } diff --git a/contrib/libstdc++/config/locale/gnu/time_members.cc b/contrib/libstdc++/config/locale/gnu/time_members.cc index db590ef..a8e9687 100644 --- a/contrib/libstdc++/config/locale/gnu/time_members.cc +++ b/contrib/libstdc++/config/locale/gnu/time_members.cc @@ -1,6 +1,6 @@ // std::time_get, std::time_put implementation, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -60,130 +60,133 @@ namespace std void __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc) { + if (!_M_data) + _M_data = new __timepunct_cache<char>; + if (!__cloc) { // "C" locale - _M_c_locale_timepunct = _S_c_locale; - - _M_date_format = "%m/%d/%y"; - _M_date_era_format = "%m/%d/%y"; - _M_time_format = "%H:%M:%S"; - _M_time_era_format = "%H:%M:%S"; - _M_date_time_format = ""; - _M_date_time_era_format = ""; - _M_am = "AM"; - _M_pm = "PM"; - _M_am_pm_format = ""; + _M_c_locale_timepunct = _S_get_c_locale(); + + _M_data->_M_date_format = "%m/%d/%y"; + _M_data->_M_date_era_format = "%m/%d/%y"; + _M_data->_M_time_format = "%H:%M:%S"; + _M_data->_M_time_era_format = "%H:%M:%S"; + _M_data->_M_date_time_format = ""; + _M_data->_M_date_time_era_format = ""; + _M_data->_M_am = "AM"; + _M_data->_M_pm = "PM"; + _M_data->_M_am_pm_format = ""; // Day names, starting with "C"'s Sunday. - _M_day1 = "Sunday"; - _M_day2 = "Monday"; - _M_day3 = "Tuesday"; - _M_day4 = "Wednesday"; - _M_day5 = "Thursday"; - _M_day6 = "Friday"; - _M_day7 = "Saturday"; + _M_data->_M_day1 = "Sunday"; + _M_data->_M_day2 = "Monday"; + _M_data->_M_day3 = "Tuesday"; + _M_data->_M_day4 = "Wednesday"; + _M_data->_M_day5 = "Thursday"; + _M_data->_M_day6 = "Friday"; + _M_data->_M_day7 = "Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = "Sun"; - _M_day_a2 = "Mon"; - _M_day_a3 = "Tue"; - _M_day_a4 = "Wed"; - _M_day_a5 = "Thu"; - _M_day_a6 = "Fri"; - _M_day_a7 = "Sat"; + _M_data->_M_aday1 = "Sun"; + _M_data->_M_aday2 = "Mon"; + _M_data->_M_aday3 = "Tue"; + _M_data->_M_aday4 = "Wed"; + _M_data->_M_aday5 = "Thu"; + _M_data->_M_aday6 = "Fri"; + _M_data->_M_aday7 = "Sat"; // Month names, starting with "C"'s January. - _M_month01 = "January"; - _M_month02 = "February"; - _M_month03 = "March"; - _M_month04 = "April"; - _M_month05 = "May"; - _M_month06 = "June"; - _M_month07 = "July"; - _M_month08 = "August"; - _M_month09 = "September"; - _M_month10 = "October"; - _M_month11 = "November"; - _M_month12 = "December"; + _M_data->_M_month01 = "January"; + _M_data->_M_month02 = "February"; + _M_data->_M_month03 = "March"; + _M_data->_M_month04 = "April"; + _M_data->_M_month05 = "May"; + _M_data->_M_month06 = "June"; + _M_data->_M_month07 = "July"; + _M_data->_M_month08 = "August"; + _M_data->_M_month09 = "September"; + _M_data->_M_month10 = "October"; + _M_data->_M_month11 = "November"; + _M_data->_M_month12 = "December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = "Jan"; - _M_month_a02 = "Feb"; - _M_month_a03 = "Mar"; - _M_month_a04 = "Apr"; - _M_month_a05 = "May"; - _M_month_a06 = "Jun"; - _M_month_a07 = "July"; - _M_month_a08 = "Aug"; - _M_month_a09 = "Sep"; - _M_month_a10 = "Oct"; - _M_month_a11 = "Nov"; - _M_month_a12 = "Dec"; + _M_data->_M_amonth01 = "Jan"; + _M_data->_M_amonth02 = "Feb"; + _M_data->_M_amonth03 = "Mar"; + _M_data->_M_amonth04 = "Apr"; + _M_data->_M_amonth05 = "May"; + _M_data->_M_amonth06 = "Jun"; + _M_data->_M_amonth07 = "Jul"; + _M_data->_M_amonth08 = "Aug"; + _M_data->_M_amonth09 = "Sep"; + _M_data->_M_amonth10 = "Oct"; + _M_data->_M_amonth11 = "Nov"; + _M_data->_M_amonth12 = "Dec"; } else { _M_c_locale_timepunct = _S_clone_c_locale(__cloc); - _M_date_format = __nl_langinfo_l(D_FMT, __cloc); - _M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc); - _M_time_format = __nl_langinfo_l(T_FMT, __cloc); - _M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc); - _M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc); - _M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT, __cloc); - _M_am = __nl_langinfo_l(AM_STR, __cloc); - _M_pm = __nl_langinfo_l(PM_STR, __cloc); - _M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc); + _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc); + _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc); + _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc); + _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc); + _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc); + _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT, __cloc); + _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc); + _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc); + _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc); // Day names, starting with "C"'s Sunday. - _M_day1 = __nl_langinfo_l(DAY_1, __cloc); - _M_day2 = __nl_langinfo_l(DAY_2, __cloc); - _M_day3 = __nl_langinfo_l(DAY_3, __cloc); - _M_day4 = __nl_langinfo_l(DAY_4, __cloc); - _M_day5 = __nl_langinfo_l(DAY_5, __cloc); - _M_day6 = __nl_langinfo_l(DAY_6, __cloc); - _M_day7 = __nl_langinfo_l(DAY_7, __cloc); + _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc); + _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc); + _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc); + _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc); + _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc); + _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc); + _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc); // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = __nl_langinfo_l(ABDAY_1, __cloc); - _M_day_a2 = __nl_langinfo_l(ABDAY_2, __cloc); - _M_day_a3 = __nl_langinfo_l(ABDAY_3, __cloc); - _M_day_a4 = __nl_langinfo_l(ABDAY_4, __cloc); - _M_day_a5 = __nl_langinfo_l(ABDAY_5, __cloc); - _M_day_a6 = __nl_langinfo_l(ABDAY_6, __cloc); - _M_day_a7 = __nl_langinfo_l(ABDAY_7, __cloc); + _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc); + _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc); + _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc); + _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc); + _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc); + _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc); + _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc); // Month names, starting with "C"'s January. - _M_month01 = __nl_langinfo_l(MON_1, __cloc); - _M_month02 = __nl_langinfo_l(MON_2, __cloc); - _M_month03 = __nl_langinfo_l(MON_3, __cloc); - _M_month04 = __nl_langinfo_l(MON_4, __cloc); - _M_month05 = __nl_langinfo_l(MON_5, __cloc); - _M_month06 = __nl_langinfo_l(MON_6, __cloc); - _M_month07 = __nl_langinfo_l(MON_7, __cloc); - _M_month08 = __nl_langinfo_l(MON_8, __cloc); - _M_month09 = __nl_langinfo_l(MON_9, __cloc); - _M_month10 = __nl_langinfo_l(MON_10, __cloc); - _M_month11 = __nl_langinfo_l(MON_11, __cloc); - _M_month12 = __nl_langinfo_l(MON_12, __cloc); + _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc); + _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc); + _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc); + _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc); + _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc); + _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc); + _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc); + _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc); + _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc); + _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc); + _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc); + _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc); // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = __nl_langinfo_l(ABMON_1, __cloc); - _M_month_a02 = __nl_langinfo_l(ABMON_2, __cloc); - _M_month_a03 = __nl_langinfo_l(ABMON_3, __cloc); - _M_month_a04 = __nl_langinfo_l(ABMON_4, __cloc); - _M_month_a05 = __nl_langinfo_l(ABMON_5, __cloc); - _M_month_a06 = __nl_langinfo_l(ABMON_6, __cloc); - _M_month_a07 = __nl_langinfo_l(ABMON_7, __cloc); - _M_month_a08 = __nl_langinfo_l(ABMON_8, __cloc); - _M_month_a09 = __nl_langinfo_l(ABMON_9, __cloc); - _M_month_a10 = __nl_langinfo_l(ABMON_10, __cloc); - _M_month_a11 = __nl_langinfo_l(ABMON_11, __cloc); - _M_month_a12 = __nl_langinfo_l(ABMON_12, __cloc); + _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc); + _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc); + _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc); + _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc); + _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc); + _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc); + _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc); + _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc); + _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc); + _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc); + _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc); + _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc); } } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void __timepunct<wchar_t>:: @@ -205,126 +208,129 @@ namespace std void __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc) { + if (!_M_data) + _M_data = new __timepunct_cache<wchar_t>; + if (!__cloc) { // "C" locale - _M_c_locale_timepunct = _S_c_locale; - - _M_date_format = L"%m/%d/%y"; - _M_date_era_format = L"%m/%d/%y"; - _M_time_format = L"%H:%M:%S"; - _M_time_era_format = L"%H:%M:%S"; - _M_date_time_format = L""; - _M_date_time_era_format = L""; - _M_am = L"AM"; - _M_pm = L"PM"; - _M_am_pm_format = L""; + _M_c_locale_timepunct = _S_get_c_locale(); + + _M_data->_M_date_format = L"%m/%d/%y"; + _M_data->_M_date_era_format = L"%m/%d/%y"; + _M_data->_M_time_format = L"%H:%M:%S"; + _M_data->_M_time_era_format = L"%H:%M:%S"; + _M_data->_M_date_time_format = L""; + _M_data->_M_date_time_era_format = L""; + _M_data->_M_am = L"AM"; + _M_data->_M_pm = L"PM"; + _M_data->_M_am_pm_format = L""; // Day names, starting with "C"'s Sunday. - _M_day1 = L"Sunday"; - _M_day2 = L"Monday"; - _M_day3 = L"Tuesday"; - _M_day4 = L"Wednesday"; - _M_day5 = L"Thursday"; - _M_day6 = L"Friday"; - _M_day7 = L"Saturday"; + _M_data->_M_day1 = L"Sunday"; + _M_data->_M_day2 = L"Monday"; + _M_data->_M_day3 = L"Tuesday"; + _M_data->_M_day4 = L"Wednesday"; + _M_data->_M_day5 = L"Thursday"; + _M_data->_M_day6 = L"Friday"; + _M_data->_M_day7 = L"Saturday"; // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = L"Sun"; - _M_day_a2 = L"Mon"; - _M_day_a3 = L"Tue"; - _M_day_a4 = L"Wed"; - _M_day_a5 = L"Thu"; - _M_day_a6 = L"Fri"; - _M_day_a7 = L"Sat"; + _M_data->_M_aday1 = L"Sun"; + _M_data->_M_aday2 = L"Mon"; + _M_data->_M_aday3 = L"Tue"; + _M_data->_M_aday4 = L"Wed"; + _M_data->_M_aday5 = L"Thu"; + _M_data->_M_aday6 = L"Fri"; + _M_data->_M_aday7 = L"Sat"; // Month names, starting with "C"'s January. - _M_month01 = L"January"; - _M_month02 = L"February"; - _M_month03 = L"March"; - _M_month04 = L"April"; - _M_month05 = L"May"; - _M_month06 = L"June"; - _M_month07 = L"July"; - _M_month08 = L"August"; - _M_month09 = L"September"; - _M_month10 = L"October"; - _M_month11 = L"November"; - _M_month12 = L"December"; + _M_data->_M_month01 = L"January"; + _M_data->_M_month02 = L"February"; + _M_data->_M_month03 = L"March"; + _M_data->_M_month04 = L"April"; + _M_data->_M_month05 = L"May"; + _M_data->_M_month06 = L"June"; + _M_data->_M_month07 = L"July"; + _M_data->_M_month08 = L"August"; + _M_data->_M_month09 = L"September"; + _M_data->_M_month10 = L"October"; + _M_data->_M_month11 = L"November"; + _M_data->_M_month12 = L"December"; // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = L"Jan"; - _M_month_a02 = L"Feb"; - _M_month_a03 = L"Mar"; - _M_month_a04 = L"Apr"; - _M_month_a05 = L"May"; - _M_month_a06 = L"Jun"; - _M_month_a07 = L"July"; - _M_month_a08 = L"Aug"; - _M_month_a09 = L"Sep"; - _M_month_a10 = L"Oct"; - _M_month_a11 = L"Nov"; - _M_month_a12 = L"Dec"; + _M_data->_M_amonth01 = L"Jan"; + _M_data->_M_amonth02 = L"Feb"; + _M_data->_M_amonth03 = L"Mar"; + _M_data->_M_amonth04 = L"Apr"; + _M_data->_M_amonth05 = L"May"; + _M_data->_M_amonth06 = L"Jun"; + _M_data->_M_amonth07 = L"Jul"; + _M_data->_M_amonth08 = L"Aug"; + _M_data->_M_amonth09 = L"Sep"; + _M_data->_M_amonth10 = L"Oct"; + _M_data->_M_amonth11 = L"Nov"; + _M_data->_M_amonth12 = L"Dec"; } else { _M_c_locale_timepunct = _S_clone_c_locale(__cloc); - _M_date_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_FMT, __cloc)); - _M_date_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_FMT, __cloc)); - _M_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT, __cloc)); - _M_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_T_FMT, __cloc)); - _M_date_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_T_FMT, __cloc)); - _M_date_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc)); - _M_am = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WAM_STR, __cloc)); - _M_pm = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WPM_STR, __cloc)); - _M_am_pm_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc)); + _M_data->_M_date_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_FMT, __cloc)); + _M_data->_M_date_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_FMT, __cloc)); + _M_data->_M_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT, __cloc)); + _M_data->_M_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_T_FMT, __cloc)); + _M_data->_M_date_time_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WD_T_FMT, __cloc)); + _M_data->_M_date_time_era_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc)); + _M_data->_M_am = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WAM_STR, __cloc)); + _M_data->_M_pm = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WPM_STR, __cloc)); + _M_data->_M_am_pm_format = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc)); // Day names, starting with "C"'s Sunday. - _M_day1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_1, __cloc)); - _M_day2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_2, __cloc)); - _M_day3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_3, __cloc)); - _M_day4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_4, __cloc)); - _M_day5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_5, __cloc)); - _M_day6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_6, __cloc)); - _M_day7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_7, __cloc)); + _M_data->_M_day1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_1, __cloc)); + _M_data->_M_day2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_2, __cloc)); + _M_data->_M_day3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_3, __cloc)); + _M_data->_M_day4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_4, __cloc)); + _M_data->_M_day5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_5, __cloc)); + _M_data->_M_day6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_6, __cloc)); + _M_data->_M_day7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WDAY_7, __cloc)); // Abbreviated day names, starting with "C"'s Sun. - _M_day_a1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_1, __cloc)); - _M_day_a2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_2, __cloc)); - _M_day_a3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_3, __cloc)); - _M_day_a4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_4, __cloc)); - _M_day_a5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_5, __cloc)); - _M_day_a6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_6, __cloc)); - _M_day_a7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_7, __cloc)); + _M_data->_M_aday1 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_1, __cloc)); + _M_data->_M_aday2 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_2, __cloc)); + _M_data->_M_aday3 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_3, __cloc)); + _M_data->_M_aday4 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_4, __cloc)); + _M_data->_M_aday5 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_5, __cloc)); + _M_data->_M_aday6 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_6, __cloc)); + _M_data->_M_aday7 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABDAY_7, __cloc)); // Month names, starting with "C"'s January. - _M_month01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_1, __cloc)); - _M_month02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_2, __cloc)); - _M_month03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_3, __cloc)); - _M_month04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_4, __cloc)); - _M_month05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_5, __cloc)); - _M_month06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_6, __cloc)); - _M_month07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_7, __cloc)); - _M_month08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_8, __cloc)); - _M_month09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_9, __cloc)); - _M_month10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_10, __cloc)); - _M_month11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_11, __cloc)); - _M_month12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_12, __cloc)); + _M_data->_M_month01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_1, __cloc)); + _M_data->_M_month02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_2, __cloc)); + _M_data->_M_month03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_3, __cloc)); + _M_data->_M_month04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_4, __cloc)); + _M_data->_M_month05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_5, __cloc)); + _M_data->_M_month06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_6, __cloc)); + _M_data->_M_month07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_7, __cloc)); + _M_data->_M_month08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_8, __cloc)); + _M_data->_M_month09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_9, __cloc)); + _M_data->_M_month10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_10, __cloc)); + _M_data->_M_month11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_11, __cloc)); + _M_data->_M_month12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WMON_12, __cloc)); // Abbreviated month names, starting with "C"'s Jan. - _M_month_a01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_1, __cloc)); - _M_month_a02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_2, __cloc)); - _M_month_a03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_3, __cloc)); - _M_month_a04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_4, __cloc)); - _M_month_a05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_5, __cloc)); - _M_month_a06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_6, __cloc)); - _M_month_a07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_7, __cloc)); - _M_month_a08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_8, __cloc)); - _M_month_a09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_9, __cloc)); - _M_month_a10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_10, __cloc)); - _M_month_a11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_11, __cloc)); - _M_month_a12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_12, __cloc)); + _M_data->_M_amonth01 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_1, __cloc)); + _M_data->_M_amonth02 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_2, __cloc)); + _M_data->_M_amonth03 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_3, __cloc)); + _M_data->_M_amonth04 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_4, __cloc)); + _M_data->_M_amonth05 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_5, __cloc)); + _M_data->_M_amonth06 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_6, __cloc)); + _M_data->_M_amonth07 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_7, __cloc)); + _M_data->_M_amonth08 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_8, __cloc)); + _M_data->_M_amonth09 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_9, __cloc)); + _M_data->_M_amonth10 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_10, __cloc)); + _M_data->_M_amonth11 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_11, __cloc)); + _M_data->_M_amonth12 = reinterpret_cast<wchar_t*>(__nl_langinfo_l(_NL_WABMON_12, __cloc)); } } #endif diff --git a/contrib/libstdc++/config/locale/gnu/time_members.h b/contrib/libstdc++/config/locale/gnu/time_members.h index 2ea2410..9cb3594 100644 --- a/contrib/libstdc++/config/locale/gnu/time_members.h +++ b/contrib/libstdc++/config/locale/gnu/time_members.h @@ -1,6 +1,6 @@ // std::time_get, std::time_put implementation, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -36,33 +36,33 @@ template<typename _CharT> __timepunct<_CharT>::__timepunct(size_t __refs) - : locale::facet(__refs) - { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - _M_name_timepunct = _S_c_name; -#endif - _M_initialize_timepunct(); - } + : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), + _M_name_timepunct(_S_get_c_name()) + { _M_initialize_timepunct(); } + + template<typename _CharT> + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) + : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL), + _M_name_timepunct(_S_get_c_name()) + { _M_initialize_timepunct(); } template<typename _CharT> - __timepunct<_CharT>::__timepunct(__c_locale __cloc, - const char* __s, + __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, size_t __refs) - : locale::facet(__refs) + : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), + _M_name_timepunct(__s) { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - _M_name_timepunct = new char[strlen(__s) + 1]; - strcpy(_M_name_timepunct, __s); -#endif + char* __tmp = new char[std::strlen(__s) + 1]; + std::strcpy(__tmp, __s); + _M_name_timepunct = __tmp; _M_initialize_timepunct(__cloc); } template<typename _CharT> __timepunct<_CharT>::~__timepunct() { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - if (_S_c_name != _M_name_timepunct) + if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; -#endif + delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } diff --git a/contrib/libstdc++/config/locale/ieee_1003.1-2001/c_locale.cc b/contrib/libstdc++/config/locale/ieee_1003.1-2001/c_locale.cc index 0a89aee..3419355 100644 --- a/contrib/libstdc++/config/locale/ieee_1003.1-2001/c_locale.cc +++ b/contrib/libstdc++/config/locale/ieee_1003.1-2001/c_locale.cc @@ -61,7 +61,7 @@ namespace std _M_falsename = "false"; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void numpunct<wchar_t>::_M_initialize_numpunct(__c_locale) @@ -91,7 +91,7 @@ namespace std _M_neg_format = money_base::_S_default_pattern; } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> void moneypunct<wchar_t>::_M_initialize_moneypunct(__c_locale) diff --git a/contrib/libstdc++/config/locale/ieee_1003.1-2001/codecvt_specializations.h b/contrib/libstdc++/config/locale/ieee_1003.1-2001/codecvt_specializations.h index 0cbfb2a..ef0923d 100644 --- a/contrib/libstdc++/config/locale/ieee_1003.1-2001/codecvt_specializations.h +++ b/contrib/libstdc++/config/locale/ieee_1003.1-2001/codecvt_specializations.h @@ -1,6 +1,6 @@ // Locale support (codecvt) -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004 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 @@ -36,8 +36,8 @@ // Written by Benjamin Kosnik <bkoz@cygnus.com> // XXX - // Define this here to codecvt.cc can have _S_max_size definition. -#define _GLIBCPP_USE___ENC_TRAITS 1 + // Define this here so codecvt.cc can have _S_max_size definition. +#define _GLIBCXX_USE___ENC_TRAITS 1 // Extension to use icov for dealing with character encodings, // including conversions and comparisons between various character @@ -81,10 +81,11 @@ explicit __enc_traits(const char* __int, const char* __ext, int __ibom = 0, int __ebom = 0) - : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0) + : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(__ebom), _M_int_bom(__ibom) { strncpy(_M_int_enc, __int, _S_max_size); strncpy(_M_ext_enc, __ext, _S_max_size); + _M_init(); } // 21.1.2 traits typedefs @@ -92,12 +93,17 @@ // typedef STATE_T state_type // requires: state_type shall meet the requirements of // CopyConstructible types (20.1.3) + // NB: This does not preseve the actual state of the conversion + // descriptor member, but it does duplicate the encoding + // information. __enc_traits(const __enc_traits& __obj): _M_in_desc(0), _M_out_desc(0) { strncpy(_M_int_enc, __obj._M_int_enc, _S_max_size); strncpy(_M_ext_enc, __obj._M_ext_enc, _S_max_size); _M_ext_bom = __obj._M_ext_bom; _M_int_bom = __obj._M_int_bom; + _M_destroy(); + _M_init(); } // Need assignment operator as well. @@ -106,21 +112,15 @@ { strncpy(_M_int_enc, __obj._M_int_enc, _S_max_size); strncpy(_M_ext_enc, __obj._M_ext_enc, _S_max_size); - _M_in_desc = 0; - _M_out_desc = 0; _M_ext_bom = __obj._M_ext_bom; _M_int_bom = __obj._M_int_bom; + _M_destroy(); + _M_init(); return *this; } ~__enc_traits() - { - __desc_type __err = reinterpret_cast<iconv_t>(-1); - if (_M_in_desc && _M_in_desc != __err) - iconv_close(_M_in_desc); - if (_M_out_desc && _M_out_desc != __err) - iconv_close(_M_out_desc); - } + { _M_destroy(); } void _M_init() @@ -130,13 +130,31 @@ { _M_in_desc = iconv_open(_M_int_enc, _M_ext_enc); if (_M_in_desc == __err) - __throw_runtime_error("creating iconv input descriptor failed."); + __throw_runtime_error(__N("__enc_traits::_M_init " + "creating iconv input descriptor failed")); } if (!_M_out_desc) { _M_out_desc = iconv_open(_M_ext_enc, _M_int_enc); if (_M_out_desc == __err) - __throw_runtime_error("creating iconv output descriptor failed."); + __throw_runtime_error(__N("__enc_traits::_M_init " + "creating iconv output descriptor failed")); + } + } + + void + _M_destroy() + { + const __desc_type __err = reinterpret_cast<iconv_t>(-1); + if (_M_in_desc && _M_in_desc != __err) + { + iconv_close(_M_in_desc); + _M_in_desc = 0; + } + if (_M_out_desc && _M_out_desc != __err) + { + iconv_close(_M_out_desc); + _M_out_desc = 0; } } @@ -171,7 +189,7 @@ const char* _M_get_external_enc() - { return _M_ext_enc; } + { return _M_ext_enc; } }; // Partial specialization @@ -230,7 +248,7 @@ do_always_noconv() const throw(); virtual int - do_length(const state_type&, const extern_type* __from, + do_length(state_type&, const extern_type* __from, const extern_type* __end, size_t __max) const; virtual int @@ -447,15 +465,15 @@ template<typename _InternT, typename _ExternT> int codecvt<_InternT, _ExternT, __enc_traits>:: - do_length(const state_type&, const extern_type* __from, + do_length(state_type&, const extern_type* __from, const extern_type* __end, size_t __max) const - { return min(__max, static_cast<size_t>(__end - __from)); } + { return std::min(__max, static_cast<size_t>(__end - __from)); } -#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS -// 74. Garbled text for codecvt::do_max_length + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 74. Garbled text for codecvt::do_max_length template<typename _InternT, typename _ExternT> int codecvt<_InternT, _ExternT, __enc_traits>:: do_max_length() const throw() { return 1; } -#endif + diff --git a/contrib/libstdc++/config/locale/ieee_1003.1-2001/messages_members.cc b/contrib/libstdc++/config/locale/ieee_1003.1-2001/messages_members.cc index aaf07a2..b37209f 100644 --- a/contrib/libstdc++/config/locale/ieee_1003.1-2001/messages_members.cc +++ b/contrib/libstdc++/config/locale/ieee_1003.1-2001/messages_members.cc @@ -47,7 +47,7 @@ namespace std return string(catgets(__nlc, __setid, __msgid, __dfault.c_str())); } -#ifdef _GLIBCPP_USE_WCHAR_T +#ifdef _GLIBCXX_USE_WCHAR_T template<> wstring messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const diff --git a/contrib/libstdc++/config/os/aix/atomicity.h b/contrib/libstdc++/config/os/aix/atomicity.h index af4fa5a..dad8aae 100644 --- a/contrib/libstdc++/config/os/aix/atomicity.h +++ b/contrib/libstdc++/config/os/aix/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: AIX version -*- C++ -*- -// Copyright (C) 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2004 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 @@ -27,33 +27,35 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _BITS_ATOMICITY_H -#define _BITS_ATOMICITY_H 1 +#include <bits/atomicity.h> /* We cannot use the cpu/powerpc/bits/atomicity.h inline assembly definitions for these operations since they depend on operations that are not available on the original POWER architecture. AIX still runs on the POWER architecture, so it would be incorrect to - assume the existence of these instructions. */ + assume the existence of these instructions. -/* This should match the type pointed to by atomic_p in - <sys/atomic_op.h>. */ -typedef int _Atomic_word; + The definition of _Atomic_word must match the type pointed to by + atomic_p in <sys/atomic_op.h>. */ -#include <sys/atomic_op.h> - -static inline int -__attribute__ ((__unused__)) -__exchange_and_add (atomic_p __mem, int __val) +extern "C" { - return fetch_and_add (__mem, __val); +#include <sys/atomic_op.h> } -static inline void -__attribute__ ((__unused__)) -__atomic_add (atomic_p __mem, int __val) +namespace __gnu_cxx { - (void) fetch_and_add (__mem, __val); -} - -#endif /* atomicity.h */ + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add (volatile _Atomic_word* __mem, int __val) + { + return ::fetch_and_add (const_cast<atomic_p>(__mem), __val); + } + + void + __attribute__ ((__unused__)) + __atomic_add (volatile _Atomic_word* __mem, int __val) + { + (void) ::fetch_and_add (const_cast<atomic_p>(__mem), __val); + } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/os/aix/ctype_base.h b/contrib/libstdc++/config/os/aix/ctype_base.h index ed41440..adcd1ce 100644 --- a/contrib/libstdc++/config/os/aix/ctype_base.h +++ b/contrib/libstdc++/config/os/aix/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000, 1999 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2003 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 @@ -48,8 +48,8 @@ static const mask xdigit = _ISXDIGIT; static const mask space = _ISSPACE; static const mask print = _ISPRINT; - static const mask graph = _ISGRAPH; + static const mask graph = _ISALPHA | _ISDIGIT | _ISPUNCT; static const mask cntrl = _ISCNTRL; static const mask punct = _ISPUNCT; - static const mask alnum = _ISALNUM; + static const mask alnum = _ISALPHA | _ISDIGIT; }; diff --git a/contrib/libstdc++/config/os/aix/ctype_noninline.h b/contrib/libstdc++/config/os/aix/ctype_noninline.h index 7cf919a..edd8d82 100644 --- a/contrib/libstdc++/config/os/aix/ctype_noninline.h +++ b/contrib/libstdc++/config/os/aix/ctype_noninline.h @@ -39,16 +39,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/aix/os_defines.h b/contrib/libstdc++/config/os/aix/os_defines.h index 6e4dbda..7888fa7 100644 --- a/contrib/libstdc++/config/os/aix/os_defines.h +++ b/contrib/libstdc++/config/os/aix/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/bsd/freebsd/ctype_base.h b/contrib/libstdc++/config/os/bsd/freebsd/ctype_base.h index 98b6265..f44a7c7 100644 --- a/contrib/libstdc++/config/os/bsd/freebsd/ctype_base.h +++ b/contrib/libstdc++/config/os/bsd/freebsd/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2003 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,7 +52,7 @@ static const mask xdigit = _CTYPE_X; static const mask space = _CTYPE_S; static const mask print = _CTYPE_R; - static const mask graph = _CTYPE_G; + static const mask graph = _CTYPE_A | _CTYPE_D | _CTYPE_P; static const mask cntrl = _CTYPE_C; static const mask punct = _CTYPE_P; static const mask alnum = _CTYPE_A | _CTYPE_D; @@ -65,7 +65,7 @@ static const mask xdigit = _X; static const mask space = _S; static const mask print = _R; - static const mask graph = _G; + static const mask graph = _A | _D | _P; static const mask cntrl = _C; static const mask punct = _P; static const mask alnum = _A | _D; diff --git a/contrib/libstdc++/config/os/bsd/freebsd/ctype_noninline.h b/contrib/libstdc++/config/os/bsd/freebsd/ctype_noninline.h index 0e108fd..ec5b575 100644 --- a/contrib/libstdc++/config/os/bsd/freebsd/ctype_noninline.h +++ b/contrib/libstdc++/config/os/bsd/freebsd/ctype_noninline.h @@ -39,16 +39,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/bsd/freebsd/os_defines.h b/contrib/libstdc++/config/os/bsd/freebsd/os_defines.h index 55040a7..1e46712 100644 --- a/contrib/libstdc++/config/os/bsd/freebsd/os_defines.h +++ b/contrib/libstdc++/config/os/bsd/freebsd/os_defines.h @@ -28,17 +28,17 @@ // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. -#define _GLIBCPP_USE_C99_CHECK 1 -#define _GLIBCPP_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999)) -#define _GLIBCPP_USE_C99_LONG_LONG_CHECK 1 -#define _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC (_GLIBCPP_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED) -#define _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_CHECK 1 -#define _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC defined _XOPEN_SOURCE +#define _GLIBCXX_USE_C99_CHECK 1 +#define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999)) +#define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1 +#define _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC (_GLIBCXX_USE_C99_DYNAMIC || !defined __LONG_LONG_SUPPORTED) +#define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_CHECK 1 +#define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC defined _XOPEN_SOURCE #endif diff --git a/contrib/libstdc++/config/os/bsd/netbsd/ctype_noninline.h b/contrib/libstdc++/config/os/bsd/netbsd/ctype_noninline.h index 80138cb..70bf41c 100644 --- a/contrib/libstdc++/config/os/bsd/netbsd/ctype_noninline.h +++ b/contrib/libstdc++/config/os/bsd/netbsd/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003 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 @@ -32,21 +32,35 @@ // // Information as gleaned from /usr/include/ctype.h - + + extern "C" const u_int8_t _C_ctype_[]; + const ctype_base::mask* ctype<char>::classic_table() throw() - { return 0; } + { return _C_ctype_ + 1; } ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _ctype_ + 1) - { } + : facet(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _ctype_ + 1) - { } + : facet(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/bsd/netbsd/os_defines.h b/contrib/libstdc++/config/os/bsd/netbsd/os_defines.h index 03f760f..a7f2530 100644 --- a/contrib/libstdc++/config/os/bsd/netbsd/os_defines.h +++ b/contrib/libstdc++/config/os/bsd/netbsd/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/djgpp/ctype_base.h b/contrib/libstdc++/config/os/djgpp/ctype_base.h index 018e20e..778847c 100644 --- a/contrib/libstdc++/config/os/djgpp/ctype_base.h +++ b/contrib/libstdc++/config/os/djgpp/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003 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,8 +49,8 @@ static const mask digit = __dj_ISDIGIT; // Numeric static const mask punct = __dj_ISPUNCT; // Punctuation static const mask xdigit = __dj_ISXDIGIT; // Hexadecimal numeric - static const mask alnum = __dj_ISALPHA; // Alphanumeric - static const mask graph = __dj_ISGRAPH; // Graphical + static const mask alnum = __dj_ISALPHA | __dj_ISDIGIT; // Alphanumeric + static const mask graph = __dj_ISALPHA | __dj_ISDIGIT | __dj_ISPUNCT; // Graphical }; diff --git a/contrib/libstdc++/config/os/djgpp/ctype_noninline.h b/contrib/libstdc++/config/os/djgpp/ctype_noninline.h index 0ec0f84..eda2679 100644 --- a/contrib/libstdc++/config/os/djgpp/ctype_noninline.h +++ b/contrib/libstdc++/config/os/djgpp/ctype_noninline.h @@ -39,16 +39,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), _M_table(__table ? __table : __dj_ctype_flags) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), _M_table(__table ? __table : __dj_ctype_flags) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/djgpp/os_defines.h b/contrib/libstdc++/config/os/djgpp/os_defines.h index ce0bf24..5a43c06 100644 --- a/contrib/libstdc++/config/os/djgpp/os_defines.h +++ b/contrib/libstdc++/config/os/djgpp/os_defines.h @@ -28,8 +28,8 @@ // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/generic/ctype_base.h b/contrib/libstdc++/config/os/generic/ctype_base.h index 564093d..03fccce 100644 --- a/contrib/libstdc++/config/os/generic/ctype_base.h +++ b/contrib/libstdc++/config/os/generic/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2003 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 @@ -48,10 +48,10 @@ static const mask xdigit = 1 << 4; static const mask space = 1 << 5; static const mask print = 1 << 6; - static const mask graph = 1 << 7; + static const mask graph = (1 << 2) | (1 << 3) | (1 << 9); // alnum|punct static const mask cntrl = 1 << 8; static const mask punct = 1 << 9; - static const mask alnum = 1 << 10; + static const mask alnum = (1 << 2) | (1 << 3); // alpha|digit }; diff --git a/contrib/libstdc++/config/os/generic/ctype_inline.h b/contrib/libstdc++/config/os/generic/ctype_inline.h index 0da0c7c..5f24fe6 100644 --- a/contrib/libstdc++/config/os/generic/ctype_inline.h +++ b/contrib/libstdc++/config/os/generic/ctype_inline.h @@ -49,16 +49,14 @@ return _M_table[static_cast<unsigned char>(__c)] & __m; else { - bool __ret = true; - bool __any_match = false; - const size_t __bitmasksize = 10; + bool __ret = false; + const size_t __bitmasksize = 15; size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0 - for (;__ret && __bitcur <= __bitmasksize; ++__bitcur) + for (; __bitcur <= __bitmasksize; ++__bitcur) { - mask __bit = static_cast<mask>(1 << __bitcur); + const mask __bit = static_cast<mask>(1 << __bitcur); if (__m & __bit) { - __any_match = true; bool __testis; switch (__bit) { @@ -99,10 +97,10 @@ __testis = false; break; } - __ret &= __testis; + __ret |= __testis; } } - return __ret & __any_match; + return __ret; } } @@ -116,7 +114,7 @@ else { // Highest bitmask in ctype_base == 10. - const size_t __bitmasksize = 10; + const size_t __bitmasksize = 15; for (;__low < __high; ++__vec, ++__low) { mask __m = 0; @@ -124,7 +122,7 @@ size_t __i = 0; for (;__i <= __bitmasksize; ++__i) { - mask __bit = static_cast<mask>(1 << __i); + const mask __bit = static_cast<mask>(1 << __i); if (this->is(__bit, *__low)) __m |= __bit; } diff --git a/contrib/libstdc++/config/os/generic/ctype_noninline.h b/contrib/libstdc++/config/os/generic/ctype_noninline.h index d07dc8b..e30348e 100644 --- a/contrib/libstdc++/config/os/generic/ctype_noninline.h +++ b/contrib/libstdc++/config/os/generic/ctype_noninline.h @@ -40,16 +40,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/generic/os_defines.h b/contrib/libstdc++/config/os/generic/os_defines.h index 143c07e..303049b 100644 --- a/contrib/libstdc++/config/os/generic/os_defines.h +++ b/contrib/libstdc++/config/os/generic/os_defines.h @@ -28,8 +28,8 @@ // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/gnu-linux/ctype_base.h b/contrib/libstdc++/config/os/gnu-linux/ctype_base.h index a431f97..fc27a3f 100644 --- a/contrib/libstdc++/config/os/gnu-linux/ctype_base.h +++ b/contrib/libstdc++/config/os/gnu-linux/ctype_base.h @@ -1,6 +1,7 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003 +// 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 @@ -48,8 +49,8 @@ static const mask xdigit = _ISxdigit; static const mask space = _ISspace; static const mask print = _ISprint; - static const mask graph = _ISgraph; + static const mask graph = _ISalpha | _ISdigit | _ISpunct; static const mask cntrl = _IScntrl; static const mask punct = _ISpunct; - static const mask alnum = _ISalnum; + static const mask alnum = _ISalpha | _ISdigit; }; diff --git a/contrib/libstdc++/config/os/gnu-linux/ctype_noninline.h b/contrib/libstdc++/config/os/gnu-linux/ctype_noninline.h index 8f06d13..925a5d0 100644 --- a/contrib/libstdc++/config/os/gnu-linux/ctype_noninline.h +++ b/contrib/libstdc++/config/os/gnu-linux/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -34,13 +34,10 @@ // Information as gleaned from /usr/include/ctype.h -#if _GLIBCPP_C_LOCALE_GNU +#if _GLIBCXX_C_LOCALE_GNU const ctype_base::mask* ctype<char>::classic_table() throw() - { - locale::classic(); - return _S_c_locale->__ctype_b; - } + { return _S_get_c_locale()->__ctype_b; } #else const ctype_base::mask* ctype<char>::classic_table() throw() @@ -59,20 +56,24 @@ } #endif -#if _GLIBCPP_C_LOCALE_GNU +#if _GLIBCXX_C_LOCALE_GNU ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) + : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)), + _M_del(__table != 0 && __del), + _M_toupper(_M_c_locale_ctype->__ctype_toupper), + _M_tolower(_M_c_locale_ctype->__ctype_tolower), + _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b), + _M_widen_ok(0), _M_narrow_ok(0) { - _M_c_locale_ctype = _S_clone_c_locale(__cloc); - _M_toupper = _M_c_locale_ctype->__ctype_toupper; - _M_tolower = _M_c_locale_ctype->__ctype_tolower; - _M_table = __table ? __table : _M_c_locale_ctype->__ctype_b; + memset(_M_widen, 0, sizeof(_M_widen)); + memset(_M_narrow, 0, sizeof(_M_narrow)); } #else ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) + : 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)); setlocale(LC_CTYPE, "C"); @@ -87,22 +88,27 @@ #endif setlocale(LC_CTYPE, __old); free(__old); - _M_c_locale_ctype = _S_c_locale; + memset(_M_widen, 0, sizeof(_M_widen)); + memset(_M_narrow, 0, sizeof(_M_narrow)); } #endif -#if _GLIBCPP_C_LOCALE_GNU - ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) : - __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) +#if _GLIBCXX_C_LOCALE_GNU + 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_toupper(_M_c_locale_ctype->__ctype_toupper), + _M_tolower(_M_c_locale_ctype->__ctype_tolower), + _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b), + _M_widen_ok(0), _M_narrow_ok(0) { - _M_c_locale_ctype = _S_c_locale; - _M_toupper = _M_c_locale_ctype->__ctype_toupper; - _M_tolower = _M_c_locale_ctype->__ctype_tolower; - _M_table = __table ? __table : _M_c_locale_ctype->__ctype_b; + memset(_M_widen, 0, sizeof(_M_widen)); + memset(_M_narrow, 0, sizeof(_M_narrow)); } #else - ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) : - __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) + 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)); setlocale(LC_CTYPE, "C"); @@ -117,7 +123,8 @@ #endif setlocale(LC_CTYPE, __old); free(__old); - _M_c_locale_ctype = _S_c_locale; + memset(_M_widen, 0, sizeof(_M_widen)); + memset(_M_narrow, 0, sizeof(_M_narrow)); } #endif diff --git a/contrib/libstdc++/config/os/gnu-linux/os_defines.h b/contrib/libstdc++/config/os/gnu-linux/os_defines.h index 21ea296..0e0194a 100644 --- a/contrib/libstdc++/config/os/gnu-linux/os_defines.h +++ b/contrib/libstdc++/config/os/gnu-linux/os_defines.h @@ -1,6 +1,6 @@ // Specific definitions for GNU/Linux -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003 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 @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. @@ -38,30 +38,8 @@ #include <features.h> -#if !defined (__GLIBC__) || (__GLIBC__ == 2 && __GLIBC_MINOR__+ 0 == 0) - -// The types __off_t and __off64_t are not defined through <sys/types.h> -// as _G_config assumes. For libc5 and glibc 2.0 instead use -// <gnu/types.h> and the old name for __off64_t. -#include <gnu/types.h> -typedef __loff_t __off64_t; - -// These systems have declarations mismatching those in libio.h by -// omitting throw qualifiers. Cleanest way out is to not provide -// throw-qualifiers at all. Defining it as empty here will make libio.h -// not define it. -#undef __THROW -#define __THROW - -// Tell Glibc not to try to provide its own inline versions of -// some math functions. Those cause assembly-time clashes with -// our definitions. -#define __NO_MATH_INLINES - -#endif - -#if defined __GLIBC__ && __GLIBC__ >= 2 // We must not see the optimized string functions GNU libc defines. +#if defined __GLIBC__ && __GLIBC__ >= 2 #define __NO_STRING_INLINES #endif diff --git a/contrib/libstdc++/config/os/hpux/ctype_base.h b/contrib/libstdc++/config/os/hpux/ctype_base.h index f2f6ad0..53bbe23 100644 --- a/contrib/libstdc++/config/os/hpux/ctype_base.h +++ b/contrib/libstdc++/config/os/hpux/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2003 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 @@ -48,8 +48,8 @@ static const mask xdigit = _ISXDIGIT; static const mask space = _ISSPACE; static const mask print = _ISPRINT; - static const mask graph = _ISGRAPH; + static const mask graph = _ISALPHA | _ISDIGIT | _ISPUNCT; static const mask cntrl = _ISCNTRL; static const mask punct = _ISPUNCT; - static const mask alnum = _ISALNUM; + static const mask alnum = _ISALPHA | _ISDIGIT; }; diff --git a/contrib/libstdc++/config/os/hpux/ctype_noninline.h b/contrib/libstdc++/config/os/hpux/ctype_noninline.h index a85bc9c..00e338b 100644 --- a/contrib/libstdc++/config/os/hpux/ctype_noninline.h +++ b/contrib/libstdc++/config/os/hpux/ctype_noninline.h @@ -40,16 +40,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : (const mask *) __SB_masks) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : (const mask *) __SB_masks) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/hpux/os_defines.h b/contrib/libstdc++/config/os/hpux/os_defines.h index 6414b41..6cba739 100644 --- a/contrib/libstdc++/config/os/hpux/os_defines.h +++ b/contrib/libstdc++/config/os/hpux/os_defines.h @@ -1,6 +1,6 @@ // Specific definitions for HPUX -*- C++ -*- -// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2002, 2004 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 @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. @@ -58,7 +58,7 @@ unconditionally, which makes intmax_t and uintmax_t long long types. - We also force _GLIBCPP_USE_LONG_LONG here so that we don't have + We also force _GLIBCXX_USE_LONG_LONG here so that we don't have to bastardize configure to deal with this sillyness. */ namespace std { @@ -75,12 +75,12 @@ namespace std #endif } -#define _GLIBCPP_USE_LONG_LONG 1 +#define _GLIBCXX_USE_LONG_LONG 1 // HPUX on IA64 requires vtable to be 64 bit aligned even at 32 bit // mode. We need to pad the vtable structure to achieve this. #if !defined(_LP64) && defined (__ia64__) -#define _GLIBCPP_VTABLE_PADDING 8 +#define _GLIBCXX_VTABLE_PADDING 8 typedef long int __padding_type; #endif @@ -91,16 +91,9 @@ typedef long int __padding_type; #define _LIBUNWIND_STD_ABI 1 #endif -/* We need explicit instantiation of the atomicity lock on HPPA if - there is no weak support. */ -#if !defined(_GLIBCPP_SUPPORTS_WEAK) && defined (__hppa__) -#define _GLIBCPP_INST_ATOMICITY_LOCK 1 -#endif - /* Don't use pragma weak in gthread headers. HP-UX rejects programs with unsatisfied external references even if all of those references are weak; gthread relies on such unsatisfied references being resolved to null pointers when weak symbol support is on. */ -#define _GLIBCPP_GTHREAD_USE_WEAK 0 - +#define _GLIBCXX_GTHREAD_USE_WEAK 0 #endif diff --git a/contrib/libstdc++/config/os/irix/atomic_word.h b/contrib/libstdc++/config/os/irix/atomic_word.h new file mode 100644 index 0000000..68b8101 --- /dev/null +++ b/contrib/libstdc++/config/os/irix/atomic_word.h @@ -0,0 +1,35 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +typedef long _Atomic_word; + +#endif diff --git a/contrib/libstdc++/config/os/irix/atomicity.h b/contrib/libstdc++/config/os/irix/atomicity.h new file mode 100644 index 0000000..83e9e02 --- /dev/null +++ b/contrib/libstdc++/config/os/irix/atomicity.h @@ -0,0 +1,42 @@ +// Low-level functions for atomic operations: IRIX version -*- C++ -*- + +// Copyright (C) 2001, 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <mutex.h> +#include <bits/atomicity.h> + +namespace __gnu_cxx +{ + _Atomic_word + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { return (_Atomic_word) test_then_add((unsigned long*) const_cast<_Atomic_word*>(__mem), __val); } + + void + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __exchange_and_add(__mem, __val); } +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/config/os/irix/irix5.2/ctype_noninline.h b/contrib/libstdc++/config/os/irix/irix5.2/ctype_noninline.h index 3cb29b6..2aeb50c 100644 --- a/contrib/libstdc++/config/os/irix/irix5.2/ctype_noninline.h +++ b/contrib/libstdc++/config/os/irix/irix5.2/ctype_noninline.h @@ -40,16 +40,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? classic_table() : __table) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? classic_table() : __table) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/irix/irix5.2/os_defines.h b/contrib/libstdc++/config/os/irix/irix5.2/os_defines.h index 1d7f968..87556f8 100644 --- a/contrib/libstdc++/config/os/irix/irix5.2/os_defines.h +++ b/contrib/libstdc++/config/os/irix/irix5.2/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/irix/irix6.5/ctype_base.h b/contrib/libstdc++/config/os/irix/irix6.5/ctype_base.h index 08557d1..d4d2003 100644 --- a/contrib/libstdc++/config/os/irix/irix6.5/ctype_base.h +++ b/contrib/libstdc++/config/os/irix/irix6.5/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2003 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 @@ -48,8 +48,8 @@ static const mask xdigit = _ISxdigit; static const mask space = _ISspace; static const mask print = _ISprint; - static const mask graph = _ISgraph; + static const mask graph = _ISalpha | _ISdigit | _ISpunct; static const mask cntrl = _IScntrl; static const mask punct = _ISpunct; - static const mask alnum = _ISalnum; + static const mask alnum = _ISalpha | _ISdigit; }; diff --git a/contrib/libstdc++/config/os/irix/irix6.5/ctype_noninline.h b/contrib/libstdc++/config/os/irix/irix6.5/ctype_noninline.h index 009e611..8fdf95e 100644 --- a/contrib/libstdc++/config/os/irix/irix6.5/ctype_noninline.h +++ b/contrib/libstdc++/config/os/irix/irix6.5/ctype_noninline.h @@ -39,18 +39,28 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? (const mask*) (__libc_attr._ctype_tbl->_class + 1) : __table) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? (const mask*) (__libc_attr._ctype_tbl->_class + 1) : __table) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/irix/irix6.5/os_defines.h b/contrib/libstdc++/config/os/irix/irix6.5/os_defines.h index 838b747..6b0174b 100644 --- a/contrib/libstdc++/config/os/irix/irix6.5/os_defines.h +++ b/contrib/libstdc++/config/os/irix/irix6.5/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. @@ -51,5 +51,8 @@ // GCC does not use thunks on IRIX. #define _G_USING_THUNKS 0 +// FINOREAD takes an "off_t *" as argument. +#define _GLIBCXX_FIONREAD_TAKES_OFF_T + #endif diff --git a/contrib/libstdc++/config/os/mingw32/ctype_noninline.h b/contrib/libstdc++/config/os/mingw32/ctype_noninline.h index 998547c..e493d40 100644 --- a/contrib/libstdc++/config/os/mingw32/ctype_noninline.h +++ b/contrib/libstdc++/config/os/mingw32/ctype_noninline.h @@ -43,16 +43,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/mingw32/os_defines.h b/contrib/libstdc++/config/os/mingw32/os_defines.h index 5c99e09..38fd3c7 100644 --- a/contrib/libstdc++/config/os/mingw32/os_defines.h +++ b/contrib/libstdc++/config/os/mingw32/os_defines.h @@ -1,6 +1,6 @@ // Specific definitions for generic platforms -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003 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 @@ -28,10 +28,21 @@ // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -# define _GLIBCPP_OS_DEFINES +#ifndef _GLIBCXX_OS_DEFINES +# define _GLIBCXX_OS_DEFINES // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. +// Define as 0, if you want, to enable inlining of gthread functions. +// By default, don't pollute libstdc++ with win32api names. +#if !defined (__GTHREAD_HIDE_WIN32API) +# define __GTHREAD_HIDE_WIN32API 1 +#endif + +// Don't let win32api windef.h define min and max as macros +// if included after stl_algobase.h. +#undef NOMINMAX +#define NOMINMAX 1 + #endif diff --git a/contrib/libstdc++/config/os/newlib/ctype_noninline.h b/contrib/libstdc++/config/os/newlib/ctype_noninline.h index b511c4a..d0cce94 100644 --- a/contrib/libstdc++/config/os/newlib/ctype_noninline.h +++ b/contrib/libstdc++/config/os/newlib/ctype_noninline.h @@ -39,16 +39,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/newlib/os_defines.h b/contrib/libstdc++/config/os/newlib/os_defines.h index 1277661..3b19787 100644 --- a/contrib/libstdc++/config/os/newlib/os_defines.h +++ b/contrib/libstdc++/config/os/newlib/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/qnx/qnx6.1/ctype_noninline.h b/contrib/libstdc++/config/os/qnx/qnx6.1/ctype_noninline.h index cf34bd4..2eef13a 100644 --- a/contrib/libstdc++/config/os/qnx/qnx6.1/ctype_noninline.h +++ b/contrib/libstdc++/config/os/qnx/qnx6.1/ctype_noninline.h @@ -39,14 +39,24 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _Ctype) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _Ctype) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/qnx/qnx6.1/os_defines.h b/contrib/libstdc++/config/os/qnx/qnx6.1/os_defines.h index 23cf097..929331c 100644 --- a/contrib/libstdc++/config/os/qnx/qnx6.1/os_defines.h +++ b/contrib/libstdc++/config/os/qnx/qnx6.1/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/solaris/solaris2.5/ctype_noninline.h b/contrib/libstdc++/config/os/solaris/solaris2.5/ctype_noninline.h index a3c27b0..a808636 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.5/ctype_noninline.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.5/ctype_noninline.h @@ -39,16 +39,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/solaris/solaris2.5/os_defines.h b/contrib/libstdc++/config/os/solaris/solaris2.5/os_defines.h index a9be0bf..7e5a14e 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.5/os_defines.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.5/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_base.h b/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_base.h index 5f8d10a..c1447e6 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_base.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2003 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,8 +49,8 @@ static const mask xdigit = _ISXDIGIT; static const mask space = _ISSPACE; static const mask print = _ISPRINT; - static const mask graph = _ISGRAPH; + static const mask graph = _ISALPHA | _ISDIGIT | _ISPUNCT; static const mask cntrl = _ISCNTRL; static const mask punct = _ISPUNCT; - static const mask alnum = _ISALNUM; + static const mask alnum = _ISALPHA | _ISDIGIT; }; diff --git a/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_noninline.h b/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_noninline.h index f65cfe7..694901a 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_noninline.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.6/ctype_noninline.h @@ -39,16 +39,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/solaris/solaris2.6/os_defines.h b/contrib/libstdc++/config/os/solaris/solaris2.6/os_defines.h index aa9ecd6..29d6cf5 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.6/os_defines.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.6/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_base.h b/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_base.h index 9b8bddc..22be358 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_base.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_base.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2003 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 @@ -50,8 +50,8 @@ static const mask xdigit = _ISXDIGIT; static const mask space = _ISSPACE; static const mask print = _ISPRINT; - static const mask graph = _ISGRAPH; + static const mask graph = _ISALPHA | _ISDIGIT | _ISPUNCT; static const mask cntrl = _ISCNTRL; static const mask punct = _ISPUNCT; - static const mask alnum = _ISALNUM; + static const mask alnum = _ISALPHA | _ISDIGIT; }; diff --git a/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_noninline.h b/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_noninline.h index c8b11a9..d4917f0 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_noninline.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.7/ctype_noninline.h @@ -40,16 +40,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/solaris/solaris2.7/os_defines.h b/contrib/libstdc++/config/os/solaris/solaris2.7/os_defines.h index cf53fa4..9131aa6 100644 --- a/contrib/libstdc++/config/os/solaris/solaris2.7/os_defines.h +++ b/contrib/libstdc++/config/os/solaris/solaris2.7/os_defines.h @@ -27,8 +27,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. diff --git a/contrib/libstdc++/config/os/tpf/ctype_base.h b/contrib/libstdc++/config/os/tpf/ctype_base.h new file mode 100644 index 0000000..0461f3a --- /dev/null +++ b/contrib/libstdc++/config/os/tpf/ctype_base.h @@ -0,0 +1,55 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// Information as gleaned from /usr/include/ctype.h + + struct ctype_base + { + // Non-standard typedefs. + typedef const int* __to_type; + + // NB: Offsets into ctype<char>::_M_table force a particular size + // on the mask type. Because of this, we don't use an enum. + typedef unsigned short mask; + static const mask upper = _ISupper; + static const mask lower = _ISlower; + static const mask alpha = _ISalpha; + static const mask digit = _ISdigit; + static const mask xdigit = _ISxdigit; + static const mask space = _ISspace; + static const mask print = _ISprint; + static const mask graph = _ISalpha | _ISdigit | _ISpunct; + static const mask cntrl = _IScntrl; + static const mask punct = _ISpunct; + static const mask alnum = _ISalpha | _ISdigit; + }; diff --git a/contrib/libstdc++/config/os/tpf/ctype_inline.h b/contrib/libstdc++/config/os/tpf/ctype_inline.h new file mode 100644 index 0000000..3f2f32d --- /dev/null +++ b/contrib/libstdc++/config/os/tpf/ctype_inline.h @@ -0,0 +1,69 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) +// functions go in ctype.cc + + bool + ctype<char>:: + is(mask __m, char __c) const + { return _M_table[static_cast<unsigned char>(__c)] & __m; } + + const char* + ctype<char>:: + is(const char* __low, const char* __high, mask* __vec) const + { + while (__low < __high) + *__vec++ = _M_table[static_cast<unsigned char>(*__low++)]; + return __high; + } + + const char* + ctype<char>:: + scan_is(mask __m, const char* __low, const char* __high) const + { + while (__low < __high + && !(_M_table[static_cast<unsigned char>(*__low)] & __m)) + ++__low; + return __low; + } + + const char* + ctype<char>:: + scan_not(mask __m, const char* __low, const char* __high) const + { + while (__low < __high + && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0) + ++__low; + return __low; + } diff --git a/contrib/libstdc++/config/os/tpf/ctype_noninline.h b/contrib/libstdc++/config/os/tpf/ctype_noninline.h new file mode 100644 index 0000000..3735b56 --- /dev/null +++ b/contrib/libstdc++/config/os/tpf/ctype_noninline.h @@ -0,0 +1,103 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// Information as gleaned from /usr/include/ctype.h + + const ctype_base::mask* + ctype<char>::classic_table() throw() + { + const ctype_base::mask* __ret; + char* __old = strdup(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, "C"); + __ret = *__ctype_b_loc(); + setlocale(LC_CTYPE, __old); + free(__old); + return __ret; + } + + ctype<char>::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del) + { + char* __old=strdup(setlocale(LC_CTYPE, NULL)); + 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); + _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)); + 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); + _M_c_locale_ctype = _S_get_c_locale(); + } + + char + ctype<char>::do_toupper(char __c) const + { return _M_toupper[static_cast<unsigned char>(__c)]; } + + const char* + ctype<char>::do_toupper(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = _M_toupper[static_cast<unsigned char>(*__low)]; + ++__low; + } + return __high; + } + + char + ctype<char>::do_tolower(char __c) const + { return _M_tolower[static_cast<unsigned char>(__c)]; } + + const char* + ctype<char>::do_tolower(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = _M_tolower[static_cast<unsigned char>(*__low)]; + ++__low; + } + return __high; + } diff --git a/contrib/libstdc++/config/os/tpf/os_defines.h b/contrib/libstdc++/config/os/tpf/os_defines.h new file mode 100644 index 0000000..40ee13a --- /dev/null +++ b/contrib/libstdc++/config/os/tpf/os_defines.h @@ -0,0 +1,45 @@ +// Specific definitions for TPF -*- C++ -*- + +// Copyright (C) 2004 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 + +// System-specific #define, typedefs, corrections, etc, go here. This +// file will come before all others. + +// TPF is a big endian OS, let it be known here. +#define _BIG_ENDIAN 1 + +// This keeps isanum, et al from being propagated as macros. +#define __NO_CTYPE 1 + +// We must not see the optimized string functions GNU libc defines. +#define __NO_STRING_INLINES + +#endif diff --git a/contrib/libstdc++/config/os/vxworks/ctype_base.h b/contrib/libstdc++/config/os/vxworks/ctype_base.h new file mode 100644 index 0000000..2a34561 --- /dev/null +++ b/contrib/libstdc++/config/os/vxworks/ctype_base.h @@ -0,0 +1,59 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2003 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// Information extracted from target/h/ctype.h. + + struct ctype_base + { + // Non-standard typedefs. + typedef const unsigned char* __to_type; + + // NB: Offsets into ctype<char>::_M_table force a particular size + // on the mask type. Because of this, we don't use an enum. + typedef unsigned char mask; + static const mask upper = _C_UPPER; + static const mask lower = _C_LOWER; + static const mask alpha = _C_UPPER | _C_LOWER; + static const mask digit = _C_NUMBER; + static const mask xdigit = _C_HEX_NUMBER; + static const mask space = _C_WHITE_SPACE | _C_CONTROL; + static const mask print = (_C_UPPER | _C_LOWER | _C_NUMBER + | _C_WHITE_SPACE | _C_PUNCT); + static const mask graph = _C_UPPER | _C_LOWER | _C_NUMBER | _C_PUNCT; + static const mask cntrl = _C_CONTROL; + static const mask punct = _C_PUNCT; + static const mask alnum = _C_UPPER | _C_LOWER | _C_NUMBER; + }; + + + diff --git a/contrib/libstdc++/config/os/vxworks/ctype_inline.h b/contrib/libstdc++/config/os/vxworks/ctype_inline.h new file mode 100644 index 0000000..f5cc78b --- /dev/null +++ b/contrib/libstdc++/config/os/vxworks/ctype_inline.h @@ -0,0 +1,71 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2000, 2003 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// Information as gleaned from target/h/ctype.h + +// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) +// functions go in ctype.cc + + bool + ctype<char>:: + is(mask __m, char __c) const + { return __ctype[static_cast<unsigned char>(__c)] & __m; } + + const char* + ctype<char>:: + is(const char* __low, const char* __high, mask* __vec) const + { + while (__low < __high) + *__vec++ = __ctype[static_cast<unsigned char>(*__low++)]; + return __high; + } + + const char* + ctype<char>:: + scan_is(mask __m, const char* __low, const char* __high) const + { + while (__low < __high + && !(__ctype[static_cast<unsigned char>(*__low)] & __m)) + ++__low; + return __low; + } + + const char* + ctype<char>:: + scan_not(mask __m, const char* __low, const char* __high) const + { + while (__low < __high + && (__ctype[static_cast<unsigned char>(*__low)] & __m)) + ++__low; + return __low; + } diff --git a/contrib/libstdc++/config/os/vxworks/ctype_noninline.h b/contrib/libstdc++/config/os/vxworks/ctype_noninline.h new file mode 100644 index 0000000..acf91a4 --- /dev/null +++ b/contrib/libstdc++/config/os/vxworks/ctype_noninline.h @@ -0,0 +1,91 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// +// Information as gleaned from target/h/ctype.h + + const ctype_base::mask* + ctype<char>::classic_table() throw() + { return __ctype; } + + ctype<char>::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } + + ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } + + char + ctype<char>::do_toupper(char __c) const + { return __toupper(__c); } + + const char* + ctype<char>::do_toupper(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = __toupper(*__low); + ++__low; + } + return __high; + } + + char + ctype<char>::do_tolower(char __c) const + { return __tolower(__c); } + + const char* + ctype<char>::do_tolower(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = __tolower(*__low); + ++__low; + } + return __high; + } diff --git a/contrib/libstdc++/config/os/vxworks/os_defines.h b/contrib/libstdc++/config/os/vxworks/os_defines.h new file mode 100644 index 0000000..c5f04ff --- /dev/null +++ b/contrib/libstdc++/config/os/vxworks/os_defines.h @@ -0,0 +1,37 @@ +// Specific definitions for VxWorks -*- C++ -*- + +// Copyright (C) 2000, 2003 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + + +#ifndef _GLIBCPP_OS_DEFINES +#define _GLIBCPP_OS_DEFINES 1 + +// System-specific #define, typedefs, corrections, etc, go here. This +// file will come before all others. + +#endif diff --git a/contrib/libstdc++/config/os/windiss/ctype_noninline.h b/contrib/libstdc++/config/os/windiss/ctype_noninline.h index 0d34695..cf75ddf 100644 --- a/contrib/libstdc++/config/os/windiss/ctype_noninline.h +++ b/contrib/libstdc++/config/os/windiss/ctype_noninline.h @@ -40,16 +40,26 @@ ctype<char>::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table == 0 ? classic_table() : __table) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table == 0 ? classic_table() : __table) - { } + { + memset(_M_widen, 0, sizeof(_M_widen)); + _M_widen_ok = 0; + memset(_M_narrow, 0, sizeof(_M_narrow)); + _M_narrow_ok = 0; + } char ctype<char>::do_toupper(char __c) const diff --git a/contrib/libstdc++/config/os/windiss/os_defines.h b/contrib/libstdc++/config/os/windiss/os_defines.h index dd8b008..136733e 100644 --- a/contrib/libstdc++/config/os/windiss/os_defines.h +++ b/contrib/libstdc++/config/os/windiss/os_defines.h @@ -28,10 +28,11 @@ // the GNU General Public License. -#ifndef _GLIBCPP_OS_DEFINES -#define _GLIBCPP_OS_DEFINES 1 +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. +#define __C9X__ 1 // for sinf etc #endif |