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]

need info on __need_ usage



Hi Ulrich,

I got referred to you  :-).  The issue is, given that glibc does
funny things with multiple inclusion of header files, it is not
correct to ever wrap these files with self-exclusionary define macros.
Therefore, fixincludes must not do this, even if such a fix looks
like it ought to be applied.  I believe that such unwrappable headers
can be detected with the regular expression, "^#if.*__need_".
The question is, "Is there a plausible chance that such an *avoidance*
of wrapping would cause compile problems on any GCC-supported
platforms?"  I cannot see how, but I figure a sanity check won't hurt...

2000-09-20  Bruce Korb  <bkorb@gnu.org>

        * gcc/fixinc/fixfixes.c(wrap_fix): disable the actual
self-exclusion
        wrap if any code is conditional on one of the GNU-ish '__need_*'
macs

Index: fixfixes.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixfixes.c,v
retrieving revision 1.35
diff -u -r1.35 fixfixes.c
--- fixfixes.c  2000/09/12 14:28:27     1.35
+++ fixfixes.c  2000/09/20 21:54:07
@@ -595,12 +595,20 @@
 
 FIX_PROC_HEAD( wrap_fix )
 {
+  tSCC   z_no_wrap_pat[] = "^#if.*__need_";
+  static regex_t no_wrapping_re = { NULL, 0, 0 };
+
   char   z_fixname[ 64 ];
   tCC*   pz_src  = p_fixd->fix_name;
   tCC*   pz_name = z_fixname;
   char*  pz_dst  = z_fixname;
+  int    do_end  = 0;
   size_t len     = 0;
 
+  if (no_wrapping_re.allocated == 0)
+    compile_re( z_no_wrap_pat, &no_wrapping_re, 0, z_no_wrap_pat,
+                "wrap_fix" );
+
   for (;;) {
     char ch = *(pz_src++);
 
@@ -625,8 +633,16 @@
     }
   }
 
-  printf( "#ifndef FIXINC_%s_CHECK\n", pz_name );
-  printf( "#define FIXINC_%s_CHECK 1\n\n", pz_name );
+  /*
+   *  IF we do *not* match the no-wrap re, then we have a double negative.
+   *  A double negative means YES.
+   */
+  if (regexec (no_wrapping_re, text, 0, NULL, 0) != 0)
+    {
+      printf( "#ifndef FIXINC_%s_CHECK\n", pz_name );
+      printf( "#define FIXINC_%s_CHECK 1\n\n", pz_name );
+      do_end = 1;
+    }
 
   if (p_fixd->patch_args[1] == (tCC*)NULL)
     fputs( text, stdout );
@@ -637,8 +653,10 @@
     if (p_fixd->patch_args[2] != (tCC*)NULL)
       fputs( p_fixd->patch_args[2], stdout );
   }
+
+  if (do_end != 0)
+    printf( "\n#endif  /* FIXINC_%s_CHECK */\n", pz_name );
 
-  printf( "\n#endif  /* FIXINC_%s_CHECK */\n", pz_name );
   if (pz_name != z_fixname)
     free( (void*)pz_name );
 }

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