Message-ID: <39454056.9A188121@softhome.net> Date: Mon, 12 Jun 2000 22:56:06 +0300 From: Laurynas Biveinis X-Mailer: Mozilla 4.72 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: DJGPP Workers Subject: Patch: sentinels for typedefs in headers Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com This implements the first part of the suggested changes to DJGPP headers - it changes __DJ_foo_t #undef __DJ_foo_t #define __DJ_foo_t to #ifndef _FOO_T_DEFINED __DJ_foo_t #define _FOO_T_DEFINED #endif I've tested this patch by including big bunch of include files into one source file, and got no warnings about redefinitions. I am not sure if wc204.txi needs updating, because this is internal change. Since this patch killed all warnings I've seen in GCC, I won't rewrite file-level sentinels in header files unless some problems are exposed. Looking forward for feedback, Laurynas Index: include/glob.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/glob.h,v retrieving revision 1.1 diff -u -r1.1 glob.h --- glob.h 1995/03/21 09:01:00 1.1 +++ glob.h 2000/06/12 20:50:51 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_glob_h_ #define __dj_include_glob_h_ @@ -12,9 +13,10 @@ #include +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif typedef struct { size_t gl_pathc; Index: include/go32.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/go32.h,v retrieving revision 1.2 diff -u -r1.2 go32.h --- go32.h 1998/11/15 14:14:42 1.2 +++ go32.h 2000/06/12 20:50:51 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_go32_h_ @@ -16,9 +17,10 @@ #include #include +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif typedef struct { unsigned long size_of_this_structure_in_bytes; Index: include/grp.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/grp.h,v retrieving revision 1.1 diff -u -r1.1 grp.h --- grp.h 1995/04/01 22:29:54 1.1 +++ grp.h 2000/06/12 20:50:52 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_grp_h_ #define __dj_include_grp_h_ @@ -11,9 +12,10 @@ #ifndef __STRICT_ANSI__ #include +#ifndef _GID_T_DEFINED __DJ_gid_t -#undef __DJ_gid_t -#define __DJ_gid_t +#define _GID_T_DEFINED +#endif struct group { gid_t gr_gid; Index: include/pwd.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/pwd.h,v retrieving revision 1.1 diff -u -r1.1 pwd.h --- pwd.h 1995/02/27 03:31:44 1.1 +++ pwd.h 2000/06/12 20:50:52 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_pwd_h_ #define __dj_include_pwd_h_ @@ -12,12 +13,14 @@ #include +#ifndef _GID_T_DEFINED __DJ_gid_t -#undef __DJ_gid_t -#define __DJ_gid_t +#define _GID_T_DEFINED +#endif +#ifndef _UID_T_DEFINED __DJ_uid_t -#undef __DJ_uid_t -#define __DJ_uid_t +#define _UID_T_DEFINED +#endif struct passwd { char * pw_name; Index: include/signal.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/signal.h,v retrieving revision 1.3 diff -u -r1.3 signal.h --- signal.h 1998/07/13 08:12:04 1.3 +++ signal.h 2000/06/12 20:50:53 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_signal_h_ @@ -24,9 +25,10 @@ #define SIG_ERR ((void (*)(int))(1)) #define SIG_IGN ((void (*)(int))(-1)) +#ifndef _PID_T_DEFINED __DJ_pid_t -#undef __DJ_pid_t -#define __DJ_pid_t +#define _PID_T_DEFINED +#endif typedef int sig_atomic_t; Index: include/stdarg.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/stdarg.h,v retrieving revision 1.3 diff -u -r1.3 stdarg.h --- stdarg.h 1996/07/25 23:49:42 1.3 +++ stdarg.h 2000/06/12 20:50:53 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_stdarg_h_ @@ -15,9 +16,10 @@ #include +#ifndef _VA_LIST_DEFINED __DJ_va_list -#undef __DJ_va_list -#define __DJ_va_list +#define _VA_LIST_DEFINED +#endif #define __dj_va_rounded_size(T) \ (((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) Index: include/stddef.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/stddef.h,v retrieving revision 1.1 diff -u -r1.1 stddef.h --- stddef.h 1994/12/07 07:02:08 1.1 +++ stddef.h 2000/06/12 20:50:53 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_stddef_h_ #define __dj_include_stddef_h_ @@ -12,12 +13,14 @@ #define offsetof(s_type, mbr) ((size_t) &((s_type *)0)->mbr) typedef int ptrdiff_t; +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif +#ifndef _WCHAR_T_DEFINED __DJ_wchar_t -#undef __DJ_wchar_t -#define __DJ_wchar_t +#define _WCHAR_T_DEFINED +#endif #ifndef __dj_ENFORCE_ANSI_FREESTANDING Index: include/stdio.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/stdio.h,v retrieving revision 1.2 diff -u -r1.2 stdio.h --- stdio.h 1998/11/15 13:37:28 1.2 +++ stdio.h 2000/06/12 20:50:55 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -32,12 +33,14 @@ #define SEEK_CUR 1 #define SEEK_END 2 +#ifndef _VA_LIST_DEFINED __DJ_va_list -#undef __DJ_va_list -#define __DJ_va_list +#define _VA_LIST_DEFINED +#endif +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif /* Note that the definitions of these fields are NOT guaranteed! They may change with any release without notice! The fact that they Index: include/stdlib.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/stdlib.h,v retrieving revision 1.5 diff -u -r1.5 stdlib.h --- stdlib.h 1999/06/03 17:22:28 1.5 +++ stdlib.h 2000/06/12 20:50:59 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -33,12 +34,14 @@ long rem; } ldiv_t; +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif +#ifndef _WCHAR_T_DEFINED __DJ_wchar_t -#undef __DJ_wchar_t -#define __DJ_wchar_t +#define _WCHAR_T_DEFINED +#endif void abort(void) __attribute__((noreturn)); int abs(int _i); Index: include/string.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/string.h,v retrieving revision 1.3 diff -u -r1.3 string.h --- string.h 2000/05/13 02:04:35 1.3 +++ string.h 2000/06/12 20:51:01 @@ -14,11 +14,12 @@ /* Some programs think they know better... */ #undef NULL - #define NULL 0 + +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif void * memchr(const void *_s, int _c, size_t _n); int memcmp(const void *_s1, const void *_s2, size_t _n); Index: include/time.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/time.h,v retrieving revision 1.4 diff -u -r1.4 time.h --- time.h 1999/06/03 17:22:28 1.4 +++ time.h 2000/06/12 20:51:02 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -19,17 +20,20 @@ /* Some programs think they know better... */ #undef NULL - #define NULL 0 + +#ifndef _CLOCK_T_DEFINED __DJ_clock_t -#undef __DJ_clock_t -#define __DJ_clock_t +#define _CLOCK_T_DEFINED +#endif +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif +#ifndef _TIME_T_DEFINED __DJ_time_t -#undef __DJ_time_t -#define __DJ_time_t +#define _TIME_T_DEFINED +#endif struct tm { int tm_sec; Index: include/unistd.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/unistd.h,v retrieving revision 1.5 diff -u -r1.5 unistd.h --- unistd.h 1999/12/24 22:08:40 1.5 +++ unistd.h 2000/06/12 20:51:05 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -60,13 +61,15 @@ #define _SC_STREAM_MAX 8 #define _SC_TZNAME_MAX 9 #define _SC_VERSION 10 - + +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif +#ifndef _SSIZE_T_DEFINED __DJ_ssize_t -#undef __DJ_ssize_t -#define __DJ_ssize_t +#define _SSIZE_T_DEFINED +#endif extern char *optarg; extern int optind, opterr, optopt; Index: include/utime.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/utime.h,v retrieving revision 1.1 diff -u -r1.1 utime.h --- utime.h 1995/03/21 09:04:36 1.1 +++ utime.h 2000/06/12 20:51:05 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_utime_h_ #define __dj_include_utime_h_ @@ -11,9 +12,10 @@ #ifndef __STRICT_ANSI__ #include +#ifndef _TIME_T_DEFINED __DJ_time_t -#undef __DJ_time_t -#define __DJ_time_t +#define _TIME_T_DEFINED +#endif struct utimbuf { time_t actime; Index: include/varargs.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/varargs.h,v retrieving revision 1.1 diff -u -r1.1 varargs.h --- varargs.h 1995/04/29 06:34:30 1.1 +++ varargs.h 2000/06/12 20:51:06 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_vararg_h_ #define __dj_include_vararg_h_ @@ -14,9 +15,10 @@ #include +#ifndef _VA_LIST_DEFINED __DJ_va_list -#undef __DJ_va_list -#define __DJ_va_list +#define _VA_LIST_DEFINED +#endif #define va_alist __dj_last_arg Index: include/wchar.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/wchar.h,v retrieving revision 1.3 diff -u -r1.3 wchar.h --- wchar.h 1999/06/03 17:22:28 1.3 +++ wchar.h 2000/06/12 20:51:06 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_wchar_h_ @@ -13,9 +14,10 @@ #include +#ifndef _WINT_T_DEFINED __DJ_wint_t -#undef __DJ_wint_t -#define __DJ_wint_t +#define _WINT_T_DEFINED +#endif #ifndef WEOF #define WEOF ((wint_t)(-1)) Index: include/wctype.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/wctype.h,v retrieving revision 1.4 diff -u -r1.4 wctype.h --- wctype.h 1999/06/03 17:22:28 1.4 +++ wctype.h 2000/06/12 20:51:06 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_wctype_h_ @@ -13,12 +14,14 @@ #include +#ifndef _WCHAR_T_DEFINED __DJ_wchar_t -#undef __DJ_wchar_t -#define __DJ_wchar_t +#define _WCHAR_T_DEFINED +#endif +#ifndef _WINT_T_DEFINED __DJ_wint_t -#undef __DJ_wint_t -#define __DJ_wint_t +#define _WINT_T_DEFINED +#endif #ifndef WEOF #define WEOF ((wint_t)(-1)) Index: include/sys/movedata.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/sys/movedata.h,v retrieving revision 1.2 diff -u -r1.2 movedata.h --- movedata.h 1998/01/01 23:38:48 1.2 +++ movedata.h 2000/06/12 20:51:08 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_sys_movedata_h_ @@ -15,9 +16,10 @@ #include +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif /* This header is intended to be included only by other headers, like and . You may Index: include/sys/stat.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/sys/stat.h,v retrieving revision 1.1 diff -u -r1.1 stat.h --- stat.h 1995/08/10 05:06:26 1.1 +++ stat.h 2000/06/12 20:51:09 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_sys_stat_h_ #define __dj_include_sys_stat_h_ @@ -34,9 +35,10 @@ #include #include +#ifndef _TIME_T_DEFINED +#define _TIME_T_DEFINED __DJ_time_t -#undef __DJ_time_t -#define __DJ_time_t +#endif struct stat { time_t st_atime; Index: include/sys/timeb.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/sys/timeb.h,v retrieving revision 1.1 diff -u -r1.1 timeb.h --- timeb.h 1995/04/02 04:05:16 1.1 +++ timeb.h 2000/06/12 20:51:09 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_sys_timeb_h_ #define __dj_include_sys_timeb_h_ @@ -14,9 +15,10 @@ #include +#ifndef _TIME_T_DEFINED __DJ_time_t -#undef __DJ_time_t -#define __DJ_time_t +#define _TIME_T_DEFINED +#endif struct timeb { Index: include/sys/times.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/sys/times.h,v retrieving revision 1.1 diff -u -r1.1 times.h --- times.h 1995/05/10 03:59:06 1.1 +++ times.h 2000/06/12 20:51:10 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_sys_times_h_ #define __dj_include_sys_times_h_ @@ -11,9 +12,10 @@ #ifndef __STRICT_ANSI__ #include +#ifndef _CLOCK_T_DEFINED __DJ_clock_t -#undef __DJ_clock_t -#define __DJ_clock_t +#define _CLOCK_T_DEFINED +#endif struct tms { clock_t tms_utime; Index: include/sys/types.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/sys/types.h,v retrieving revision 1.4 diff -u -r1.4 types.h --- types.h 1999/06/03 17:22:29 1.4 +++ types.h 2000/06/12 20:51:10 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -19,24 +20,30 @@ typedef int mode_t; typedef int nlink_t; +#ifndef _GID_T_DEFINED __DJ_gid_t -#undef __DJ_gid_t -#define __DJ_gid_t +#define _GID_T_DEFINED +#endif +#ifndef _OFF_T_DEFINED __DJ_off_t -#undef __DJ_off_t -#define __DJ_off_t +#define _OFF_T_DEFINED +#endif +#ifndef _PID_T_DEFINED __DJ_pid_t -#undef __DJ_pid_t -#define __DJ_pid_t +#define _PID_T_DEFINED +#endif +#ifndef _SIZE_T_DEFINED __DJ_size_t -#undef __DJ_size_t -#define __DJ_size_t +#define _SIZE_T_DEFINED +#endif +#ifndef _SSIZE_T_DEFINED __DJ_ssize_t -#undef __DJ_ssize_t -#define __DJ_ssize_t +#define _SSIZE_T_DEFINED +#endif +#ifndef _UID_T_DEFINED __DJ_uid_t -#undef __DJ_uid_t -#define __DJ_uid_t +#define _UID_T_DEFINED +#endif #ifndef _POSIX_SOURCE @@ -54,9 +61,10 @@ #define FD_ISSET(n, p) ((p)->fd_bits[(n) / 8] & (1 << ((n) & 7))) #define FD_ZERO(p) memset ((void *)(p), 0, sizeof (*(p))) +#ifndef _TIME_T_DEFINED __DJ_time_t -#undef __DJ_time_t -#define __DJ_time_t +#define _TIME_T_DEFINED +#endif #endif /* !_POSIX_SOURCE */ #endif /* !__STRICT_ANSI__ */ Index: include/sys/wait.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/sys/wait.h,v retrieving revision 1.3 diff -u -r1.3 wait.h --- wait.h 1998/07/12 16:55:36 1.3 +++ wait.h 2000/06/12 20:51:11 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #ifndef __dj_include_sys_wait_h_ @@ -22,9 +23,10 @@ #define WTERMSIG(stat_val) ( ((stat_val) >> 8 ) & 0x3ff) #define WUNTRACED 0 +#ifndef _PID_T_DEFINED __DJ_pid_t -#undef __DJ_pid_t -#define __DJ_pid_t +#define _PID_T_DEFINED +#endif pid_t wait(int *stat_loc); pid_t waitpid(pid_t pid, int *stat_loc, int options);