public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about creating stdint.h on systems that don't have it
@ 2009-04-14 16:10 Steve Ellcey
  2009-04-14 16:22 ` Joseph S. Myers
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Ellcey @ 2009-04-14 16:10 UTC (permalink / raw)
  To: gcc; +Cc: joseph, dave

I am working on the c99 stdint.h support for HP-UX.  On HP-UX 11.23 and
11.31 where stdint.h exists I am setting use_gcc_stdint to "wrap" and
adding some hacks to inclhack.def and that seems to be working.

On HP-UX 11.11 there is no stdint.h but I think we want to provide one. 
I tried setting use_gcc_stdint to "provide" but that doesn't work
because HP-UX 11.11 already has typedefs in other header files for some
of the things the GCC provided stdint.h wants to typedef like
int8_fast_t.

I believe I want to create my own stdint.h header file, one that looks
more like the HP-UX 11.23 one than the GCC provided one, but I am not
sure how to do that.  I don't see any examples in inclhack.def of
providing a header file that doesn't exist, only cases of changing or
completely replacing existing header files.

Is there a standard way of having GCC provide a new header file
for a given platform?

Steve Ellcey
sje@cup.hp.com

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

* Re: Question about creating stdint.h on systems that don't have it
  2009-04-14 16:10 Question about creating stdint.h on systems that don't have it Steve Ellcey
@ 2009-04-14 16:22 ` Joseph S. Myers
  2009-04-14 16:24   ` Steve Ellcey
  2009-04-14 16:31   ` John David Anglin
  0 siblings, 2 replies; 8+ messages in thread
From: Joseph S. Myers @ 2009-04-14 16:22 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: gcc, dave

On Tue, 14 Apr 2009, Steve Ellcey wrote:

> On HP-UX 11.11 there is no stdint.h but I think we want to provide one. 
> I tried setting use_gcc_stdint to "provide" but that doesn't work
> because HP-UX 11.11 already has typedefs in other header files for some
> of the things the GCC provided stdint.h wants to typedef like
> int8_fast_t.

GCC allows duplicate typedefs in system headers (there's also a proposal 
for C1x to allow them more generally, as C++ does).  So as long as the 
types are consistent with those in other headers (is this a system with 
inttypes.h but not stdint.h?) there should be no problem with using GCC's 
copy.

> Is there a standard way of having GCC provide a new header file
> for a given platform?

You'd create an alternative setting to "provide", "wrap" and "none", say 
"hpux", and add code to handle it.  But you shouldn't need to do so simply 
because some other headers define some of the types.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: Question about creating stdint.h on systems that don't have it
  2009-04-14 16:22 ` Joseph S. Myers
@ 2009-04-14 16:24   ` Steve Ellcey
  2009-04-14 18:10     ` John David Anglin
  2009-04-14 16:31   ` John David Anglin
  1 sibling, 1 reply; 8+ messages in thread
From: Steve Ellcey @ 2009-04-14 16:24 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc, dave

On Tue, 2009-04-14 at 15:50 +0000, Joseph S. Myers wrote:

> > Is there a standard way of having GCC provide a new header file
> > for a given platform?
> 
> You'd create an alternative setting to "provide", "wrap" and "none", say 
> "hpux", and add code to handle it.  But you shouldn't need to do so simply 
> because some other headers define some of the types.

OK, when looking at the preprocessed output I see:

typedef signed char int_least8_t;
typedef __INT_LEAST8_TYPE__ int_least8_t;

So the problem seems to be that __INT_LEAST8_TYPE__ isn't defined.
On HP-UX 11.23 where I use "wrap" I created a hpux-stdint.h file
(like glibc-stdint.h and newlib-stdint.h) to use.  I guess I need
to use this on HP-UX 11.11 too, even though I am using "provide"
instead of "wrap".

Steve Ellcey
sje@cup.hp.com


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

* Re: Question about creating stdint.h on systems that don't have it
  2009-04-14 16:22 ` Joseph S. Myers
  2009-04-14 16:24   ` Steve Ellcey
@ 2009-04-14 16:31   ` John David Anglin
  2009-04-14 17:02     ` Andrew Pinski
  2009-04-14 18:18     ` Steve Ellcey
  1 sibling, 2 replies; 8+ messages in thread
From: John David Anglin @ 2009-04-14 16:31 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: sje, gcc

I have a patch to provide stdint.h on HP-UX that I have been testing.
I have resolved the consistency issues with inttypes.h although there
are some slightly wierd aspects.  For example, I found "signed char" and
"char" are inconsistent, yet characters are signed.  The specification
of some types differs from that in inttypes.h for some types but gcc
doesn't object.  For example, I specify "long long int" instead of just
"long long".

I have to define __STDC_EXT__ under all circumstances to get consistency
of the long long types in the 32-bit runtime.  Previously, gcc for hpux
tried to mirror the behavior of the HP C compiler wrt long long types.

I think the patch chould work for most HP-UX versions except perhaps
11.31 and later.  These systems may provide stdint.h.  I don't have
access to a machine with 11.31 or later.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

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

* Re: Question about creating stdint.h on systems that don't have it
  2009-04-14 16:31   ` John David Anglin
@ 2009-04-14 17:02     ` Andrew Pinski
  2009-04-14 18:18     ` Steve Ellcey
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew Pinski @ 2009-04-14 17:02 UTC (permalink / raw)
  To: John David Anglin; +Cc: Joseph S. Myers, sje, gcc

On Tue, Apr 14, 2009 at 9:18 AM, John David Anglin
<dave@hiauly1.hia.nrc.ca> wrote:
> I have a patch to provide stdint.h on HP-UX that I have been testing.
> I have resolved the consistency issues with inttypes.h although there
> are some slightly wierd aspects.  For example, I found "signed char" and
> "char" are inconsistent, yet characters are signed.  The specification
> of some types differs from that in inttypes.h for some types but gcc
> doesn't object.  For example, I specify "long long int" instead of just
> "long long".

There are three distant character types in C and C++; signed char,
unsigned char and char.  Even if char is signed by default char and
signed char are still incompatible types.  This is different from long
long int and long long where they are the same type.

Thanks,
Andrew Pinski

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

* Re: Question about creating stdint.h on systems that don't have it
  2009-04-14 16:24   ` Steve Ellcey
@ 2009-04-14 18:10     ` John David Anglin
  0 siblings, 0 replies; 8+ messages in thread
From: John David Anglin @ 2009-04-14 18:10 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Joseph S. Myers, gcc

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

Attached is my change as it currently stands.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

[-- Attachment #2: stdint.d.2 --]
[-- Type: text/plain, Size: 5846 bytes --]

Index: config.gcc
===================================================================
--- config.gcc	(revision 145670)
+++ config.gcc	(working copy)
@@ -937,6 +937,7 @@
 	    tmake_file="$tmake_file pa/t-slibgcc-dwarf-ver"
 	fi
 	use_collect2=yes
+	use_gcc_stdint=provide
 	gas=yes
 	;;
 hppa*64*-*-hpux11*)
@@ -974,6 +975,7 @@
 		thread_file=posix
 		;;
 	esac
+	use_gcc_stdint=provide
 	gas=yes
 	;;
 hppa[12]*-*-hpux11*)
@@ -1003,6 +1005,7 @@
 		thread_file=posix
 		;;
 	esac
+	use_gcc_stdint=provide
 	use_collect2=yes
 	gas=yes
 	;;
Index: config/pa/pa64-hpux.h
===================================================================
--- config/pa/pa64-hpux.h	(revision 145670)
+++ config/pa/pa64-hpux.h	(working copy)
@@ -19,6 +19,20 @@
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+/* C99 stdint.h types.  */
+#undef INT64_TYPE
+#define INT64_TYPE "long int"
+#undef UINT64_TYPE
+#define UINT64_TYPE "long unsigned int"
+#undef INT_LEAST64_TYPE
+#define INT_LEAST64_TYPE "long int"
+#undef UINT_LEAST64_TYPE
+#define UINT_LEAST64_TYPE "long unsigned int"
+#undef INT_FAST64_TYPE
+#define INT_FAST64_TYPE "long int"
+#undef UINT_FAST64_TYPE
+#define UINT_FAST64_TYPE "long unsigned int"
+
 /* We can debug dynamically linked executables on hpux11; we also
    want dereferencing of a NULL pointer to cause a SEGV.  Do not move
    the "+Accept TypeMismatch" switch.  We check for it in collect2
Index: config/pa/pa-hpux.h
===================================================================
--- config/pa/pa-hpux.h	(revision 145670)
+++ config/pa/pa-hpux.h	(working copy)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for HP-UX.
-   Copyright (C) 1991, 1995, 1996, 2002, 2003, 2004, 2007, 2008
+   Copyright (C) 1991, 1995, 1996, 2002, 2003, 2004, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -32,6 +32,39 @@
 #define SIZE_TYPE "unsigned int"
 #define PTRDIFF_TYPE "int"
 
+/* C99 stdint.h types.  */
+#define INT8_TYPE "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 "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 "int"
+#define INT_FAST16_TYPE "int"
+#define INT_FAST32_TYPE "int"
+#define INT_FAST64_TYPE "long long int"
+#define UINT_FAST8_TYPE "unsigned int"
+#define UINT_FAST16_TYPE "unsigned int"
+#define UINT_FAST32_TYPE "unsigned int"
+#define UINT_FAST64_TYPE "long long unsigned int"
+
+#define INTPTR_TYPE "long int"
+#define UINTPTR_TYPE "long unsigned int"
+
+#define SIG_ATOMIC_TYPE "unsigned int"
+
 #define LONG_DOUBLE_TYPE_SIZE 128
 #define HPUX_LONG_DOUBLE_LIBRARY
 #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
@@ -56,11 +89,11 @@
 	builtin_define ("__hpux__");				\
 	builtin_define ("__unix");				\
 	builtin_define ("__unix__");				\
+	builtin_define ("__STDC_EXT__");			\
 	if (c_dialect_cxx ())					\
 	  {							\
 	    builtin_define ("_HPUX_SOURCE");			\
 	    builtin_define ("_INCLUDE_LONGLONG");		\
-	    builtin_define ("__STDC_EXT__");			\
 	  }							\
 	else if (!flag_iso)					\
 	  {							\
@@ -76,8 +109,6 @@
 		builtin_define ("_PWB");			\
 		builtin_define ("PWB");				\
 	      }							\
-	    else						\
-	      builtin_define ("__STDC_EXT__");			\
 	  }							\
 	if (TARGET_SIO)						\
 	  builtin_define ("_SIO");				\
Index: config/pa/pa-hpux10.h
===================================================================
--- config/pa/pa-hpux10.h	(revision 145670)
+++ config/pa/pa-hpux10.h	(working copy)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler, for HP PA-RISC
    Copyright (C) 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Tim Moore (moore@defmacro.cs.utah.edu)
 
 This file is part of GCC.
@@ -38,11 +38,11 @@
 	builtin_define ("__hpux__");					\
 	builtin_define ("__unix");					\
 	builtin_define ("__unix__");					\
+	builtin_define ("__STDC_EXT__");				\
 	if (c_dialect_cxx ())						\
 	  {								\
 	    builtin_define ("_HPUX_SOURCE");				\
 	    builtin_define ("_INCLUDE_LONGLONG");			\
-	    builtin_define ("__STDC_EXT__");				\
 	    builtin_define ("__STDCPP__");				\
 	  }								\
 	else if (!flag_iso)						\
@@ -58,8 +58,6 @@
 		builtin_define ("_PWB");				\
 		builtin_define ("PWB");					\
 	      }								\
-	    else							\
-	      builtin_define ("__STDC_EXT__");				\
 	  }								\
 	if (flag_pa_unix >= 1995)					\
 	  {								\
Index: config/pa/pa-hpux11.h
===================================================================
--- config/pa/pa-hpux11.h	(revision 145670)
+++ config/pa/pa-hpux11.h	(working copy)
@@ -37,11 +37,11 @@
 	builtin_define ("__hpux__");					\
 	builtin_define ("__unix");					\
 	builtin_define ("__unix__");					\
+	builtin_define ("__STDC_EXT__");				\
 	if (c_dialect_cxx ())						\
 	  {								\
 	    builtin_define ("_HPUX_SOURCE");				\
 	    builtin_define ("_INCLUDE_LONGLONG");			\
-	    builtin_define ("__STDC_EXT__");				\
 	    builtin_define ("__STDCPP__");				\
 	  }								\
 	else								\
@@ -59,8 +59,6 @@
 		    builtin_define ("_PWB");				\
 		    builtin_define ("PWB");				\
 		  }							\
-		else							\
-		  builtin_define ("__STDC_EXT__");			\
 	      }								\
 	  }								\
 	if (!TARGET_64BIT)						\

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

* Re: Question about creating stdint.h on systems that don't have it
  2009-04-14 16:31   ` John David Anglin
  2009-04-14 17:02     ` Andrew Pinski
@ 2009-04-14 18:18     ` Steve Ellcey
  2009-04-14 22:48       ` John David Anglin
  1 sibling, 1 reply; 8+ messages in thread
From: Steve Ellcey @ 2009-04-14 18:18 UTC (permalink / raw)
  To: John David Anglin; +Cc: Joseph S. Myers, gcc

On Tue, 2009-04-14 at 12:18 -0400, John David Anglin wrote:
> I have a patch to provide stdint.h on HP-UX that I have been testing.
> I have resolved the consistency issues with inttypes.h although there
> are some slightly wierd aspects.  For example, I found "signed char" and
> "char" are inconsistent, yet characters are signed.  The specification
> of some types differs from that in inttypes.h for some types but gcc
> doesn't object.  For example, I specify "long long int" instead of just
> "long long".
> 
> I have to define __STDC_EXT__ under all circumstances to get consistency
> of the long long types in the 32-bit runtime.  Previously, gcc for hpux
> tried to mirror the behavior of the HP C compiler wrt long long types.

Rather then define __STDC_EXT__ all the time I was looking at defining
__LL_MODE__.  I created this inclhack.def entry:


+fix = {
+    hackname  = hpux_longlong;
+    mach      = "*-hp-hpux11.[12]*";
+    files     = sys/_inttypes.h;
+    select    = "#endif.*__LP64__.*";
+    c_fix     = format;
+    c_fix_arg = "%0\n#if !defined(__STDC_EXT__) && !defined(__LP64__)
&& define
d(__STDC__) && ((__STDC_VERSION__-1+1) >= 199901L)\n#define __LL_MODE__
\n#undef 
__STDC_32_MODE__\n#endif\n";
+    test_text = "#include <sys/stdsyms.h>";
+};


> I think the patch chould work for most HP-UX versions except perhaps
> 11.31 and later.  These systems may provide stdint.h.  I don't have
> access to a machine with 11.31 or later.

I think all 11.23 systems should have stdint.h too. It is only 11.11 and
older systems that do not have stdint.h.  I don't have any 11.00 systems
anymore but I am currently looking at 11.11.

I got your patch and will compare that with what I have and see if I can
merge the two.

Steve Ellcey
sje@cup.hp.com

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

* Re: Question about creating stdint.h on systems that don't have it
  2009-04-14 18:18     ` Steve Ellcey
@ 2009-04-14 22:48       ` John David Anglin
  0 siblings, 0 replies; 8+ messages in thread
From: John David Anglin @ 2009-04-14 22:48 UTC (permalink / raw)
  To: sje; +Cc: joseph, gcc

> > I have to define __STDC_EXT__ under all circumstances to get consistency
> > of the long long types in the 32-bit runtime.  Previously, gcc for hpux
> > tried to mirror the behavior of the HP C compiler wrt long long types.
> 
> Rather then define __STDC_EXT__ all the time I was looking at defining
> __LL_MODE__.  I created this inclhack.def entry:

I guess the main issue is whether large file support should always
be enabled or not.

> +fix = {
> +    hackname  = hpux_longlong;
> +    mach      = "*-hp-hpux11.[12]*";

> I got your patch and will compare that with what I have and see if I can
> merge the two.

Thanks.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

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

end of thread, other threads:[~2009-04-14 18:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 16:10 Question about creating stdint.h on systems that don't have it Steve Ellcey
2009-04-14 16:22 ` Joseph S. Myers
2009-04-14 16:24   ` Steve Ellcey
2009-04-14 18:10     ` John David Anglin
2009-04-14 16:31   ` John David Anglin
2009-04-14 17:02     ` Andrew Pinski
2009-04-14 18:18     ` Steve Ellcey
2009-04-14 22:48       ` John David Anglin

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).