]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use shmat syscall for Linux implementation
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 26 Oct 2016 20:04:48 +0000 (18:04 -0200)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 28 Dec 2016 22:31:05 +0000 (20:31 -0200)
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.

12 files changed:
ChangeLog
sysdeps/unix/sysv/linux/alpha/kernel-features.h
sysdeps/unix/sysv/linux/alpha/syscalls.list
sysdeps/unix/sysv/linux/arm/syscalls.list
sysdeps/unix/sysv/linux/generic/syscalls.list
sysdeps/unix/sysv/linux/hppa/syscalls.list
sysdeps/unix/sysv/linux/ia64/syscalls.list
sysdeps/unix/sysv/linux/microblaze/syscalls.list
sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
sysdeps/unix/sysv/linux/shmat.c
sysdeps/unix/sysv/linux/x86_64/syscalls.list

index 19c898cd79252862dfed559fc22fae5bda97d90a..2e2eb6d0a4d65cdbec5a93734966b81d1f4ad1ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2016-12-28  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * 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.
+
        * sysvipc/Makefile (tests): Add test-sysvsem.
        * sysvipc/test-sysvsem.c: New file.
 
index f09222d2259ea7ce901fd69524a8cfb2a2a322da..2fc3b7758aef1b90ba5fa148fb9270559e135a95 100644 (file)
@@ -29,4 +29,7 @@
 #undef __ASSUME_STATFS64
 #define __ASSUME_STATFS64 0
 
+/* Alpha defines SysV ipc shmat syscall with a different name.  */
+#define __NR_shmat __NR_osf_shmat
+
 #endif /* _KERNEL_FEATURES_H */
index 8d3a042afee0934977232952940f49530a1fd024..9948d2d176ffdbbb89ef95054c8ff7096db144bf 100644 (file)
@@ -1,6 +1,5 @@
 # File name    Caller  Syscall name    # args  Strong name     Weak names
 
-shmat          -       osf_shmat       i:ipi   __shmat         shmat
 oldshmctl      EXTRA   shmctl          i:iip   __old_shmctl    shmctl@GLIBC_2.0
 shmdt          -       shmdt           i:s     __shmdt         shmdt
 shmget         -       shmget          i:iii   __shmget        shmget
index 1b2de93518ebc272ddcfc5bd64c7388aa3488bc8..f50a5cf6bff4f4a1e1fbb42bb9d0336717021c0f 100644 (file)
@@ -23,7 +23,6 @@ personality   EXTRA   personality     Ei:i    __personality   personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmat          -       shmat           i:ipi   __shmat         shmat
 shmdt          -       shmdt           i:s     __shmdt         shmdt
 shmget         -       shmget          i:iii   __shmget        shmget
 
index e12fb3e8b1efcea49b3c86a54a4b87163631f1d4..0df73a9e2bbfe0b2a9109c1cb36f8ebb4a27fca7 100644 (file)
@@ -3,7 +3,6 @@
 # SysV APIs
 shmget         -       shmget          i:iii   __shmget        shmget
 shmctl         -       shmctl          i:iip   __shmctl        shmctl
-shmat          -       shmat           i:ipi   __shmat         shmat
 shmdt          -       shmdt           i:s     __shmdt         shmdt
 
 # Socket APIs
index a8fbc444177af462645eeee1b4a92e77dd741807..f757f026af2e9d179cfff739a454f4eba21b0f50 100644 (file)
@@ -1,7 +1,6 @@
 # File name    Caller  Syscall name    # args  Strong name     Weak names
 
 # semaphore and shm system calls
-shmat          -       shmat           i:ipi   __shmat         shmat
 shmctl         -       shmctl          i:iip   __shmctl        shmctl
 shmdt          -       shmdt           i:s     __shmdt         shmdt
 shmget         -       shmget          i:iii   __shmget        shmget
index eda4e4e20907977803b260cf123aef6690630e8c..b0a3a4439191180620bb2e629e5ae57de2d30681 100644 (file)
@@ -5,7 +5,6 @@ umount2         -       umount          2       __umount2       umount2
 getpriority    -       getpriority     i:ii    __getpriority   getpriority
 
 # semaphore and shm system calls
-shmat          -       shmat           i:ipi   __shmat         shmat
 shmctl         -       shmctl          i:iip   __shmctl        shmctl
 shmdt          -       shmdt           i:s     __shmdt         shmdt
 shmget         -       shmget          i:iii   __shmget        shmget
index d9afda0548c89888b7cbad4a344d03ccc5e97076..8b844f2f7620c4bdcdc91614220c1ef8eb64b89d 100644 (file)
@@ -8,6 +8,5 @@ personality     EXTRA   personality     Ei:i    __personality   personality
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmat           -       shmat           i:ipi   __shmat         shmat
 shmdt           -       shmdt           i:s     __shmdt         shmdt
 shmget          -       shmget          i:iii   __shmget        shmget
index 9cbbd38918544874aff7157e92475fd862d61e31..e93c87a5efe94f9a6611c1359640f9bd7689faef 100644 (file)
@@ -2,6 +2,5 @@
 
 # Semaphore and shm system calls.  msgctl, shmctl, and semctl have C
 # wrappers (to set __IPC_64).
-shmat          -       shmat           i:ipi   __shmat         shmat
 shmdt          -       shmdt           i:s     __shmdt         shmdt
 shmget         -       shmget          i:iii   __shmget        shmget
index 924d182d69a35949f2d20ca253b106689e64eacb..40ed7c5b91fd80c66aa9dbb78d34a8ef4362eec9 100644 (file)
@@ -1,7 +1,6 @@
-# File name    Caller  Syscall name    # args  Strong name     Weak names
+# File name     Caller  Syscall name    # args  Strong name     Weak names
 
 # semaphore and shm system calls
-shmat          -       shmat           i:ipi   __shmat         shmat
-shmctl         -       shmctl          i:iip   __shmctl        shmctl
-shmdt          -       shmdt           i:s     __shmdt         shmdt
-shmget         -       shmget          i:iii   __shmget        shmget
+shmctl          -       shmctl          i:iip   __shmctl        shmctl
+shmdt           -       shmdt           i:s     __shmdt         shmdt
+shmget          -       shmget          i:iii   __shmget        shmget
index 5afc93c9a918b3eb82f47d56741fa4b7c2170ec5..d1ef323e374cb52148bb6ba4ff1f59dab7342420 100644 (file)
    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
 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
 }
index 573ed0735d3b0b26b82e14cd2d532b6f13c64265..8712bb83ed782292b1f6add5d7b68207947f7b47 100644 (file)
@@ -6,7 +6,6 @@ pread64         -       pread64         Ci:ipii __libc_pread    __libc_pread64 __pread64 pread64 __prea
 preadv64       -       preadv          Ci:ipii preadv64        preadv
 pwrite64       -       pwrite64        Ci:ipii __libc_pwrite   __libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
 pwritev64      -       pwritev         Ci:ipii pwritev64       pwritev
-shmat          -       shmat           i:ipi   __shmat         shmat
 shmctl         -       shmctl          i:iip   __shmctl        shmctl
 shmdt          -       shmdt           i:s     __shmdt         shmdt
 shmget         -       shmget          i:iii   __shmget        shmget