This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
3.0 PATCH: Fix wchar_t/wint_t definitions for bi-arch Solaris 7/8 and IRIX 6
- To: gcc-patches at gcc dot gnu dot org
- Subject: 3.0 PATCH: Fix wchar_t/wint_t definitions for bi-arch Solaris 7/8 and IRIX 6
- From: Rainer Orth <ro at TechFak dot Uni-Bielefeld dot DE>
- Date: Fri, 1 Jun 2001 19:27:26 +0200 (MEST)
- Cc: Neil Booth <neil at daikokuya dot demon dot co dot uk>, Andrew Macleod <amacleod at cygnus dot com>, <David dot Billinghurst at riotinto dot com>, "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
This is an updated version of
http://gcc.gnu.org/ml/gcc-patches/2001-05/msg01961.html
based on various comments I've received. Bootstrapped with no regressions
on bi-arch (32x64) sparc-sun-solaris2.8, 64x32 sparcv9-sun-solaris2.8 and
32x64 mips-sgi-irix6.2.
One comment may be in order: I've provided a default for wint_t in
config/svr4.h because this is where 32-bit SPARC get's it's default for
wchar_t, too. I couldn't find anything on wint_t in SVID 4
(http://www.sco.com/developer/devspecs/) though, so this might have to be
revised.
Ok to check in (branch and trunk)?
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Email: ro@TechFak.Uni-Bielefeld.DE
Thu May 31 19:32:06 2001 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
gcc/testsuite:
* gcc.dg/wchar_t-1.c: New file.
* gcc.dg/wint_t-1.c: Likewise.
gcc:
* 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/svr4.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.
* config/mips/iris6.h (NO_BUILTIN_WCHAR_TYPE): Define.
(WCHAR_TYPE): Override.
(WCHAR_TYPE_SIZE): Likewise.
(SUBTARGET_CPP_SIZE_SPEC): Simplify, define __WCHAR_TYPE__ as
appropriate.
* config/sparc/sol2-sld-64.h (NO_BUILTIN_WCHAR_TYPE): Define.
(WCHAR_TYPE): Override.
(WCHAR_TYPE_SIZE): Likewise.
(CPP_ARCH32_SPEC): Add __WCHAR_TYPE__ definition.
(CPP_ARCH64_SPEC): Likewise.
Index: gcc/config/svr4.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/svr4.h,v
retrieving revision 1.23
diff -u -p -r1.23 svr4.h
--- svr4.h 2000/02/26 20:24:45 1.23
+++ svr4.h 2001/06/01 17:06:15
@@ -232,6 +232,12 @@ Boston, MA 02111-1307, USA.
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE BITS_PER_WORD
+#undef WINT_TYPE
+#define WINT_TYPE "long int"
+
+#undef WINT_TYPE_SIZE
+#define WINT_TYPE_SIZE BITS_PER_WORD
+
/* This causes trouble, because it requires the host machine
to support ANSI C. */
/* #define MULTIBYTE_CHARS */
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/01 17:06:21
@@ -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/01 17:06:22
@@ -161,11 +161,32 @@
%{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
")
+/* wchar_t is called differently in <wchar.h> for 32 and 64-bit
+ compilations. */
+#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. */
+#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/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 1 10:06:27 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 1 10:06:27 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__;
+}