From patchwork Tue Dec 27 14:01:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 89083 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp4999697qgi; Tue, 27 Dec 2016 06:03:53 -0800 (PST) X-Received: by 10.84.149.139 with SMTP id m11mr67171991pla.38.1482847433448; Tue, 27 Dec 2016 06:03:53 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 92si46607336plc.147.2016.12.27.06.03.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 06:03:53 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-76360-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-76360-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-76360-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=c36R9cBOCU5H8jGWvI2DDddHAELdpyQ WOmxqktTHe3C2Q90basVZMlCKzY6iPJ8SB3pilreuhdaNwXNP9s3oz10Sub1z6mo YKGmQKPCl6S7LcfaDF1VcH+0p+QUBGxbilJzU2umH1xaCsjLFqj8Zb3eEK8frMTP gpk577MoPRzc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=WF5/HTDj/p2+7hMl95z5+RSs3Fc=; b=JrEQ6 WVR6JvnK4YwugzkN95oj2tsB2Ha61cd1cT6RQa7VPwCCwcTc7YEDT7FK8jnOdnfw DcAS/HU5OieTooShX4l8yxu9SS9/F6oSwvDZN5KuvZjZSJyNhdaXlGlJSExAaiae GLE/fNhXOaBCRny7Vn9o4lQ2XLyjDZ1LRCGvxU= Received: (qmail 77666 invoked by alias); 27 Dec 2016 14:02:02 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 77354 invoked by uid 89); 27 Dec 2016 14:02:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Alpha, socket X-HELO: mail-yw0-f172.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+VPhG2+VmIS3pFCjvRrCS6RnzILM+uMVOat8Akv+yPM=; b=S98FQroM2BHtncpcfyycCnelBtYY/ecwg/pk9LGaBBaQgXahXbQb96WDf1D1TDUVWC f4L/vVD/cYPlO3UwAtq2YxpB1bUVF71wgyAfNJZmuXVdTCEuJ6cvNCHHpPVPQJsmTEFX hSkua56tCP3D3h70+0mkcUWYESTkZJmB0kW0byr3x/vU9uii5l2DAoiWoqdqPhgndYvc rZ4/17I6oBD8mH4PUihfChVvGC26E3cC9LOUR2DzW8hKWcNWAafynFGr2kewUtWrB/jQ 5SY8H0G5d/99nu3uQjaQyY8HwTDNeFqW6iFTce5LM0G+E9E+OBM7wXz1Ic6Hby7mkKOJ hPlQ== X-Gm-Message-State: AIkVDXKNlnszTQ5S+2LWeCLTa0OGAKxiwbDsq89/1On1ph8TBrTRWUJ5ED/5QnROXoC1gWDC X-Received: by 10.13.203.69 with SMTP id n66mr24867511ywd.220.1482847310615; Tue, 27 Dec 2016 06:01:50 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 13/17] Use shmat syscall for Linux implementation Date: Tue, 27 Dec 2016 12:01:22 -0200 Message-Id: <1482847286-29933-14-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1482847286-29933-1-git-send-email-adhemerval.zanella@linaro.org> References: <1482847286-29933-1-git-send-email-adhemerval.zanella@linaro.org> 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. --- ChangeLog | 16 ++++++++++++++++ sysdeps/unix/sysv/linux/alpha/kernel-features.h | 3 +++ sysdeps/unix/sysv/linux/alpha/syscalls.list | 1 - sysdeps/unix/sysv/linux/arm/syscalls.list | 1 - sysdeps/unix/sysv/linux/generic/syscalls.list | 1 - sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 - sysdeps/unix/sysv/linux/ia64/syscalls.list | 1 - sysdeps/unix/sysv/linux/microblaze/syscalls.list | 1 - sysdeps/unix/sysv/linux/mips/mips64/syscalls.list | 1 - sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list | 9 ++++----- sysdeps/unix/sysv/linux/shmat.c | 17 ++++++++--------- sysdeps/unix/sysv/linux/x86_64/syscalls.list | 1 - 12 files changed, 31 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/sysdeps/unix/sysv/linux/alpha/kernel-features.h index f09222d..2fc3b77 100644 --- a/sysdeps/unix/sysv/linux/alpha/kernel-features.h +++ b/sysdeps/unix/sysv/linux/alpha/kernel-features.h @@ -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 */ diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list index 8d3a042..9948d2d 100644 --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list index 1b2de93..f50a5cf 100644 --- a/sysdeps/unix/sysv/linux/arm/syscalls.list +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/generic/syscalls.list b/sysdeps/unix/sysv/linux/generic/syscalls.list index e12fb3e..0df73a9 100644 --- a/sysdeps/unix/sysv/linux/generic/syscalls.list +++ b/sysdeps/unix/sysv/linux/generic/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list index a8fbc44..f757f02 100644 --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list index eda4e4e..b0a3a44 100644 --- a/sysdeps/unix/sysv/linux/ia64/syscalls.list +++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list index d9afda0..8b844f2 100644 --- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list +++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list index 9cbbd38..e93c87a 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list index 924d182..40ed7c5 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list +++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list @@ -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 diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c index 5afc93c..d1ef323 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 . */ -#include -#include +#include #include - #include -#include -#include +#include /* 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 } diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list index 573ed07..8712bb8 100644 --- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list @@ -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