1// { dg-do compile }
2
3typedef __SIZE_TYPE__ size_t;
4void*   __cxa_allocate_exception(size_t) throw();
5typedef struct { } __gthread_mutex_t;
6extern int __gthr_win32_mutex_unlock (__gthread_mutex_t *);
7int __gthread_mutex_lock (__gthread_mutex_t *__mutex);
8int __gthread_mutex_unlock (__gthread_mutex_t *__mutex);
9void   __throw_concurrence_lock_error();
10void   __throw_concurrence_unlock_error();
11class __mutex   {
12    __gthread_mutex_t _M_mutex;
13public:
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};
23class __scoped_lock   {
24    typedef __mutex __mutex_type;
25    __mutex_type& _M_device;
26public:
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;
35void * __cxa_allocate_exception(size_t thrown_size) throw()
36{
37  void *ret;
38  if (! ret)
39    __scoped_lock sentry(emergency_mutex);
40}
41