From patchwork Wed Nov 2 19:26:47 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: 80540 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp291842qge; Wed, 2 Nov 2016 12:29:23 -0700 (PDT) X-Received: by 10.99.47.7 with SMTP id v7mr8105065pgv.15.1478114963202; Wed, 02 Nov 2016 12:29:23 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id eq11si3922736pad.249.2016.11.02.12.29.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2016 12:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-74326-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-74326-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-74326-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=Aq5G0hSFDvSOtZd69Kwfzhkcx3wUidQ 0Ype7F/wc2zgS5i+pjTl5NfcdYVYrqd7ZsqoiayE6Ky9djtliYj3ATGTFJ6k2G4k AVdq0jyc7IblqhBoGm9MX9hm5DFWYzNm5TvpyxD8dlzbRLmFP2RDHD5CH2Nh6L97 k9ObZ+/jif74= 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=J0kV3mKUPOO8CEcdxammwX7d1V4=; b=OjVI3 pFGjbkP1Fv4VRHZjx6KaXt2ikiVi7tGc9a98b1E/Awou0i6IkmkuSw9xdKF+u69e BoTej638X/aDnHxmpwmR7PZegSrjh/H79yeaKkSKLDHxj7fqHpVW0JcqpGne09eA XbX6ThjvgMfqiNBuG1FafScrR/FOT5upAwLVps= Received: (qmail 65673 invoked by alias); 2 Nov 2016 19:27:27 -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 65437 invoked by uid 89); 2 Nov 2016 19:27:26 -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=five X-HELO: mail-ua0-f181.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=VocZ50b/rsAg6Bwevm5YpLKJYZPvmHwaLbGKJjQaUow=; b=MBI2bPdSo6M1OGnWqEEYWl1m5d0ZWwtQTlNBdpF3ccw7mrjNyZ+gFNLsMF8bMS4DSU h4SRUklsBrkpDSpUYev4fIXhOibSRK5vL8HGsrq9O5WDU6Z6Nk8szVj0QccM5+2fei29 n9gOn/gQ3FfjjBWvf3l8bMpCz6dT1FKOf5kNhmJQVUNwSK14+jgpjO2Z1NfBN62cdOTl Fm6vKQf7mpcqQe880lBW5jliyAErq8zvXPGPbAObwd//evI76HQiIqygsWOHuJPuF7JT wF7xfPR/Kr1evD5gWzADUY697cm0FY3nJ8pIfYZUJWlqqgV4dhsfKhcZ+h3+HlUPQJhC 36nA== X-Gm-Message-State: ABUngveUU1VPwdhda/zpa3Kyk3ZPUfIuo/+61rop7rCnJnICf9ty8eCwdlvpq7eF+i15k9D6 X-Received: by 10.176.1.9 with SMTP id 9mr4240742uak.112.1478114833236; Wed, 02 Nov 2016 12:27:13 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 10/16] Consolidate Linux semtimedop implementation Date: Wed, 2 Nov 2016 17:26:47 -0200 Message-Id: <1478114813-3526-11-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1478114813-3526-1-git-send-email-adhemerval.zanella@linaro.org> 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 consolidates the semtimedop Linux implementation in only one default file, sysdeps/unix/sysv/linux/semtimedop.c. If tries to use the direct syscall if it is supported, otherwise will use the old ipc multiplex mechanism. Checked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/m68k/semtimedop.S: Remove file. * sysdeps/unix/sysv/linux/s390/semtimedop.c: Reorganize headers and add a comment about s390 syscall difference from default one. * sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Use semtimedop syscall if it is defined. --- ChangeLog | 6 +++ sysdeps/unix/sysv/linux/m68k/semtimedop.S | 69 ------------------------------- sysdeps/unix/sysv/linux/s390/semtimedop.c | 12 +++--- sysdeps/unix/sysv/linux/semtimedop.c | 13 +++--- 4 files changed, 20 insertions(+), 80 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/m68k/semtimedop.S -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/m68k/semtimedop.S b/sysdeps/unix/sysv/linux/m68k/semtimedop.S deleted file mode 100644 index b291070..0000000 --- a/sysdeps/unix/sysv/linux/m68k/semtimedop.S +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2003-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Andreas Schwab , 2003. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -#define SYSOP_semtimedop 4 - -#define SVRSP 8 /* saved register space */ -#define PARMS 4+SVRSP /* space for 3 saved regs */ -#define SEMID PARMS -#define SOPS SEMID+4 -#define NSOPS SOPS+4 -#define TIMEOUT NSOPS+4 - - .text -ENTRY (semtimedop) - - /* Save registers. */ - move.l %d2, %a1 - move.l %d3, -(%sp) - cfi_adjust_cfa_offset (4) - move.l %d5, -(%sp) - cfi_adjust_cfa_offset (4) - cfi_register (%d2, %a1) - cfi_rel_offset (%d3, 0) - cfi_rel_offset (%d5, 4) - - move.l #SYSOP_semtimedop, %d1 - move.l SEMID(%sp), %d2 - move.l NSOPS(%sp), %d3 - move.l SOPS(%sp), %d5 - move.l TIMEOUT(%sp), %a0 - move.l #SYS_ify (ipc), %d0 - - trap #0 - - /* Restore registers. */ - move.l (%sp)+, %d5 - cfi_adjust_cfa_offset (-4) - cfi_restore (%d5) - move.l (%sp)+, %d3 - cfi_adjust_cfa_offset (-4) - cfi_restore (%d3) - move.l %a1, %d2 - cfi_restore (%d2) - - /* Check for error. */ - tst.l %d0 - jmi SYSCALL_ERROR_LABEL - - /* Successful; return the syscall's value. */ - ret - -PSEUDO_END (semtimedop) diff --git a/sysdeps/unix/sysv/linux/s390/semtimedop.c b/sysdeps/unix/sysv/linux/s390/semtimedop.c index f226953..db43f00 100644 --- a/sysdeps/unix/sysv/linux/s390/semtimedop.c +++ b/sysdeps/unix/sysv/linux/s390/semtimedop.c @@ -16,12 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include #include #include - #include -#include +#include /* Perform user-defined atomical operation of array of semaphores. */ @@ -29,6 +27,10 @@ int semtimedop (int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) { - return INLINE_SYSCALL (ipc, 5, IPCOP_semtimedop, - semid, (int) nsops, timeout, sops); + /* The s390 sys_ipc variant has only five parameters instead of six + (as for default variant) and the only difference is the handling of + SEMTIMEDOP where on s390 the third parameter is used as a pointer + to a struct timespec where the generic variant uses fifth parameter. */ + return INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, nsops, timeout, + sops); } diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c index 30ee7fe..d9249d2 100644 --- a/sysdeps/unix/sysv/linux/semtimedop.c +++ b/sysdeps/unix/sysv/linux/semtimedop.c @@ -16,12 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include #include #include - #include -#include +#include /* Perform user-defined atomical operation of array of semaphores. */ @@ -29,7 +27,10 @@ int semtimedop (int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) { - return INLINE_SYSCALL (ipc, 6, IPCOP_semtimedop, - semid, (int) nsops, 0, sops, - timeout); +#ifdef __ASSUME_SYSVIPC_SYSCALL + return INLINE_SYSCALL_CALL (semtimedop, semid, nsops, sops, timeout); +#else + return INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, nsops, 0, sops, + timeout); +#endif }