diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/libstdc++-v3/config/cpu | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/libstdc++-v3/config/cpu')
24 files changed, 1719 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/config/cpu/alpha/atomic_word.h b/gcc-4.9/libstdc++-v3/config/cpu/alpha/atomic_word.h new file mode 100644 index 000000000..bc92faec6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/alpha/atomic_word.h @@ -0,0 +1,33 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +typedef int _Atomic_word; + +#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("mb":::"memory") +#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("wmb":::"memory") + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/arm/cxxabi_tweaks.h b/gcc-4.9/libstdc++-v3/config/cpu/arm/cxxabi_tweaks.h new file mode 100644 index 000000000..77190c720 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/arm/cxxabi_tweaks.h @@ -0,0 +1,82 @@ +// Control various target specific ABI tweaks. ARM version. + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/cxxabi_tweaks.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cxxabi.h} + */ + +#ifndef _CXXABI_TWEAKS_H +#define _CXXABI_TWEAKS_H 1 + +#ifdef __cplusplus +namespace __cxxabiv1 +{ + extern "C" + { +#endif + +#ifdef __ARM_EABI__ + // The ARM EABI uses the least significant bit of a 32-bit + // guard variable. */ +#define _GLIBCXX_GUARD_TEST(x) ((*(x) & 1) != 0) +#define _GLIBCXX_GUARD_SET(x) *(x) = 1 +#define _GLIBCXX_GUARD_BIT 1 +#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) +#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) + typedef int __guard; + + // We also want the element size in array cookies. +#define _GLIBCXX_ELTSIZE_IN_COOKIE 1 + + // __cxa_vec_ctor should return a pointer to the array. + typedef void * __cxa_vec_ctor_return_type; +#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return x + // Constructors and destructors return the "this" pointer. + typedef void * __cxa_cdtor_return_type; + +#else // __ARM_EABI__ + + // The generic ABI uses the first byte of a 64-bit guard variable. +#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0) +#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1 +#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1) +#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) +#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) + __extension__ typedef int __guard __attribute__((mode (__DI__))); + + // __cxa_vec_ctor has void return type. + typedef void __cxa_vec_ctor_return_type; +#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return + // Constructors and destructors do not return a value. + typedef void __cxa_cdtor_return_type; + +#endif //!__ARM_EABI__ + +#ifdef __cplusplus + } +} // namespace __cxxabiv1 +#endif + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/cris/atomic_word.h b/gcc-4.9/libstdc++-v3/config/cpu/cris/atomic_word.h new file mode 100644 index 000000000..71b1b6444 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/cris/atomic_word.h @@ -0,0 +1,31 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#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/gcc-4.9/libstdc++-v3/config/cpu/cris/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/cris/atomicity.h new file mode 100644 index 000000000..ef1ae8cac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/cris/atomicity.h @@ -0,0 +1,89 @@ +// Low-level functions for atomic operations: CRIS version -*- C++ -*- + +// Copyright (C) 2001-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <ext/atomicity.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + _Atomic_word + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + int __tmp; + _Atomic_word __result; + +#if (__CRIS_arch_version >= 32) + __asm__ __volatile__ (" clearf p \n" + "0: \n" + " move.d %4,%2 \n" + " move.d [%3],%0 \n" + " add.d %0,%2 \n" + " ax \n" + " move.d %2,[%3] \n" + " bcs 0b \n" + " clearf p \n" + : "=&r" (__result), "=Q" (*__mem), "=&r" (__tmp) + : "r" (__mem), "g" (__val), "Q" (*__mem) + : "memory"); +#elif (__CRIS_arch_version >= 10) + __asm__ __volatile__ (" clearf \n" + "0: \n" + " move.d %4,%2 \n" + " move.d [%3],%0 \n" + " add.d %0,%2 \n" + " ax \n" + " move.d %2,[%3] \n" + " bwf 0b \n" + " clearf \n" + : "=&r" (__result), "=Q" (*__mem), "=&r" (__tmp) + : "r" (__mem), "g" (__val), "Q" (*__mem) + /* The memory clobber must stay, regardless of + current uses of this function. */ + : "memory"); +#else + __asm__ __volatile__ (" move $ccr,$r9 \n" + " di \n" + " move.d %4,%2 \n" + " move.d [%3],%0 \n" + " add.d %0,%2 \n" + " move.d %2,[%3] \n" + " move $r9,$ccr \n" + : "=&r" (__result), "=Q" (*__mem), "=&r" (__tmp) + : "r" (__mem), "g" (__val), "Q" (*__mem) + : "r9", + /* The memory clobber must stay, regardless of + current uses of this function. */ + "memory"); +#endif + + return __result; + } + + void + __atomic_add(volatile _Atomic_word* __mem, int __val) throw () + { __exchange_and_add(__mem, __val); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/gcc-4.9/libstdc++-v3/config/cpu/generic/atomic_word.h b/gcc-4.9/libstdc++-v3/config/cpu/generic/atomic_word.h new file mode 100644 index 000000000..b46dee522 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/generic/atomic_word.h @@ -0,0 +1,47 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file atomic_word.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +typedef int _Atomic_word; + +// Define these two macros using the appropriate memory barrier for the target. +// The commented out versions below are the defaults. +// See ia64/atomic_word.h for an alternative approach. + +// This one prevents loads from being hoisted across the barrier; +// in other words, this is a Load-Load acquire barrier. +// This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h. +// #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory") + +// This one prevents stores from being sunk across the barrier; in other +// words, a Store-Store release barrier. +// #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory") + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/generic/atomicity_builtins/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/generic/atomicity_builtins/atomicity.h new file mode 100644 index 000000000..bef2ee15c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/generic/atomicity_builtins/atomicity.h @@ -0,0 +1,44 @@ +// Low-level functions for atomic operations: version for CPUs providing +// atomic builtins -*- C++ -*- + +// Copyright (C) 2006-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include <bits/atomic_word.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) throw () + { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/gcc-4.9/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h new file mode 100644 index 000000000..3be1f3f7b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h @@ -0,0 +1,59 @@ +// Low-level functions for atomic operations: Generic version -*- C++ -*- + +// Copyright (C) 1999-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <ext/atomicity.h> +#include <ext/concurrence.h> + +namespace +{ + __gnu_cxx::__mutex& + get_atomic_mutex() + { + static __gnu_cxx::__mutex atomic_mutex; + return atomic_mutex; + } +} // anonymous namespace + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + __gnu_cxx::__scoped_lock sentry(get_atomic_mutex()); + _Atomic_word __result; + __result = *__mem; + *__mem += __val; + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) throw () + { __exchange_and_add(__mem, __val); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/gcc-4.9/libstdc++-v3/config/cpu/generic/cpu_defines.h b/gcc-4.9/libstdc++-v3/config/cpu/generic/cpu_defines.h new file mode 100644 index 000000000..b8560c58c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/generic/cpu_defines.h @@ -0,0 +1,33 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2005-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/cpu_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_CPU_DEFINES +#define _GLIBCXX_CPU_DEFINES 1 + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h b/gcc-4.9/libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h new file mode 100644 index 000000000..6fabe3af7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h @@ -0,0 +1,59 @@ +// Control various target specific ABI tweaks. Generic version. + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/cxxabi_tweaks.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cxxabi.h} + */ + +#ifndef _CXXABI_TWEAKS_H +#define _CXXABI_TWEAKS_H 1 + +#ifdef __cplusplus +namespace __cxxabiv1 +{ + extern "C" + { +#endif + + // The generic ABI uses the first byte of a 64-bit guard variable. +#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0) +#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1 +#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1) +#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) +#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) + __extension__ typedef int __guard __attribute__((mode (__DI__))); + + // __cxa_vec_ctor has void return type. + typedef void __cxa_vec_ctor_return_type; +#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return + // Constructors and destructors do not return a value. + typedef void __cxa_cdtor_return_type; + +#ifdef __cplusplus + } +} // namespace __cxxabiv1 +#endif + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/generic/opt/bits/opt_random.h b/gcc-4.9/libstdc++-v3/config/cpu/generic/opt/bits/opt_random.h new file mode 100644 index 000000000..f841a21d6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/generic/opt/bits/opt_random.h @@ -0,0 +1,38 @@ +// Optimizations for random number handling, generic version -*- C++ -*- + +// Copyright (C) 2012-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/opt_random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _BITS_OPT_RANDOM_H +#define _BITS_OPT_RANDOM_H 1 + +#pragma GCC system_header + + + + +#endif // _BITS_OPT_RANDOM_H diff --git a/gcc-4.9/libstdc++-v3/config/cpu/generic/opt/ext/opt_random.h b/gcc-4.9/libstdc++-v3/config/cpu/generic/opt/ext/opt_random.h new file mode 100644 index 000000000..41eb809b1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/generic/opt/ext/opt_random.h @@ -0,0 +1,38 @@ +// Optimizations for random number extensions, generic version -*- C++ -*- + +// Copyright (C) 2012-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file ext/opt_random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ext/random} + */ + +#ifndef _EXT_OPT_RANDOM_H +#define _EXT_OPT_RANDOM_H 1 + +#pragma GCC system_header + + + + +#endif // _EXT_OPT_RANDOM_H diff --git a/gcc-4.9/libstdc++-v3/config/cpu/hppa/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/hppa/atomicity.h new file mode 100644 index 000000000..b037c8202 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/hppa/atomicity.h @@ -0,0 +1,94 @@ +// Low-level functions for atomic operations: PA-RISC version -*- C++ -*- + +// Copyright (C) 2002-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include <ext/atomicity.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + 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; + + // 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; + + int + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + _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) + : "memory"); + + result = *__mem; + *__mem = result + __val; + __asm__ __volatile__ ("stw %1,0(%0)" + : : "r" (&lock), "r" (tmp) : "memory"); + return result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) throw () + { + 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) + : "memory"); + + *__mem += __val; + __asm__ __volatile__ ("stw %1,0(%0)" + : : "r" (&lock), "r" (tmp) : "memory"); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/gcc-4.9/libstdc++-v3/config/cpu/i386/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/i386/atomicity.h new file mode 100644 index 000000000..93d29ceb4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/i386/atomicity.h @@ -0,0 +1,73 @@ +// Low-level functions for atomic operations: x86, x >= 3 version -*- C++ -*- + +// Copyright (C) 2003-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <ext/atomicity.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + 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) throw () + { + 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) throw () + { __exchange_and_add(__mem, __val); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/gcc-4.9/libstdc++-v3/config/cpu/i486/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/i486/atomicity.h new file mode 100644 index 000000000..0992b99ff --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/i486/atomicity.h @@ -0,0 +1,52 @@ +// Low-level functions for atomic operations: x86, x >= 4 version -*- C++ -*- + +// Copyright (C) 1999-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <ext/atomicity.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + 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) throw () + { + __asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}" + : "=m" (*__mem) : "ir" (__val), "m" (*__mem)); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + diff --git a/gcc-4.9/libstdc++-v3/config/cpu/i486/opt/bits/opt_random.h b/gcc-4.9/libstdc++-v3/config/cpu/i486/opt/bits/opt_random.h new file mode 100644 index 000000000..463279ef8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/i486/opt/bits/opt_random.h @@ -0,0 +1,219 @@ +// Optimizations for random number functions, x86 version -*- C++ -*- + +// Copyright (C) 2012-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/opt_random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _BITS_OPT_RANDOM_H +#define _BITS_OPT_RANDOM_H 1 + +#include <x86intrin.h> + + +#pragma GCC system_header + + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef __SSE3__ + template<> + template<typename _UniformRandomNumberGenerator> + void + normal_distribution<double>:: + __generate(typename normal_distribution<double>::result_type* __f, + typename normal_distribution<double>::result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + typedef uint64_t __uctype; + + if (__f == __t) + return; + + if (_M_saved_available) + { + _M_saved_available = false; + *__f++ = _M_saved * __param.stddev() + __param.mean(); + + if (__f == __t) + return; + } + + constexpr uint64_t __maskval = 0xfffffffffffffull; + static const __m128i __mask = _mm_set1_epi64x(__maskval); + static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull); + static const __m128d __three = _mm_set1_pd(3.0); + const __m128d __av = _mm_set1_pd(__param.mean()); + + const __uctype __urngmin = __urng.min(); + const __uctype __urngmax = __urng.max(); + const __uctype __urngrange = __urngmax - __urngmin; + const __uctype __uerngrange = __urngrange + 1; + + while (__f + 1 < __t) + { + double __le; + __m128d __x; + do + { + union + { + __m128i __i; + __m128d __d; + } __v; + + if (__urngrange > __maskval) + { + if (__detail::_Power_of_2(__uerngrange)) + __v.__i = _mm_and_si128(_mm_set_epi64x(__urng(), + __urng()), + __mask); + else + { + const __uctype __uerange = __maskval + 1; + const __uctype __scaling = __urngrange / __uerange; + const __uctype __past = __uerange * __scaling; + uint64_t __v1; + do + __v1 = __uctype(__urng()) - __urngmin; + while (__v1 >= __past); + __v1 /= __scaling; + uint64_t __v2; + do + __v2 = __uctype(__urng()) - __urngmin; + while (__v2 >= __past); + __v2 /= __scaling; + + __v.__i = _mm_set_epi64x(__v1, __v2); + } + } + else if (__urngrange == __maskval) + __v.__i = _mm_set_epi64x(__urng(), __urng()); + else if ((__urngrange + 2) * __urngrange >= __maskval + && __detail::_Power_of_2(__uerngrange)) + { + uint64_t __v1 = __urng() * __uerngrange + __urng(); + uint64_t __v2 = __urng() * __uerngrange + __urng(); + + __v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2), + __mask); + } + else + { + size_t __nrng = 2; + __uctype __high = __maskval / __uerngrange / __uerngrange; + while (__high > __uerngrange) + { + ++__nrng; + __high /= __uerngrange; + } + const __uctype __highrange = __high + 1; + const __uctype __scaling = __urngrange / __highrange; + const __uctype __past = __highrange * __scaling; + __uctype __tmp; + + uint64_t __v1; + do + { + do + __tmp = __uctype(__urng()) - __urngmin; + while (__tmp >= __past); + __v1 = __tmp / __scaling; + for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) + { + __tmp = __v1; + __v1 *= __uerngrange; + __v1 += __uctype(__urng()) - __urngmin; + } + } + while (__v1 > __maskval || __v1 < __tmp); + + uint64_t __v2; + do + { + do + __tmp = __uctype(__urng()) - __urngmin; + while (__tmp >= __past); + __v2 = __tmp / __scaling; + for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) + { + __tmp = __v2; + __v2 *= __uerngrange; + __v2 += __uctype(__urng()) - __urngmin; + } + } + while (__v2 > __maskval || __v2 < __tmp); + + __v.__i = _mm_set_epi64x(__v1, __v2); + } + + __v.__i = _mm_or_si128(__v.__i, __two); + __x = _mm_sub_pd(__v.__d, __three); + __m128d __m = _mm_mul_pd(__x, __x); + __le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m)); + } + while (__le == 0.0 || __le >= 1.0); + + double __mult = (std::sqrt(-2.0 * std::log(__le) / __le) + * __param.stddev()); + + __x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av); + + _mm_storeu_pd(__f, __x); + __f += 2; + } + + if (__f != __t) + { + result_type __x, __y, __r2; + + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + _M_saved = __x * __mult; + _M_saved_available = true; + *__f = __y * __mult * __param.stddev() + __param.mean(); + } + } +#endif + + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + + +#endif // _BITS_OPT_RANDOM_H diff --git a/gcc-4.9/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h b/gcc-4.9/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h new file mode 100644 index 000000000..e5c0a8407 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h @@ -0,0 +1,140 @@ +// Optimizations for random number extensions, x86 version -*- C++ -*- + +// Copyright (C) 2012-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file ext/random.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ext/random} + */ + +#ifndef _EXT_OPT_RANDOM_H +#define _EXT_OPT_RANDOM_H 1 + +#pragma GCC system_header + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + +#ifdef __SSE2__ + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace { + + template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2, + uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4> + inline __m128i __sse2_recursion(__m128i __a, __m128i __b, + __m128i __c, __m128i __d) + { + __m128i __y = _mm_srli_epi32(__b, __sr1); + __m128i __z = _mm_srli_si128(__c, __sr2); + __m128i __v = _mm_slli_epi32(__d, __sl1); + __z = _mm_xor_si128(__z, __a); + __z = _mm_xor_si128(__z, __v); + __m128i __x = _mm_slli_si128(__a, __sl2); + __y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1)); + __z = _mm_xor_si128(__z, __x); + return _mm_xor_si128(__z, __y); + } + + } + + +#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1 + template<typename _UIntType, size_t __m, + size_t __pos1, size_t __sl1, size_t __sl2, + size_t __sr1, size_t __sr2, + uint32_t __msk1, uint32_t __msk2, + uint32_t __msk3, uint32_t __msk4, + uint32_t __parity1, uint32_t __parity2, + uint32_t __parity3, uint32_t __parity4> + void simd_fast_mersenne_twister_engine<_UIntType, __m, + __pos1, __sl1, __sl2, __sr1, __sr2, + __msk1, __msk2, __msk3, __msk4, + __parity1, __parity2, __parity3, + __parity4>:: + _M_gen_rand(void) + { + __m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]); + __m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]); + + size_t __i; + for (__i = 0; __i < _M_nstate - __pos1; ++__i) + { + __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, + __msk1, __msk2, __msk3, __msk4> + (_M_state[__i], _M_state[__i + __pos1], __r1, __r2); + _mm_store_si128(&_M_state[__i], __r); + __r1 = __r2; + __r2 = __r; + } + for (; __i < _M_nstate; ++__i) + { + __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, + __msk1, __msk2, __msk3, __msk4> + (_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2); + _mm_store_si128(&_M_state[__i], __r); + __r1 = __r2; + __r2 = __r; + } + + _M_pos = 0; + } + + +#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1 + template<typename _UIntType, size_t __m, + size_t __pos1, size_t __sl1, size_t __sl2, + size_t __sr1, size_t __sr2, + uint32_t __msk1, uint32_t __msk2, + uint32_t __msk3, uint32_t __msk4, + uint32_t __parity1, uint32_t __parity2, + uint32_t __parity3, uint32_t __parity4> + bool + operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, + __m, __pos1, __sl1, __sl2, __sr1, __sr2, + __msk1, __msk2, __msk3, __msk4, + __parity1, __parity2, __parity3, __parity4>& __lhs, + const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, + __m, __pos1, __sl1, __sl2, __sr1, __sr2, + __msk1, __msk2, __msk3, __msk4, + __parity1, __parity2, __parity3, __parity4>& __rhs) + { + __m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]); + for (size_t __i = 1; __i < __lhs._M_nstate; ++__i) + __res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i], + __rhs._M_state[__i])); + return (_mm_movemask_epi8(__res) == 0xffff + && __lhs._M_pos == __rhs._M_pos); + } + + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // __SSE2__ + +#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + +#endif // _EXT_OPT_RANDOM_H diff --git a/gcc-4.9/libstdc++-v3/config/cpu/ia64/atomic_word.h b/gcc-4.9/libstdc++-v3/config/cpu/ia64/atomic_word.h new file mode 100644 index 000000000..ee4cee389 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/ia64/atomic_word.h @@ -0,0 +1,64 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +#include <bits/cxxabi_tweaks.h> + +typedef int _Atomic_word; + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ + // Test the first byte of __g and ensure that no loads are hoisted across + // the test. + inline bool + __test_and_acquire (__cxxabiv1::__guard *__g) + { + unsigned char __c; + unsigned char *__p = reinterpret_cast<unsigned char *>(__g); + // ldN.acq is a load with an implied hoist barrier. + // would ld8+mask be faster than just doing an ld1? + __asm __volatile ("ld1.acq %0 = %1" : "=r"(__c) : "m"(*__p) : "memory"); + return __c != 0; + } + + // Set the first byte of __g to 1 and ensure that no stores are sunk + // across the store. + inline void + __set_and_release (__cxxabiv1::__guard *__g) + { + unsigned char *__p = reinterpret_cast<unsigned char *>(__g); + // stN.rel is a store with an implied sink barrier. + // could load word, set flag, and CAS it back + __asm __volatile ("st1.rel %0 = %1" : "=m"(*__p) : "r"(1) : "memory"); + } + + // We don't define the _BARRIER macros on ia64 because the barriers are + // included in the test and set, above. +#define _GLIBCXX_GUARD_TEST_AND_ACQUIRE(G) __gnu_cxx::__test_and_acquire (G) +#define _GLIBCXX_GUARD_SET_AND_RELEASE(G) __gnu_cxx::__set_and_release (G) +} + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/m68k/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/m68k/atomicity.h new file mode 100644 index 000000000..6b90d2c2d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/m68k/atomicity.h @@ -0,0 +1,132 @@ +// Low-level functions for atomic operations: m68k version -*- C++ -*- + +// Copyright (C) 2001-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <ext/atomicity.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if ( defined(__mc68020__) || defined(__mc68030__) \ + || defined(__mc68040__) || defined(__mc68060__) ) \ + && !defined(__mcpu32__) + // These variants support compare-and-swap. + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + 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. + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + _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; + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + _Atomic_word __result; + + // bset with no immediate addressing (not SMP-safe) +#if defined(__mcfisaa__) || defined(__mcfisaaplus__) + __asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b" + : /* no outputs */ + : "a"(&_Atomicity_lock<0>::_S_atomicity_lock) + : "cc", "memory"); + + // CPU32 and CF ISAs B & C support test-and-set (SMP-safe). +#elif defined(__mcpu32__) || defined(__mcfisab__) || defined (__mcfisac__) + __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; + } + +#endif /* TAS / BSET */ + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) throw () + { + // Careful: using add.l with a memory destination is not + // architecturally guaranteed to be atomic. + __exchange_and_add(__mem, __val); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/gcc-4.9/libstdc++-v3/config/cpu/microblaze/cpu_defines.h b/gcc-4.9/libstdc++-v3/config/cpu/microblaze/cpu_defines.h new file mode 100644 index 000000000..ac60ef8a4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/microblaze/cpu_defines.h @@ -0,0 +1,39 @@ +// Specific definitions for Xilinx MicroBlaze platforms -*- C++ -*- + +// Copyright (C) 2009-2014 Free Software Foundation, Inc. +// +// Contributed by Michael Eager <eager@eagercon.com>. +// +// 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/cpu_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_CPU_DEFINES +#define _GLIBCXX_CPU_DEFINES 1 + +// Optimize memory size for embedded systems +// -- Use abort for eh terminate +#define _GLIBCXX_NO_VERBOSE_TERMINATE 1 + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/powerpc/atomic_word.h b/gcc-4.9/libstdc++-v3/config/cpu/powerpc/atomic_word.h new file mode 100644 index 000000000..12eafd8db --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/powerpc/atomic_word.h @@ -0,0 +1,37 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +typedef int _Atomic_word; + +#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("isync":::"memory") +#ifdef __NO_LWSYNC__ +#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory") +#else +#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory") +#endif + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/powerpc/cpu_defines.h b/gcc-4.9/libstdc++-v3/config/cpu/powerpc/cpu_defines.h new file mode 100644 index 000000000..fe6f2a664 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/powerpc/cpu_defines.h @@ -0,0 +1,36 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2005-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/cpu_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_CPU_DEFINES +#define _GLIBCXX_CPU_DEFINES 1 + +// Integer divide instructions don't trap on PowerPC. +#define __glibcxx_integral_traps false + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/sh/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/sh/atomicity.h new file mode 100644 index 000000000..226fdd33a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/sh/atomicity.h @@ -0,0 +1,108 @@ +// Low-level functions for atomic operations: sh version -*- C++ -*- + +// Copyright (C) 1999-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#ifdef __SH4A__ + +#include <ext/atomicity.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + typedef int _Atomic_word; + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add (volatile _Atomic_word* __mem, int __val) throw () + { + _Atomic_word __result; + + __asm__ __volatile__ + ("0:\n" + "\tmovli.l\t@%2,r0\n" + "\tmov\tr0,%1\n" + "\tadd\t%3,r0\n" + "\tmovco.l\tr0,@%2\n" + "\tbf\t0b" + : "+m" (*__mem), "=&r" (__result) + : "r" (__mem), "rI08" (__val) + : "r0"); + + return __result; + } + + + void + __attribute__ ((__unused__)) + __atomic_add (volatile _Atomic_word* __mem, int __val) throw () + { + asm("0:\n" + "\tmovli.l\t@%1,r0\n" + "\tadd\t%2,r0\n" + "\tmovco.l\tr0,@%1\n" + "\tbf\t0b" + : "+m" (*__mem) + : "r" (__mem), "rI08" (__val) + : "r0"); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#else /* !__SH4A__ */ + +/* This is generic/atomicity.h */ + +#include <ext/atomicity.h> +#include <ext/concurrence.h> + +namespace +{ + __gnu_cxx::__mutex atomic_mutex; +} // anonymous namespace + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + __gnu_cxx::__scoped_lock sentry(atomic_mutex); + _Atomic_word __result; + __result = *__mem; + *__mem += __val; + return __result; + } + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word* __mem, int __val) throw () + { __exchange_and_add(__mem, __val); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* !__SH4A__ */ diff --git a/gcc-4.9/libstdc++-v3/config/cpu/sparc/atomic_word.h b/gcc-4.9/libstdc++-v3/config/cpu/sparc/atomic_word.h new file mode 100644 index 000000000..c0c2064e5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/sparc/atomic_word.h @@ -0,0 +1,48 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +#ifdef __arch64__ + typedef long _Atomic_word; +#else + typedef int _Atomic_word; +#endif + +#if defined(__sparc_v9__) +// These are necessary under the V9 RMO model, though it is almost never +// used in userspace. +#define _GLIBCXX_READ_MEM_BARRIER \ + __asm __volatile ("membar #LoadLoad":::"memory") +#define _GLIBCXX_WRITE_MEM_BARRIER \ + __asm __volatile ("membar #StoreStore":::"memory") + +#elif defined(__sparc_v8__) +// This is necessary under the PSO model. +#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("stbar":::"memory") + +#endif + +#endif diff --git a/gcc-4.9/libstdc++-v3/config/cpu/sparc/atomicity.h b/gcc-4.9/libstdc++-v3/config/cpu/sparc/atomicity.h new file mode 100644 index 000000000..54b513286 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/config/cpu/sparc/atomicity.h @@ -0,0 +1,124 @@ +// Low-level functions for atomic operations: Sparc version -*- C++ -*- + +// Copyright (C) 1999-2014 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 3, 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <ext/atomicity.h> + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef __arch64__ + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw () + { + _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) throw () + { + _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__ */ + + 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) throw () + { + _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) throw () + { + _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__ */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace |