diff mbox

[RTEMS] Always use atomic builtins for libstdc++

Message ID 1474530076-1161-1-git-send-email-sebastian.huber@embedded-brains.de
State New
Headers show

Commit Message

Sebastian Huber Sept. 22, 2016, 7:41 a.m. UTC
libstdc++-v3/
	* config/cpu/m68k/atomicity.h: Adjust comment.
	* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Honor
	explicit atomicity_dir setup via configure.host.
	* configure.host (rtems-*): Set atomicity_dir.
	* configure: Regenerate.
---
 libstdc++-v3/acinclude.m4                |  5 +++--
 libstdc++-v3/config/cpu/m68k/atomicity.h |  3 +++
 libstdc++-v3/configure                   | 11 ++++++-----
 libstdc++-v3/configure.host              |  4 ++++
 4 files changed, 16 insertions(+), 7 deletions(-)

Comments

Andreas Schwab Sept. 22, 2016, 8:34 a.m. UTC | #1
On Sep 22 2016, Sebastian Huber <sebastian.huber@embedded-brains.de> wrote:

> diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
> index 6d897be..3256ce4 100644
> --- a/libstdc++-v3/acinclude.m4
> +++ b/libstdc++-v3/acinclude.m4
> @@ -3490,9 +3490,10 @@ EOF
>    AC_LANG_RESTORE
>  
>    # Set atomicity_dir to builtins if all but the long long test above passes.
> -  if test "$glibcxx_cv_atomic_bool" = yes \
> +  if ( test "$glibcxx_cv_atomic_bool" = yes \
>       && test "$glibcxx_cv_atomic_short" = yes \
> -     && test "$glibcxx_cv_atomic_int" = yes; then
> +     && test "$glibcxx_cv_atomic_int" = yes ) \
> +     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then

In the shell grouping is expressed by { }.

Andreas.
Jonathan Wakely Sept. 22, 2016, 8:47 a.m. UTC | #2
On 22/09/16 09:41 +0200, Sebastian Huber wrote:
>libstdc++-v3/
>	* config/cpu/m68k/atomicity.h: Adjust comment.
>	* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Honor
>	explicit atomicity_dir setup via configure.host.
>	* configure.host (rtems-*): Set atomicity_dir.
>	* configure: Regenerate.
>---
> libstdc++-v3/acinclude.m4                |  5 +++--
> libstdc++-v3/config/cpu/m68k/atomicity.h |  3 +++
> libstdc++-v3/configure                   | 11 ++++++-----
> libstdc++-v3/configure.host              |  4 ++++
> 4 files changed, 16 insertions(+), 7 deletions(-)
>
>diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>index 6d897be..3256ce4 100644
>--- a/libstdc++-v3/acinclude.m4
>+++ b/libstdc++-v3/acinclude.m4
>@@ -3490,9 +3490,10 @@ EOF
>   AC_LANG_RESTORE
>
>   # Set atomicity_dir to builtins if all but the long long test above passes.
>-  if test "$glibcxx_cv_atomic_bool" = yes \
>+  if ( test "$glibcxx_cv_atomic_bool" = yes \
>      && test "$glibcxx_cv_atomic_short" = yes \
>-     && test "$glibcxx_cv_atomic_int" = yes; then
>+     && test "$glibcxx_cv_atomic_int" = yes ) \
>+     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then

Could you adjust the comment too please? Maybe something like:

   # Set atomicity_dir to builtins if all but the long long test above passes,
   # or if the builtins were already chosen (e.g. by configure.host).

OK with an adjusted comment, thanks.
Sebastian Huber Sept. 22, 2016, 8:49 a.m. UTC | #3
On 22/09/16 10:47, Jonathan Wakely wrote:
> On 22/09/16 09:41 +0200, Sebastian Huber wrote:
>> libstdc++-v3/
>>     * config/cpu/m68k/atomicity.h: Adjust comment.
>>     * acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Honor
>>     explicit atomicity_dir setup via configure.host.
>>     * configure.host (rtems-*): Set atomicity_dir.
>>     * configure: Regenerate.
>> ---
>> libstdc++-v3/acinclude.m4                |  5 +++--
>> libstdc++-v3/config/cpu/m68k/atomicity.h |  3 +++
>> libstdc++-v3/configure                   | 11 ++++++-----
>> libstdc++-v3/configure.host              |  4 ++++
>> 4 files changed, 16 insertions(+), 7 deletions(-)
>>
>> diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>> index 6d897be..3256ce4 100644
>> --- a/libstdc++-v3/acinclude.m4
>> +++ b/libstdc++-v3/acinclude.m4
>> @@ -3490,9 +3490,10 @@ EOF
>>   AC_LANG_RESTORE
>>
>>   # Set atomicity_dir to builtins if all but the long long test above 
>> passes.
>> -  if test "$glibcxx_cv_atomic_bool" = yes \
>> +  if ( test "$glibcxx_cv_atomic_bool" = yes \
>>      && test "$glibcxx_cv_atomic_short" = yes \
>> -     && test "$glibcxx_cv_atomic_int" = yes; then
>> +     && test "$glibcxx_cv_atomic_int" = yes ) \
>> +     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
>
> Could you adjust the comment too please? Maybe something like:
>
>   # Set atomicity_dir to builtins if all but the long long test above 
> passes,
>   # or if the builtins were already chosen (e.g. by configure.host).
>
> OK with an adjusted comment, thanks.
>
>

Thanks for the quick review. I would like to back port this to GCC 6.
Jonathan Wakely Sept. 22, 2016, 8:50 a.m. UTC | #4
On 22/09/16 09:47 +0100, Jonathan Wakely wrote:
>On 22/09/16 09:41 +0200, Sebastian Huber wrote:
>>libstdc++-v3/
>>	* config/cpu/m68k/atomicity.h: Adjust comment.
>>	* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Honor
>>	explicit atomicity_dir setup via configure.host.
>>	* configure.host (rtems-*): Set atomicity_dir.
>>	* configure: Regenerate.
>>---
>>libstdc++-v3/acinclude.m4                |  5 +++--
>>libstdc++-v3/config/cpu/m68k/atomicity.h |  3 +++
>>libstdc++-v3/configure                   | 11 ++++++-----
>>libstdc++-v3/configure.host              |  4 ++++
>>4 files changed, 16 insertions(+), 7 deletions(-)
>>
>>diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>>index 6d897be..3256ce4 100644
>>--- a/libstdc++-v3/acinclude.m4
>>+++ b/libstdc++-v3/acinclude.m4
>>@@ -3490,9 +3490,10 @@ EOF
>>  AC_LANG_RESTORE
>>
>>  # Set atomicity_dir to builtins if all but the long long test above passes.
>>-  if test "$glibcxx_cv_atomic_bool" = yes \
>>+  if ( test "$glibcxx_cv_atomic_bool" = yes \
>>     && test "$glibcxx_cv_atomic_short" = yes \
>>-     && test "$glibcxx_cv_atomic_int" = yes; then
>>+     && test "$glibcxx_cv_atomic_int" = yes ) \
>>+     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
>
>Could you adjust the comment too please? Maybe something like:
>
>  # Set atomicity_dir to builtins if all but the long long test above passes,
>  # or if the builtins were already chosen (e.g. by configure.host).
>
>OK with an adjusted comment, thanks.

(And adjusted for Andreas's point about {} too of course, so we don't
start a subshell here.)
Jonathan Wakely Sept. 22, 2016, 10:28 a.m. UTC | #5
On 22/09/16 10:49 +0200, Sebastian Huber wrote:
>
>
>On 22/09/16 10:47, Jonathan Wakely wrote:
>>On 22/09/16 09:41 +0200, Sebastian Huber wrote:
>>>libstdc++-v3/
>>>    * config/cpu/m68k/atomicity.h: Adjust comment.
>>>    * acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Honor
>>>    explicit atomicity_dir setup via configure.host.
>>>    * configure.host (rtems-*): Set atomicity_dir.
>>>    * configure: Regenerate.
>>>---
>>>libstdc++-v3/acinclude.m4                |  5 +++--
>>>libstdc++-v3/config/cpu/m68k/atomicity.h |  3 +++
>>>libstdc++-v3/configure                   | 11 ++++++-----
>>>libstdc++-v3/configure.host              |  4 ++++
>>>4 files changed, 16 insertions(+), 7 deletions(-)
>>>
>>>diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>>>index 6d897be..3256ce4 100644
>>>--- a/libstdc++-v3/acinclude.m4
>>>+++ b/libstdc++-v3/acinclude.m4
>>>@@ -3490,9 +3490,10 @@ EOF
>>>  AC_LANG_RESTORE
>>>
>>>  # Set atomicity_dir to builtins if all but the long long test 
>>>above passes.
>>>-  if test "$glibcxx_cv_atomic_bool" = yes \
>>>+  if ( test "$glibcxx_cv_atomic_bool" = yes \
>>>     && test "$glibcxx_cv_atomic_short" = yes \
>>>-     && test "$glibcxx_cv_atomic_int" = yes; then
>>>+     && test "$glibcxx_cv_atomic_int" = yes ) \
>>>+     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
>>
>>Could you adjust the comment too please? Maybe something like:
>>
>>  # Set atomicity_dir to builtins if all but the long long test 
>>above passes,
>>  # or if the builtins were already chosen (e.g. by configure.host).
>>
>>OK with an adjusted comment, thanks.
>>
>>
>
>Thanks for the quick review. I would like to back port this to GCC 6.

No objection from me, as the common part won't affect other targets.
So if you're confident doing so as RTEMS maintainer then go ahead.
Jonathan Wakely Sept. 22, 2016, 10:55 a.m. UTC | #6
On 22/09/16 11:28 +0100, Jonathan Wakely wrote:
>On 22/09/16 10:49 +0200, Sebastian Huber wrote:
>>
>>
>>On 22/09/16 10:47, Jonathan Wakely wrote:
>>>On 22/09/16 09:41 +0200, Sebastian Huber wrote:
>>>>libstdc++-v3/
>>>>   * config/cpu/m68k/atomicity.h: Adjust comment.
>>>>   * acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Honor
>>>>   explicit atomicity_dir setup via configure.host.
>>>>   * configure.host (rtems-*): Set atomicity_dir.
>>>>   * configure: Regenerate.
>>>>---
>>>>libstdc++-v3/acinclude.m4                |  5 +++--
>>>>libstdc++-v3/config/cpu/m68k/atomicity.h |  3 +++
>>>>libstdc++-v3/configure                   | 11 ++++++-----
>>>>libstdc++-v3/configure.host              |  4 ++++
>>>>4 files changed, 16 insertions(+), 7 deletions(-)
>>>>
>>>>diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>>>>index 6d897be..3256ce4 100644
>>>>--- a/libstdc++-v3/acinclude.m4
>>>>+++ b/libstdc++-v3/acinclude.m4
>>>>@@ -3490,9 +3490,10 @@ EOF
>>>> AC_LANG_RESTORE
>>>>
>>>> # Set atomicity_dir to builtins if all but the long long test 
>>>>above passes.
>>>>-  if test "$glibcxx_cv_atomic_bool" = yes \
>>>>+  if ( test "$glibcxx_cv_atomic_bool" = yes \
>>>>    && test "$glibcxx_cv_atomic_short" = yes \
>>>>-     && test "$glibcxx_cv_atomic_int" = yes; then
>>>>+     && test "$glibcxx_cv_atomic_int" = yes ) \
>>>>+     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
>>>
>>>Could you adjust the comment too please? Maybe something like:
>>>
>>> # Set atomicity_dir to builtins if all but the long long test 
>>>above passes,
>>> # or if the builtins were already chosen (e.g. by configure.host).
>>>
>>>OK with an adjusted comment, thanks.
>>>
>>>
>>
>>Thanks for the quick review. I would like to back port this to GCC 6.
>
>No objection from me, as the common part won't affect other targets.
>So if you're confident doing so as RTEMS maintainer then go ahead.

N.B. if you're going to require libatomic for RTEMS then you should
check if the preprocessor conditions in libsupc++/exception_ptr.h
and libsupc++/eh_ptr.cc are appropriate. If exception_ptr is not
currently enabled for RTEMS then you could enable it, since libatomic
will ensure the required atomics are available.
Sebastian Huber Sept. 27, 2016, 11:24 a.m. UTC | #7
On 22/09/16 12:55, Jonathan Wakely wrote:
> [...]
> N.B. if you're going to require libatomic for RTEMS then you should
> check if the preprocessor conditions in libsupc++/exception_ptr.h
> and libsupc++/eh_ptr.cc are appropriate. If exception_ptr is not
> currently enabled for RTEMS then you could enable it, since libatomic
> will ensure the required atomics are available. 

Thanks for the hint. I added a ticket for RTEMS:

http://devel.rtems.org/ticket/2791
diff mbox

Patch

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 6d897be..3256ce4 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3490,9 +3490,10 @@  EOF
   AC_LANG_RESTORE
 
   # Set atomicity_dir to builtins if all but the long long test above passes.
-  if test "$glibcxx_cv_atomic_bool" = yes \
+  if ( test "$glibcxx_cv_atomic_bool" = yes \
      && test "$glibcxx_cv_atomic_short" = yes \
-     && test "$glibcxx_cv_atomic_int" = yes; then
+     && test "$glibcxx_cv_atomic_int" = yes ) \
+     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
     AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS, 1,
     [Define if the compiler supports C++11 atomics.])
     atomicity_dir=cpu/generic/atomicity_builtins
diff --git a/libstdc++-v3/config/cpu/m68k/atomicity.h b/libstdc++-v3/config/cpu/m68k/atomicity.h
index f421330..a9ddc6b 100644
--- a/libstdc++-v3/config/cpu/m68k/atomicity.h
+++ b/libstdc++-v3/config/cpu/m68k/atomicity.h
@@ -48,6 +48,9 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
 #elif defined(__rtems__)
+  // This code is only provided for reference.  RTEMS uses now the atomic
+  // builtins and libatomic.  See configure.host.
+  //
   // TAS/JBNE is unsafe on systems with strict priority-based scheduling.
   // Disable interrupts, which we can do only from supervisor mode.
   _Atomic_word
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 6332c4d..ac9282d 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -15539,9 +15539,10 @@  ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
   # Set atomicity_dir to builtins if all but the long long test above passes.
-  if test "$glibcxx_cv_atomic_bool" = yes \
+  if ( test "$glibcxx_cv_atomic_bool" = yes \
      && test "$glibcxx_cv_atomic_short" = yes \
-     && test "$glibcxx_cv_atomic_int" = yes; then
+     && test "$glibcxx_cv_atomic_int" = yes ) \
+     || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
 
 $as_echo "#define _GLIBCXX_ATOMIC_BUILTINS 1" >>confdefs.h
 
@@ -15573,7 +15574,7 @@  $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 15576 "configure"
+#line 15577 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -15615,7 +15616,7 @@  ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 15618 "configure"
+#line 15619 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -15649,7 +15650,7 @@  $as_echo "$enable_int128" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15652 "configure"
+#line 15653 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index c0cc3ee..eb56ab1 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -296,6 +296,10 @@  case "${host_os}" in
     os_include_dir="os/qnx/qnx6.1"
     c_model=c
     ;;
+  rtems*)
+    # Use libatomic if necessary and avoid libstdc++ specific atomicity support
+    atomicity_dir="cpu/generic/atomicity_builtins"
+    ;;
   solaris2)
     # This too-vague configuration does not provide enough information
     # to select a ctype include, and thus os_include_dir is a crap shoot.