[PATCH] Use the _unlocked stdio macros only when they're all available

Daniel Fandrich dan at coneharvesters.com
Wed Jun 29 19:19:39 UTC 2011


Signed-off-by: Daniel Fandrich <dan at coneharvesters.com>
---
 include/libbb.h    |   67 ++++++++++++++++++++++++++-------------------------
 include/platform.h |    4 +++
 2 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/include/libbb.h b/include/libbb.h
index 963ae1e..203bfb0 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -164,39 +164,40 @@ int sysinfo(struct sysinfo* info);
  * But don't define foo to foo_unlocked if foo_unlocked
  * is a macro (it might be defined back to foo!).
  */
-#ifndef getc_unlocked
-# undef  getc
-# define getc(stream) getc_unlocked(stream)
-#endif
-#ifndef getchar_unlocked
-# undef  getchar
-# define getchar() getchar_unlocked()
-#endif
-#ifndef putc_unlocked
-# undef  putc
-# define putc(c, stream) putc_unlocked(c, stream)
-#endif
-#ifndef putchar_unlocked
-# undef  putchar
-# define putchar(c) putchar_unlocked(c)
-#endif
-#ifndef fgetc_unlocked
-# undef  fgetc
-# define fgetc(stream) fgetc_unlocked(stream)
-#endif
-#ifndef fputc_unlocked
-# undef  fputc
-# define fputc(c, stream) fputc_unlocked(c, stream)
-#endif
-#ifndef fgets_unlocked
-# undef  fgets
-# define fgets(s, n, stream) fgets_unlocked(s, n, stream)
-#endif
-#ifndef fputs_unlocked
-# undef  fputs
-# define fputs(s, stream) fputs_unlocked(s, stream)
-#endif
-
+#ifdef HAVE_UNLOCKED_STDIO
+# ifndef getc_unlocked
+#  undef  getc
+#  define getc(stream) getc_unlocked(stream)
+# endif
+# ifndef getchar_unlocked
+#  undef  getchar
+#  define getchar() getchar_unlocked()
+# endif
+# ifndef putc_unlocked
+#  undef  putc
+#  define putc(c, stream) putc_unlocked(c, stream)
+# endif
+# ifndef putchar_unlocked
+#  undef  putchar
+#  define putchar(c) putchar_unlocked(c)
+# endif
+# ifndef fgetc_unlocked
+#  undef  fgetc
+#  define fgetc(stream) fgetc_unlocked(stream)
+# endif
+# ifndef fputc_unlocked
+#  undef  fputc
+#  define fputc(c, stream) fputc_unlocked(c, stream)
+# endif
+# ifndef fgets_unlocked
+#  undef  fgets
+#  define fgets(s, n, stream) fgets_unlocked(s, n, stream)
+# endif
+# ifndef fputs_unlocked
+#  undef  fputs
+#  define fputs(s, stream) fputs_unlocked(s, stream)
+# endif
+#endif /* HAVE_UNLOCKED_STDIO */
 
 /* Make all declarations hidden (-fvisibility flag only affects definitions) */
 /* (don't include system headers after this until corresponding pop!) */
diff --git a/include/platform.h b/include/platform.h
index d186e49..1e5e071 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -349,6 +349,7 @@ typedef unsigned smalluint;
 #define HAVE_STRSEP 1
 #define HAVE_STRSIGNAL 1
 #define HAVE_STRVERSCMP 1
+#define HAVE_UNLOCKED_STDIO 1
 #define HAVE_VASPRINTF 1
 #define HAVE_GETLINE 1
 #define HAVE_XTABS 1
@@ -358,6 +359,7 @@ typedef unsigned smalluint;
 
 #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 1)
 # undef HAVE_NET_ETHERNET_H
+# undef HAVE_UNLOCKED_STDIO
 #endif
 
 #if defined(__UCLIBC_MAJOR__)
@@ -386,6 +388,7 @@ typedef unsigned smalluint;
 # undef HAVE_STRSEP
 # undef HAVE_STRSIGNAL
 # undef HAVE_STRVERSCMP
+# undef HAVE_UNLOCKED_STDIO
 # undef HAVE_VASPRINTF
 # undef HAVE_NET_ETHERNET_H
 #endif
@@ -424,6 +427,7 @@ typedef unsigned smalluint;
 # undef HAVE_STPCPY
 # undef HAVE_STRCHRNUL
 # undef HAVE_STRVERSCMP
+# undef HAVE_UNLOCKED_STDIO
 # undef HAVE_NET_ETHERNET_H
 #endif
 
-- 
1.7.0.4



More information about the busybox mailing list