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]

Re: [C++ patch] use __PTRDIFF_TYPE__ in newabi header


Jason Merrill wrote:
> Please do.  There's no reason we can't include it in the .cc files,
> especially since we provide stddef.h.
ok, I reverted it with the attached, sorry for the delay,
booted/tested on sparc-sun-solaris2.7

> It would probably make sense for the compiler to provide cstddef, as well,
> actually.
I think you're right

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-05-09  Nathan Sidwell  <nathan@codesourcery.com>

	* tinfo.cc: Revert my 2000-05-08 and 2000-05-07 changes.
	* vec.cc: Revert my 2000-05-07 change.

Index: cp/tinfo.cc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tinfo.cc,v
retrieving revision 1.29
diff -c -3 -p -r1.29 tinfo.cc
*** tinfo.cc	2000/05/08 20:52:32	1.29
--- tinfo.cc	2000/05/09 20:56:39
*************** using namespace abi;
*** 579,592 ****
  // initial part of a vtable, this structure is used with offsetof, so we don't
  // have to keep alignments consistent manually.
  struct vtable_prefix {
!   __PTRDIFF_TYPE__ whole_object;           // offset to most derived object
    const __class_type_info *whole_type;  // pointer to most derived type_info
    const void *origin;               // what a class's vptr points to
  };
  
  template <typename T>
  inline const T *
! adjust_pointer (const void *base, __PTRDIFF_TYPE__ offset)
  {
    return reinterpret_cast <const T *>
      (reinterpret_cast <const char *> (base) + offset);
--- 579,592 ----
  // initial part of a vtable, this structure is used with offsetof, so we don't
  // have to keep alignments consistent manually.
  struct vtable_prefix {
!   ptrdiff_t whole_object;           // offset to most derived object
    const __class_type_info *whole_type;  // pointer to most derived type_info
    const void *origin;               // what a class's vptr points to
  };
  
  template <typename T>
  inline const T *
! adjust_pointer (const void *base, ptrdiff_t offset)
  {
    return reinterpret_cast <const T *>
      (reinterpret_cast <const char *> (base) + offset);
*************** adjust_pointer (const void *base, __PTRD
*** 595,607 ****
  // ADDR is a pointer to an object.  Convert it to a pointer to a base,
  // using OFFSET. IS_VIRTUAL is true, if we are getting a virtual base.
  inline void const *
! convert_to_base (void const *addr, bool is_virtual, __PTRDIFF_TYPE__ offset)
  {
    if (is_virtual)
      {
        const void *vtable = *static_cast <const void *const *> (addr);
        
!       offset = *adjust_pointer<__PTRDIFF_TYPE__> (vtable, offset);
      }
  
    return adjust_pointer<void> (addr, offset);
--- 595,607 ----
  // ADDR is a pointer to an object.  Convert it to a pointer to a base,
  // using OFFSET. IS_VIRTUAL is true, if we are getting a virtual base.
  inline void const *
! convert_to_base (void const *addr, bool is_virtual, ptrdiff_t offset)
  {
    if (is_virtual)
      {
        const void *vtable = *static_cast <const void *const *> (addr);
        
!       offset = *adjust_pointer<ptrdiff_t> (vtable, offset);
      }
  
    return adjust_pointer<void> (addr, offset);
*************** __do_upcast (const __class_type_info *ds
*** 716,722 ****
  }
  
  inline __class_type_info::__sub_kind __class_type_info::
! __find_public_src (__PTRDIFF_TYPE__ src2dst,
                     const void *obj_ptr,
                     const __class_type_info *src_type,
                     const void *src_ptr) const
--- 716,722 ----
  }
  
  inline __class_type_info::__sub_kind __class_type_info::
! __find_public_src (ptrdiff_t src2dst,
                     const void *obj_ptr,
                     const __class_type_info *src_type,
                     const void *src_ptr) const
*************** __find_public_src (__PTRDIFF_TYPE__ src2
*** 730,736 ****
  }
  
  __class_type_info::__sub_kind __class_type_info::
! __do_find_public_src (__PTRDIFF_TYPE__,
                        const void *obj_ptr,
                        const __class_type_info *,
                        const void *src_ptr) const
--- 730,736 ----
  }
  
  __class_type_info::__sub_kind __class_type_info::
! __do_find_public_src (ptrdiff_t,
                        const void *obj_ptr,
                        const __class_type_info *,
                        const void *src_ptr) const
*************** __do_find_public_src (__PTRDIFF_TYPE__,
*** 742,748 ****
  }
  
  __class_type_info::__sub_kind __si_class_type_info::
! __do_find_public_src (__PTRDIFF_TYPE__ src2dst,
                        const void *obj_ptr,
                        const __class_type_info *src_type,
                        const void *src_ptr) const
--- 742,748 ----
  }
  
  __class_type_info::__sub_kind __si_class_type_info::
! __do_find_public_src (ptrdiff_t src2dst,
                        const void *obj_ptr,
                        const __class_type_info *src_type,
                        const void *src_ptr) const
*************** __do_find_public_src (__PTRDIFF_TYPE__ s
*** 753,759 ****
  }
  
  __class_type_info::__sub_kind __vmi_class_type_info::
! __do_find_public_src (__PTRDIFF_TYPE__ src2dst,
                        const void *obj_ptr,
                        const __class_type_info *src_type,
                        const void *src_ptr) const
--- 753,759 ----
  }
  
  __class_type_info::__sub_kind __vmi_class_type_info::
! __do_find_public_src (ptrdiff_t src2dst,
                        const void *obj_ptr,
                        const __class_type_info *src_type,
                        const void *src_ptr) const
*************** __do_find_public_src (__PTRDIFF_TYPE__ s
*** 761,773 ****
    if (obj_ptr == src_ptr && *this == *src_type)
      return __contained_public;
    
!   for (__SIZE_TYPE__ i = vmi_base_count; i--;)
      {
        if (!vmi_bases[i].__is_public_p ())
          continue; // Not public, can't be here.
        
        const void *base = obj_ptr;
!       __PTRDIFF_TYPE__ offset = vmi_bases[i].__offset ();
        bool is_virtual = vmi_bases[i].__is_virtual_p ();
        
        if (is_virtual)
--- 761,773 ----
    if (obj_ptr == src_ptr && *this == *src_type)
      return __contained_public;
    
!   for (size_t i = vmi_base_count; i--;)
      {
        if (!vmi_bases[i].__is_public_p ())
          continue; // Not public, can't be here.
        
        const void *base = obj_ptr;
!       ptrdiff_t offset = vmi_bases[i].__offset ();
        bool is_virtual = vmi_bases[i].__is_virtual_p ();
        
        if (is_virtual)
*************** __do_find_public_src (__PTRDIFF_TYPE__ s
*** 791,797 ****
  }
  
  bool __class_type_info::
! __do_dyncast (__PTRDIFF_TYPE__,
                __sub_kind access_path,
                const __class_type_info *dst_type,
                const void *obj_ptr,
--- 791,797 ----
  }
  
  bool __class_type_info::
! __do_dyncast (ptrdiff_t,
                __sub_kind access_path,
                const __class_type_info *dst_type,
                const void *obj_ptr,
*************** __do_dyncast (__PTRDIFF_TYPE__,
*** 817,823 ****
  }
  
  bool __si_class_type_info::
! __do_dyncast (__PTRDIFF_TYPE__ src2dst,
                __sub_kind access_path,
                const __class_type_info *dst_type,
                const void *obj_ptr,
--- 817,823 ----
  }
  
  bool __si_class_type_info::
! __do_dyncast (ptrdiff_t src2dst,
                __sub_kind access_path,
                const __class_type_info *dst_type,
                const void *obj_ptr,
*************** __do_dyncast (__PTRDIFF_TYPE__ src2dst,
*** 857,863 ****
  // work by filling in things lazily (when we know we need the information),
  // and opportunisticly take early success or failure results.
  bool __vmi_class_type_info::
! __do_dyncast (__PTRDIFF_TYPE__ src2dst,
                __sub_kind access_path,
                const __class_type_info *dst_type,
                const void *obj_ptr,
--- 857,863 ----
  // work by filling in things lazily (when we know we need the information),
  // and opportunisticly take early success or failure results.
  bool __vmi_class_type_info::
! __do_dyncast (ptrdiff_t src2dst,
                __sub_kind access_path,
                const __class_type_info *dst_type,
                const void *obj_ptr,
*************** __do_dyncast (__PTRDIFF_TYPE__ src2dst,
*** 884,895 ****
        return false;
      }
    bool result_ambig = false;
!   for (__SIZE_TYPE__ i = vmi_base_count; i--;)
      {
        __dyncast_result result2;
        void const *base = obj_ptr;
        __sub_kind base_access = access_path;
!       __PTRDIFF_TYPE__ offset = vmi_bases[i].__offset ();
        bool is_virtual = vmi_bases[i].__is_virtual_p ();
        
        if (is_virtual)
--- 884,895 ----
        return false;
      }
    bool result_ambig = false;
!   for (size_t i = vmi_base_count; i--;)
      {
        __dyncast_result result2;
        void const *base = obj_ptr;
        __sub_kind base_access = access_path;
!       ptrdiff_t offset = vmi_bases[i].__offset ();
        bool is_virtual = vmi_bases[i].__is_virtual_p ();
        
        if (is_virtual)
*************** __do_upcast (__sub_kind access_path,
*** 1071,1082 ****
    if (src_details & __flags_unknown_mask)
      src_details = vmi_flags;
    
!   for (__SIZE_TYPE__ i = vmi_base_count; i--;)
      {
        __upcast_result result2 (src_details);
        const void *base = obj_ptr;
        __sub_kind sub_access = access_path;
!       __PTRDIFF_TYPE__ offset = vmi_bases[i].__offset ();
        bool is_virtual = vmi_bases[i].__is_virtual_p ();
        
        if (!vmi_bases[i].__is_public_p ())
--- 1071,1082 ----
    if (src_details & __flags_unknown_mask)
      src_details = vmi_flags;
    
!   for (size_t i = vmi_base_count; i--;)
      {
        __upcast_result result2 (src_details);
        const void *base = obj_ptr;
        __sub_kind sub_access = access_path;
!       ptrdiff_t offset = vmi_bases[i].__offset ();
        bool is_virtual = vmi_bases[i].__is_virtual_p ();
        
        if (!vmi_bases[i].__is_public_p ())
*************** extern "C++" void *
*** 1141,1153 ****
  __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
!                 __PTRDIFF_TYPE__ src2dst) // how src and dst are related
  {
    const void *vtable = *static_cast <const void *const *> (src_ptr);
    const vtable_prefix *prefix =
!       adjust_pointer <vtable_prefix>
!         (vtable, -reinterpret_cast <__PTRDIFF_TYPE__>
!           (&static_cast <vtable_prefix *> (NULL)->origin));
    const void *whole_ptr =
        adjust_pointer <void> (src_ptr, prefix->whole_object);
    const __class_type_info *whole_type = prefix->whole_type;
--- 1141,1152 ----
  __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
!                 ptrdiff_t src2dst) // how src and dst are related
  {
    const void *vtable = *static_cast <const void *const *> (src_ptr);
    const vtable_prefix *prefix =
!       adjust_pointer <vtable_prefix> (vtable, 
! 				      -offsetof (vtable_prefix, origin));
    const void *whole_ptr =
        adjust_pointer <void> (src_ptr, prefix->whole_object);
    const __class_type_info *whole_type = prefix->whole_type;
Index: cp/vec.cc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/vec.cc,v
retrieving revision 1.5
diff -c -3 -p -r1.5 vec.cc
*** vec.cc	2000/05/07 09:40:33	1.5
--- vec.cc	2000/05/09 20:56:39
*************** namespace __cxxabiv1
*** 41,59 ****
  
  /* allocate and construct array */
  extern "C++" void *
! __cxa_vec_new (__SIZE_TYPE__ element_count,
!                __SIZE_TYPE__ element_size,
!                __SIZE_TYPE__ padding_size,
                 void (*constructor) (void *),
                 void (*destructor) (void *))
  {
!   __SIZE_TYPE__ size = element_count * element_size + padding_size;
    char *base = static_cast <char *> (operator new[] (size));
    
    if (padding_size)
      {
        base += padding_size;
!       reinterpret_cast <__SIZE_TYPE__ *> (base)[-1] = element_count;
      }
    try
      {
--- 41,59 ----
  
  /* allocate and construct array */
  extern "C++" void *
! __cxa_vec_new (size_t element_count,
!                size_t element_size,
!                size_t padding_size,
                 void (*constructor) (void *),
                 void (*destructor) (void *))
  {
!   size_t size = element_count * element_size + padding_size;
    char *base = static_cast <char *> (operator new[] (size));
    
    if (padding_size)
      {
        base += padding_size;
!       reinterpret_cast <size_t *> (base)[-1] = element_count;
      }
    try
      {
*************** __cxa_vec_new (__SIZE_TYPE__ element_cou
*** 72,83 ****
  /* construct array */
  extern "C++" void
  __cxa_vec_ctor (void *array_address,
!                 __SIZE_TYPE__ element_count,
!                 __SIZE_TYPE__ element_size,
                  void (*constructor) (void *),
                  void (*destructor) (void *))
  {
!   __SIZE_TYPE__ ix = 0;
    char *ptr = static_cast <char *> (array_address);
    
    try
--- 72,83 ----
  /* construct array */
  extern "C++" void
  __cxa_vec_ctor (void *array_address,
!                 size_t element_count,
!                 size_t element_size,
                  void (*constructor) (void *),
                  void (*destructor) (void *))
  {
!   size_t ix = 0;
    char *ptr = static_cast <char *> (array_address);
    
    try
*************** __cxa_vec_ctor (void *array_address,
*** 97,110 ****
  /* destruct array */
  extern "C++" void
  __cxa_vec_dtor (void *array_address,
!                 __SIZE_TYPE__ element_count,
!                 __SIZE_TYPE__ element_size,
                  void (*destructor) (void *))
  {
    if (destructor)
      {
        char *ptr = static_cast <char *> (array_address);
!       __SIZE_TYPE__ ix = element_count;
        bool unwinding = std::uncaught_exception ();
        
        ptr += element_count * element_size;
--- 97,110 ----
  /* destruct array */
  extern "C++" void
  __cxa_vec_dtor (void *array_address,
!                 size_t element_count,
!                 size_t element_size,
                  void (*destructor) (void *))
  {
    if (destructor)
      {
        char *ptr = static_cast <char *> (array_address);
!       size_t ix = element_count;
        bool unwinding = std::uncaught_exception ();
        
        ptr += element_count * element_size;
*************** __cxa_vec_dtor (void *array_address,
*** 133,147 ****
  /* destruct and release array */
  extern "C++" void
  __cxa_vec_delete (void *array_address,
!                   __SIZE_TYPE__ element_size,
!                   __SIZE_TYPE__ padding_size,
                    void (*destructor) (void *))
  {
    char *base = static_cast <char *> (array_address);
    
    if (padding_size)
      {
!       __SIZE_TYPE__ element_count = reinterpret_cast <__SIZE_TYPE__ *> (base)[-1];
        base -= padding_size;
        try
          {
--- 133,147 ----
  /* destruct and release array */
  extern "C++" void
  __cxa_vec_delete (void *array_address,
!                   size_t element_size,
!                   size_t padding_size,
                    void (*destructor) (void *))
  {
    char *base = static_cast <char *> (array_address);
    
    if (padding_size)
      {
!       size_t element_count = reinterpret_cast <size_t *> (base)[-1];
        base -= padding_size;
        try
          {

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