system.h, gcc.c, toplev.c

John Carr jfc@mit.edu
Wed Feb 18 17:37:00 GMT 1998


This patch reduces system.h to include a reasonable set of include
files, uses ANSI string functions when autoconf defines STDC_HEADERS,
makes corresponding changes to gcc.c, and converts toplev.c to use
system.h.

I don't think toplev.c needs <sys/stat.h>, but there might be a system
where it does.  Anyone remember?

Wed Feb 18 18:18:28 1998  John Carr  <jfc@mit.edu>

	* system.h: Do not include <sys/types.h>, <sys/stat.h>, <errno.h>,
	<unistd.h>, <sys/param.h>, <limit.h>, <time.h>, or <fcntl.h>.
	If STDC_HEADERS, use ANSI names for string functions.

	* gcc.c: Restore includes deleted from system.h.

	* toplev.c: Include <system.h> instead of <stdio.h>, <ctype.h>,
	<stdlib.h>, and <string.h>.  Do not include <sys/stat.h>.

Index: system.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/system.h,v
retrieving revision 1.2
diff -c -3 -p -r1.2 system.h
*** system.h	1998/02/15 20:36:23	1.2
--- system.h	1998/02/18 23:16:32
***************
*** 67,81 ****
     host does not conform to Posix.  */
  #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
  
- 
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <errno.h>
- 
- #ifndef errno
- extern int errno;
- #endif
- 
  #ifdef HAVE_STRING_H
  # include <string.h>
  #else
--- 67,72 ----
*************** extern int errno;
*** 87,135 ****
  #ifdef HAVE_STDLIB_H
  # include <stdlib.h>
  #endif
- 
- #ifdef HAVE_UNISTD_H
- # include <unistd.h>
- #endif
- 
- #ifdef HAVE_SYS_PARAM_H
- # include <sys/param.h>
- #endif
- 
- #if HAVE_LIMITS_H
- # include <limits.h>
- #endif
  
! #ifdef TIME_WITH_SYS_TIME
! # include <sys/time.h>
! # include <time.h>
! #else
! # if HAVE_SYS_TIME_H
! # include <sys/time.h>
! # else
! #  include <time.h>
! #endif
! #endif
! 
! #ifdef HAVE_FCNTL_H
! # include <fcntl.h>
! #else
! # include <sys/file.h>
  #endif
! 
! #ifndef SEEK_SET
! # define SEEK_SET 0
! # define SEEK_CUR 1
! # define SEEK_END 2
! #endif
! #ifndef F_OK
! # define F_OK 0
! # define X_OK 1
! # define W_OK 2
! # define R_OK 4
! #endif
! 
! 
  
  #ifndef bcopy
  # ifdef HAVE_BCOPY
--- 78,96 ----
  #ifdef HAVE_STDLIB_H
  # include <stdlib.h>
  #endif
  
! /* Prefer ANSI functions when they are known to be available.  */
! #ifdef STDC_HEADERS
! #undef HAVE_BCOPY
! #undef HAVE_BCMP
! #undef HAVE_BZERO
! #undef HAVE_INDEX
! #undef HAVE_RINDEX
! #else /* STDC_HEADERS */
! #if __GNUC__ > 1
! #undef HAVE_BCOPY		/* Use compiler builtin memcpy */
  #endif
! #endif /* STDC_HEADERS */
  
  #ifndef bcopy
  # ifdef HAVE_BCOPY


Index: gcc.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/gcc.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 gcc.c
*** gcc.c	1998/02/15 20:41:09	1.13
--- gcc.c	1998/02/18 23:43:11
*************** compilation is specified by a string cal
*** 36,41 ****
--- 36,97 ----
  #include "gansidecl.h"
  #include "system.h"
  
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ 
+ #ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif
+ 
+ #include <errno.h>
+ 
+ #ifndef errno
+ extern int errno;
+ #endif
+ 
+ #ifdef HAVE_FCNTL_H
+ # include <fcntl.h>
+ #else
+ # include <sys/file.h>
+ #endif
+ 
+ #ifdef HAVE_SYS_PARAM_H
+ # include <sys/param.h>
+ #endif
+ 
+ #if HAVE_LIMITS_H
+ # include <limits.h>
+ #endif
+ 
+ #ifdef TIME_WITH_SYS_TIME
+ # include <sys/time.h>
+ # include <time.h>
+ #else
+ # if HAVE_SYS_TIME_H
+ # include <sys/time.h>
+ # else
+ #  include <time.h>
+ #endif
+ #endif
+ 
+ #ifdef HAVE_FCNTL_H
+ # include <fcntl.h>
+ #else
+ # include <sys/file.h>
+ #endif
+ 
+ #ifndef SEEK_SET
+ # define SEEK_SET 0
+ # define SEEK_CUR 1
+ # define SEEK_END 2
+ #endif
+ #ifndef F_OK
+ # define F_OK 0
+ # define X_OK 1
+ # define W_OK 2
+ # define R_OK 4
+ #endif
+ 
  #include <signal.h>
  #ifdef __STDC__
  #include <stdarg.h>

Index: toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.43
diff -c -3 -p -r1.43 toplev.c
*** toplev.c	1998/02/15 22:28:32	1.43
--- toplev.c	1998/02/18 23:15:41
*************** Boston, MA 02111-1307, USA.  */
*** 29,53 ****
  #else
  #include <varargs.h>
  #endif
! #include <stdio.h>
  #include <signal.h>
  #include <setjmp.h>
  #include <sys/types.h>
! #include <ctype.h>
! #include <sys/stat.h>
  #undef FLOAT
  #ifdef HAVE_SYS_PARAM_H
  #include <sys/param.h>
- #endif
- #if HAVE_STDLIB_H
- #include <stdlib.h>
- #endif
- #ifdef HAVE_STRING_H
- #include <string.h>
- #else
- #ifdef HAVE_STRINGS_H
- #include <strings.h>
- #endif
  #endif
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
--- 29,42 ----
  #else
  #include <varargs.h>
  #endif
! #include "system.h"
  #include <signal.h>
  #include <setjmp.h>
  #include <sys/types.h>
! 
  #undef FLOAT
  #ifdef HAVE_SYS_PARAM_H
  #include <sys/param.h>
  #endif
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>





More information about the Gcc mailing list