]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
unlocked-io: also deal with fileno
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 5 Sep 2025 20:54:08 +0000 (13:54 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 5 Sep 2025 20:54:44 +0000 (13:54 -0700)
This shouldn’t affect performance on glibc, where fileno and
fileno_unlocked are aliases under the theory that no locking is needed.
However, it might help a bit on platforms like FreeBSD where
fileno_unlocked is inline and does not lock.
* lib/unlocked-io.h (fileno, fileno_unlocked):
Define as needed, similarly to fgets etc.
* m4/unlocked-io.m4 (gl_FUNC_GLIBC_UNLOCKED_IO):
Also check fileno_unlocked.

ChangeLog
lib/unlocked-io.h
m4/unlocked-io.m4

index c8f5c0da3a31e6c1a964565e986f855f4426a42e..d5fde9e134a2241c8407996f2f12e3f124400d96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2025-09-05  Paul Eggert  <eggert@cs.ucla.edu>
 
+       unlocked-io: also deal with fileno
+       This shouldn’t affect performance on glibc, where fileno and
+       fileno_unlocked are aliases under the theory that no locking is needed.
+       However, it might help a bit on platforms like FreeBSD where
+       fileno_unlocked is inline and does not lock.
+       * lib/unlocked-io.h (fileno, fileno_unlocked):
+       Define as needed, similarly to fgets etc.
+       * m4/unlocked-io.m4 (gl_FUNC_GLIBC_UNLOCKED_IO):
+       Also check fileno_unlocked.
+
        progname: static check instead of dynamic
        * lib/progname.c: Don’t include stdio.h or stdlib.h.
        (set_program_name): Omit dynamic check that (with current glibc
index 69ea6641a3fb09d3dc66b9e1a72c74f416e5c18d..8a7719c4876e71effcc610139ee24913530bd6cf 100644 (file)
 #  define fgets_unlocked(x,y,z) fgets (x,y,z)
 # endif
 
+# if HAVE_DECL_FILENO_UNLOCKED || defined fileno_unlocked
+#  undef fileno
+#  define fileno(x) fileno_unlocked (x)
+# else
+#  define fileno_unlocked(x) fileno (x)
+# endif
+
 # if HAVE_DECL_FPUTC_UNLOCKED || defined fputc_unlocked
 #  undef fputc
 #  define fputc(x,y) fputc_unlocked (x,y)
index 97f43f4b6c4e0c2492e8af88f517ffb77fa42059..a5eacecc61c21556d04ffa9719b223d0c3af6e59 100644 (file)
@@ -1,5 +1,5 @@
 # unlocked-io.m4
-# serial 16
+# serial 17
 dnl Copyright (C) 1998-2006, 2009-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,6 +25,7 @@ AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
   AC_CHECK_DECLS_ONCE([ferror_unlocked])
   AC_CHECK_DECLS_ONCE([fflush_unlocked])
   AC_CHECK_DECLS_ONCE([fgets_unlocked])
+  AC_CHECK_DECLS_ONCE([fileno_unlocked])
   AC_CHECK_DECLS_ONCE([fputc_unlocked])
   AC_CHECK_DECLS_ONCE([fputs_unlocked])
   AC_CHECK_DECLS_ONCE([fread_unlocked])