| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
typedef __SIZE_TYPE__ size_t; |
| 4 |
void* __cxa_allocate_exception(size_t) throw(); |
| 5 |
typedef struct { } __gthread_mutex_t; |
| 6 |
extern int __gthr_win32_mutex_unlock (__gthread_mutex_t *); |
| 7 |
int __gthread_mutex_lock (__gthread_mutex_t *__mutex); |
| 8 |
int __gthread_mutex_unlock (__gthread_mutex_t *__mutex); |
| 9 |
void __throw_concurrence_lock_error(); |
| 10 |
void __throw_concurrence_unlock_error(); |
| 11 |
class __mutex { |
| 12 |
__gthread_mutex_t _M_mutex; |
| 13 |
public: |
| 14 |
void lock() { |
| 15 |
if (__gthread_mutex_lock(&_M_mutex) != 0) |
| 16 |
__throw_concurrence_lock_error(); |
| 17 |
} |
| 18 |
void unlock() { |
| 19 |
if (__gthread_mutex_unlock(&_M_mutex) != 0) |
| 20 |
__throw_concurrence_unlock_error(); |
| 21 |
} |
| 22 |
}; |
| 23 |
class __scoped_lock { |
| 24 |
typedef __mutex __mutex_type; |
| 25 |
__mutex_type& _M_device; |
| 26 |
public: |
| 27 |
explicit __scoped_lock(__mutex_type& __name) : _M_device(__name) { |
| 28 |
_M_device.lock(); |
| 29 |
} |
| 30 |
~__scoped_lock() throw() { |
| 31 |
_M_device.unlock(); |
| 32 |
} |
| 33 |
}; |
| 34 |
__mutex emergency_mutex; |
| 35 |
void * __cxa_allocate_exception(size_t thrown_size) throw() |
| 36 |
{ |
| 37 |
void *ret; |
| 38 |
if (! ret) |
| 39 |
__scoped_lock sentry(emergency_mutex); |
| 40 |
return 0; |
| 41 |
} |