blob: 9e7b21ba6a367f7b3e2a267f0c1aa2712710cccf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// { dg-do compile }
typedef __SIZE_TYPE__ size_t;
class bad_alloc { };
typedef struct {
} __gthread_mutex_t;
int __gthread_mutex_unlock (__gthread_mutex_t *__mutex);
class __concurrence_unlock_error {
};
inline void __throw_concurrence_unlock_error() {
throw __concurrence_unlock_error();
}
class __mutex {
__gthread_mutex_t _M_mutex;
public:
void unlock() {
if (__gthread_mutex_unlock(&_M_mutex) != 0)
__throw_concurrence_unlock_error();
}
};
class free_list {
typedef __mutex __mutex_type;
__mutex_type& _M_get_mutex();
void _M_get(size_t __sz) throw(bad_alloc);
};
void free_list::_M_get(size_t __sz) throw(bad_alloc)
{
__mutex_type& __bfl_mutex = _M_get_mutex();
__bfl_mutex.unlock();
int __ctr = 2;
while (__ctr) {
size_t* __ret = 0;
--__ctr;
try {
__ret = (size_t*) (::operator new(__sz + sizeof(size_t)));
}
catch(const bad_alloc&) { }
}
}
|