2001-03-28 19:04:51 +08:00
|
|
|
// -*- C++ -*- Allocate exception objects.
|
2022-01-03 17:42:10 +08:00
|
|
|
// Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
2001-03-28 19:04:51 +08:00
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-25 00:22:03 +08:00
|
|
|
// This file is part of GCC.
|
2001-03-28 19:04:51 +08:00
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-25 00:22:03 +08:00
|
|
|
// GCC is free software; you can redistribute it and/or modify
|
2001-03-28 19:04:51 +08:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
2009-04-09 23:00:19 +08:00
|
|
|
// the Free Software Foundation; either version 3, or (at your option)
|
2001-03-28 19:04:51 +08:00
|
|
|
// any later version.
|
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-25 00:22:03 +08:00
|
|
|
// GCC is distributed in the hope that it will be useful,
|
2001-03-28 19:04:51 +08:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
2009-04-09 23:00:19 +08:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2009-04-09 23:00:19 +08:00
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2001-03-28 19:04:51 +08:00
|
|
|
|
|
|
|
// This is derived from the C++ ABI for IA-64. Where we diverge
|
|
|
|
// for cross-architecture compatibility are noted with "@@@".
|
|
|
|
|
2005-11-22 08:19:07 +08:00
|
|
|
#include <bits/c++config.h>
|
2001-03-28 19:04:51 +08:00
|
|
|
#include <cstdlib>
|
2004-08-03 04:28:22 +08:00
|
|
|
#if _GLIBCXX_HOSTED
|
2001-03-28 19:04:51 +08:00
|
|
|
#include <cstring>
|
2004-08-03 04:28:22 +08:00
|
|
|
#endif
|
2001-07-03 07:08:28 +08:00
|
|
|
#include <climits>
|
2002-06-19 23:19:53 +08:00
|
|
|
#include <exception>
|
2001-03-28 19:04:51 +08:00
|
|
|
#include "unwind-cxx.h"
|
2006-09-14 17:48:15 +08:00
|
|
|
#include <ext/concurrence.h>
|
2015-01-22 17:21:48 +08:00
|
|
|
#include <new>
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2004-08-03 04:28:22 +08:00
|
|
|
#if _GLIBCXX_HOSTED
|
|
|
|
using std::free;
|
|
|
|
using std::malloc;
|
2006-05-10 23:43:20 +08:00
|
|
|
using std::memset;
|
2004-08-03 04:28:22 +08:00
|
|
|
#else
|
2005-12-19 08:56:05 +08:00
|
|
|
// In a freestanding environment, these functions may not be available
|
|
|
|
// -- but for now, we assume that they are.
|
2004-08-03 04:28:22 +08:00
|
|
|
extern "C" void *malloc (std::size_t);
|
|
|
|
extern "C" void free(void *);
|
2006-01-18 19:22:10 +08:00
|
|
|
extern "C" void *memset (void *, int, std::size_t);
|
2004-08-03 04:28:22 +08:00
|
|
|
#endif
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2004-08-03 04:28:22 +08:00
|
|
|
using namespace __cxxabiv1;
|
2001-03-28 19:04:51 +08:00
|
|
|
|
|
|
|
// ??? How to control these parameters.
|
|
|
|
|
|
|
|
// Guess from the size of basic types how large a buffer is reasonable.
|
|
|
|
// Note that the basic c++ exception header has 13 pointers and 2 ints,
|
|
|
|
// so on a system with PSImode pointers we're talking about 56 bytes
|
|
|
|
// just for overhead.
|
|
|
|
|
|
|
|
#if INT_MAX == 32767
|
|
|
|
# define EMERGENCY_OBJ_SIZE 128
|
|
|
|
# define EMERGENCY_OBJ_COUNT 16
|
2012-12-21 18:12:48 +08:00
|
|
|
#elif !defined (_GLIBCXX_LLP64) && LONG_MAX == 2147483647
|
2001-03-28 19:04:51 +08:00
|
|
|
# define EMERGENCY_OBJ_SIZE 512
|
|
|
|
# define EMERGENCY_OBJ_COUNT 32
|
|
|
|
#else
|
|
|
|
# define EMERGENCY_OBJ_SIZE 1024
|
|
|
|
# define EMERGENCY_OBJ_COUNT 64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GTHREADS
|
|
|
|
# undef EMERGENCY_OBJ_COUNT
|
|
|
|
# define EMERGENCY_OBJ_COUNT 4
|
|
|
|
#endif
|
|
|
|
|
2016-03-25 02:13:40 +08:00
|
|
|
namespace __gnu_cxx
|
|
|
|
{
|
|
|
|
void __freeres();
|
|
|
|
}
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2015-01-22 17:21:48 +08:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
// A fixed-size heap, variable size object allocator
|
|
|
|
class pool
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
pool();
|
|
|
|
|
2019-01-21 19:47:30 +08:00
|
|
|
_GLIBCXX_NODISCARD void *allocate (std::size_t);
|
2015-01-22 17:21:48 +08:00
|
|
|
void free (void *);
|
|
|
|
|
|
|
|
bool in_pool (void *);
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct free_entry {
|
|
|
|
std::size_t size;
|
|
|
|
free_entry *next;
|
|
|
|
};
|
|
|
|
struct allocated_entry {
|
|
|
|
std::size_t size;
|
2015-01-28 17:53:39 +08:00
|
|
|
char data[] __attribute__((aligned));
|
2015-01-22 17:21:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// A single mutex controlling emergency allocations.
|
|
|
|
__gnu_cxx::__mutex emergency_mutex;
|
|
|
|
|
|
|
|
// The free-list
|
|
|
|
free_entry *first_free_entry;
|
|
|
|
// The arena itself - we need to keep track of these only
|
|
|
|
// to implement in_pool.
|
|
|
|
char *arena;
|
|
|
|
std::size_t arena_size;
|
2016-03-25 02:13:40 +08:00
|
|
|
|
|
|
|
friend void __gnu_cxx::__freeres();
|
2015-01-22 17:21:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
pool::pool()
|
|
|
|
{
|
|
|
|
// Allocate the arena - we could add a GLIBCXX_EH_ARENA_SIZE environment
|
|
|
|
// to make this tunable.
|
|
|
|
arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
|
|
|
|
+ EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception));
|
|
|
|
arena = (char *)malloc (arena_size);
|
|
|
|
if (!arena)
|
|
|
|
{
|
|
|
|
// If the allocation failed go without an emergency pool.
|
|
|
|
arena_size = 0;
|
|
|
|
first_free_entry = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2015-01-22 17:21:48 +08:00
|
|
|
// Populate the free-list with a single entry covering the whole arena
|
|
|
|
first_free_entry = reinterpret_cast <free_entry *> (arena);
|
|
|
|
new (first_free_entry) free_entry;
|
|
|
|
first_free_entry->size = arena_size;
|
|
|
|
first_free_entry->next = NULL;
|
|
|
|
}
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2015-01-22 17:21:48 +08:00
|
|
|
void *pool::allocate (std::size_t size)
|
|
|
|
{
|
|
|
|
__gnu_cxx::__scoped_lock sentry(emergency_mutex);
|
2015-01-28 17:53:39 +08:00
|
|
|
// We need an additional size_t member plus the padding to
|
|
|
|
// ensure proper alignment of data.
|
|
|
|
size += offsetof (allocated_entry, data);
|
2015-01-22 17:21:48 +08:00
|
|
|
// And we need to at least hand out objects of the size of
|
|
|
|
// a freelist entry.
|
|
|
|
if (size < sizeof (free_entry))
|
|
|
|
size = sizeof (free_entry);
|
2015-01-28 17:53:39 +08:00
|
|
|
// And we need to align objects we hand out to the maximum
|
|
|
|
// alignment required on the target (this really aligns the
|
2015-01-22 17:21:48 +08:00
|
|
|
// tail which will become a new freelist entry).
|
2015-01-28 17:53:39 +08:00
|
|
|
size = ((size + __alignof__ (allocated_entry::data) - 1)
|
|
|
|
& ~(__alignof__ (allocated_entry::data) - 1));
|
2015-01-22 17:21:48 +08:00
|
|
|
// Search for an entry of proper size on the freelist.
|
|
|
|
free_entry **e;
|
|
|
|
for (e = &first_free_entry;
|
|
|
|
*e && (*e)->size < size;
|
|
|
|
e = &(*e)->next)
|
|
|
|
;
|
|
|
|
if (!*e)
|
|
|
|
return NULL;
|
|
|
|
allocated_entry *x;
|
|
|
|
if ((*e)->size - size >= sizeof (free_entry))
|
|
|
|
{
|
2017-06-02 16:10:48 +08:00
|
|
|
// Split block if it is too large.
|
2015-01-22 17:21:48 +08:00
|
|
|
free_entry *f = reinterpret_cast <free_entry *>
|
|
|
|
(reinterpret_cast <char *> (*e) + size);
|
|
|
|
std::size_t sz = (*e)->size;
|
|
|
|
free_entry *next = (*e)->next;
|
|
|
|
new (f) free_entry;
|
|
|
|
f->next = next;
|
|
|
|
f->size = sz - size;
|
|
|
|
x = reinterpret_cast <allocated_entry *> (*e);
|
|
|
|
new (x) allocated_entry;
|
|
|
|
x->size = size;
|
|
|
|
*e = f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Exact size match or too small overhead for a free entry.
|
|
|
|
std::size_t sz = (*e)->size;
|
|
|
|
free_entry *next = (*e)->next;
|
|
|
|
x = reinterpret_cast <allocated_entry *> (*e);
|
|
|
|
new (x) allocated_entry;
|
|
|
|
x->size = sz;
|
|
|
|
*e = next;
|
|
|
|
}
|
|
|
|
return &x->data;
|
|
|
|
}
|
[multiple changes]
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.
* testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise.
* testsuite/18_support/exception_ptr/current_exception.cc: Use it.
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise.
* testsuite/18_support/exception_ptr/lifespan.cc: Likewise.
2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at>
Add (again) exception propagation support as per N2179. Feature is
available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined.
* libsupc++/exception_ptr.h (exception_ptr, current_exception,
copy_exception, rethrow_exception): New file, implement exception
propagation.
* libsupc++/eh_ptr.cc (exception_ptr, current_exception,
rethrow_exception, __gxx_dependent_exception_cleanup): Likewise.
* libsupc++/unwind-cxx.h (__cxa_exception): Add reference count.
(__cxa_dependent_exception, __cxa_allocate_dependent_exception,
__cxa_free_dependent_exception, __get_dependent_exception_from_ue,
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception,
__gxx_dependent_exception_class, __get_object_from_ue,
__get_object_from_ambiguous_exception): Add.
(__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename.
(__is_gxx_exception_class): Handle dependent exceptions.
* libsupc++/eh_arm.cc (__cxa_type_match): Likewise.
* libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise.
* libsupc++/eh_personality.cc (__gxx_personality_*): Likewise.
* libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception,
__cxa_free_dependent_exception): Add.
* libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference
counting.
* libsupc++/exception: Conditionally include exception_ptr.h.
* libsupc++/Makefile.am: Register new files.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Add new symbols.
* testsuite/18_support/exception_ptr/current_exception.cc: Test the
core functionality of current_exception().
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the
core functionality of rethrow_exception().
* testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of
exception objects during exception propagation.
From-SVN: r139509
2008-08-23 19:28:30 +08:00
|
|
|
|
2015-01-22 17:21:48 +08:00
|
|
|
void pool::free (void *data)
|
|
|
|
{
|
|
|
|
__gnu_cxx::__scoped_lock sentry(emergency_mutex);
|
|
|
|
allocated_entry *e = reinterpret_cast <allocated_entry *>
|
2015-01-28 17:53:39 +08:00
|
|
|
(reinterpret_cast <char *> (data) - offsetof (allocated_entry, data));
|
2015-01-22 17:21:48 +08:00
|
|
|
std::size_t sz = e->size;
|
2017-06-02 16:10:48 +08:00
|
|
|
if (!first_free_entry
|
|
|
|
|| (reinterpret_cast <char *> (e) + sz
|
|
|
|
< reinterpret_cast <char *> (first_free_entry)))
|
2015-01-22 17:21:48 +08:00
|
|
|
{
|
2017-06-02 16:10:48 +08:00
|
|
|
// If the free list is empty or the entry is before the
|
|
|
|
// first element and cannot be merged with it add it as
|
|
|
|
// the first free entry.
|
2015-01-22 17:21:48 +08:00
|
|
|
free_entry *f = reinterpret_cast <free_entry *> (e);
|
|
|
|
new (f) free_entry;
|
|
|
|
f->size = sz;
|
2017-06-02 16:10:48 +08:00
|
|
|
f->next = first_free_entry;
|
2015-01-22 17:21:48 +08:00
|
|
|
first_free_entry = f;
|
|
|
|
}
|
|
|
|
else if (reinterpret_cast <char *> (e) + sz
|
|
|
|
== reinterpret_cast <char *> (first_free_entry))
|
|
|
|
{
|
|
|
|
// Check if we can merge with the first free entry being right
|
|
|
|
// after us.
|
|
|
|
free_entry *f = reinterpret_cast <free_entry *> (e);
|
|
|
|
new (f) free_entry;
|
|
|
|
f->size = sz + first_free_entry->size;
|
|
|
|
f->next = first_free_entry->next;
|
|
|
|
first_free_entry = f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Else search for a free item we can merge with at its end.
|
|
|
|
free_entry **fe;
|
|
|
|
for (fe = &first_free_entry;
|
|
|
|
(*fe)->next
|
|
|
|
&& (reinterpret_cast <char *> ((*fe)->next)
|
|
|
|
> reinterpret_cast <char *> (e) + sz);
|
|
|
|
fe = &(*fe)->next)
|
|
|
|
;
|
2017-06-02 16:10:48 +08:00
|
|
|
// If we can merge the next block into us do so and continue
|
|
|
|
// with the cases below.
|
|
|
|
if (reinterpret_cast <char *> (e) + sz
|
|
|
|
== reinterpret_cast <char *> ((*fe)->next))
|
|
|
|
{
|
|
|
|
sz += (*fe)->next->size;
|
|
|
|
(*fe)->next = (*fe)->next->next;
|
|
|
|
}
|
2015-01-22 17:21:48 +08:00
|
|
|
if (reinterpret_cast <char *> (*fe) + (*fe)->size
|
|
|
|
== reinterpret_cast <char *> (e))
|
2017-06-02 16:10:48 +08:00
|
|
|
// Merge with the freelist entry.
|
2015-01-22 17:21:48 +08:00
|
|
|
(*fe)->size += sz;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Else put it after it which keeps the freelist sorted.
|
|
|
|
free_entry *f = reinterpret_cast <free_entry *> (e);
|
|
|
|
new (f) free_entry;
|
|
|
|
f->size = sz;
|
|
|
|
f->next = (*fe)->next;
|
|
|
|
(*fe)->next = f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool pool::in_pool (void *ptr)
|
|
|
|
{
|
|
|
|
char *p = reinterpret_cast <char *> (ptr);
|
|
|
|
return (p > arena
|
|
|
|
&& p < arena + arena_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
pool emergency_pool;
|
2001-03-28 19:04:51 +08:00
|
|
|
}
|
|
|
|
|
2016-03-25 02:13:40 +08:00
|
|
|
namespace __gnu_cxx
|
|
|
|
{
|
|
|
|
void
|
|
|
|
__freeres()
|
|
|
|
{
|
|
|
|
if (emergency_pool.arena)
|
|
|
|
{
|
|
|
|
::free(emergency_pool.arena);
|
|
|
|
emergency_pool.arena = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-28 19:04:51 +08:00
|
|
|
extern "C" void *
|
2011-10-11 03:03:39 +08:00
|
|
|
__cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
|
2001-03-28 19:04:51 +08:00
|
|
|
{
|
|
|
|
void *ret;
|
|
|
|
|
2009-01-08 06:50:42 +08:00
|
|
|
thrown_size += sizeof (__cxa_refcounted_exception);
|
2004-08-03 04:28:22 +08:00
|
|
|
ret = malloc (thrown_size);
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2015-01-22 17:21:48 +08:00
|
|
|
if (!ret)
|
|
|
|
ret = emergency_pool.allocate (thrown_size);
|
2006-09-14 17:48:15 +08:00
|
|
|
|
2015-01-22 17:21:48 +08:00
|
|
|
if (!ret)
|
|
|
|
std::terminate ();
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2009-01-08 06:50:42 +08:00
|
|
|
memset (ret, 0, sizeof (__cxa_refcounted_exception));
|
2001-03-28 19:04:51 +08:00
|
|
|
|
2009-01-08 06:50:42 +08:00
|
|
|
return (void *)((char *)ret + sizeof (__cxa_refcounted_exception));
|
2001-03-28 19:04:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" void
|
2011-10-11 03:03:39 +08:00
|
|
|
__cxxabiv1::__cxa_free_exception(void *vptr) _GLIBCXX_NOTHROW
|
2001-03-28 19:04:51 +08:00
|
|
|
{
|
2015-01-22 17:21:48 +08:00
|
|
|
char *ptr = (char *) vptr - sizeof (__cxa_refcounted_exception);
|
|
|
|
if (emergency_pool.in_pool (ptr))
|
|
|
|
emergency_pool.free (ptr);
|
2001-03-28 19:04:51 +08:00
|
|
|
else
|
2015-01-22 17:21:48 +08:00
|
|
|
free (ptr);
|
2001-03-28 19:04:51 +08:00
|
|
|
}
|
[multiple changes]
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.
* testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise.
* testsuite/18_support/exception_ptr/current_exception.cc: Use it.
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise.
* testsuite/18_support/exception_ptr/lifespan.cc: Likewise.
2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at>
Add (again) exception propagation support as per N2179. Feature is
available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined.
* libsupc++/exception_ptr.h (exception_ptr, current_exception,
copy_exception, rethrow_exception): New file, implement exception
propagation.
* libsupc++/eh_ptr.cc (exception_ptr, current_exception,
rethrow_exception, __gxx_dependent_exception_cleanup): Likewise.
* libsupc++/unwind-cxx.h (__cxa_exception): Add reference count.
(__cxa_dependent_exception, __cxa_allocate_dependent_exception,
__cxa_free_dependent_exception, __get_dependent_exception_from_ue,
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception,
__gxx_dependent_exception_class, __get_object_from_ue,
__get_object_from_ambiguous_exception): Add.
(__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename.
(__is_gxx_exception_class): Handle dependent exceptions.
* libsupc++/eh_arm.cc (__cxa_type_match): Likewise.
* libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise.
* libsupc++/eh_personality.cc (__gxx_personality_*): Likewise.
* libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception,
__cxa_free_dependent_exception): Add.
* libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference
counting.
* libsupc++/exception: Conditionally include exception_ptr.h.
* libsupc++/Makefile.am: Register new files.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Add new symbols.
* testsuite/18_support/exception_ptr/current_exception.cc: Test the
core functionality of current_exception().
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the
core functionality of rethrow_exception().
* testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of
exception objects during exception propagation.
From-SVN: r139509
2008-08-23 19:28:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
extern "C" __cxa_dependent_exception*
|
2011-10-11 03:03:39 +08:00
|
|
|
__cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW
|
[multiple changes]
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.
* testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise.
* testsuite/18_support/exception_ptr/current_exception.cc: Use it.
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise.
* testsuite/18_support/exception_ptr/lifespan.cc: Likewise.
2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at>
Add (again) exception propagation support as per N2179. Feature is
available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined.
* libsupc++/exception_ptr.h (exception_ptr, current_exception,
copy_exception, rethrow_exception): New file, implement exception
propagation.
* libsupc++/eh_ptr.cc (exception_ptr, current_exception,
rethrow_exception, __gxx_dependent_exception_cleanup): Likewise.
* libsupc++/unwind-cxx.h (__cxa_exception): Add reference count.
(__cxa_dependent_exception, __cxa_allocate_dependent_exception,
__cxa_free_dependent_exception, __get_dependent_exception_from_ue,
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception,
__gxx_dependent_exception_class, __get_object_from_ue,
__get_object_from_ambiguous_exception): Add.
(__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename.
(__is_gxx_exception_class): Handle dependent exceptions.
* libsupc++/eh_arm.cc (__cxa_type_match): Likewise.
* libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise.
* libsupc++/eh_personality.cc (__gxx_personality_*): Likewise.
* libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception,
__cxa_free_dependent_exception): Add.
* libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference
counting.
* libsupc++/exception: Conditionally include exception_ptr.h.
* libsupc++/Makefile.am: Register new files.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Add new symbols.
* testsuite/18_support/exception_ptr/current_exception.cc: Test the
core functionality of current_exception().
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the
core functionality of rethrow_exception().
* testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of
exception objects during exception propagation.
From-SVN: r139509
2008-08-23 19:28:30 +08:00
|
|
|
{
|
|
|
|
__cxa_dependent_exception *ret;
|
|
|
|
|
|
|
|
ret = static_cast<__cxa_dependent_exception*>
|
|
|
|
(malloc (sizeof (__cxa_dependent_exception)));
|
|
|
|
|
|
|
|
if (!ret)
|
2015-01-22 17:21:48 +08:00
|
|
|
ret = static_cast <__cxa_dependent_exception*>
|
|
|
|
(emergency_pool.allocate (sizeof (__cxa_dependent_exception)));
|
[multiple changes]
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.
* testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise.
* testsuite/18_support/exception_ptr/current_exception.cc: Use it.
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise.
* testsuite/18_support/exception_ptr/lifespan.cc: Likewise.
2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at>
Add (again) exception propagation support as per N2179. Feature is
available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined.
* libsupc++/exception_ptr.h (exception_ptr, current_exception,
copy_exception, rethrow_exception): New file, implement exception
propagation.
* libsupc++/eh_ptr.cc (exception_ptr, current_exception,
rethrow_exception, __gxx_dependent_exception_cleanup): Likewise.
* libsupc++/unwind-cxx.h (__cxa_exception): Add reference count.
(__cxa_dependent_exception, __cxa_allocate_dependent_exception,
__cxa_free_dependent_exception, __get_dependent_exception_from_ue,
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception,
__gxx_dependent_exception_class, __get_object_from_ue,
__get_object_from_ambiguous_exception): Add.
(__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename.
(__is_gxx_exception_class): Handle dependent exceptions.
* libsupc++/eh_arm.cc (__cxa_type_match): Likewise.
* libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise.
* libsupc++/eh_personality.cc (__gxx_personality_*): Likewise.
* libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception,
__cxa_free_dependent_exception): Add.
* libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference
counting.
* libsupc++/exception: Conditionally include exception_ptr.h.
* libsupc++/Makefile.am: Register new files.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Add new symbols.
* testsuite/18_support/exception_ptr/current_exception.cc: Test the
core functionality of current_exception().
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the
core functionality of rethrow_exception().
* testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of
exception objects during exception propagation.
From-SVN: r139509
2008-08-23 19:28:30 +08:00
|
|
|
|
2015-01-22 17:21:48 +08:00
|
|
|
if (!ret)
|
|
|
|
std::terminate ();
|
[multiple changes]
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.
* testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise.
* testsuite/18_support/exception_ptr/current_exception.cc: Use it.
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise.
* testsuite/18_support/exception_ptr/lifespan.cc: Likewise.
2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at>
Add (again) exception propagation support as per N2179. Feature is
available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined.
* libsupc++/exception_ptr.h (exception_ptr, current_exception,
copy_exception, rethrow_exception): New file, implement exception
propagation.
* libsupc++/eh_ptr.cc (exception_ptr, current_exception,
rethrow_exception, __gxx_dependent_exception_cleanup): Likewise.
* libsupc++/unwind-cxx.h (__cxa_exception): Add reference count.
(__cxa_dependent_exception, __cxa_allocate_dependent_exception,
__cxa_free_dependent_exception, __get_dependent_exception_from_ue,
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception,
__gxx_dependent_exception_class, __get_object_from_ue,
__get_object_from_ambiguous_exception): Add.
(__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename.
(__is_gxx_exception_class): Handle dependent exceptions.
* libsupc++/eh_arm.cc (__cxa_type_match): Likewise.
* libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise.
* libsupc++/eh_personality.cc (__gxx_personality_*): Likewise.
* libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception,
__cxa_free_dependent_exception): Add.
* libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference
counting.
* libsupc++/exception: Conditionally include exception_ptr.h.
* libsupc++/Makefile.am: Register new files.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Add new symbols.
* testsuite/18_support/exception_ptr/current_exception.cc: Test the
core functionality of current_exception().
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the
core functionality of rethrow_exception().
* testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of
exception objects during exception propagation.
From-SVN: r139509
2008-08-23 19:28:30 +08:00
|
|
|
|
|
|
|
memset (ret, 0, sizeof (__cxa_dependent_exception));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
__cxxabiv1::__cxa_free_dependent_exception
|
2011-10-11 03:03:39 +08:00
|
|
|
(__cxa_dependent_exception *vptr) _GLIBCXX_NOTHROW
|
[multiple changes]
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.
* testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise.
* testsuite/18_support/exception_ptr/current_exception.cc: Use it.
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise.
* testsuite/18_support/exception_ptr/lifespan.cc: Likewise.
2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at>
Add (again) exception propagation support as per N2179. Feature is
available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined.
* libsupc++/exception_ptr.h (exception_ptr, current_exception,
copy_exception, rethrow_exception): New file, implement exception
propagation.
* libsupc++/eh_ptr.cc (exception_ptr, current_exception,
rethrow_exception, __gxx_dependent_exception_cleanup): Likewise.
* libsupc++/unwind-cxx.h (__cxa_exception): Add reference count.
(__cxa_dependent_exception, __cxa_allocate_dependent_exception,
__cxa_free_dependent_exception, __get_dependent_exception_from_ue,
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception,
__gxx_dependent_exception_class, __get_object_from_ue,
__get_object_from_ambiguous_exception): Add.
(__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename.
(__is_gxx_exception_class): Handle dependent exceptions.
* libsupc++/eh_arm.cc (__cxa_type_match): Likewise.
* libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise.
* libsupc++/eh_personality.cc (__gxx_personality_*): Likewise.
* libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception,
__cxa_free_dependent_exception): Add.
* libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference
counting.
* libsupc++/exception: Conditionally include exception_ptr.h.
* libsupc++/Makefile.am: Register new files.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Add new symbols.
* testsuite/18_support/exception_ptr/current_exception.cc: Test the
core functionality of current_exception().
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the
core functionality of rethrow_exception().
* testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of
exception objects during exception propagation.
From-SVN: r139509
2008-08-23 19:28:30 +08:00
|
|
|
{
|
2015-01-22 17:21:48 +08:00
|
|
|
if (emergency_pool.in_pool (vptr))
|
|
|
|
emergency_pool.free (vptr);
|
[multiple changes]
2008-08-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add.
* testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise.
* testsuite/18_support/exception_ptr/current_exception.cc: Use it.
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise.
* testsuite/18_support/exception_ptr/lifespan.cc: Likewise.
2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at>
Add (again) exception propagation support as per N2179. Feature is
available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined.
* libsupc++/exception_ptr.h (exception_ptr, current_exception,
copy_exception, rethrow_exception): New file, implement exception
propagation.
* libsupc++/eh_ptr.cc (exception_ptr, current_exception,
rethrow_exception, __gxx_dependent_exception_cleanup): Likewise.
* libsupc++/unwind-cxx.h (__cxa_exception): Add reference count.
(__cxa_dependent_exception, __cxa_allocate_dependent_exception,
__cxa_free_dependent_exception, __get_dependent_exception_from_ue,
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception,
__gxx_dependent_exception_class, __get_object_from_ue,
__get_object_from_ambiguous_exception): Add.
(__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename.
(__is_gxx_exception_class): Handle dependent exceptions.
* libsupc++/eh_arm.cc (__cxa_type_match): Likewise.
* libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise.
* libsupc++/eh_personality.cc (__gxx_personality_*): Likewise.
* libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception,
__cxa_free_dependent_exception): Add.
* libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference
counting.
* libsupc++/exception: Conditionally include exception_ptr.h.
* libsupc++/Makefile.am: Register new files.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Add new symbols.
* testsuite/18_support/exception_ptr/current_exception.cc: Test the
core functionality of current_exception().
* testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the
core functionality of rethrow_exception().
* testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of
exception objects during exception propagation.
From-SVN: r139509
2008-08-23 19:28:30 +08:00
|
|
|
else
|
|
|
|
free (vptr);
|
|
|
|
}
|