1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

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>
This commit is contained in:
Florian Weimer
2021-06-21 08:25:15 +02:00
parent a749a00fb5
commit c6e7ec2f12
67 changed files with 86 additions and 41 deletions

View File

@ -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