3.0 PATCH: Fix wchar_t/wint_t definitions for bi-arch Solaris 7/8 and IRIX 6 (version 2)

Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Fri Jun 8 11:37:00 GMT 2001


As promised a few days ago, this is another updated version of

	http://gcc.gnu.org/ml/gcc-patches/2001-06/msg00026.html

incorporating Joseph's comment.  This is unchanged for the IRIX 6 part
(which already bootstrapped without regressions on mips-sgi-irix6.2), and
bootstraps on sparc-sun-solaris2.8 and sparcv9-sun-solaris2.8 are on the
way.

Ok for branch and trunk, provided those are ok?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University

Email: ro@TechFak.Uni-Bielefeld.DE

Fri Jun  8 13:13:17 2001  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config/mips/iris6.h (NO_BUILTIN_WINT_TYPE): Define.
	(WINT_TYPE): Override.
	(WINT_TYPE_SIZE): Likewise.
	(SUBTARGET_CPP_SIZE_SPEC): Define __WINT_TYPE__ as appropriate.

	* config/sparc/sol2.h (WINT_TYPE): Define.
	(WINT_TYPE_SIZE): Likewise.

	* config/sparc/sol2-sld-64.h (NO_BUILTIN_WINT_TYPE): Define.
	(WINT_TYPE): Override.
	(WINT_TYPE_SIZE): Likewise.
	(CPP_ARCH32_SPEC): Add __WINT_TYPE__ definition.
	(CPP_ARCH64_SPEC): Likewise.

	* gcc.dg/wchar_t-1.c: New file.
	* gcc.dg/wint_t-1.c: Likewise.

Index: gcc/config/mips/iris6.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6.h,v
retrieving revision 1.28.2.3
diff -u -p -r1.28.2.3 iris6.h
--- iris6.h	2001/05/23 06:55:03	1.28.2.3
+++ iris6.h	2001/06/08 18:07:52
@@ -39,6 +39,26 @@ Boston, MA 02111-1307, USA.  */
    we avoid creating such labels.  */
 #define DWARF2_GENERATE_TEXT_SECTION_LABEL 0
 
+/* wchar_t is defined differently with and without -mabi=64.  */
+
+#define NO_BUILTIN_WCHAR_TYPE
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE (Pmode == DImode ? "int" : "long int")
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+/* Same for wint_t.  */
+
+#define NO_BUILTIN_WINT_TYPE
+
+#undef WINT_TYPE
+#define WINT_TYPE (Pmode == DImode ? "int" : "long int")
+
+#undef WINT_TYPE_SIZE
+#define WINT_TYPE_SIZE 32
+
 /* For Irix 6, -mabi=64 implies TARGET_LONG64.  */
 /* This is handled in override_options.  */
 
@@ -57,10 +77,12 @@ Boston, MA 02111-1307, USA.  */
 
 #undef SUBTARGET_CPP_SIZE_SPEC
 #define SUBTARGET_CPP_SIZE_SPEC "\
-%{mabi=32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
-%{mabi=n32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \
-%{mabi=64: -D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \
-%{!mabi*: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}"
+%{mabi=32|mabi=n32: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
+-D__WCHAR_TYPE__=long\\ int -D__WINT_TYPE__=long\\ int} \
+%{mabi=64: -D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
+-D__WCHAR_TYPE__=int -D__WINT_TYPE__=int} \
+%{!mabi*: -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
+-D__WCHAR_TYPE__=long\\ int -D__WINT_TYPE__=long\\ int}"
 
 /* We must make -mips3 do what -mlong64 used to do.  */
 /* ??? If no mipsX option given, but a mabi=X option is, then should set
Index: gcc/config/sparc/sol2-sld-64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2-sld-64.h,v
retrieving revision 1.13.4.1
diff -u -p -r1.13.4.1 sol2-sld-64.h
--- sol2-sld-64.h	2001/04/11 13:04:21	1.13.4.1
+++ sol2-sld-64.h	2001/06/08 18:07:58
@@ -161,11 +161,35 @@
 %{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
 ")
 
+/* wchar_t is called differently in <wchar.h> for 32 and 64-bit
+   compilations.  This is called for by SCD 2.4.1, p. 6-83, Figure 6-65
+   (32-bit) and p. 6P-10, Figure 6.38 (64-bit).  */
+#define NO_BUILTIN_WCHAR_TYPE
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE (TARGET_ARCH64 ? "int" : "long int")
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+/* Same for wint_t.  See SCD 2.4.1, p. 6-83, Figure 6-66 (32-bit).  There's
+   no corresponding 64-bit definition, but this is what Solaris 8
+   <iso/wchar_iso.h> uses.  */
+#define NO_BUILTIN_WINT_TYPE
+
+#undef WINT_TYPE
+#define WINT_TYPE (TARGET_ARCH64 ? "int" : "long int")
+
+#undef WINT_TYPE_SIZE
+#define WINT_TYPE_SIZE 32
+
 #undef CPP_ARCH32_SPEC
 #define CPP_ARCH32_SPEC "-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
+-D__WCHAR_TYPE__=long\\ int -D__WINT_TYPE__=long\\ int \
 -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
 #undef CPP_ARCH64_SPEC
 #define CPP_ARCH64_SPEC "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
+-D__WCHAR_TYPE__=int -D__WINT_TYPE__=int \
 -D__arch64__ -Acpu=sparc64 -Amachine=sparcv9 -D__sparcv9"
 
 #undef CPP_ARCH_SPEC
Index: gcc/config/sparc/sol2.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2.h,v
retrieving revision 1.24.4.2
diff -u -p -r1.24.4.2 sol2.h
--- sol2.h	2001/05/30 20:26:42	1.24.4.2
+++ sol2.h	2001/06/08 18:07:58
@@ -1,5 +1,6 @@
 /* Definitions of target machine for GNU compiler, for SPARC running Solaris 2
-   Copyright 1992, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright 1992, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001 Free Software Foundation, Inc.
    Contributed by Ron Guilmette (rfg@netcom.com).
    Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
 
@@ -22,6 +23,14 @@ Boston, MA 02111-1307, USA.  */
 
 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
 #include "sparc/sysv4.h"
+
+/* Solaris 2 uses a wint_t different from the default. This is required
+   by the SCD 2.4.1, p. 6-83, Figure 6-66.  */
+#undef	WINT_TYPE
+#define	WINT_TYPE "long int"
+
+#undef	WINT_TYPE_SIZE
+#define	WINT_TYPE_SIZE BITS_PER_WORD
 
 #undef CPP_PREDEFINES
 #define CPP_PREDEFINES \
Index: gcc/testsuite/gcc.dg/wchar_t-1.c
===================================================================
RCS file: wchar_t-1.c
diff -N wchar_t-1.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ wchar_t-1.c	Fri Jun  8 11:08:02 2001
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+/* Compile with -Wall to get a warning if built-in and system wchar_t don't
+   match.  */
+
+#define _STDDEF_H
+#include <wchar.h>
+
+__WCHAR_TYPE__ __wc_t__;
+wchar_t *wc_t_p;
+
+void
+wct (void)
+{
+  wc_t_p = &__wc_t__;
+}
Index: gcc/testsuite/gcc.dg/wint_t-1.c
===================================================================
RCS file: wint_t-1.c
diff -N wint_t-1.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ wint_t-1.c	Fri Jun  8 11:08:02 2001
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+/* Compile with -Wall to get a warning if built-in and system wint_t don't
+   match.  */
+
+#define _STDDEF_H
+#include <wchar.h>
+
+__WINT_TYPE__ __wi_t__;
+wint_t *wi_t_p;
+
+void
+wit (void)
+{
+  wi_t_p = &__wi_t__;
+}



More information about the Gcc-patches mailing list