bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/4] stdio: use __REDIRECT for fwrite, fwrite_unlocked


From: Paul Eggert
Subject: [PATCH 1/4] stdio: use __REDIRECT for fwrite, fwrite_unlocked
Date: Wed, 15 May 2013 20:52:17 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

---
 ChangeLog      | 10 ++++++++++
 lib/stdio.in.h | 19 +++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dfb2e5c..3544972 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2013-05-15  Paul Eggert  <address@hidden>
 
+       stdio: use __REDIRECT for fwrite, fwrite_unlocked
+       * lib/stdio.in.h (fwrite):
+       When working around bug 11959, use __REDIRECT rather than '#define
+       fwrite(...) ... fwrite (...) ...'.  This is a more-targeted way to
+       fix the -Wunused-value issue with clang, and it works with GCC too.
+       Problem with targeting reported by Eric Blake in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00067.html>.
+       (fwrite_unlocked): Treat like fwrite.  I ran into this issue while
+       debugging the fwrite issue.
+
        stdio: port --enable-gcc-warnings to clang
        * lib/stdio.in.h (fwrite) [__clang__]: Ignore -Wunused-value entirely,
        since the GCC workaround for fwrite does not pacify clang.
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 115c976..d945d5c 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -582,13 +582,20 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
    versions of gcc and clang, and is not needed for C++.  */
 #  if (0 < __USE_FORTIFY_LEVEL                                          \
        && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
+       && 3 < __GNUC__ + (4 <= __GNUC_MINOR__)                          \
        && !defined __cplusplus)
-#   ifdef __clang__
-#    pragma clang diagnostic ignored "-Wunused-value"
-#   elif 3 < __GNUC__ + (4 <= __GNUC_MINOR__)
-#    undef fwrite
-#    define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; })
-#   endif
+#   undef fwrite
+#   undef fwrite_unlocked
+extern size_t __REDIRECT (rpl_fwrite,
+                          (const void *__restrict, size_t, size_t,
+                           FILE *__restrict),
+                          fwrite);
+extern size_t __REDIRECT (rpl_fwrite_unlocked,
+                          (const void *__restrict, size_t, size_t,
+                           FILE *__restrict),
+                          fwrite_unlocked);
+#   define fwrite rpl_fwrite
+#   define fwrite_unlocked rpl_fwrite_unlocked
 #  endif
 # endif
 _GL_CXXALIASWARN (fwrite);
-- 
1.7.11.7





reply via email to

[Prev in Thread] Current Thread [Next in Thread]