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