This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 12/16] Use shmat syscall for Linux implementation
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Wed, 2 Nov 2016 17:26:49 -0200
- Subject: [PATCH v2 12/16] Use shmat syscall for Linux implementation
- Authentication-results: sourceware.org; auth=none
- References: <1478114813-3526-1-git-send-email-adhemerval.zanella@linaro.org>
Changes from previous version:
- Use __ASSUME_SYSVIPC_SYSCALL instead of __NR_syscall to issue the
wired syscall or the ipc one.
--
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/shmat.c (shmat): Use shmat syscall if it is
defined.
---
ChangeLog | 3 +++
sysdeps/unix/sysv/linux/shmat.c | 17 ++++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index 5afc93c..97a15c2 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -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_SYSVIPC_SYSCALL
+ return 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
}
--
2.7.4