This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[C++ PATCH]: New abi tweaks


Hi,
I've installed the attached patch which affects the new-abi (under
the obvious rule). No change to old-abi which I booted and tested
on sparc-sun-solaris2.7.

I explicitly declare some of the runtime functions as extern "C++", as
otherwise g++ thought they were in a C header file and made them
implicitly extern "C". A tweak to the ptr-to-member typeinfo, and
corrected and extended its test case.

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
2000-05-05  Nathan Sidwell  <nathan@codesourcery.com>

	* rtti.c (ptmd_initializer): Set non-public, if class is
	incomplete.
	
	* inc/cxxabi.h (__dynamic_cast): Explicitly say extern "C++".
	(__cxa_vec_new, __cxa_vec_ctor, __cxa_vec_dtor,
	__cxa_vec_delete): Likewise.
	* tinfo.cc (__dynamic_cast): Likewise.
	* vec.cc (__cxa_vec_new, __cxa_vec_ctor, __cxa_vec_dtor,
	__cxa_vec_delete): Likewise.

Index: cp/rtti.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/rtti.c,v
retrieving revision 1.87
diff -c -3 -p -r1.87 rtti.c
*** rtti.c	2000/04/20 14:25:32	1.87
--- rtti.c	2000/05/05 15:56:24
*************** ptmd_initializer (desc, target, non_publ
*** 1440,1446 ****
        *non_public_ptr = 1;
      }
    if (!COMPLETE_TYPE_P (klass))
!     flags |= 0x10;
    init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init);
    init = tree_cons (NULL_TREE,
                      build_unary_op (ADDR_EXPR,
--- 1440,1449 ----
        *non_public_ptr = 1;
      }
    if (!COMPLETE_TYPE_P (klass))
!     {
!       flags |= 0x10;
!       *non_public_ptr = 1;
!     }
    init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init);
    init = tree_cons (NULL_TREE,
                      build_unary_op (ADDR_EXPR,
Index: cp/inc/cxxabi.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/inc/cxxabi.h,v
retrieving revision 1.9
diff -c -3 -p -r1.9 cxxabi.h
*** cxxabi.h	2000/05/02 01:25:15	1.9
--- cxxabi.h	2000/05/05 15:56:25
*************** protected:
*** 394,399 ****
--- 394,400 ----
  };
  
  /* dynamic cast runtime */
+ extern "C++"
  void *__dynamic_cast (const void *__src_ptr,    /* object started from */
                        const __class_type_info *__src_type, /* static type of object */
                        const __class_type_info *__dst_type, /* desired target type */
*************** void *__dynamic_cast (const void *__src_
*** 409,414 ****
--- 410,416 ----
  /* array ctor/dtor routines */
  
  /* allocate and construct array */
+ extern "C++"
  void *__cxa_vec_new (size_t __element_count,
                       size_t __element_size,
                       size_t __padding_size,
*************** void *__cxa_vec_new (size_t __element_co
*** 416,421 ****
--- 418,424 ----
                       void (*__destructor) (void *));
  
  /* construct array */
+ extern "C++"
  void __cxa_vec_ctor (void *__array_address,
                       size_t __element_count,
                       size_t __element_size,
*************** void __cxa_vec_ctor (void *__array_addre
*** 423,434 ****
--- 426,439 ----
                       void (*__destructor) (void *));
  
  /* destruct array */
+ extern "C++"
  void __cxa_vec_dtor (void *__array_address,
                       size_t __element_count,
                       size_t __element_size,
                       void (*__destructor) (void *));
  
  /* destruct and release array */
+ extern "C++"
  void __cxa_vec_delete (void *__array_address,
                         size_t __element_size,
                         size_t __padding_size,
Index: cp/tinfo.cc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tinfo.cc,v
retrieving revision 1.26
diff -c -3 -p -r1.26 tinfo.cc
*** tinfo.cc	2000/05/02 01:25:15	1.26
--- tinfo.cc	2000/05/05 15:56:25
*************** __do_upcast (__sub_kind access_path,
*** 1137,1143 ****
  }
  
  // this is the external interface to the dynamic cast machinery
! void *
  __dynamic_cast (const void *src_ptr,    // object started from
                  const __class_type_info *src_type, // type of the starting object
                  const __class_type_info *dst_type, // desired target type
--- 1137,1143 ----
  }
  
  // this is the external interface to the dynamic cast machinery
! extern "C++" void *
  __dynamic_cast (const void *src_ptr,    // object started from
                  const __class_type_info *src_type, // type of the starting object
                  const __class_type_info *dst_type, // desired target type
Index: cp/vec.cc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/vec.cc,v
retrieving revision 1.3
diff -c -3 -p -r1.3 vec.cc
*** vec.cc	2000/05/02 01:25:15	1.3
--- vec.cc	2000/05/05 15:56:25
*************** namespace __cxxabiv1
*** 40,46 ****
  {
  
  /* allocate and construct array */
! void *
  __cxa_vec_new (size_t element_count,
                 size_t element_size,
                 size_t padding_size,
--- 40,46 ----
  {
  
  /* allocate and construct array */
! extern "C++" void *
  __cxa_vec_new (size_t element_count,
                 size_t element_size,
                 size_t padding_size,
*************** __cxa_vec_new (size_t element_count,
*** 70,76 ****
  }
  
  /* construct array */
! void
  __cxa_vec_ctor (void *array_address,
                  size_t element_count,
                  size_t element_size,
--- 70,76 ----
  }
  
  /* construct array */
! extern "C++" void
  __cxa_vec_ctor (void *array_address,
                  size_t element_count,
                  size_t element_size,
*************** __cxa_vec_ctor (void *array_address,
*** 95,101 ****
  }
  
  /* destruct array */
! void
  __cxa_vec_dtor (void *array_address,
                  size_t element_count,
                  size_t element_size,
--- 95,101 ----
  }
  
  /* destruct array */
! extern "C++" void
  __cxa_vec_dtor (void *array_address,
                  size_t element_count,
                  size_t element_size,
*************** __cxa_vec_dtor (void *array_address,
*** 131,137 ****
  }
  
  /* destruct and release array */
! void
  __cxa_vec_delete (void *array_address,
                    size_t element_size,
                    size_t padding_size,
--- 131,137 ----
  }
  
  /* destruct and release array */
! extern "C++" void
  __cxa_vec_delete (void *array_address,
                    size_t element_size,
                    size_t padding_size,
2000-05-05  Nathan Sidwell  <nathan@codesourcery.com>

	* g++.old-deja/g++.abi/ptrflags.C: Correct and extend.
	
Index: testsuite/g++.old-deja/g++.abi/ptrflags.C
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C,v
retrieving revision 1.1
diff -c -3 -p -r1.1 ptrflags.C
*** ptrflags.C	2000/04/20 14:27:59	1.1
--- ptrflags.C	2000/05/05 15:56:25
*************** using namespace abi;
*** 14,21 ****
  
  int expect (int flags, type_info const &info)
  {
!   __pointer_class_type_info const *ptr =
!       dynamic_cast <__pointer_class_type_info const *> (&info);
    if (!ptr)
      return 0;
    if (ptr->quals != flags)
--- 14,21 ----
  
  int expect (int flags, type_info const &info)
  {
!   __pointer_type_info const *ptr =
!       dynamic_cast <__pointer_type_info const *> (&info);
    if (!ptr)
      return 0;
    if (ptr->quals != flags)
*************** int main ()
*** 31,55 ****
      return 2;
    if (! expect (2, typeid (A volatile *)))
      return 3;
!   if (! expect (4, typeid (A __restrict__ *)))
      return 4;
!   if (! expect (0, typeid (void A::*))
      return 5;
!   if (! expect (0, typeid (void A::**))
      return 6;
  
    if (! expect (8 | 0, typeid (B *)))
!     return 1;
    if (! expect (8 | 1, typeid (B const *)))
!     return 2;
    if (! expect (8 | 2, typeid (B volatile *)))
!     return 3;
!   if (! expect (8 | 4, typeid (B __restrict__ *)))
!     return 4;
!   if (! expect (8 | 0, typeid (void B::*))
!     return 5;
!   if (! expect (8 | 0, typeid (void B::**))
!     return 6;
    
    return 0;
  }
--- 31,59 ----
      return 2;
    if (! expect (2, typeid (A volatile *)))
      return 3;
!   if (! expect (4, typeid (A *__restrict__ *)))
      return 4;
!   if (! expect (0, typeid (int A::*)))
      return 5;
!   if (! expect (0, typeid (int A::**)))
      return 6;
  
    if (! expect (8 | 0, typeid (B *)))
!     return 11;
    if (! expect (8 | 1, typeid (B const *)))
!     return 12;
    if (! expect (8 | 2, typeid (B volatile *)))
!     return 13;
!   if (! expect (8 | 4, typeid (B *__restrict__ *)))
!     return 14;
!   if (! expect (16 | 0, typeid (int B::*)))
!     return 15;
!   if (! expect (8 | 0, typeid (int B::**)))
!     return 16;
!   if (! expect (8 | 0, typeid (B A::*)))
!     return 17;
!   if (! expect (24, typeid (B B::*)))
!     return 18;
    
    return 0;
  }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]