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


Richard Henderson wrote:
> 
> On Sun, May 07, 2000 at 10:46:51AM +0100, Nathan Sidwell wrote:
> > + // We use the compiler builtins __SIZE__TYPE__ and __PTRDIFF_TYPE__ ...
>                                           ^^
> 
> >         // This shift, being of a signed type, is implementation defined. GCC
> >         // implements such shifts as arithmetic, which is what we want.
> > !       return __PTRDIFF_TYPE__ (vmi_offset_flags) >> offset_shift;
> 
> Isn't something like `signed int (foo)' illegal, that you can only use
> this form with single token types?  While we're perhaps safe with most
> ports, it would seem prudent to write this as `(__PTRDIFF_TYPE__)foo'.
> Either that or create a local typedef.

Nathan Sidwell wrote:
> 
> The <new> headerfile still has this problem, but I'd not discussed
> that with Mark prior to his vacation. That too should be converted
> in the same way I guess.

Hmmm... Well, since <new> is distributed with GCC, I guess there's
no danger of __SIZE_TYPE__ not being defined.

Would something like this be appropriate, then?

-- 
Branko Čibej                 <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
voice: (+386 1) 586 53 49     fax: (+386 1) 586 52 70


2000-05-08  Branko Cibej  <branko.cibej@hermes.si>

	* cp/inc/new: Don't include <stddef.h>, and use `__SIZE_TYPE__'
	instead of `size_t'.
	* cp/new1.cc:  Include <stddef.h> for `size_t'.
	* cp/new2.cc:  Likewise.

	* cp/inc/cxxabi.h:  Fix typos in comment.
	(__base_class_info::__offset): Use `static_cast' instead of conversion.


Index: cp/new1.cc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/new1.cc,v
retrieving revision 1.7
diff -u -p -r1.7 new1.cc
--- new1.cc 2000/05/02 01:25:15 1.7
+++ new1.cc 2000/05/08 08:22:32
@@ -27,6 +27,7 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
+#include <stddef.h>
 #include "new"
 using std::new_handler;
 using std::bad_alloc;
Index: cp/new2.cc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/new2.cc,v
retrieving revision 1.8
diff -u -p -r1.8 new2.cc
--- new2.cc 2000/05/02 01:25:15 1.8
+++ new2.cc 2000/05/08 08:22:32
@@ -27,6 +27,7 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
+#include <stddef.h>
 #include "new"
 
 extern "C" void free (void *);
Index: cp/inc/cxxabi.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/inc/cxxabi.h,v
retrieving revision 1.11
diff -u -p -r1.11 cxxabi.h
--- cxxabi.h 2000/05/07 09:40:34 1.11
+++ cxxabi.h 2000/05/08 08:22:32
@@ -49,11 +49,11 @@
 
 #ifdef __cplusplus
 
-// We use the compiler builtins __SIZE__TYPE__ and __PTRDIFF_TYPE__ instead of
+// We use the compiler builtins __SIZE_TYPE__ and __PTRDIFF_TYPE__ instead of
 // std::size_t and std::ptrdiff_t respectively. This makes us independant of
 // the conformance level of <cstddef> and whether -fhonor-std was supplied.
 // <cstddef> is not currently available during compiler building anyway.
-// including <stddef.h> would be wrong, as that would rudely place size_t in
+// Including <stddef.h> would be wrong, as that would rudely place size_t in
 // the global namespace.
 
 #include <typeinfo>
@@ -215,7 +215,7 @@ public:
     { 
       // This shift, being of a signed type, is implementation defined. GCC
       // implements such shifts as arithmetic, which is what we want.
-      return __PTRDIFF_TYPE__ (vmi_offset_flags) >> offset_shift;
+      return static_cast<__PTRDIFF_TYPE__> (vmi_offset_flags) >> offset_shift;
     }
 };
 
Index: cp/inc/new
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/inc/new,v
retrieving revision 1.8
diff -u -p -r1.8 new
--- new 2000/05/02 01:25:15 1.8
+++ new 2000/05/08 08:22:32
@@ -30,8 +30,13 @@
 #ifndef __NEW__
 #define __NEW__
 
+// We use the compiler builtin __SIZE_TYPE__ instead of std::size_t. This
+// makes us independant of the conformance level of <cstddef> and whether
+// -fhonor-std was supplied. <cstddef> is not currently available during
+// compiler building anyway. Including <stddef.h> would be wrong, as that
+// would rudely place size_t in the global namespace.
+
 #pragma interface "new"
-#include <stddef.h>
 #include <exception>
 
 extern "C++" {
@@ -51,18 +56,18 @@ namespace std {
 } // namespace std
 
 // replaceable signatures
-void *operator new (size_t) throw (std::bad_alloc);
-void *operator new[] (size_t) throw (std::bad_alloc);
+void *operator new (__SIZE_TYPE__) throw (std::bad_alloc);
+void *operator new[] (__SIZE_TYPE__) throw (std::bad_alloc);
 void operator delete (void *) throw();
 void operator delete[] (void *) throw();
-void *operator new (size_t, const std::nothrow_t&) throw();
-void *operator new[] (size_t, const std::nothrow_t&) throw();
+void *operator new (__SIZE_TYPE__, const std::nothrow_t&) throw();
+void *operator new[] (__SIZE_TYPE__, const std::nothrow_t&) throw();
 void operator delete (void *, const std::nothrow_t&) throw();
 void operator delete[] (void *, const std::nothrow_t&) throw();
 
 // default placement versions of operator new
-inline void *operator new(size_t, void *place) throw() { return place; }
-inline void *operator new[](size_t, void *place) throw() { return place; }
+inline void *operator new(__SIZE_TYPE__, void *place) throw() { return place; }
+inline void *operator new[](__SIZE_TYPE__, void *place) throw() { return place; }
 } // extern "C++"
 
 #endif

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