3232#define HAVE_PTHREAD_RWLOCK
3333#endif
3434
35+ #ifndef THROW_OR_ABORT
36+ # if __cpp_exceptions
37+ # define THROW_OR_ABORT (exception ) (throw (exception))
38+ # else
39+ # include < cstdlib>
40+ # define THROW_OR_ABORT (exception ) \
41+ do { \
42+ (void )exception; \
43+ std::abort (); \
44+ } while (0 )
45+ # endif
46+ #endif
47+
3548namespace std {
3649namespace detail {
3750
@@ -62,13 +75,13 @@ class shared_mutex_pthread {
6275 shared_mutex_pthread () {
6376 int __ret = pthread_rwlock_init (&_M_rwlock, NULL );
6477 if (__ret == ENOMEM)
65- throw std::bad_alloc ();
78+ THROW_OR_ABORT ( std::bad_alloc () );
6679 else if (__ret == EAGAIN)
67- throw std::system_error (
68- std::make_error_code (errc::resource_unavailable_try_again));
80+ THROW_OR_ABORT ( std::system_error (
81+ std::make_error_code (errc::resource_unavailable_try_again))) ;
6982 else if (__ret == EPERM)
70- throw std::system_error (
71- std::make_error_code (errc::operation_not_permitted));
83+ THROW_OR_ABORT ( std::system_error (
84+ std::make_error_code (errc::operation_not_permitted))) ;
7285 // Errors not handled: EBUSY, EINVAL
7386 assert (__ret == 0 );
7487 }
@@ -86,8 +99,8 @@ class shared_mutex_pthread {
8699 void lock () {
87100 int __ret = pthread_rwlock_wrlock (&_M_rwlock);
88101 if (__ret == EDEADLK)
89- throw std::system_error (
90- std::make_error_code (errc::resource_deadlock_would_occur));
102+ THROW_OR_ABORT ( std::system_error (
103+ std::make_error_code (errc::resource_deadlock_would_occur))) ;
91104 // Errors not handled: EINVAL
92105 assert (__ret == 0 );
93106 }
@@ -119,8 +132,8 @@ class shared_mutex_pthread {
119132 __ret = pthread_rwlock_rdlock (&_M_rwlock);
120133 } while (__ret == EAGAIN);
121134 if (__ret == EDEADLK)
122- throw std::system_error (
123- std::make_error_code (errc::resource_deadlock_would_occur));
135+ THROW_OR_ABORT ( std::system_error (
136+ std::make_error_code (errc::resource_deadlock_would_occur))) ;
124137 // Errors not handled: EINVAL
125138 assert (__ret == 0 );
126139 }
@@ -369,8 +382,8 @@ class shared_lock {
369382
370383 void unlock () {
371384 if (!_M_owns)
372- throw std::system_error (
373- std::make_error_code (errc::resource_deadlock_would_occur));
385+ THROW_OR_ABORT ( std::system_error (
386+ std::make_error_code (errc::resource_deadlock_would_occur))) ;
374387 _M_pm->unlock_shared ();
375388 _M_owns = false ;
376389 }
@@ -394,11 +407,11 @@ class shared_lock {
394407 private:
395408 void _M_lockable () const {
396409 if (_M_pm == nullptr )
397- throw std::system_error (
398- std::make_error_code (errc::operation_not_permitted));
410+ THROW_OR_ABORT ( std::system_error (
411+ std::make_error_code (errc::operation_not_permitted))) ;
399412 if (_M_owns)
400- throw std::system_error (
401- std::make_error_code (errc::resource_deadlock_would_occur));
413+ THROW_OR_ABORT ( std::system_error (
414+ std::make_error_code (errc::resource_deadlock_would_occur))) ;
402415 }
403416
404417 mutex_type* _M_pm;
0 commit comments