[PATCH] libstdc++: bvector: undef always_inline macro
Alexandre Oliva
oliva@adacore.com
Wed Nov 15 05:53:53 GMT 2023
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
More information about the Libstdc++
mailing list