about summary refs log tree commit diff
path: root/rt
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-06-21 08:25:15 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-06-21 08:25:15 +0200
commitc6e7ec2f123bceb323836cc4558f9586959ebf58 (patch)
tree9fc6a7af72b75e9996ed0e0c90278f976737e3ab /rt
parenta749a00fb55e7ee7ede658ef12de4c7de1570b99 (diff)
downloadglibc-c6e7ec2f123bceb323836cc4558f9586959ebf58.tar.gz
glibc-c6e7ec2f123bceb323836cc4558f9586959ebf58.tar.xz
glibc-c6e7ec2f123bceb323836cc4558f9586959ebf58.zip
rt: Move shm_open into libc
This function has no dependency on libpthread, so the move is also
applied to Hurd.

To avoid localplt failures, use __open64_nocancel instead of
pthread_setcancelstate and open.

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'rt')
-rw-r--r--rt/Makefile4
-rw-r--r--rt/Versions9
-rw-r--r--rt/shm_open.c17
3 files changed, 20 insertions, 10 deletions
diff --git a/rt/Makefile b/rt/Makefile
index 47bc594dee..ba141c82f2 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -24,6 +24,9 @@ include ../Makeconfig
 
 headers	:= aio.h mqueue.h bits/mqueue.h bits/mqueue2.h
 
+routines = \
+  shm_open \
+
 librt-routines = \
   aio_cancel \
   aio_error \
@@ -49,7 +52,6 @@ librt-routines = \
   mq_timedreceive \
   mq_timedsend \
   mq_unlink \
-  shm_open \
   shm_unlink \
   timer_create \
   timer_delete \
diff --git a/rt/Versions b/rt/Versions
index f151f85ef6..e1d208eeb3 100644
--- a/rt/Versions
+++ b/rt/Versions
@@ -1,3 +1,11 @@
+libc {
+  GLIBC_2.2 {
+    shm_open;
+  }
+  GLIBC_2.34 {
+    shm_open;
+  }
+}
 librt {
   GLIBC_2.1 {
     aio_cancel;
@@ -19,7 +27,6 @@ librt {
     lio_listio64;
   }
   GLIBC_2.2 {
-    shm_open;
     shm_unlink;
     timer_create;
     timer_delete;
diff --git a/rt/shm_open.c b/rt/shm_open.c
index a89aac4102..40eb8902a8 100644
--- a/rt/shm_open.c
+++ b/rt/shm_open.c
@@ -18,13 +18,15 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <not-cancel.h>
 #include <pthread.h>
+#include <shlib-compat.h>
 #include <shm-directory.h>
 #include <unistd.h>
 
 /* Open shared memory object.  */
 int
-shm_open (const char *name, int oflag, mode_t mode)
+__shm_open (const char *name, int oflag, mode_t mode)
 {
   struct shmdir_name dirname;
   if (__shm_get_name (&dirname, name, false) != 0)
@@ -35,18 +37,17 @@ shm_open (const char *name, int oflag, mode_t mode)
 
   oflag |= O_NOFOLLOW | O_CLOEXEC;
 
-  /* Disable asynchronous cancellation.  */
-  int state;
-  pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
-
-  int fd = open (dirname.name, oflag, mode);
+  int fd = __open64_nocancel (dirname.name, oflag, mode);
   if (fd == -1 && __glibc_unlikely (errno == EISDIR))
     /* It might be better to fold this error with EINVAL since
        directory names are just another example for unsuitable shared
        object names and the standard does not mention EISDIR.  */
     __set_errno (EINVAL);
 
-  pthread_setcancelstate (state, NULL);
-
   return fd;
 }
+versioned_symbol (libc, __shm_open, shm_open, GLIBC_2_34);
+
+#if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_34)
+compat_symbol (libc, __shm_open, shm_open, GLIBC_2_2);
+#endif