This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patches: gcc, libio, libobjc and libg++ for build with `-ansi -D_XOPEN_SOURCE=500'


The enclosed patches allow me to build successfully under i686 linux
with
BOOT_CFLAGS="-ansi -D_XOPEN_SOURCE=500 -g -O3" (ie., the
Single UNIX Specification Version 2 namespace).  The changes are mainly
to uses the ansi version of compiler extensions such as inline, asm,
etc.
In order to drop to the base Open Group namespace, probably more
prototypes would have to be added here and there.  I noted that
libiberty
needs strdup and mktemp.

Dave
2000-09-18  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* collect2.c (read_file): Use PTR not caddr_t.
	intl/loadmsgcat.c (_nl_load_domain, _nl_unload_domain): Likewise.
	crtstuff.c: Use __asm__ instead of asm.
	system.h: Prototype fputc_unlocked if it is not declared and always
	include alloca.h if available.
	configure.in: Check declaration for fputc_unlocked.
	configure: Rebuilt.
	
--- collect2.c.orig	Mon Aug 14 16:46:15 2000
+++ collect2.c	Mon Sep 18 14:01:11 2000
@@ -3498,7 +3498,7 @@
     page_size = sysconf (_SC_PAGE_SIZE);
 
   p->rounded_size = ((p->size + page_size - 1) / page_size) * page_size;
-  p->start = mmap ((caddr_t) 0,
+  p->start = mmap ((PTR) 0,
 		   (rw) ? p->rounded_size : p->size,
 		   (rw) ? (PROT_READ | PROT_WRITE) : PROT_READ,
 		   MAP_FILE | MAP_VARIABLE | MAP_SHARED,
--- configure.in.orig	Sat Sep  9 18:57:17 2000
+++ configure.in	Wed Sep 13 18:01:23 2000
@@ -534,8 +534,8 @@
 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
 gcc_AC_CHECK_DECLS(bcopy bzero bcmp \
 	index rindex getenv atol sbrk abort atof getcwd getwd \
-	strsignal putc_unlocked fputs_unlocked strstr environ \
-	malloc realloc calloc free basename getopt, , ,[
+	strsignal putc_unlocked fputc_unlocked fputs_unlocked \
+	strstr environ malloc realloc calloc free basename getopt, , ,[
 #include "gansidecl.h"
 #include "system.h"])
 
--- crtstuff.c.orig	Fri Aug 25 03:21:54 2000
+++ crtstuff.c	Mon Sep 18 14:30:30 2000
@@ -59,6 +59,10 @@
 #include "tm.h"
 #include "tsystem.h"
 
+#if !defined(asm) && defined(__GNUC__)
+#define asm __asm__
+#endif
+
 #include "defaults.h"
 #include "frame.h"
 
--- intl/loadmsgcat.c.orig	Tue Jun  6 03:23:42 2000
+++ intl/loadmsgcat.c	Mon Sep 18 14:21:22 2000
@@ -152,7 +152,7 @@
 #if (defined HAVE_MMAP_FILE && !defined DISALLOW_MMAP) \
     || defined _LIBC
       if (use_mmap)
-	munmap ((caddr_t) data, size);
+	munmap ((PTR) data, size);
       else
 #endif
 	free (data);
@@ -191,7 +191,7 @@
 #if (defined HAVE_MMAP_FILE && !defined DISALLOW_MMAP) \
     || defined _LIBC
       if (use_mmap)
-	munmap ((caddr_t) data, size);
+	munmap ((PTR) data, size);
       else
 #endif
 	free (data);
@@ -213,7 +213,7 @@
      struct loaded_domain *domain;
 {
   if (domain->use_mmap)
-    munmap ((caddr_t) domain->data, domain->mmap_size);
+    munmap ((PTR) domain->data, domain->mmap_size);
   else
     free ((void *) domain->data);
 
--- system.h.orig	Mon Aug 21 14:01:50 2000
+++ system.h	Mon Sep 18 15:44:33 2000
@@ -57,7 +57,8 @@
    code is multi-thread safe by default.  If it is set to 0, then do
    not worry about using the _unlocked functions.
    
-   fputs_unlocked is an extension and needs to be prototyped specially.  */
+   fputc_unlocked and fputs_unlocked are extensions and need to be
+   prototyped specially.  */
 
 #if defined HAVE_PUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
 # undef putc
@@ -66,6 +67,9 @@
 #if defined HAVE_FPUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
 # undef fputc
 # define fputc(C, Stream) fputc_unlocked (C, Stream)
+# if defined (HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
+extern int fputc_unlocked PARAMS ((int, FILE *));
+# endif
 #endif
 #if defined HAVE_FPUTS_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
 # undef fputs
@@ -183,6 +187,10 @@
 #   include <strings.h>
 #  endif
 # endif
+#endif
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
 #endif
 
 #ifdef HAVE_STDLIB_H
2000-09-18  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* streambuf.cc: Use __linux__ rather than linux.

--- streambuf.cc.orig	Wed May  6 17:08:52 1998
+++ streambuf.cc	Thu Sep 14 18:05:47 2000
@@ -350,7 +350,7 @@
 			 && (rdbuf()->_flags & _IO_NO_READS+_IO_NO_WRITES)
 			     != _IO_NO_READS+_IO_NO_WRITES; }
 
-#if defined(linux)
+#if defined(__linux__)
 #define IO_CLEANUP
 #endif
 
2000-08-18  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* Object.m: Change // comments to C style comments.
	encoding.c (MAX, MIN, ROUND): Use __typeof__ instead of typeof.
	archive.c (ROUND): Likewise.
	gc.c (ROUND): Likewise.
	libobjc_entry.c: Use __asm__ instead of asm.
	objc/objc.h, objc/objc-list.h: Define inline as __inline__ when
	appropriate.

--- Object.m.orig	Sat Jul 29 03:09:34 2000
+++ Object.m	Thu Sep 14 16:02:10 2000
@@ -119,8 +119,8 @@
 {
   if ([self isEqual:anotherObject])
     return 0;
-  // Ordering objects by their address is pretty useless, 
-  // so subclasses should override this is some useful way.
+  /* Ordering objects by their address is pretty useless, 
+     so subclasses should override this is some useful way. */
   else if (self > anotherObject)
     return 1;
   else 
@@ -191,11 +191,11 @@
   return method_get_imp(class_get_instance_method(self, aSel));
 }
 
-// Indicates if the receiving class or instance conforms to the given protocol
-// not usually overridden by subclasses
-//
-// Modified 9/5/94 to always search the class object's protocol list, rather
-// than the meta class.
+/* Indicates if the receiving class or instance conforms to the given protocol
+   not usually overridden by subclasses
+
+   Modified 9/5/94 to always search the class protocol list, rather
+   than the meta class of the object. */
 
 + (BOOL) conformsTo: (Protocol*)aProtocol
 {
@@ -356,27 +356,27 @@
     return class_get_version (self);
 }
 
-// These are used to write or read the instance variables 
-// declared in this particular part of the object.  Subclasses
-// should extend these, by calling [super read/write: aStream]
-// before doing their own archiving.  These methods are private, in
-// the sense that they should only be called from subclasses.
+/* These are used to write or read the instance variables 
+   declared in this particular part of the object.  Subclasses
+   should extend these, by calling [super read/write: aStream]
+   before doing their own archiving.  These methods are private, in
+   the sense that they should only be called from subclasses. */
 
 - read: (TypedStream*)aStream
 {
-  // [super read: aStream];  
+  /* [super read: aStream]; */
   return self;
 }
 
 - write: (TypedStream*)aStream
 {
-  // [super write: aStream];
+  /* [super write: aStream]; */
   return self;
 }
 
 - awake
 {
-  // [super awake];
+  /* [super awake]; */
   return self;
 }
 
--- archive.c.orig	Fri Mar 26 18:44:04 1999
+++ archive.c	Thu Sep 14 12:31:48 2000
@@ -36,7 +36,7 @@
 extern int fflush(FILE*);
 
 #define ROUND(V, A) \
-  ({ typeof(V) __v=(V); typeof(A) __a=(A);  \
+  ({ __typeof__ (V) __v=(V); __typeof__ (A) __a=(A);  \
      __a*((__v+__a-1)/__a); })
 
 #define PTR2LONG(P) (((char*)(P))-(char*)0)
--- encoding.c.orig	Thu Sep  7 00:33:54 2000
+++ encoding.c	Thu Sep 14 13:50:36 2000
@@ -31,15 +31,15 @@
 #include "encoding.h"
 
 #define MAX(X, Y)                    \
-  ({ typeof(X) __x = (X), __y = (Y); \
+  ({ __typeof__ (X) __x = (X), __y = (Y); \
      (__x > __y ? __x : __y); })
 
 #define MIN(X, Y)                    \
-  ({ typeof(X) __x = (X), __y = (Y); \
+  ({ __typeof__ (X) __x = (X), __y = (Y); \
      (__x < __y ? __x : __y); })
 
 #define ROUND(V, A) \
-  ({ typeof(V) __v=(V); typeof(A) __a=(A); \
+  ({ __typeof__ (V) __v=(V); __typeof__ (A) __a=(A); \
      __a*((__v+__a-1)/__a); })
 
 
--- gc.c.orig	Tue Sep 29 22:13:09 1998
+++ gc.c	Thu Sep 14 12:04:22 2000
@@ -58,7 +58,7 @@
    The offset is incremented with the size of the type.  */
 
 #define ROUND(V, A) \
-  ({ typeof(V) __v=(V); typeof(A) __a=(A); \
+  ({ __typeof__ (V) __v=(V); __typeof__ (A) __a=(A); \
      __a*((__v+__a-1)/__a); })
 
 #define SET_BIT_FOR_OFFSET(mask, offset) \
--- libobjc_entry.c.orig	Sat Sep  4 11:09:19 1999
+++ libobjc_entry.c	Thu Sep 14 12:33:19 2000
@@ -52,4 +52,4 @@
   This section terminates the list of imports under GCC. If you do not
   include this then you will have problems when linking with DLLs.
   */
-asm (".section .idata$3\n" ".long 0,0,0,0,0,0,0,0");
+__asm__ (".section .idata$3\n" ".long 0,0,0,0,0,0,0,0");
--- objc/objc-list.h.orig	Wed Mar 29 15:19:06 2000
+++ objc/objc-list.h	Thu Sep 14 13:47:08 2000
@@ -28,6 +28,10 @@
 #ifndef __GNU_OBJC_LIST_H
 #define __GNU_OBJC_LIST_H
 
+#if !defined(inline) && defined(__GNUC__)
+#define inline __inline__
+#endif
+
 struct objc_list {
   void *head;
   struct objc_list *tail;
--- objc/objc.h.orig	Sat Sep  4 11:09:20 1999
+++ objc/objc.h	Thu Sep 14 13:45:00 2000
@@ -33,6 +33,10 @@
 
 #include <stddef.h>
 
+#if !defined(inline) && defined(__GNUC__)
+#define inline __inline__
+#endif
+
 /*
 ** Definition of the boolean type.  
 */
2000-09-18  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* src/bitcount.c: Use __inline__ with GNU C.

--- src/bitcount.c.orig	Mon Aug 31 06:12:25 1998
+++ src/bitcount.c	Thu Sep 14 14:01:07 2000
@@ -25,10 +25,15 @@
 
 #include "bitprims.h"
 
-#if !defined(inline) && !defined(__GNUC__) && !defined(__cplusplus)
-#define inline
+#if !defined(inline) && !defined(__cplusplus)
+# ifdef __GNUC__
+#  define inline __inline__
+# else
+#  define inline
+# endif
 #endif
 
+
 #if 0
  /*
   * This function counts the number of bits in a long.
@@ -108,10 +113,7 @@
 
 #if 0
 From: Tommy.Thorn@irisa.fr (Tommy Thorn)
-#ifdef __GNUC__
-inline
-#endif
-static unsigned
+static inline unsigned
 bitcount(unsigned x)
 {
   /* Clasical way to count set bits in a word, sligtly optimized */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]