diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9dfb7f6751..357fe77e9b0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-09-15 Mark Mitchell + + * testsuite/g++.old-deja/g++.abi/cxa_vec.C: Adjust for ARM + EABI. + 2004-09-15 Mark Mitchell * g++.dg/opt/switch1.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C index a6fdc44e597..3c05f16f28e 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C @@ -22,14 +22,17 @@ static bool dtor_repeat = false; #endif // our pseudo ctors and dtors -static void ctor (void *) +static abi::__cxa_cdtor_return_type ctor (void *x) { if (!ctor_count) throw 1; ctor_count--; +#ifdef __ARM_EABI__ + return x; +#endif } -static void dtor (void *) +static abi::__cxa_cdtor_return_type dtor (void *x) { if (!dtor_count) { @@ -38,6 +41,9 @@ static void dtor (void *) throw 1; } dtor_count--; +#ifdef __ARM_EABI__ + return x; +#endif } // track new and delete diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8b52da2c9e4..4598b25903e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,42 @@ +2004-09-15 Mark Mitchell + + * config/cpu/arm/cxxabi_tweaks.h (__cxa_cdtor_return_type): + Define. + * config/cpu/generic/cxxabi_tweaks.h (__cxa_cdtor_return_type): + Define. + * libsupc++/cxxabi.h (__cxa_cdtor_return_type): New type. + (__cxa_vec_new): Use it. + (__cxa_vec_new2): Likewise. + (__cxa_vec_new3): Likewise. + (__cxa_vec_cdtor): Likewise. + (__cxa_vec_cctor): Likeiwse. + (__cxa_vec_dtor): Likewise. + (__cxa_vec_cleanup): Likewise. + (__cxa_vec_delete2): Likewise. + (__cxa_vec_delete3): Likewise. + * libsupc++/vec.cc (__cxa_vec_new): Likewise. + (__cxa_vec_new2): Likewise. + (__cxa_vec_new3): Likewise. + (__cxa_vec_cdtor): Likewise. + (__cxa_vec_cctor): Likeiwse. + (__cxa_vec_dtor): Likewise. + (__cxa_vec_cleanup): Likewise. + (__cxa_vec_delete2): Likewise. + (__cxa_vec_delete3): Likewise. + (__aeabi_vec_ctor_nocookie_nodtor): New function. + (__aeabi_vec_ctor_cookie_nodtor): Likewise. + (__aeabi_vec_cctor_nocookie_nodtor): Likewise. + (__aeabi_vec_new_cookie_noctor): Likewise. + (__aeabi_vec_new_nocookie): Likewise. + (__aeabi_vec_new_cookie_nodtor): Likewise. + (__aeabi_vec_new_cookie): Likewise. + (__aeabi_vec_dtor): Likewise. + (__aeabi_vec_dtor_cookie): Likewise. + (__aeabi_vec_delete): Likewise. + (__aeabi_vec_delete3): Likewise. + (__aeabi_vec_delete3_nodtor): Likewise. + (__aeabi_atexit): Likewise. + 2004-09-14 Nathan Myers * include/bits/fstream.tcc (xsgetn): Slightly tweak the recent fix diff --git a/libstdc++-v3/config/cpu/arm/cxxabi_tweaks.h b/libstdc++-v3/config/cpu/arm/cxxabi_tweaks.h index 95fe12c9d8f..06c16fa3993 100644 --- a/libstdc++-v3/config/cpu/arm/cxxabi_tweaks.h +++ b/libstdc++-v3/config/cpu/arm/cxxabi_tweaks.h @@ -48,6 +48,8 @@ namespace __cxxabiv1 // __cxa_vec_ctor should return a pointer to the array. typedef void * __cxa_vec_ctor_return_type; #define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return x + // Constructors and destructors return the "this" pointer. + typedef void * __cxa_cdtor_return_type; #else // __ARM_EABI__ @@ -59,6 +61,8 @@ namespace __cxxabiv1 // __cxa_vec_ctor has void return type. typedef void __cxa_vec_ctor_return_type; #define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return + // Constructors and destructors do not return a value. + typedef void __cxa_cdtor_return_type; #endif //!__ARM_EABI__ diff --git a/libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h b/libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h index 48a0dec568b..5cacb3c5531 100644 --- a/libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h +++ b/libstdc++-v3/config/cpu/generic/cxxabi_tweaks.h @@ -43,6 +43,8 @@ namespace __cxxabiv1 // __cxa_vec_ctor has void return type. typedef void __cxa_vec_ctor_return_type; #define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return + // Constructors and destructors do not return a value. + typedef void __cxa_cdtor_return_type; #ifdef __cplusplus } // namespace __cxxabiv1 diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h index dfed54e69ee..39a41c61aee 100644 --- a/libstdc++-v3/libsupc++/cxxabi.h +++ b/libstdc++-v3/libsupc++/cxxabi.h @@ -50,6 +50,8 @@ #ifdef __cplusplus namespace __cxxabiv1 { + typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *); + extern "C" { #endif @@ -57,54 +59,55 @@ namespace __cxxabiv1 // Allocate array. void* __cxa_vec_new(size_t __element_count, size_t __element_size, - size_t __padding_size, void (*__constructor) (void*), - void (*__destructor) (void*)); + size_t __padding_size, __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor); void* __cxa_vec_new2(size_t __element_count, size_t __element_size, - size_t __padding_size, void (*__constructor) (void*), - void (*__destructor) (void*), void *(*__alloc) (size_t), + size_t __padding_size, __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor, void *(*__alloc) (size_t), void (*__dealloc) (void*)); void* __cxa_vec_new3(size_t __element_count, size_t __element_size, - size_t __padding_size, void (*__constructor) (void*), - void (*__destructor) (void*), void *(*__alloc) (size_t), + size_t __padding_size, __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor, void *(*__alloc) (size_t), void (*__dealloc) (void*, size_t)); // Construct array. __cxa_vec_ctor_return_type __cxa_vec_ctor(void* __array_address, size_t __element_count, - size_t __element_size, void (*__constructor) (void*), - void (*__destructor) (void*)); + size_t __element_size, __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor); __cxa_vec_ctor_return_type __cxa_vec_cctor(void* dest_array, void* src_array, size_t element_count, - size_t element_size, void (*constructor) (void*, void*), - void (*destructor) (void*)); + size_t element_size, + __cxa_cdtor_return_type (*constructor) (void*, void*), + __cxa_cdtor_type destructor); // Destruct array. void __cxa_vec_dtor(void* __array_address, size_t __element_count, - size_t __element_size, void (*__destructor) (void*)); + size_t __element_size, __cxa_cdtor_type destructor); void __cxa_vec_cleanup(void* __array_address, size_t __element_count, - size_t __element_size, void (*__destructor) (void*)); + size_t __element_size, __cxa_cdtor_type destructor); // Destruct and release array. void __cxa_vec_delete(void* __array_address, size_t __element_size, - size_t __padding_size, void (*__destructor) (void*)); + size_t __padding_size, __cxa_cdtor_type destructor); void __cxa_vec_delete2(void* __array_address, size_t __element_size, - size_t __padding_size, void (*__destructor) (void*), + size_t __padding_size, __cxa_cdtor_type destructor, void (*__dealloc) (void*)); void __cxa_vec_delete3(void* __array_address, size_t __element_size, - size_t __padding_size, void (*__destructor) (void*), + size_t __padding_size, __cxa_cdtor_type destructor, void (*__dealloc) (void*, size_t)); int diff --git a/libstdc++-v3/libsupc++/vec.cc b/libstdc++-v3/libsupc++/vec.cc index 2708c19aca9..7e93d1cfea0 100644 --- a/libstdc++-v3/libsupc++/vec.cc +++ b/libstdc++-v3/libsupc++/vec.cc @@ -70,8 +70,8 @@ namespace __cxxabiv1 __cxa_vec_new(std::size_t element_count, std::size_t element_size, std::size_t padding_size, - void (*constructor) (void *), - void (*destructor) (void *)) + __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor) { return __cxa_vec_new2(element_count, element_size, padding_size, constructor, destructor, @@ -82,8 +82,8 @@ namespace __cxxabiv1 __cxa_vec_new2(std::size_t element_count, std::size_t element_size, std::size_t padding_size, - void (*constructor) (void *), - void (*destructor) (void *), + __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor, void *(*alloc) (std::size_t), void (*dealloc) (void *)) { @@ -120,8 +120,8 @@ namespace __cxxabiv1 __cxa_vec_new3(std::size_t element_count, std::size_t element_size, std::size_t padding_size, - void (*constructor) (void *), - void (*destructor) (void *), + __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor, void *(*alloc) (std::size_t), void (*dealloc) (void *, std::size_t)) { @@ -159,8 +159,8 @@ namespace __cxxabiv1 __cxa_vec_ctor(void *array_address, std::size_t element_count, std::size_t element_size, - void (*constructor) (void *), - void (*destructor) (void *)) + __cxa_cdtor_type constructor, + __cxa_cdtor_type destructor) { std::size_t ix = 0; char *ptr = static_cast(array_address); @@ -188,8 +188,8 @@ namespace __cxxabiv1 void *src_array, std::size_t element_count, std::size_t element_size, - void (*constructor) (void *, void *), - void (*destructor) (void *)) + __cxa_cdtor_return_type (*constructor) (void *, void *), + __cxa_cdtor_type destructor) { std::size_t ix = 0; char *dest_ptr = static_cast(dest_array); @@ -218,7 +218,7 @@ namespace __cxxabiv1 __cxa_vec_dtor(void *array_address, std::size_t element_count, std::size_t element_size, - void (*destructor) (void *)) + __cxa_cdtor_type destructor) { if (destructor) { @@ -253,7 +253,7 @@ namespace __cxxabiv1 __cxa_vec_cleanup(void *array_address, std::size_t element_count, std::size_t element_size, - void (*destructor) (void *)) + __cxa_cdtor_type destructor) { if (destructor) { @@ -282,7 +282,7 @@ namespace __cxxabiv1 __cxa_vec_delete(void *array_address, std::size_t element_size, std::size_t padding_size, - void (*destructor) (void *)) + __cxa_cdtor_type destructor) { __cxa_vec_delete2(array_address, element_size, padding_size, destructor, @@ -293,7 +293,7 @@ namespace __cxxabiv1 __cxa_vec_delete2(void *array_address, std::size_t element_size, std::size_t padding_size, - void (*destructor) (void *), + __cxa_cdtor_type destructor, void (*dealloc) (void *)) { if (!array_address) @@ -326,7 +326,7 @@ namespace __cxxabiv1 __cxa_vec_delete3(void *array_address, std::size_t element_size, std::size_t padding_size, - void (*destructor) (void *), + __cxa_cdtor_type destructor, void (*dealloc) (void *, std::size_t)) { if (!array_address) @@ -358,3 +358,155 @@ namespace __cxxabiv1 } } // namespace __cxxabiv1 +#if defined(__arm__) && defined(__ARM_EABI__) + +// The ARM C++ ABI requires that the library provide these additional +// helper functions. There are placed in this file, despite being +// architecture-specifier, so that the compiler can inline the __cxa +// functions into these functions as appropriate. + +namespace __aeabiv1 +{ + extern "C" void * + __aeabi_vec_ctor_nocookie_nodtor (void *array_address, + abi::__cxa_cdtor_type constructor, + std::size_t element_size, + std::size_t element_count) + { + return abi::__cxa_vec_ctor (array_address, element_count, element_size, + constructor, /*destructor=*/NULL); + } + + extern "C" void * + __aeabi_vec_ctor_cookie_nodtor (void *array_address, + abi::__cxa_cdtor_type constructor, + std::size_t element_size, + std::size_t element_count) + { + if (array_address == NULL) + return NULL; + + array_address = reinterpret_cast(array_address) + 2; + reinterpret_cast(array_address)[-2] = element_size; + reinterpret_cast(array_address)[-1] = element_count; + return abi::__cxa_vec_ctor (array_address, + element_count, element_size, + constructor, /*destructor=*/NULL); + } + + extern "C" void * + __aeabi_vec_cctor_nocookie_nodtor (void *dest_array, + void *src_array, + std::size_t element_size, + std::size_t element_count, + void *(*constructor) (void *, void *)) + { + return abi::__cxa_vec_cctor (dest_array, src_array, + element_count, element_size, + constructor, NULL); + } + + extern "C" void * + __aeabi_vec_new_cookie_noctor (std::size_t element_size, + std::size_t element_count) + { + return abi::__cxa_vec_new(element_count, element_size, + 2 * sizeof (std::size_t), + /*constructor=*/NULL, /*destructor=*/NULL); + } + + extern "C" void * + __aeabi_vec_new_nocookie (std::size_t element_size, + std::size_t element_count, + abi::__cxa_cdtor_type constructor) + { + return abi::__cxa_vec_new (element_count, element_size, 0, constructor, + NULL); + } + + extern "C" void * + __aeabi_vec_new_cookie_nodtor (std::size_t element_size, + std::size_t element_count, + abi::__cxa_cdtor_type constructor) + { + return abi::__cxa_vec_new(element_count, element_size, + 2 * sizeof (std::size_t), + constructor, NULL); + } + + extern "C" void * + __aeabi_vec_new_cookie(std::size_t element_size, + std::size_t element_count, + abi::__cxa_cdtor_type constructor, + abi::__cxa_cdtor_type destructor) + { + return abi::__cxa_vec_new (element_count, element_size, + 2 * sizeof (std::size_t), + constructor, destructor); + } + + + extern "C" void * + __aeabi_vec_dtor (void *array_address, + abi::__cxa_cdtor_type destructor, + std::size_t element_size, + std::size_t element_count) + { + abi::__cxa_vec_dtor (array_address, element_count, element_size, + destructor); + return reinterpret_cast (array_address) - 2; + } + + extern "C" void * + __aeabi_vec_dtor_cookie (void *array_address, + abi::__cxa_cdtor_type destructor) + { + abi::__cxa_vec_dtor (array_address, + reinterpret_cast(array_address)[-1], + reinterpret_cast(array_address)[-2], + destructor); + return reinterpret_cast (array_address) - 2; + } + + + extern "C" void + __aeabi_vec_delete (void *array_address, + abi::__cxa_cdtor_type destructor) + { + abi::__cxa_vec_delete (array_address, + reinterpret_cast(array_address)[-2], + 2 * sizeof (std::size_t), + destructor); + } + + extern "C" void + __aeabi_vec_delete3 (void *array_address, + abi::__cxa_cdtor_type destructor, + void (*dealloc) (void *, std::size_t)) + { + abi::__cxa_vec_delete3 (array_address, + reinterpret_cast(array_address)[-2], + 2 * sizeof (std::size_t), + destructor, dealloc); + } + + extern "C" void + __aeabi_vec_delete3_nodtor (void *array_address, + void (*dealloc) (void *, std::size_t)) + { + abi::__cxa_vec_delete3 (array_address, + reinterpret_cast(array_address)[-2], + 2 * sizeof (std::size_t), + /*destructor=*/NULL, dealloc); + } + + extern "C" int + __aeabi_atexit (void *object, + void (*destructor) (void *), + void *dso_handle) + { + return abi::__cxa_atexit(destructor, object, dso_handle); + } +} // namespace __aeabiv1 + +#endif // defined(__arm__) && defined(__ARM_EABI__)