public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <oliva@adacore.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: "Jonathan Wakely" <jwakely@redhat.com>,
	"François Dumont" <frs.dumont@gmail.com>,
	"Jonathan Wakely" <jwakely.gcc@gmail.com>,
	libstdc++ <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++: bvector: undef always_inline macro
Date: Wed, 15 Nov 2023 02:53:53 -0300	[thread overview]
Message-ID: <or7cmj36ku.fsf@lxoliva.fsfla.org> (raw)
In-Reply-To: <0bc0279d-0f50-a0a6-1535-50dbb6ce1110@idea> (Patrick Palka's message of "Tue, 14 Nov 2023 21:20:55 -0500 (EST)")

On Nov 14, 2023, Patrick Palka <ppalka@redhat.com> wrote:

> Hmm, in which headers do we currently undef _GLIBCXX_ALWAYS_INLINE?

None whatsoever, AFAICT.  Of the 7 headers that mention
_GLIBCXX_ALWAYS_INLINE, some (but not all) #define it, and none #undef it.

Bringing them in line with the alleged custom would require an
(untested) patch like this.  (It also makes sure that no #include stands
between the #define and the uses)


libstdc++: define and undefine always_inline macro wherever used

---
 libstdc++-v3/include/bits/atomic_base.h    |   10 ++++++----
 libstdc++-v3/include/bits/atomic_futex.h   |    2 ++
 libstdc++-v3/include/bits/char_traits.h    |    8 +++++---
 libstdc++-v3/include/bits/semaphore_base.h |    7 +++++++
 libstdc++-v3/include/bits/stl_bvector.h    |   10 ++++++----
 libstdc++-v3/include/std/barrier           |    8 ++++++++
 libstdc++-v3/include/std/latch             |    7 +++++++
 7 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 974872ad7a630..5562365c74c74 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -42,14 +42,14 @@
 #include <bits/atomic_wait.h>
 #endif
 
-#ifndef _GLIBCXX_ALWAYS_INLINE
-#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
-#endif
-
 #define __glibcxx_want_atomic_value_initialization
 #define __glibcxx_want_atomic_flag_test
 #include <bits/version.h>
 
+#ifndef _GLIBCXX_ALWAYS_INLINE
+#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -2067,4 +2067,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
+#undef _GLIBCXX_ALWAYS_INLINE
+
 #endif
diff --git a/libstdc++-v3/include/bits/atomic_futex.h b/libstdc++-v3/include/bits/atomic_futex.h
index 6b37ce5ed120e..0f370fa82de06 100644
--- a/libstdc++-v3/include/bits/atomic_futex.h
+++ b/libstdc++-v3/include/bits/atomic_futex.h
@@ -357,4 +357,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
+#undef _GLIBCXX_ALWAYS_INLINE
+
 #endif
diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index e9b4e84af994f..e56818b254b67 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -57,13 +57,13 @@
 # include <bits/stl_construct.h>
 #endif
 
+#define __glibcxx_want_constexpr_char_traits
+#include <bits/version.h>
+
 #ifndef _GLIBCXX_ALWAYS_INLINE
 # define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
 #endif
 
-#define __glibcxx_want_constexpr_char_traits
-#include <bits/version.h>
-
 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -1027,4 +1027,6 @@ _GLIBCXX_END_NAMESPACE_VERSION
 
 #endif  // C++11
 
+#undef _GLIBCXX_ALWAYS_INLINE
+
 #endif // _CHAR_TRAITS_H
diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h
index 2b3c196040baa..06a45f6876a26 100644
--- a/libstdc++-v3/include/bits/semaphore_base.h
+++ b/libstdc++-v3/include/bits/semaphore_base.h
@@ -45,6 +45,10 @@
 # include <semaphore.h>	// sem_t, sem_init, sem_wait, sem_post etc.
 #endif
 
+#ifndef _GLIBCXX_ALWAYS_INLINE
+#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -274,4 +278,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
+
+#undef _GLIBCXX_ALWAYS_INLINE
+
 #endif // _GLIBCXX_SEMAPHORE_BASE_H
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 64f04c1f4f599..c1aa3396414d2 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -56,15 +56,15 @@
 #ifndef _STL_BVECTOR_H
 #define _STL_BVECTOR_H 1
 
-#ifndef _GLIBCXX_ALWAYS_INLINE
-#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
-#endif
-
 #if __cplusplus >= 201103L
 #include <initializer_list>
 #include <bits/functional_hash.h>
 #endif
 
+#ifndef _GLIBCXX_ALWAYS_INLINE
+#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -1630,4 +1630,6 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
+#undef _GLIBCXX_ALWAYS_INLINE
+
 #endif
diff --git a/libstdc++-v3/include/std/barrier b/libstdc++-v3/include/std/barrier
index 8e03a5820c6e5..5aaffa62086c4 100644
--- a/libstdc++-v3/include/std/barrier
+++ b/libstdc++-v3/include/std/barrier
@@ -52,6 +52,10 @@
 
 #include <array>
 
+#ifndef _GLIBCXX_ALWAYS_INLINE
+#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -261,5 +265,9 @@ It looks different from literature pseudocode for two main reasons:
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+
+#undef _GLIBCXX_ALWAYS_INLINE
+
 #endif // __cpp_lib_barrier
+
 #endif // _GLIBCXX_BARRIER
diff --git a/libstdc++-v3/include/std/latch b/libstdc++-v3/include/std/latch
index 27cd80d71005f..0548ddd67ae57 100644
--- a/libstdc++-v3/include/std/latch
+++ b/libstdc++-v3/include/std/latch
@@ -40,6 +40,10 @@
 #include <bits/atomic_base.h>
 #include <ext/numeric_traits.h>
 
+#ifndef _GLIBCXX_ALWAYS_INLINE
+#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -90,5 +94,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+
+#undef _GLIBCXX_ALWAYS_INLINE
+
 #endif // __cpp_lib_latch
 #endif // _GLIBCXX_LATCH


-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

  reply	other threads:[~2023-11-15  5:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 16:10 [PATCH] libstdc++: optimize bit iterators assuming normalization [PR110807] Alexandre Oliva
2023-11-08 19:32 ` Jonathan Wakely
2023-11-09  1:17   ` [PATCH v2] " Alexandre Oliva
2023-11-09  1:22     ` Jonathan Wakely
2023-11-09  3:36       ` [PATCH v3] " Alexandre Oliva
2023-11-09  5:57         ` François Dumont
2023-11-09  8:16           ` Jonathan Wakely
2023-11-09 19:49             ` [PATCH] libstdc++: bvector: undef always_inline macro Alexandre Oliva
2023-11-09 20:18               ` Jonathan Wakely
2023-11-15  2:20                 ` Patrick Palka
2023-11-15  5:53                   ` Alexandre Oliva [this message]
2023-11-15  2:44                 ` Alexandre Oliva
2023-11-15  5:08                   ` Alexandre Oliva
2023-11-15  8:22                   ` Jonathan Wakely
2023-11-16  4:40                     ` Alexandre Oliva
2024-02-07 16:25       ` [PATCH v2] libstdc++: optimize bit iterators assuming normalization [PR110807] Torbjorn SVENSSON
2024-02-07 16:36         ` Jonathan Wakely
2024-02-09  8:49           ` Torbjorn SVENSSON

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=or7cmj36ku.fsf@lxoliva.fsfla.org \
    --to=oliva@adacore.com \
    --cc=frs.dumont@gmail.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).