changeset 10366:d41011f37051

use unlocked I/O in getdelim 2008-08-27 Paolo Bonzini <bonzini@gnu.org> * lib/getdelim.c (flockfile, funlockfile): Make all of them dummy if one is not available. Do not touch them if USE_UNLOCKED_IO, instead letting unlocked-io.h do that. (getc_maybe_unlocked): New. * m4/getdelim.m4 (gl_PREREQ_GETDELIM): Check for getc_unlocked.
author Paolo Bonzini <bonzini@gnu.org>
date Wed, 27 Aug 2008 14:44:58 +0200
parents a61ef477bb04
children 3939073a5bf9
files ChangeLog lib/getdelim.c m4/getdelim.m4
diffstat 3 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-08-27  Paolo Bonzini  <bonzini@gnu.org>
+
+	* lib/getdelim.c (flockfile, funlockfile): Make all of them
+	dummy if one is not available.  Do not touch them if
+	USE_UNLOCKED_IO, instead letting unlocked-io.h do that.
+	(getc_maybe_unlocked): New.
+	* m4/getdelim.m4 (gl_PREREQ_GETDELIM): Check for getc_unlocked.
+
 2008-08-26  Eric Blake  <ebb9@byu.net>
 
 	doc/INSTALL: resync from autoconf
--- a/lib/getdelim.c
+++ b/lib/getdelim.c
@@ -33,13 +33,18 @@
 #ifndef SSIZE_MAX
 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
 #endif
-#if !HAVE_FLOCKFILE
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+# define getc_maybe_unlocked(fp)	getc(fp)
+#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
 # undef flockfile
+# undef funlockfile
 # define flockfile(x) ((void) 0)
-#endif
-#if !HAVE_FUNLOCKFILE
-# undef funlockfile
 # define funlockfile(x) ((void) 0)
+# define getc_maybe_unlocked(fp)	getc(fp)
+#else
+# define getc_maybe_unlocked(fp)	getc_unlocked(fp)
 #endif
 
 /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
@@ -79,7 +84,7 @@
     {
       int i;
 
-      i = getc (fp);
+      i = getc_maybe_unlocked (fp);
       if (i == EOF)
 	{
 	  result = -1;
--- a/m4/getdelim.m4
+++ b/m4/getdelim.m4
@@ -31,4 +31,5 @@
 AC_DEFUN([gl_PREREQ_GETDELIM],
 [
   AC_CHECK_FUNCS([flockfile funlockfile])
+  AC_CHECK_DECLS([getc_unlocked])
 ])