From patchwork Tue Nov 8 20:30:03 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: 692477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tD1JQ2KwMz9t0G for ; Wed, 9 Nov 2016 07:34:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="EIgalCsy"; dkim-atps=neutral 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=tfT2SPkJ772oDo9VfNkE5y7wYmlxmPm AWK4HMfCHOzYdKFWgUqklOPl/XhmUphdfN0yznC/nOuDyHHc9xev4uPBn+4l/RNE oZz68nx48hkksBFDmF+iYALRM/zAqCvoblezp4GeSvxjKuPcmjZ9OvC+9bx7+Fho Ze4BpPfPUjdA= 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=TPoW7UaTIhxitCU0GoeUABi54L4=; b=EIgal CsymBCQM+0FHg+xby7pzdy9vjoKUkepM6pkNvpoTKZWRKELg5IC6O/pZEBq+OOjk HLhHrP3xi5ls8AlK8b7315+rUihX4GSmVjn7GX5rWXJsYIuQgsixrhmFf+ATFDqg CYFbE4Jd+04x8BoqVCAGc1hRCs5QunErO/5AjQ= Received: (qmail 126122 invoked by alias); 8 Nov 2016 20:30:53 -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 125539 invoked by uid 89); 8 Nov 2016 20:30:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=1613, UD:syscall.h, s39064, syscallh X-HELO: mail-ua0-f169.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=A192Bf9ijakjYoyyk3D/wqGLEbeSR81m7fPx7vX+1cM=; b=CW9cfV2ATXZCPJS8EC1jySvVlPr+udOzNI4hwIx0lwybqhDZP9C6EZ8QwSVJMRdPc0 +mU2IPrn1ECMC0hUAhU38Y7b3TPGPQxukqsiWpKOk2WZFVHQhXrFK+XupyLbRmylrw6v BQjmSKO4UDp1BIpA1JcJbGclBSgWjrcT3NsQ8lMKASkJmitkwWLH0U/Av1uIVYuraXHm gvYeo0ZDtdSmszlH8Ev8eJdMOIWmiZLRxiFEkEeusogQ1n5oCRSujFo1248grvsX+N7y yrjOaVAv80dtA/2+xk15F9nIC01djhiUe9eMRvFiWAn+CW+BUq7DiM0MfGinzJG3dKQN 1VGg== X-Gm-Message-State: ABUngvfo7+WE1NmKRAKLyqxjKHECwuBamuv77/3A7g8gR2leozm16E83jElQ+QTjqNF15TKD X-Received: by 10.176.67.196 with SMTP id l62mr8107755ual.164.1478637035318; Tue, 08 Nov 2016 12:30:35 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 13/17] Use shmat syscall for Linux implementation Date: Tue, 8 Nov 2016 18:30:03 -0200 Message-Id: <1478637007-31212-14-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1478637007-31212-1-git-send-email-adhemerval.zanella@linaro.org> References: <1478637007-31212-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Remove semat from syscalls.list. - Fixed alpha build with correct __NR_shmat definition. --- 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(-) 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 63e037e..c6883c5 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list @@ -5,6 +5,5 @@ truncate - truncate i:si truncate truncate64 # 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..a105bcb 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_SYSVIPC_SYSCALL + 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 8c5bfcb..1c2c663 100644 --- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list @@ -2,7 +2,6 @@ arch_prctl EXTRA arch_prctl i:ii __arch_prctl arch_prctl modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt -shmat - shmat i:ipi __shmat shmat shmctl - shmctl i:iip __shmctl shmctl shmdt - shmdt i:s __shmdt shmdt shmget - shmget i:iii __shmget shmget