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



A small nit.  Perhaps I should make it clearer in the README.
Please use the ``c_fix = format'' whenever possible.
Extracted from the cited README:

4.  There are currently four methods of fixing a file:

    1.  a series of sed expressions....

    2.  a shell script...

    3.  Replacement text...

    4.  A C language subroutine ...

    If at all possible, you should try to use one of the C language
    fixes as it is far more efficient.  There are currently five
    such fixes, three of which are very special purpose:
    ....
    v) format - Replaces text selected with a regular expression with
        a specialized formating string.  The formatting works as follows:

Also, may as well make the bypass regex be:

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

We'll worry about __GNUC__ 10 another day :-).

Actually, what if there were some built in macros that converted
these version numbers into 32 bit numbers that were guaranteed
to be properly ordered?  Then:

  #ifdef __current_gcc_version
  #if __current_gcc_version >= __make_gcc_version( 3.1.0 )
  #else /* __GNUC__ is guaranteed to be 2 or less */

That may constrain us to 255 point releases and 255 minor versions,
but is there anyone out there who cares?  Come to think of it, why
don't those who really need this just add this you your sys headers:

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

> 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 05:00:14
> ***************
> *** 1031,1036 ****
> --- 1031,1051 ----
>   
>   
>   /*
> +  *  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__ [>=]= 3';
> +     sed = 's@^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$@& 
> || __GNUC__ == 3@';
> +     test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
> + };
> + 
> + 
> + /*
>    *  Fix HP & Sony's use of "../machine/xxx.h"
>    *  to refer to:  <machine/xxx.h>
>    */
> 


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