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]

Re: PATCH: FreeBSD system header didn't like the move to __GNUC__ == 3


In article <B4DFCB7CDE2DD4118F690008C78694167B3686@tahoe.allegronetworks.com>,
Bruce Korb <bkorb@allegronetworks.com> writes:

> A small nit.  Perhaps I should make it clearer in the README.

No, it was fairly clear in the README to prefer the C language
subroutines.  Actually, I didn't immediately see how to use
`c_fix = format' instead of sed in this case.  I will take another
stab at it.  I will also include a patch to the README.

> Also, may as well make the bypass regex be:

>   bypass = "__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)";

OK.

[...]

> #define __MAKE_VERSION(r,v,p)  (((r)<<16)+((v)<<8)+(p))
> #define __CURRENT_GCC_VERSION  \
>         MAKE_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_???__)

> No source changes to GCC.  No future breakage as in below.
> I think it the right way to go.

Yes, I think that might be good.  BTW, the third-level macro is
__GNUC_PATCHLEVEL__ (`gcc -dM -E -|grep GNUC' is your friend).
However, it is not set for gcc 2.95 (and before?).  I will forward
your suggestion for sys/cdefs.h on FreeBSD going forward, but we still
need a fixinc fix to handle all past shipping versions of that file.

Here is a better version of the patch to add the fix (also includes
changes due to feedback from Alexandre Oliva and Joseph S. Myers -
Thanks for all the timely feedback):

2001-02-20  Loren J. Rittle  <ljrittle@acm.org>

	* fixinc/inclhack.def (freebsd_gcc3_breakage): New fix.
	* fixinc/README: Document how to convert sed expression
	to format c_fix.

Index: fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.101
diff -c -r1.101 inclhack.def
*** inclhack.def	2001/02/06 22:17:08	1.101
--- inclhack.def	2001/02/20 22:27:15
***************
*** 1031,1036 ****
--- 1031,1053 ----
  
  
  /*
+  *  Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
+  *  neither the existence of GCC 3 nor its exact feature set yet break
+  *  (by design?) when __GNUC__ is set beyond 2.
+  */
+ fix = {
+     hackname  = freebsd_gcc3_breakage;
+     mach      = *-*-freebsd*;
+     files     = sys/cdefs.h;
+     bypass    = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
+     c_fix     = format;
+     c_fix_arg = '%0 || __GNUC__ >= 3';
+     c_fix_arg = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
+     test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
+ };
+ 
+ 
+ /*
   *  Fix HP & Sony's use of "../machine/xxx.h"
   *  to refer to:  <machine/xxx.h>
   */
Index: fixinc/README
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/README,v
retrieving revision 1.13
diff -c -r1.13 README
*** README	2001/01/02 00:35:51	1.13
--- README	2001/02/20 22:53:58
***************
*** 181,186 ****
--- 181,202 ----
          replaced.  You may delete text by supplying an empty string for
          the format (the first "c_fix_arg").
  
+ 	Note: In general, a format c_fix may be used in place of one
+ 	sed expression.  However, it will need to be rewritten by
+ 	hand.  For example:
+ 
+ 	sed = 's@^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$'
+ 	       '@& || __GNUC__ >= 3@';
+ 
+ 	may be rewritten using a format c_fix as:
+ 
+ 	c_fix     = format;
+ 	c_fix_arg = '%0 || __GNUC__ >= 3';
+ 	c_fix_arg = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
+ 
+ 	[Bruce, should any fix containing multiple sed expressions be
+ 	 rewritten as multiple fixes using format c_fix?]
+ 
  EXAMPLES OF FIXES:
  ==================
  


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