diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-06-21 08:25:15 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-06-21 08:25:15 +0200 |
commit | c6e7ec2f123bceb323836cc4558f9586959ebf58 (patch) | |
tree | 9fc6a7af72b75e9996ed0e0c90278f976737e3ab /rt/shm_open.c | |
parent | a749a00fb55e7ee7ede658ef12de4c7de1570b99 (diff) | |
download | glibc-c6e7ec2f123bceb323836cc4558f9586959ebf58.tar.gz |
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/shm_open.c')
-rw-r--r-- | rt/shm_open.c | 17 |
1 files changed, 9 insertions, 8 deletions
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 |