[PATCH] CPP tweaks for NetBSD/sparc64

Jason R Thorpe thorpej@wasabisystems.com
Fri May 3 14:44:00 GMT 2002


On Fri, May 03, 2002 at 02:41:27PM -0700, Jason R Thorpe wrote:

 > The following makes some CPP tweaks for the NetBSD/sparc64 target:
 > 
 > 	* Add -D_LP64 when building 64-bit binaries (see my previous
 > 	  patch for the NetBSD/alpha target for an explanation).
 > 
 > 	* Fix __SIZE_TYPE__ and __PTRDIFF_TYPE__ when using -m32.
 > 
 > Committed to trunk.
 > 
 > I'd like to apply at least the _LP64 change to the 3.1 branch, but
 > also need to verify if the __SIZE_TYPE__/__PTRDIFF_TYPE__ is needed
 > there, too.  Assuming they are, ok for 3.1 branch?
 > 
 >         * config/sparc/netbsd-elf.c (CPP_SUBTARGET_SPEC64): Remove
 >         -D__arch64__.  Add -D_LP64.
 >         (CPP_ARCH32_SPEC): Redefine to match the non-bi-arch version
 >         from sparc.h.
 >         (CPP_ARCH64_SPEC): Likewise.
 >         (NO_BUILTIN_PTRDIFF_TYPE): Undef.
 >         (NO_BUILTIN_SIZE_TYPE): Undef.

Foo.  And this time, with the patch actually attached.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: config/sparc/netbsd-elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/netbsd-elf.h,v
retrieving revision 1.5
diff -u -r1.5 netbsd-elf.h
--- config/sparc/netbsd-elf.h	17 Apr 2002 14:22:17 -0000	1.5
+++ config/sparc/netbsd-elf.h	3 May 2002 21:28:55 -0000
@@ -31,11 +31,27 @@
 /* CPP defines used for 64 bit code.  */
 #undef CPP_SUBTARGET_SPEC64
 #define CPP_SUBTARGET_SPEC64 \
-  "-D__sparc64__ -D__arch64__ -D__sparc_v9__ %{posix:-D_POSIX_SOURCE}"
+  "-D__sparc64__ -D__sparc_v9__ -D_LP64 %{posix:-D_POSIX_SOURCE}"
 
 /* CPP defines used for 32 bit code.  */
 #undef CPP_SUBTARGET_SPEC32
 #define CPP_SUBTARGET_SPEC32 "-D__sparc %{posix:-D_POSIX_SOURCE}"
+
+/* CPP_ARCH32_SPEC and CPP_ARCH64_SPEC are wrong from sparc/sparc.h; we
+   always want the non-SPARC_BI_ARCH versions, since the SPARC_BI_ARCH
+   versions define __SIZE_TYPE__ and __PTRDIFF_TYPE__ incorrectly for
+   NetBSD.  */
+#undef CPP_ARCH32_SPEC
+#define CPP_ARCH32_SPEC "-D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
+
+#undef CPP_ARCH64_SPEC
+#define CPP_ARCH64_SPEC "-D__arch64__ -Acpu=sparc64 -Amachine=sparc64"
+
+/* sparc/sparc.h defines NO_BUILTIN_SIZE_TYPE and NO_BUILTIN_PTRDIFF_TYPE
+   if SPARC_BI_ARCH is defined.  This is wrong for NetBSD; size_t and
+   ptrdiff_t do not change for 32-bit vs. 64-bit.  */
+#undef NO_BUILTIN_PTRDIFF_TYPE
+#undef NO_BUILTIN_SIZE_TYPE
 
 /* SIZE_TYPE and PTRDIFF_TYPE are wrong from sparc/sparc.h.  */
 #undef SIZE_TYPE


More information about the Gcc-patches mailing list