]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
htl: move {,_IO_}f{,un,try}lockfile implementation into libc
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 13 Nov 2025 20:13:53 +0000 (21:13 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 13 Nov 2025 22:01:07 +0000 (23:01 +0100)
14 files changed:
htl/Makefile
htl/Versions
htl/lockfile.c [deleted file]
htl/pt-initialize.c
include/stdio.h
stdio-common/flockfile.c
stdio-common/funlockfile.c
sysdeps/htl/flockfile.c
sysdeps/htl/ftrylockfile.c
sysdeps/htl/funlockfile.c
sysdeps/htl/pthread-functions.h
sysdeps/mach/hurd/i386/libc.abilist
sysdeps/mach/hurd/i386/libpthread.abilist
sysdeps/mach/hurd/x86_64/libpthread.abilist

index 15cff60d3145e5c8a3a0ea15ff1ca8bc80a55f35..2f2ad0cccb60636b4ec28ffcda869b8c5b93f346 100644 (file)
@@ -20,7 +20,7 @@ subdir := htl
 srcdir = .
 
 MICROKERNEL := mach
-SYSDEPS := lockfile
+SYSDEPS :=
 
 LCLHDRS :=
 
@@ -36,7 +36,6 @@ libpthread-routines := \
   pt-setname-np \
   cancellation \
   herrno \
-  $(SYSDEPS) \
   # libpthread-routine
 
 headers := \
@@ -220,8 +219,6 @@ install-lib-ldscripts := libpthread_syms.a
 
 include ../Makeconfig
 
-CFLAGS-lockfile.c = -D_IO_MTSAFE_IO
-
 all: # Make this the default target; it will be defined in Rules.
 
 subdir_install: $(inst_libdir)/libpthread2.a $(inst_libdir)/libpthread_syms.a
index b56b185a1095bde5117df435f6210160be71735f..2a83eb1b2794a204a61c5e310f1589d7f2d92c15 100644 (file)
@@ -1,6 +1,7 @@
 libc {
 
   GLIBC_2.12 {
+    flockfile; ftrylockfile; funlockfile;
     pthread_self;
     __pthread_get_cleanup_stack;
     __pthread_key_create;
@@ -313,12 +314,9 @@ libc {
 
 libpthread {
   GLIBC_2.2.6 {
-    _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile;
     __errno_location; __h_errno_location;
   }
   GLIBC_2.12 {
-    flockfile; ftrylockfile; funlockfile;
-
     pthread_atfork;
 
     pthread_create;
diff --git a/htl/lockfile.c b/htl/lockfile.c
deleted file mode 100644 (file)
index b76a59a..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* lockfile - Handle locking and unlocking of streams.  Hurd pthread version.
-   Copyright (C) 2000-2025 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library;  if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <pthread.h>           /* Must come before <stdio.h>! */
-#include <stdio.h>
-
-#undef _IO_flockfile
-#undef _IO_funlockfile
-#undef _IO_ftrylockfile
-
-void
-_IO_flockfile (FILE *fp)
-{
-  _IO_lock_lock (*fp->_lock);
-}
-
-void
-_IO_funlockfile (FILE *fp)
-{
-  _IO_lock_unlock (*fp->_lock);
-}
-
-int
-_IO_ftrylockfile (FILE *fp)
-{
-  return __libc_lock_trylock_recursive (*fp->_lock);
-}
-
-#undef flockfile
-#undef funlockfile
-#undef ftrylockfile
-
-void flockfile (FILE *)
-     __attribute__ ((weak, alias ("_IO_flockfile")));
-void funlockfile (FILE *)
-     __attribute__ ((weak, alias ("_IO_funlockfile")));
-int ftrylockfile (FILE *)
-     __attribute__ ((weak, alias ("_IO_ftrylockfile")));
index 86fe66fb3aeb52eb57f36fa82463acc6f5ba9259..bc8bb1e501f8991d40d36933b627351aa253cb53 100644 (file)
@@ -28,9 +28,6 @@
 
 #if IS_IN (libpthread)
 static const struct pthread_functions pthread_functions = {
-  .ptr__IO_flockfile = _IO_flockfile,
-  .ptr__IO_funlockfile = _IO_funlockfile,
-  .ptr__IO_ftrylockfile = _IO_ftrylockfile,
 };
 #endif /* IS_IN (libpthread) */
 
index b892c5b4af9aac0c2518dc1c5175bb94305921c5..17bb5ffdb6875596ba99eb0e41acdeec0300884c 100644 (file)
@@ -206,10 +206,12 @@ _Noreturn void __libc_message_wrapper (const char *vmaname,
    __libc_message_wrapper (__libc_assert_vma_name, __VA_ARGS__)
 
 /* Acquire ownership of STREAM.  */
-extern void __flockfile (FILE *__stream) attribute_hidden;
+extern void __flockfile (FILE *__stream);
+libc_hidden_proto (__flockfile)
 
 /* Relinquish the ownership granted for STREAM.  */
-extern void __funlockfile (FILE *__stream) attribute_hidden;
+extern void __funlockfile (FILE *__stream);
+libc_hidden_proto (__funlockfile)
 
 /* Try to acquire ownership of STREAM but do not block if it is not
    possible.  */
index f563390bbce1cb8768e8f1e553ed4d5cdc59d155..0c7b95d5870df5f165fa973e47253925f74e7c20 100644 (file)
@@ -24,5 +24,6 @@ __flockfile (FILE *stream)
 {
   _IO_lock_lock (*stream->_lock);
 }
+libc_hidden_def(__flockfile)
 weak_alias (__flockfile, flockfile);
 weak_alias (__flockfile, _IO_flockfile)
index 443364edc7c92e003aeea5417fe0553f23e7af04..23f2044d6b5354e67cb4195d4a5b8341c7d18a6a 100644 (file)
@@ -25,5 +25,6 @@ __funlockfile (FILE *stream)
 {
   _IO_lock_unlock (*stream->_lock);
 }
+libc_hidden_def(__funlockfile)
 weak_alias (__funlockfile, _IO_funlockfile)
 weak_alias (__funlockfile, funlockfile);
index 0a9cc8874aac36b2fa82f752f9cbd165b1202846..86c31f44be42098a696c18caba9a9408447a194f 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
-#include <libc-lockP.h>
+#include <stdio-lock.h>
 
 
 void
 __flockfile (FILE *stream)
 {
-#ifdef SHARED
-  __libc_ptf_call (_IO_flockfile, (stream), 0);
-#endif
+  _IO_lock_lock (*stream->_lock);
 }
-weak_alias (__flockfile, _IO_flockfile)
-weak_alias (__flockfile, flockfile)
+libc_hidden_def(__flockfile)
+weak_alias (__flockfile, _IO_flockfile);
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_2_6, GLIBC_2_12)
+versioned_symbol (libc, __flockfile, flockfile, GLIBC_2_0);
+# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libpthread, __flockfile, flockfile, GLIBC_2_12);
+# endif
+#else
+weak_alias (__flockfile, flockfile);
+#endif
index b8acd30ea4ea7dedf6728fc890b3c49c9e058654..c0e30aa0902c0c27f9c7caee4f1dda79046e6dd3 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
-#include <libc-lockP.h>
+#include <stdio-lock.h>
 
 
 int
 __ftrylockfile (FILE *stream)
 {
-#ifdef SHARED
-  return __libc_ptf_call (_IO_ftrylockfile, (stream), 0);
+  return _IO_lock_trylock (*stream->_lock);
+}
+weak_alias (__ftrylockfile, _IO_ftrylockfile);
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_2_6, GLIBC_2_12)
+versioned_symbol (libc, __ftrylockfile, ftrylockfile, GLIBC_2_0);
+# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libpthread, __ftrylockfile, ftrylockfile, GLIBC_2_12);
+# endif
 #else
-  return 0;
+weak_alias (__ftrylockfile, ftrylockfile);
 #endif
-}
-weak_alias (__ftrylockfile, _IO_ftrylockfile)
-weak_alias (__ftrylockfile, ftrylockfile)
index c89d17ad27951f9cabf16f00b3b18e396bff729e..20039b8482e88a9a076a4b7c629b363f96f8b925 100644 (file)
 void
 __funlockfile (FILE *stream)
 {
-#ifdef SHARED
-  __libc_ptf_call (_IO_funlockfile, (stream), 0);
-#endif
+  _IO_lock_unlock (*stream->_lock);
 }
-weak_alias (__funlockfile, _IO_funlockfile)
-weak_alias (__funlockfile, funlockfile)
+libc_hidden_def(__funlockfile)
+weak_alias (__funlockfile, _IO_funlockfile);
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_2_6, GLIBC_2_12)
+versioned_symbol (libc, __funlockfile, funlockfile, GLIBC_2_0);
+# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
+compat_symbol (libpthread, __funlockfile, funlockfile, GLIBC_2_12);
+# endif
+#else
+weak_alias (__funlockfile, funlockfile);
+#endif
index 2b1feb4e042f120fcc4fa03d40b11330a9416108..4fab472e50d31a012ee0144b0cbee4590fea327a 100644 (file)
@@ -26,9 +26,6 @@
    so if possible avoid breaking it and append new hooks to the end.  */
 struct pthread_functions
 {
-  void (*ptr__IO_flockfile) (FILE *);
-  void (*ptr__IO_funlockfile) (FILE *);
-  int (*ptr__IO_ftrylockfile) (FILE *);
 };
 
 /* Variable in libc.so.  */
index e5bd47ac397674663a5fca2bcaa83d37273fbb06..bbd00ed11a98370ce52a9b84e941703913ae28ed 100644 (file)
@@ -33,6 +33,9 @@ GLIBC_2.12 __pthread_key_create F
 GLIBC_2.12 __pthread_kill F
 GLIBC_2.12 __pthread_mutex_transfer_np F
 GLIBC_2.12 __pthread_self F
+GLIBC_2.12 flockfile F
+GLIBC_2.12 ftrylockfile F
+GLIBC_2.12 funlockfile F
 GLIBC_2.12 pthread_attr_destroy F
 GLIBC_2.12 pthread_attr_getdetachstate F
 GLIBC_2.12 pthread_attr_getguardsize F
index b9fd3dd489d60702be91bf4398ce98a6e1f77b07..b0516ddbc19fc83bed6e0ad0ae0533510effcd6f 100644 (file)
@@ -4,9 +4,6 @@ GLIBC_2.12 __pthread_spin_lock F
 GLIBC_2.12 __pthread_spin_trylock F
 GLIBC_2.12 __pthread_spin_unlock F
 GLIBC_2.12 _pthread_spin_lock F
-GLIBC_2.12 flockfile F
-GLIBC_2.12 ftrylockfile F
-GLIBC_2.12 funlockfile F
 GLIBC_2.12 pthread_atfork F
 GLIBC_2.12 pthread_create F
 GLIBC_2.12 pthread_spin_destroy F
@@ -14,9 +11,6 @@ GLIBC_2.12 pthread_spin_init F
 GLIBC_2.12 pthread_spin_lock F
 GLIBC_2.12 pthread_spin_trylock F
 GLIBC_2.12 pthread_spin_unlock F
-GLIBC_2.2.6 _IO_flockfile F
-GLIBC_2.2.6 _IO_ftrylockfile F
-GLIBC_2.2.6 _IO_funlockfile F
 GLIBC_2.2.6 __errno_location F
 GLIBC_2.2.6 __h_errno_location F
 GLIBC_2.21 pthread_hurd_cond_timedwait_np F
index e72dca501b664de98c44ff40b04430f4b2a33001..5724c88a6bf81d9dbd2c0a0dbee239eaf43f1432 100644 (file)
@@ -1,6 +1,3 @@
-GLIBC_2.38 _IO_flockfile F
-GLIBC_2.38 _IO_ftrylockfile F
-GLIBC_2.38 _IO_funlockfile F
 GLIBC_2.38 __errno_location F
 GLIBC_2.38 __h_errno_location F
 GLIBC_2.38 __pthread_spin_destroy F
@@ -16,9 +13,6 @@ GLIBC_2.38 cnd_init F
 GLIBC_2.38 cnd_signal F
 GLIBC_2.38 cnd_timedwait F
 GLIBC_2.38 cnd_wait F
-GLIBC_2.38 flockfile F
-GLIBC_2.38 ftrylockfile F
-GLIBC_2.38 funlockfile F
 GLIBC_2.38 mtx_destroy F
 GLIBC_2.38 mtx_init F
 GLIBC_2.38 mtx_lock F