You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2008/07/27 00:09:58 UTC

svn commit: r680049 - in /stdcxx/branches/4.2.x/include/rw: _config-gcc.h _defs.h

Author: sebor
Date: Sat Jul 26 15:09:58 2008
New Revision: 680049

URL: http://svn.apache.org/viewvc?rev=680049&view=rev
Log:
2008-07-26  Martin Sebor  <se...@roguewave.com>

	STDCXX-998
	* include/rw/_defs.h [_RWSTD_ATTRIBUTE_NOTHROW] (_RWSTD_DECLARE_NOTHROW,
	_RWSTD_DEFINE_NOTHROW): Defined new helper macros to make it possible to
	declare functions with the attribute((nothrow)) when it's available and
	to use the empty exception specification to emulate the same feature
	when it isn't.
	(__rw_assert_fail): Used _RWSTD_DECLARE_NOTHROW.
	* include/rw/_config-gcc.h [gcc >= 3.3] (RWSTD_ATTRIBUTE_NOTHROW):
	Defined.

Modified:
    stdcxx/branches/4.2.x/include/rw/_config-gcc.h
    stdcxx/branches/4.2.x/include/rw/_defs.h

Modified: stdcxx/branches/4.2.x/include/rw/_config-gcc.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/rw/_config-gcc.h?rev=680049&r1=680048&r2=680049&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/rw/_config-gcc.h (original)
+++ stdcxx/branches/4.2.x/include/rw/_config-gcc.h Sat Jul 26 15:09:58 2008
@@ -88,6 +88,13 @@
 // (it may still exit by throwing an exception or by calling longjmp)
 #define _RWSTD_ATTRIBUTE_NORETURN   _RWSTD_GNUC_ATTRIBUTE ((noreturn))
 
+#if __GNUG__ > 3 || __GNUG__ == 3 && __GNUC_MINOR__ >= 3
+  // gcc attribute((nothrow)) to indicate that a function doesn't throw
+  // exceptions; unlike the emtpy exception specification the attribute
+  // avoids the cost of checking for exceptions and calling unexpected()
+#  define _RWSTD_ATTRIBUTE_NOTHROW   _RWSTD_GNUC_ATTRIBUTE ((nothrow))
+#endif   // gcc >= 3.3
+
 #ifdef _RWSTD_OS_LINUX
 
 #  ifdef _RWSTD_NO_NEW_HEADER

Modified: stdcxx/branches/4.2.x/include/rw/_defs.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/rw/_defs.h?rev=680049&r1=680048&r2=680049&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/rw/_defs.h (original)
+++ stdcxx/branches/4.2.x/include/rw/_defs.h Sat Jul 26 15:09:58 2008
@@ -1133,6 +1133,19 @@
 #endif   // _RWSTD_ATTR_NORETURN
 
 
+#ifdef _RWSTD_ATTRIBUTE_NOTHROW
+   // gcc (and others) __attribute__ ((nothrow))
+#  define _RWSTD_DECLARE_NOTHROW  _RWSTD_ATTRIBUTE_NOTHROW
+   // attributes cannot appear on function definitions
+#  define _RWSTD_DEFINE_NOTHROW   /* empty */
+#else
+   // emulate using empty exception specifications which must
+   // be specified for both declarations and definitions
+#  define _RWSTD_DECLARE_NOTHROW  _THROWS(())
+#  define _RWSTD_DEFINE_NOTHROW   _THROWS(())
+#endif   // _RWSTD_ATTR_NORETURN
+
+
 // compile-time assertion - asserts constant expressions during
 // compilation with no runtime overhead; failed assertions are reported
 // as compilation errors
@@ -1154,7 +1167,8 @@
 // called for failed assertions
 void _RWSTD_EXPORT
 __rw_assert_fail (const char*, const char*, int, const char*)
-    _RWSTD_ATTRIBUTE_NORETURN;
+    _RWSTD_ATTRIBUTE_NORETURN _RWSTD_DECLARE_NOTHROW;
+
 
 
 #ifdef __SUNPRO_CC