This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
More function decorations
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: libstdc++ at gcc dot gnu dot org, Paolo Carlini <paolo dot carlini at oracle dot com>
- Date: Fri, 17 Apr 2009 13:28:14 +0200
- Subject: More function decorations
Hi,
this patch adds Paolo's _GLIBCXX_PURE and _GLIBCXX_CONST macros. I also
added _GLIBCXX_NORETURN that is important marker too.
For _GLIBCXX_NORETURN I found only one use so far that is in _M_error of
debug/formater.h and I added decorations to the stl_tree to finish the
file and started in Makefile order with atomic.cc
I noticed that atomic already have __attribute__ ((const)) marker and it
is missing __const__ around it, so I decided to stop here and discuss
procedure. I guess we want to update them to _GLIBCXX_CONST macros for
consistency?
Tested on x86_64-linux
Honza
* include/debug/formater.h: Include bits/c++config.h.
(_M_error): Mark noreturn.
* include/bits/c++config (_GLIBCXX_PURE, _GLIBCXX_CONST,
_GLIBCXX_NORETURN): New.
* include/bits/stl_tree.h (_Rb_tree_increment, _Rb_tree_increment,
_Rb_tree_decrement, _Rb_tree_decrement, _Rb_tree_black_count): Mark pure.
* include/c_compatibility/stdatomic.h (atomic_flag_test_and_set_explicit,
atomic_flag_clear_explicit, __atomic_flag_wait_explicit,
__atomic_flag_for_address): Mark by throw ().
* src/atomic.cc (atomic_flag_test_and_set_explicit,
atomic_flag_clear_explicit, __atomic_flag_wait_explicit,
__atomic_flag_for_address): Mark by throw ().
Index: src/atomic.cc
===================================================================
--- src/atomic.cc (revision 146188)
+++ src/atomic.cc (working copy)
@@ -78,7 +78,7 @@
{
bool
atomic_flag_test_and_set_explicit(volatile __atomic_flag_base* __a,
- memory_order __m)
+ memory_order __m) throw ()
{
volatile atomic_flag d(__a->_M_i);
return d.test_and_set(__m);
@@ -86,7 +86,7 @@
void
atomic_flag_clear_explicit(volatile __atomic_flag_base* __a,
- memory_order __m)
+ memory_order __m) throw ()
{
volatile atomic_flag d(__a->_M_i);
return d.clear(__m);
@@ -94,14 +94,14 @@
void
__atomic_flag_wait_explicit(volatile __atomic_flag_base* __a,
- memory_order __x)
+ memory_order __x) throw ()
{
while (atomic_flag_test_and_set_explicit(__a, __x))
{ };
}
volatile __atomic_flag_base*
- __atomic_flag_for_address(const volatile void* __z)
+ __atomic_flag_for_address(const volatile void* __z) throw ()
{
uintptr_t __u = reinterpret_cast<uintptr_t>(__z);
__u += (__u >> 2) + (__u << 4);
Index: include/debug/formatter.h
===================================================================
--- include/debug/formatter.h (revision 146188)
+++ include/debug/formatter.h (working copy)
@@ -29,6 +29,7 @@
#ifndef _GLIBCXX_DEBUG_FORMATTER_H
#define _GLIBCXX_DEBUG_FORMATTER_H 1
+#include <bits/c++config.h>
#include <typeinfo>
#include <debug/debug.h>
@@ -347,7 +348,7 @@
const _Error_formatter&
_M_message(_Debug_msg_id __id) const;
- void
+ _GLIBCXX_NORETURN void
_M_error() const;
private:
Index: include/bits/c++config
===================================================================
--- include/bits/c++config (revision 146188)
+++ include/bits/c++config (working copy)
@@ -314,4 +314,16 @@
#undef min
#undef max
+#ifndef _GLIBCXX_PURE
+# define _GLIBCXX_PURE __attribute__ ((__pure__))
+#endif
+
+#ifndef _GLIBCXX_CONST
+# define _GLIBCXX_CONST __attribute__ ((__const__))
+#endif
+
+#ifndef _GLIBCXX_NORETURN
+# define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
+#endif
+
// End of prewritten config; the discovered settings follow.
Index: include/bits/stl_tree.h
===================================================================
--- include/bits/stl_tree.h (revision 146188)
+++ include/bits/stl_tree.h (working copy)
@@ -137,16 +137,16 @@
#endif
};
- _Rb_tree_node_base*
+ _GLIBCXX_PURE _Rb_tree_node_base*
_Rb_tree_increment(_Rb_tree_node_base* __x) throw ();
- const _Rb_tree_node_base*
+ _GLIBCXX_PURE const _Rb_tree_node_base*
_Rb_tree_increment(const _Rb_tree_node_base* __x) throw ();
- _Rb_tree_node_base*
+ _GLIBCXX_PURE _Rb_tree_node_base*
_Rb_tree_decrement(_Rb_tree_node_base* __x) throw ();
- const _Rb_tree_node_base*
+ _GLIBCXX_PURE const _Rb_tree_node_base*
_Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ();
template<typename _Tp>
@@ -1448,7 +1448,7 @@
return __n;
}
- unsigned int
+ _GLIBCXX_PURE unsigned int
_Rb_tree_black_count(const _Rb_tree_node_base* __node,
const _Rb_tree_node_base* __root) throw ();
Index: include/c_compatibility/stdatomic.h
===================================================================
--- include/c_compatibility/stdatomic.h (revision 146188)
+++ include/c_compatibility/stdatomic.h (working copy)
@@ -121,24 +121,24 @@
// Accessor functions for base atomic_flag type.
bool
- atomic_flag_test_and_set_explicit(volatile __atomic_flag_base*, memory_order);
+ atomic_flag_test_and_set_explicit(volatile __atomic_flag_base*, memory_order) throw ();
inline bool
atomic_flag_test_and_set(volatile __atomic_flag_base* __a)
{ return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
void
- atomic_flag_clear_explicit(volatile __atomic_flag_base*, memory_order);
+ atomic_flag_clear_explicit(volatile __atomic_flag_base*, memory_order) throw ();
inline void
atomic_flag_clear(volatile __atomic_flag_base* __a)
{ atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
void
- __atomic_flag_wait_explicit(volatile __atomic_flag_base*, memory_order);
+ __atomic_flag_wait_explicit(volatile __atomic_flag_base*, memory_order) throw ();
volatile __atomic_flag_base*
- __atomic_flag_for_address(const volatile void* __z) __attribute__((const));
+ __atomic_flag_for_address(const volatile void* __z) throw () __attribute__((const));
// Implementation specific defines.
#define _ATOMIC_LOAD_(__a, __x) \