1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Use shmat syscall for Linux implementation

This patch add a direct call to shmat syscall if it is supported by
kernel features.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmat): Remove.
	* sysdeps/unix/sysv/linux/arm/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmat):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmat):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmat): Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h (__NR_shmat):
	Define to __NR_osf_shmat.
	* sysdeps/unix/sysv/linux/shmat.c (shmat): Use shmat syscall if it is
	defined.
This commit is contained in:
Adhemerval Zanella
2016-10-26 18:04:48 -02:00
parent 1afc369f1a
commit 8232e7d209
12 changed files with 31 additions and 22 deletions

View File

@ -16,13 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <ipc_priv.h>
#include <sysdep.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
/* Attach the shared memory segment associated with SHMID to the data
segment of the calling process. SHMADDR and SHMFLG determine how
@ -31,17 +28,19 @@
void *
shmat (int shmid, const void *shmaddr, int shmflg)
{
#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
return (void*) INLINE_SYSCALL_CALL (shmat, shmid, shmaddr, shmflg);
#else
INTERNAL_SYSCALL_DECL(err);
unsigned long resultvar;
void *raddr;
resultvar = INTERNAL_SYSCALL (ipc, err, 5, IPCOP_shmat,
shmid, shmflg,
(long int) &raddr,
(void *) shmaddr);
resultvar = INTERNAL_SYSCALL_CALL (ipc, err, IPCOP_shmat, shmid, shmflg,
&raddr, shmaddr);
if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))
return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (resultvar,
err));
return raddr;
#endif
}