about summary refs log tree commit diff
path: root/rt
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-06-25 10:30:36 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-06-25 11:55:27 +0200
commit32e750516c653bc3005aaef87124a587a7bef196 (patch)
treea90a00b58b191b7691cc2252ac4cf81b0aa50a74 /rt
parent406fb327fb3b617d6abdd54bed2967c2a9f384c4 (diff)
downloadglibc-32e750516c653bc3005aaef87124a587a7bef196.tar.gz
glibc-32e750516c653bc3005aaef87124a587a7bef196.tar.xz
glibc-32e750516c653bc3005aaef87124a587a7bef196.zip
Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc
The symbols were moved using scripts/move-symbol-to-libc.py.

There is a minor oddity here: This is generic code shared with Hurd,
and Hurd does not have time64 support.  This is why the
versioned_symbol export for __aio_suspend_time64 is restricted to
the PTHREAD_IN_LIBC code.

Reviewed-by: Adhemerva Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'rt')
-rw-r--r--rt/Makefile2
-rw-r--r--rt/Versions6
-rw-r--r--rt/aio_suspend.c49
3 files changed, 45 insertions, 12 deletions
diff --git a/rt/Makefile b/rt/Makefile
index 29c9aa5f05..a373cd06c7 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -29,7 +29,6 @@ routines = \
   shm_unlink \
 
 librt-routines = \
-  aio_suspend \
   aio_write \
   aio_write64 \
   librt-compat \
@@ -63,6 +62,7 @@ $(librt-routines-var) += \
   aio_read64 \
   aio_return \
   aio_sigqueue \
+  aio_suspend \
 
 tests := tst-shm tst-timer tst-timer2 \
 	 tst-aio tst-aio64 tst-aio2 tst-aio3 tst-aio4 tst-aio5 tst-aio6 \
diff --git a/rt/Versions b/rt/Versions
index 0780dc8400..d54b9cc4bf 100644
--- a/rt/Versions
+++ b/rt/Versions
@@ -12,6 +12,8 @@ libc {
     aio_read64;
     aio_return;
     aio_return64;
+    aio_suspend;
+    aio_suspend64;
 %endif
   }
   GLIBC_2.2 {
@@ -31,6 +33,8 @@ libc {
     aio_read64;
     aio_return;
     aio_return64;
+    aio_suspend;
+    aio_suspend64;
 %endif
     shm_open;
     shm_unlink;
@@ -63,9 +67,9 @@ librt {
     aio_read64;
     aio_return;
     aio_return64;
-%endif
     aio_suspend;
     aio_suspend64;
+%endif
     aio_write;
     aio_write64;
     lio_listio;
diff --git a/rt/aio_suspend.c b/rt/aio_suspend.c
index 6fd5b1bee2..29f01d1023 100644
--- a/rt/aio_suspend.c
+++ b/rt/aio_suspend.c
@@ -36,6 +36,8 @@
 
 #include <libc-lock.h>
 #include <aio_misc.h>
+#include <pthreadP.h>
+#include <shlib-compat.h>
 
 
 struct clparam
@@ -56,7 +58,7 @@ cleanup (void *arg)
 #ifdef DONT_NEED_AIO_MISC_COND
   /* Acquire the mutex.  If pthread_cond_*wait is used this would
      happen implicitly.  */
-  pthread_mutex_lock (&__aio_requests_mutex);
+  __pthread_mutex_lock (&__aio_requests_mutex);
 #endif
 
   const struct clparam *param = (const struct clparam *) arg;
@@ -88,7 +90,7 @@ cleanup (void *arg)
 #endif
 
   /* Release the mutex.  */
-  pthread_mutex_unlock (&__aio_requests_mutex);
+  __pthread_mutex_unlock (&__aio_requests_mutex);
 }
 
 #ifdef DONT_NEED_AIO_MISC_COND
@@ -105,7 +107,7 @@ do_aio_misc_wait (unsigned int *cntr, const struct __timespec64 *timeout)
 #endif
 
 int
-__aio_suspend_time64 (const struct aiocb *const list[], int nent,
+___aio_suspend_time64 (const struct aiocb *const list[], int nent,
 		      const struct __timespec64 *timeout)
 {
   if (__glibc_unlikely (nent < 0))
@@ -125,7 +127,7 @@ __aio_suspend_time64 (const struct aiocb *const list[], int nent,
   unsigned int cntr = 1;
 
   /* Request the mutex.  */
-  pthread_mutex_lock (&__aio_requests_mutex);
+  __pthread_mutex_lock (&__aio_requests_mutex);
 
   /* There is not yet a finished request.  Signal the request that
      we are working for it.  */
@@ -184,7 +186,11 @@ __aio_suspend_time64 (const struct aiocb *const list[], int nent,
 	  .nent = nent
 	};
 
-      pthread_cleanup_push (cleanup, &clparam);
+#if PTHREAD_IN_LIBC
+      __libc_cleanup_region_start (1, cleanup, &clparam);
+#else
+      __pthread_cleanup_push (cleanup, &clparam);
+#endif
 
 #ifdef DONT_NEED_AIO_MISC_COND
       result = do_aio_misc_wait (&cntr, timeout == NULL ? NULL : &ts);
@@ -194,7 +200,11 @@ __aio_suspend_time64 (const struct aiocb *const list[], int nent,
 				       timeout == NULL ? NULL : &ts32);
 #endif
 
+#if PTHREAD_IN_LIBC
+      __libc_cleanup_region_end (0);
+#else
       pthread_cleanup_pop (0);
+#endif
     }
 
   /* Now remove the entry in the waiting list for all requests
@@ -239,13 +249,22 @@ __aio_suspend_time64 (const struct aiocb *const list[], int nent,
     }
 
   /* Release the mutex.  */
-  pthread_mutex_unlock (&__aio_requests_mutex);
+  __pthread_mutex_unlock (&__aio_requests_mutex);
 
   return result;
 }
 
-#if __TIMESIZE != 64
-librt_hidden_def (__aio_suspend_time64)
+#if __TIMESIZE == 64
+strong_alias (___aio_suspend_time64, __aio_suspend)
+#else /* __TIMESIZE != 64 */
+# if PTHREAD_IN_LIBC
+libc_hidden_ver (___aio_suspend_time64, __aio_suspend_time64)
+/* The conditional is slightly wrong: PTHREAD_IN_LIBC is a stand-in
+   for whether time64 support is needed.  */
+versioned_symbol (libc, ___aio_suspend_time64, __aio_suspend_time64, GLIBC_2_34);
+# else
+librt_hidden_ver (___aio_suspend_time64, __aio_suspend_time64)
+# endif
 
 int
 __aio_suspend (const struct aiocb *const list[], int nent,
@@ -258,6 +277,16 @@ __aio_suspend (const struct aiocb *const list[], int nent,
 
   return __aio_suspend_time64 (list, nent, timeout != NULL ? &ts64 : NULL);
 }
-#endif
+#endif /* __TIMESPEC64 != 64 */
+
+#if PTHREAD_IN_LIBC
+versioned_symbol (libc, __aio_suspend, aio_suspend, GLIBC_2_34);
+versioned_symbol (libc, __aio_suspend, aio_suspend64, GLIBC_2_34);
+# if OTHER_SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_34)
+compat_symbol (librt, __aio_suspend, aio_suspend, GLIBC_2_1);
+compat_symbol (librt, __aio_suspend, aio_suspend64, GLIBC_2_1);
+# endif
+#else /* !PTHREAD_IN_LIBC */
 weak_alias (__aio_suspend, aio_suspend)
-weak_alias (aio_suspend, aio_suspend64)
+weak_alias (__aio_suspend, aio_suspend64)
+#endif /* !PTHREAD_IN_LIBC */