public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix fixincl extern inline glibc hacks
@ 2007-03-21 18:34 Jakub Jelinek
  2007-03-24 18:52 ` Bruce Korb
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2007-03-21 18:34 UTC (permalink / raw)
  To: Bruce Korb; +Cc: gcc-patches

Hi!

glibc now defines __extern_inline and __extern_always_inline macros
and uses them in installed headers when GNU89 extern inline semantics is
needed, but current trunk gcc fixincludes still changes it even when
it is not needed, which results in suboptimal code.
Also, even when using older glibc headers, with gcc -std=gnu99 -fgnu89-inline
extern inlines would be fixincluded out, while they can be used just fine.

The following patch ought to fix it, ok for trunk?

2007-03-21  Jakub Jelinek  <jakub@redhat.com>

	* inclhack.def (glibc_c99_inline_1): Define __USE_EXTERN_INLINES
	if __extern_inline or __GNUC_GNU_INLINE__ is defined rather than
	__STDC_VERSION__ < 199901L.
	(glibc_c99_inline_2): Replace #if __STDC_VERSION__ < 199901L
	with #ifdef __GNUC_GNU_INLINE__.
	(glibc_c99_inline_3): Add select.  Replace __STDC_VERSION__ >= 199901L
	with defined(__GNUC_STDC_INLINE__).
	(glibc_c99_inline_4): Change select, add second c_fix_arg.
	Replace #if __STDC_VERSION__ < 199901L with
	#ifdef __GNUC_GNU_INLINE__.
	* fixincl.x: Regenerated.
	* tests/base/bits/string2.h: Update.
	* tests/base/sys/sysmacros.h: Update.
	* tests/base/sys/stat.h: Update.

--- fixincludes/inclhack.def.jj	2007-03-19 20:46:44.000000000 +0100
+++ fixincludes/inclhack.def	2007-03-21 17:04:59.000000000 +0100
@@ -1311,7 +1311,7 @@ fix = {
     files     = features.h, '*/features.h';
     select    = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
     c_fix     = format;
-    c_fix_arg = "%0 && __STDC_VERSION__ < 199901L";
+    c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
     test_text = <<-EOT
 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
     && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
@@ -1331,13 +1331,13 @@ fix = {
     files     = sys/stat.h, '*/sys/stat.h';
     select    = "extern __inline__ int";
     sed     = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
-              "#if __STDC_VERSION__ < 199901L\\\nextern\\\n#endif\\\n"
+              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
               "__inline__ int \\1/";
     sed     = "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/"
-              "#if __STDC_VERSION__ < 199901L\\\nextern\\\n#endif\\\n"
+              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
               "__inline__ int __REDIRECT\\1 (\\2/";
     sed     = "s/^extern __inline__ int/"
-              "#if __STDC_VERSION__ < 199901L\\\nextern\\\n#endif\\\n"
+              "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
               "__inline__ int/";
     test_text = <<-EOT
 	extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
@@ -1351,9 +1351,10 @@ fix = {
 fix = {
     hackname  = glibc_c99_inline_3;
     files     = bits/string2.h, '*/bits/string2.h';
+    select    = "extern __inline";
     bypass    = "__STDC_VERSION__";
     c_fix     = format;
-    c_fix_arg = "# if defined(__cplusplus) || __STDC_VERSION__ >= 19901L";
+    c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
     c_fix_arg = "^# ifdef __cplusplus$";
     test_text = <<-EOT
 	# ifdef __cplusplus
@@ -1369,9 +1370,10 @@ fix = {
     hackname  = glibc_c99_inline_4;
     files     = sys/sysmacros.h, '*/sys/sysmacros.h';
     bypass    = "__STDC_VERSION__";
-    select    = '(^| )extern ';
+    select    = "extern __inline";
     c_fix     = format;
-    c_fix_arg = "\n#if __STDC_VERSION__ < 199901L\nextern\n#endif\n";
+    c_fix_arg = "\n#ifdef __GNUC_GNU_INLINE__\nextern\n#endif\n";
+    c_fix_arg = '(^| )extern ';
     test_text = <<-EOT
 	__extension__ extern __inline unsigned int
 	__extension__ __extern_inline unsigned int
--- fixincludes/fixincl.x.jj	2007-03-19 20:46:44.000000000 +0100
+++ fixincludes/fixincl.x	2007-03-21 17:39:23.000000000 +0100
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Sunday March 18, 2007 at 05:06:12 PM CET
+ * It has been AutoGen-ed  Wednesday March 21, 2007 at 05:39:23 PM CET
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Mar 18 17:06:12 CET 2007
+/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Mar 21 17:39:23 CET 2007
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -2215,7 +2215,7 @@ static tTestDesc aGlibc_C99_Inline_1Test
  */
 static const char* apzGlibc_C99_Inline_1Patch[] = {
     "format",
-    "%0 && __STDC_VERSION__ < 199901L",
+    "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)",
     (char*)NULL };
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -2249,15 +2249,15 @@ static tTestDesc aGlibc_C99_Inline_2Test
  *  Fix Command Arguments for Glibc_C99_Inline_2
  */
 static const char* apzGlibc_C99_Inline_2Patch[] = { "sed",
-    "-e", "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/#if __STDC_VERSION__ < 199901L\\\n\
+    "-e", "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/#ifdef __GNUC_GNU_INLINE__\\\n\
 extern\\\n\
 #endif\\\n\
 __inline__ int \\1/",
-    "-e", "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/#if __STDC_VERSION__ < 199901L\\\n\
+    "-e", "s/extern int __REDIRECT\\(_NTH\\|\\) (\\(stat\\|lstat\\|fstat\\)/#ifdef __GNUC_GNU_INLINE__\\\n\
 extern\\\n\
 #endif\\\n\
 __inline__ int __REDIRECT\\1 (\\2/",
-    "-e", "s/^extern __inline__ int/#if __STDC_VERSION__ < 199901L\\\n\
+    "-e", "s/^extern __inline__ int/#ifdef __GNUC_GNU_INLINE__\\\n\
 extern\\\n\
 #endif\\\n\
 __inline__ int/",
@@ -2281,21 +2281,28 @@ tSCC zGlibc_C99_Inline_3List[] =
 #define apzGlibc_C99_Inline_3Machs (const char**)NULL
 
 /*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zGlibc_C99_Inline_3Select0[] =
+       "extern __inline";
+
+/*
  *  content bypass pattern - skip fix if pattern found
  */
 tSCC zGlibc_C99_Inline_3Bypass0[] =
        "__STDC_VERSION__";
 
-#define    GLIBC_C99_INLINE_3_TEST_CT  1
+#define    GLIBC_C99_INLINE_3_TEST_CT  2
 static tTestDesc aGlibc_C99_Inline_3Tests[] = {
-  { TT_NEGREP,   zGlibc_C99_Inline_3Bypass0, (regex_t*)NULL }, };
+  { TT_NEGREP,   zGlibc_C99_Inline_3Bypass0, (regex_t*)NULL },
+  { TT_EGREP,    zGlibc_C99_Inline_3Select0, (regex_t*)NULL }, };
 
 /*
  *  Fix Command Arguments for Glibc_C99_Inline_3
  */
 static const char* apzGlibc_C99_Inline_3Patch[] = {
     "format",
-    "# if defined(__cplusplus) || __STDC_VERSION__ >= 19901L",
+    "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)",
     "^# ifdef __cplusplus$",
     (char*)NULL };
 
@@ -2320,7 +2327,7 @@ tSCC zGlibc_C99_Inline_4List[] =
  *  content selection pattern - do fix if pattern found
  */
 tSCC zGlibc_C99_Inline_4Select0[] =
-       "(^| )extern ";
+       "extern __inline";
 
 /*
  *  content bypass pattern - skip fix if pattern found
@@ -2339,9 +2346,10 @@ static tTestDesc aGlibc_C99_Inline_4Test
 static const char* apzGlibc_C99_Inline_4Patch[] = {
     "format",
     "\n\
-#if __STDC_VERSION__ < 199901L\n\
+#ifdef __GNUC_GNU_INLINE__\n\
 extern\n\
 #endif\n",
+    "(^| )extern ",
     (char*)NULL };
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -8466,7 +8474,7 @@ static const char* apzX11_SprintfPatch[]
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          252
+#define REGEX_COUNT          253
 #define MACH_LIST_SIZE_LIMIT 261
 #define FIX_COUNT            208
 
--- fixincludes/tests/base/bits/string2.h.jj	2006-11-06 13:02:35.000000000 +0100
+++ fixincludes/tests/base/bits/string2.h	2007-03-21 18:46:35.000000000 +0100
@@ -10,7 +10,7 @@
 
 
 #if defined( GLIBC_C99_INLINE_3_CHECK )
-# if defined(__cplusplus) || __STDC_VERSION__ >= 19901L
+# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)
 #  define __STRING_INLINE inline
 # else
 #  define __STRING_INLINE extern __inline
--- fixincludes/tests/base/sys/sysmacros.h.jj	2007-02-07 13:07:17.000000000 +0100
+++ fixincludes/tests/base/sys/sysmacros.h	2007-03-21 18:47:30.000000000 +0100
@@ -11,13 +11,13 @@
 
 #if defined( GLIBC_C99_INLINE_4_CHECK )
 __extension__
-#if __STDC_VERSION__ < 199901L
+#ifdef __GNUC_GNU_INLINE__
 extern
 #endif
 __inline unsigned int
 __extension__ __extern_inline unsigned int
 
-#if __STDC_VERSION__ < 199901L
+#ifdef __GNUC_GNU_INLINE__
 extern
 #endif
 __inline unsigned int
--- fixincludes/tests/base/sys/stat.h.jj	2006-11-06 13:02:35.000000000 +0100
+++ fixincludes/tests/base/sys/stat.h	2007-03-21 18:48:09.000000000 +0100
@@ -15,11 +15,11 @@
 
 
 #if defined( GLIBC_C99_INLINE_2_CHECK )
-#if __STDC_VERSION__ < 199901L
+#ifdef __GNUC_GNU_INLINE__
 extern
 #endif
 __inline__ int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
-#if __STDC_VERSION__ < 199901L
+#ifdef __GNUC_GNU_INLINE__
 extern
 #endif
 __inline__ int

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix fixincl extern inline glibc hacks
  2007-03-21 18:34 [PATCH] Fix fixincl extern inline glibc hacks Jakub Jelinek
@ 2007-03-24 18:52 ` Bruce Korb
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Korb @ 2007-03-24 18:52 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

Jakub Jelinek wrote:
> Hi!
> 
> glibc now defines __extern_inline and __extern_always_inline macros
> and uses them in installed headers when GNU89 extern inline semantics is
> needed, but current trunk gcc fixincludes still changes it even when
> it is not needed, which results in suboptimal code.
> Also, even when using older glibc headers, with gcc -std=gnu99 -fgnu89-inline
> extern inlines would be fixincluded out, while they can be used just fine.
> 
> The following patch ought to fix it, ok for trunk?

Yummy.   Looks reasonable to me...

Yes, please.  Thank you - Bruce

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-24 17:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21 18:34 [PATCH] Fix fixincl extern inline glibc hacks Jakub Jelinek
2007-03-24 18:52 ` Bruce Korb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).