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: 17118 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 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 }