public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH: Provide stdint.h for IRIX 5/6
@ 2009-11-17 13:36 Rainer Orth
  2009-11-17 13:38 ` Joseph S. Myers
  0 siblings, 1 reply; 9+ messages in thread
From: Rainer Orth @ 2009-11-17 13:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bruce Korb, Joseph S. Myers, Steve Ellcey

The following patch immplements stdint.h for IRIX 6.5.  In theory, it
should work on IRIX 5.3 and 6.x (x < 5), too, but I haven't revived my
5.3 systems yet and don't have e.g. 6.2 any longer, so I'd appreciate
testing by users that do.

Again, I've added the necessary definitions to config/mips/iris.h
directly.

I need to fix a couple of issues with the IRIX 6.5 stdint.h:

* Type mismatches between the *_{MIN, MAX} constants and the
  corresponding types.

* Uses of casts in *INT*_C macros which inhibit their use in
  preprocessor tests.

With the fixed stdint.h, all the c99-stdint-?.c tests pass in both the
n32 and n64 ABIs.  A full bootstrap is still in progress.

Unfortunately, there's one problem with the fixincludes tests: several
fail make check:

stdint.h /vol/gcc/src/gcc-dist/fixincludes/tests/base/stdint.h differ: char 3915, line 165
*** stdint.h	Tue Nov 17 14:23:58 2009
--- /vol/gcc/src/gcc-dist/fixincludes/tests/base/stdint.h	Mon Nov 16 22:37:26 2009
***************
*** 162,178 ****
  #if defined( IRIX_STDINT_C99_TYPES_CHECK )
  #define INT64_MIN               (-0x7fffffffffffffffLL - 1)
  #define INT64_MAX               0x7fffffffffffffffLL
! #define UINT32_MAX __UINT32_MAX__
  #define UINT64_MAX              0xffffffffffffffffULL
! #define INTPTR_MIN (-INTPTR_MAX - 1)
! #define INTPTR_MAX (2147483647l)
! #define UINTPTR_MAX (4294967295ul)
  #define INTPTR_MIN              (-0x7fffffffffffffffL - 1)
  #define INTPTR_MAX              0x7fffffffffffffffL
  #define UINTPTR_MAX             0xffffffffffffffffUL
! #define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
! #define PTRDIFF_MAX __PTRDIFF_MAX__
! #define SIZE_MAX __SIZE_MAX__
  #endif  /* IRIX_STDINT_C99_TYPES_CHECK */
  
  
--- 162,178 ----
  #if defined( IRIX_STDINT_C99_TYPES_CHECK )
  #define INT64_MIN               (-0x7fffffffffffffffLL - 1)
  #define INT64_MAX               0x7fffffffffffffffLL
! #define UINT32_MAX              0xffffffffU
  #define UINT64_MAX              0xffffffffffffffffULL
! #define INTPTR_MIN              (-0x7fffffffL - 1)
! #define INTPTR_MAX              0x7fffffffL
! #define UINTPTR_MAX             0xffffffffUL
  #define INTPTR_MIN              (-0x7fffffffffffffffL - 1)
  #define INTPTR_MAX              0x7fffffffffffffffL
  #define UINTPTR_MAX             0xffffffffffffffffUL
! #define PTRDIFF_MIN             (-0x7fffffffffffffffL - 1)
! #define PTRDIFF_MAX             0x7fffffffffffffffL
! #define SIZE_MAX                0xffffffffffffffffUL
  #endif  /* IRIX_STDINT_C99_TYPES_CHECK */
  
  
***************
*** 181,188 ****
  #define INT16_C(x)              (x)
  #define INT32_C(x)              (x)
  #define INT64_C(x)              (x ## LL)
! #define UINT8_C(c) __UINT8_C(c)
! #define UINT16_C(c) __UINT16_C(c)
  #define UINT32_C(x)             (x ## U)
  #define UINT64_C(x)             (x ## ULL)
  #define INTMAX_C(x)             (x ## LL)
--- 181,188 ----
  #define INT16_C(x)              (x)
  #define INT32_C(x)              (x)
  #define INT64_C(x)              (x ## LL)
! #define UINT8_C(x)              (x)
! #define UINT16_C(x)             (x)
  #define UINT32_C(x)             (x ## U)
  #define UINT64_C(x)             (x ## ULL)
  #define INTMAX_C(x)             (x ## LL)

This happens because some sed fixes in newlib_stdint_1 (UINT32_MAX,
PTRDIFF_MIN, PTRDIFF_MAX, UINT8_C, UINT16_C) and hpux_c99_intptr
(INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX) aren't specific enough.  I'll
probably need help from Josef (author of newlib_stdint_1) and Steve to
fix this.

When this is fixed, ok for mainline?

     Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2009-11-17  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	fixincludes:
	* inclhack.def (irix_stdint_c99): Renamed to irix_stdint_c99_mode.
	(irix_stdint_c99_types): New fix.
	(irix_stdint_c99_macros): Likewise.
	* fixincl.x: Regenerate.
	* tests/base/stdint.h [IRIX_STDINT_C99_CHECK]: Renamed to
	IRIX_STDINT_C99_MODE_CHECK.
	[IRIX_STDINT_C99_TYPES_CHECK]: New test.
	[IRIX_STDINT_C99_MACROS_CHECK]: Likewise.

	gcc:
	* config.gcc (mips-sgi-irix[56]*): Set use_gcc_stdint.
	* config/mips/iris.h (INT8_TYPE, INT16_TYPE, INT32_TYPE,
	INT64_TYPE): Define.
	(UINT8_TYPE, UINT16_TYPE, UINT32_TYPE, UINT64_TYPE): Define.
	(INT_LEAST8_TYPE, INT_LEAST16_TYPE, INT_LEAST32_TYPE,
	INT_LEAST64_TYPE): Define.
	(UINT_LEAST8_TYPE, UINT_LEAST16_TYPE, UINT_LEAST32_TYPE,
	UINT_LEAST64_TYPE): Define.
	(INT_FAST8_TYPE, INT_FAST16_TYPE, INT_FAST32_TYPE)
	INT_FAST64_TYPE): Define.
	(UINT_FAST8_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE,
	UINT_FAST64_TYPE): Define.
	(INTMAX_TYPE, UINTMAX_TYPE): Define.
	(INTPTR_TYPE, UINTPTR_TYPE): Define.
	(SIG_ATOMIC_TYPE): Define.

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 154216)
+++ gcc/config.gcc	(working copy)
@@ -1647,12 +1648,23 @@
 	case ${target} in
 	*-*-irix5*)
 		tm_file="${tm_file} mips/iris5.h"
+		use_gcc_stdint=provide
 		;;
 
 	*-*-irix6*)
 		tm_file="${tm_file} mips/iris6.h"
 		tmake_file="${tmake_file} mips/t-iris6"
 		tm_defines="${tm_defines} MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_N32"
+		case ${target} in
+		*-*-irix6.[0-4]*)
+			use_gcc_stdint=provide
+			;;
+		*-*-irix6.5*)
+			# Only IRIX Development Foundation 1.3 for IRIX 6.5
+			# provides stdint.h.
+			use_gcc_stdint=wrap
+			;;
+		esac
 		;;
 	esac
 	if test "x$stabs" = xyes
Index: gcc/config/mips/iris.h
===================================================================
--- gcc/config/mips/iris.h	(revision 154216)
+++ gcc/config/mips/iris.h	(working copy)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler.  Generic IRIX version.
    Copyright (C) 1993, 1995, 1996, 1998, 2000,
-   2001, 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -77,6 +77,42 @@
 #undef WINT_TYPE_SIZE
 #define WINT_TYPE_SIZE 32
 
+/* C99 stdint.h types.  */
+#define INT8_TYPE "signed char"
+#define INT16_TYPE "short int"
+#define INT32_TYPE "int"
+#define INT64_TYPE "long long int"
+#define UINT8_TYPE "unsigned char"
+#define UINT16_TYPE "short unsigned int"
+#define UINT32_TYPE "unsigned int"
+#define UINT64_TYPE "long long unsigned int"
+
+#define INT_LEAST8_TYPE "signed char"
+#define INT_LEAST16_TYPE "short int"
+#define INT_LEAST32_TYPE "int"
+#define INT_LEAST64_TYPE "long long int"
+#define UINT_LEAST8_TYPE "unsigned char"
+#define UINT_LEAST16_TYPE "short unsigned int"
+#define UINT_LEAST32_TYPE "unsigned int"
+#define UINT_LEAST64_TYPE "long long unsigned int"
+
+#define INT_FAST8_TYPE "signed char"
+#define INT_FAST16_TYPE "short int"
+#define INT_FAST32_TYPE "int"
+#define INT_FAST64_TYPE "long long int"
+#define UINT_FAST8_TYPE "unsigned char"
+#define UINT_FAST16_TYPE "short unsigned int"
+#define UINT_FAST32_TYPE "unsigned int"
+#define UINT_FAST64_TYPE "long long unsigned int"
+
+#define INTMAX_TYPE "long long int"
+#define UINTMAX_TYPE "long long unsigned int"
+
+#define INTPTR_TYPE "long int"
+#define UINTPTR_TYPE "long unsigned int"
+
+#define SIG_ATOMIC_TYPE "int"
+
 /* Plain char is unsigned in the SGI compiler.  */
 #undef DEFAULT_SIGNED_CHAR
 #define DEFAULT_SIGNED_CHAR 0
Index: fixincludes/tests/base/stdint.h
===================================================================
--- fixincludes/tests/base/stdint.h	(revision 154216)
+++ fixincludes/tests/base/stdint.h	(working copy)
@@ -152,13 +152,44 @@
 #endif  /* HPUX_STDINT_LEAST_FAST_CHECK */
 
 
-#if defined( IRIX_STDINT_C99_CHECK )
+#if defined( IRIX_STDINT_C99_MODE_CHECK )
 #if 0
 #error This header file is to be used only for c99 mode compilations
 #else
-#endif  /* IRIX_STDINT_C99_CHECK */
+#endif  /* IRIX_STDINT_C99_MODE_CHECK */
 
 
+#if defined( IRIX_STDINT_C99_TYPES_CHECK )
+#define INT64_MIN               (-0x7fffffffffffffffLL - 1)
+#define INT64_MAX               0x7fffffffffffffffLL
+#define UINT32_MAX              0xffffffffU
+#define UINT64_MAX              0xffffffffffffffffULL
+#define INTPTR_MIN              (-0x7fffffffL - 1)
+#define INTPTR_MAX              0x7fffffffL
+#define UINTPTR_MAX             0xffffffffUL
+#define INTPTR_MIN              (-0x7fffffffffffffffL - 1)
+#define INTPTR_MAX              0x7fffffffffffffffL
+#define UINTPTR_MAX             0xffffffffffffffffUL
+#define PTRDIFF_MIN             (-0x7fffffffffffffffL - 1)
+#define PTRDIFF_MAX             0x7fffffffffffffffL
+#define SIZE_MAX                0xffffffffffffffffUL
+#endif  /* IRIX_STDINT_C99_TYPES_CHECK */
+
+
+#if defined( IRIX_STDINT_C99_MACROS_CHECK )
+#define INT8_C(x)               (x)
+#define INT16_C(x)              (x)
+#define INT32_C(x)              (x)
+#define INT64_C(x)              (x ## LL)
+#define UINT8_C(x)              (x)
+#define UINT16_C(x)             (x)
+#define UINT32_C(x)             (x ## U)
+#define UINT64_C(x)             (x ## ULL)
+#define INTMAX_C(x)             (x ## LL)
+#define UINTMAX_C(x)            (x ## ULL)
+#endif  /* IRIX_STDINT_C99_MACROS_CHECK */
+
+
 #if defined( NEWLIB_STDINT_1_CHECK )
 /* @todo - Add support for wint_t types. */
 #define INT32_MIN (-INT32_MAX - 1)
Index: fixincludes/inclhack.def
===================================================================
--- fixincludes/inclhack.def	(revision 154216)
+++ fixincludes/inclhack.def	(working copy)
@@ -2511,7 +2511,7 @@
  *  otherwise.
  */
 fix = {
-    hackname  = irix_stdint_c99;
+    hackname  = irix_stdint_c99_mode;
     files     = stdint.h;
     select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
 
@@ -2525,6 +2525,87 @@
 
 
 /*
+ *  IRIX 6.5 <stdint.h> has some *_MIN/MAX constants whose types don't
+ *  match the corresponding types, as required by ISO C99.
+ */
+fix = {
+    hackname  = irix_stdint_c99_types;
+    files     = stdint.h;
+    mach      = "mips-sgi-irix6.5";
+    sed       = "s@^#define INT64_MIN.*$@"
+                "#define INT64_MIN               (-0x7fffffffffffffffLL - 1)@";
+    sed       = "s@^#define INT64_MAX.*$@"
+                "#define INT64_MAX               0x7fffffffffffffffLL@";
+    sed       = "s@^#define UINT32_MAX.*$@"
+                "#define UINT32_MAX              0xffffffffU@";
+    sed       = "s@^#define UINT64_MAX.*$@"
+                "#define UINT64_MAX              0xffffffffffffffffULL@";
+    sed       = "s@^#define INTPTR_MIN.*INT32_MIN$@"
+                "#define INTPTR_MIN              (-0x7fffffffL - 1)@";
+    sed       = "s@^#define INTPTR_MAX.*INT32_MAX$@"
+                "#define INTPTR_MAX              0x7fffffffL@";
+    sed       = "s@^#define UINTPTR_MAX.*UINT32_MAX$@"
+                "#define UINTPTR_MAX             0xffffffffUL@";
+    sed       = "s@^#define INTPTR_MIN.*INT64_MIN@"
+                "#define INTPTR_MIN              (-0x7fffffffffffffffL - 1)@";
+    sed       = "s@^#define INTPTR_MAX.*INT64_MAX$@"
+                "#define INTPTR_MAX              0x7fffffffffffffffL@";
+    sed       = "s@^#define UINTPTR_MAX.*UINT64_MAX$@"
+                "#define UINTPTR_MAX             0xffffffffffffffffUL@";
+    sed       = "s@^#define PTRDIFF_MIN.*INT64_MIN$@"
+                "#define PTRDIFF_MIN             (-0x7fffffffffffffffL - 1)@";
+    sed       = "s@^#define PTRDIFF_MAX.*INT64_MAX$@"
+                "#define PTRDIFF_MAX             0x7fffffffffffffffL@";
+    sed       = "s@^#define SIZE_MAX.*UINT64_MAX#@"
+                "#define SIZE_MAX                0xffffffffffffffffUL@";
+    test_text = "#define INT64_MIN               (-0x7fffffffffffffff - 1)\n"
+                "#define INT64_MAX               0x7fffffffffffffff\n"
+                "#define UINT32_MAX              0xffffffff\n"
+                "#define UINT64_MAX              0xffffffffffffffff\n"
+                "#define INTPTR_MIN              INT32_MIN\n"
+                "#define INTPTR_MAX              INT32_MAX\n"
+                "#define UINTPTR_MAX             UINT32_MAX\n"
+                "#define INTPTR_MIN              INT64_MIN\n"
+                "#define INTPTR_MAX              INT64_MAX\n"
+                "#define UINTPTR_MAX             UINT64_MAX\n"
+                "#define PTRDIFF_MIN             INT64_MIN\n"
+                "#define PTRDIFF_MAX             INT64_MAX\n"
+                "#define SIZE_MAX                UINT64_MAX";
+};
+
+
+/*
+ *  IRIX 6.5 <stdint.h> uses casts in some macros which cannot thus be used
+ *  in preprocessor tests, although ISO C99 requires this.
+ */
+fix = {
+    hackname  = irix_stdint_c99_macros;
+    files     = stdint.h;
+    mach      = "mips-sgi-irix6.5";
+    sed       = "s@^#define INT8_C(x).*$@#define INT8_C(x)               (x)@";
+    sed       = "s@^#define INT16_C(x).*$@#define INT16_C(x)              (x)@";
+    sed       = "s@^#define INT32_C(x).*$@#define INT32_C(x)              (x)@";
+    sed       = "s@^#define INT64_C(x).*$@#define INT64_C(x)              (x ## LL)@";
+    sed       = "s@^#define UINT8_C(x).*$@#define UINT8_C(x)              (x)@";
+    sed       = "s@^#define UINT16_C(x).*$@#define UINT16_C(x)             (x)@";
+    sed       = "s@^#define UINT32_C(x).*$@#define UINT32_C(x)             (x ## U)@";
+    sed       = "s@^#define UINT64_C(x).*$@#define UINT64_C(x)             (x ## ULL)@";
+    sed       = "s@^#define INTMAX_C(x).*$@#define INTMAX_C(x)             (x ## LL)@";
+    sed       = "s@^#define UINTMAX_C(x).*$@#define UINTMAX_C(x)            (x ## ULL)@";
+    test_text = "#define INT8_C(x)               (int_least8_t)(x)\n"
+                "#define INT16_C(x)              (int_least16_t)(x)\n"
+                "#define INT32_C(x)              (int_least32_t)(x)\n"
+                "#define INT64_C(x)              (int_least64_t)(x)\n"
+                "#define UINT8_C(x)              (uint_least8_t)(x)\n"
+                "#define UINT16_C(x)             (uint_least16_t)(x)\n"
+                "#define UINT32_C(x)             (uint_least32_t)(x)\n"
+                "#define UINT64_C(x)             (uint_least64_t)(x)\n"
+                "#define INTMAX_C(x)             (intmax_t)(x)\n"
+                "#define UINTMAX_C(x)            (uintmax_t)(x)";
+};
+
+
+/*
  *  IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
  *  some functions that take a va_list as
  *  taking char *.  However, GCC uses void * for va_list, so

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-01-26 19:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17 13:36 PATCH: Provide stdint.h for IRIX 5/6 Rainer Orth
2009-11-17 13:38 ` Joseph S. Myers
2009-11-17 19:58   ` Rainer Orth
2009-11-18  2:17     ` Bruce Korb
2009-11-18 14:15       ` Rainer Orth
2009-11-18 22:56         ` Bruce Korb
2010-01-26 15:21           ` Rainer Orth
2010-01-26 19:27             ` Bruce Korb
2010-01-26 19:45               ` Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).