From a342444c67382961a80b87c516fb6b2d85a15ffc Mon Sep 17 00:00:00 2001 From: kan Date: Fri, 7 Nov 2003 02:44:01 +0000 Subject: Gcc 3.3.3 20031106 C++ support bits. --- contrib/libstdc++/config/cpu/m68k/atomicity.h | 73 ++++++++-------------- .../config/locale/generic/ctype_members.cc | 32 ++++++++-- .../libstdc++/config/locale/gnu/ctype_members.cc | 39 +++++++++--- contrib/libstdc++/config/os/generic/ctype_inline.h | 16 ++--- contrib/libstdc++/config/os/hpux/os_defines.h | 8 ++- 5 files changed, 97 insertions(+), 71 deletions(-) (limited to 'contrib/libstdc++/config') diff --git a/contrib/libstdc++/config/cpu/m68k/atomicity.h b/contrib/libstdc++/config/cpu/m68k/atomicity.h index db32735..c80e2e3 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 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 @@ -32,8 +32,9 @@ typedef int _Atomic_word; -#if defined(__mc68020__) || defined(__mc68030__) \ - || defined(__mc68040__) || defined(__mc68060__) +#if ( defined(__mc68020__) || defined(__mc68030__) \ + || defined(__mc68040__) || defined(__mc68060__) ) \ + && !defined(__mcpu32__) // These variants support compare-and-swap. static inline _Atomic_word @@ -74,8 +75,7 @@ __exchange_and_add (volatile _Atomic_word *__mem, int __val) return __result; } -#elif !defined(__mcf5200__) && !defined(__mcf5300__) -// 68000, 68010, cpu32 and 5400 support test-and-set. +#else template struct __Atomicity_lock @@ -94,9 +94,26 @@ __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) - : "m"(__Atomicity_lock<0>::_S_atomicity_lock)); + : "+m"(__Atomicity_lock<0>::_S_atomicity_lock) + : /* none */ + : "cc"); +#endif __result = *__mem; *__mem = __result + __val; @@ -106,45 +123,7 @@ __exchange_and_add (volatile _Atomic_word *__mem, int __val) return __result; } -#elif defined(__vxWorks__) || defined(__embedded__) -// The best we can hope for is to disable interrupts, which we -// can only do 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; -} - -#else -// These variants do not support any atomic operations at all. - -#warning "__exchange_and_add is not atomic for this target" - -static inline _Atomic_word -__attribute__ ((__unused__)) -__exchange_and_add (volatile _Atomic_word *__mem, int __val) -{ - _Atomic_word __result; - - __result = *__mem; - *__mem = __result + __val; - - return __result; -} - -#endif /* CAS / IRQ / TAS */ +#endif /* TAS / BSET */ static inline void __attribute__ ((__unused__)) @@ -155,4 +134,4 @@ __atomic_add (volatile _Atomic_word* __mem, int __val) (void) __exchange_and_add (__mem, __val); } -#endif /* atomicity.h */ +#endif /* _BITS_ATOMICITY_H */ diff --git a/contrib/libstdc++/config/locale/generic/ctype_members.cc b/contrib/libstdc++/config/locale/generic/ctype_members.cc index f147983..71e810a 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 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 @@ -126,15 +126,35 @@ namespace std bool ctype:: do_is(mask __m, char_type __c) const - { return static_cast(iswctype(__c, _M_convert_to_wmask(__m))); } + { + bool __ret = false; + const size_t __bitmasksize = 10; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + { + const mask __bit = static_cast(1 << __bitcur); + if (__m & __bit) + __ret |= iswctype(__c, _M_convert_to_wmask(__bit)); + } + return __ret; + } const wchar_t* ctype:: - do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __m) const + do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const { - while (__lo < __hi && !this->do_is(*__m, *__lo)) - ++__lo; - return __lo; + for (;__lo < __hi; ++__vec, ++__lo) + { + const size_t __bitmasksize = 10; + mask __m = 0; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + { + const mask __bit = static_cast(1 << __bitcur); + if (iswctype(*__lo, _M_convert_to_wmask(__bit))) + __m |= __bit; + } + *__vec = __m; + } + return __hi; } const wchar_t* diff --git a/contrib/libstdc++/config/locale/gnu/ctype_members.cc b/contrib/libstdc++/config/locale/gnu/ctype_members.cc index e0be949..ee4cc0a 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 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 @@ -129,19 +129,42 @@ namespace std bool ctype:: - do_is(mask __m, char_type __c) const + do_is(mask __m, wchar_t __c) const { - return static_cast(__iswctype_l(__c, _M_convert_to_wmask(__m), - _M_c_locale_ctype)); + // Highest bitmask in ctype_base == 10, but extra in "C" + // library for blank. + bool __ret = false; + const size_t __bitmasksize = 11; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + { + const mask __bit = static_cast(_ISbit(__bitcur)); + if (__m & __bit) + __ret |= __iswctype_l(__c, _M_convert_to_wmask(__bit), + _M_c_locale_ctype); + } + return __ret; } const wchar_t* ctype:: - do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __m) const + do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const { - while (__lo < __hi && !this->do_is(*__m, *__lo)) - ++__lo; - return __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(_ISbit(__bitcur)); + if (__iswctype_l(*__lo, _M_convert_to_wmask(__bit), + _M_c_locale_ctype)) + __m |= __bit; + } + *__vec = __m; + } + return __hi; } const wchar_t* diff --git a/contrib/libstdc++/config/os/generic/ctype_inline.h b/contrib/libstdc++/config/os/generic/ctype_inline.h index be43c47..0da0c7c 100644 --- a/contrib/libstdc++/config/os/generic/ctype_inline.h +++ b/contrib/libstdc++/config/os/generic/ctype_inline.h @@ -50,13 +50,15 @@ else { bool __ret = true; - const int __bitmasksize = 11; - int __bitcur = 0; // Lowest bitmask in ctype_base == 0 - for (;__ret && __bitcur < __bitmasksize; ++__bitcur) + bool __any_match = false; + const size_t __bitmasksize = 10; + size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0 + for (;__ret && __bitcur <= __bitmasksize; ++__bitcur) { mask __bit = static_cast(1 << __bitcur); if (__m & __bit) { + __any_match = true; bool __testis; switch (__bit) { @@ -100,7 +102,7 @@ __ret &= __testis; } } - return __ret; + return __ret & __any_match; } } @@ -114,13 +116,13 @@ else { // Highest bitmask in ctype_base == 10. - const int __bitmasksize = 11; + const size_t __bitmasksize = 10; for (;__low < __high; ++__vec, ++__low) { mask __m = 0; // Lowest bitmask in ctype_base == 0 - int __i = 0; - for (;__i < __bitmasksize; ++__i) + size_t __i = 0; + for (;__i <= __bitmasksize; ++__i) { mask __bit = static_cast(1 << __i); if (this->is(__bit, *__low)) diff --git a/contrib/libstdc++/config/os/hpux/os_defines.h b/contrib/libstdc++/config/os/hpux/os_defines.h index 27951c1..6414b41 100644 --- a/contrib/libstdc++/config/os/hpux/os_defines.h +++ b/contrib/libstdc++/config/os/hpux/os_defines.h @@ -97,8 +97,10 @@ typedef long int __padding_type; #define _GLIBCPP_INST_ATOMICITY_LOCK 1 #endif -/* Don't use pragma weak in gthread headers. */ -#ifdef __hppa__ +/* 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 -#endif + #endif -- cgit v1.1