From patchwork Mon Nov 22 18:54:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 48004 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 76A22385801C for ; Mon, 22 Nov 2021 18:55:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76A22385801C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637607346; bh=SNGLLfgGr59lvGBZy9LVbpz42xbruEcSgmO+8+x2lgU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=o1NsXDAKTm0HdMprGW/lW6fFNwv0QTwEJtYB361h5IQhV0WcQbxojtrHDuDV0SL8u coE6zwG/HWPHEnwErCMK4GGGpbK3StVR2YkGfQNiRefqHFprBSnk58vlwJcMtBz58C 56CyGYCBXK1dl20QJMZ0KXN2bP4PiV9HunT44Vtc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) by sourceware.org (Postfix) with ESMTPS id 1FE843858400 for ; Mon, 22 Nov 2021 18:54:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1FE843858400 Received: by mail-ua1-x92b.google.com with SMTP id y5so38621003ual.7 for ; Mon, 22 Nov 2021 10:54:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SNGLLfgGr59lvGBZy9LVbpz42xbruEcSgmO+8+x2lgU=; b=mxcCMhu+k4UIM4fmO+MFc+ndNnw4N+uMQgFPhlA3i5DvDvYYe5QBtmNOcaSi5f/Uye xZs3aSJq2r+Z9+30mlfRXdZZ0wNoR3U2+heuK4OLnjxbh2DIlvIQ2QGPr5jFN2IUm2ck Hg4/01Z/dK0H/Qe5Icgu3smyemb/MNddZuduQzSLqbNQxW1vJEpNfGYJnvroX5v+JRLo qRCJfY+yylwzlKB5h6Q4UUQNCbJTQ6doQPBdiw/niSf5qB1PExU2rF/umlK1EmGlhjJa /sbo6rBgHezB49pbTaDVKGdUEjOwMK6iDAFeanxgHx5G6FChILZCafnuSaB3voFYQWSe 8KGw== X-Gm-Message-State: AOAM531DHzh3/mqxmlzii0FIISa9gwj+BBf2rIEjD/CkKgabdjrfxuZ2 tJFSXdehWBje0RydfibXcNJaB6cUb63Aug== X-Google-Smtp-Source: ABdhPJynCytjk+SK0Ef1dJ6SfuWWs8o4YdeU3+OrofIdJh593f6bnZ+9OEZQitum09uNZ1cXLqHHNA== X-Received: by 2002:a05:6102:2c6:: with SMTP id h6mr136461207vsh.13.1637607282432; Mon, 22 Nov 2021 10:54:42 -0800 (PST) Received: from birita.. ([2804:431:c7cb:e054:bce6:bc54:280c:f077]) by smtp.gmail.com with ESMTPSA id g187sm5197166vsc.10.2021.11.22.10.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 10:54:42 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 1/6] linux: Add fanotify_mark C implementation Date: Mon, 22 Nov 2021 15:54:32 -0300 Message-Id: <20211122185437.1934590-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Passing 64-bit arguments on syscalls.list is tricky: it requires to reimplement the expected kernel abi in each architecture. This is way to better to represent in C code where we already have macros for this (SYSCALL_LL64). Checked on x86_64-linux-gnu. --- sysdeps/unix/sysv/linux/Makefile | 3 +- sysdeps/unix/sysv/linux/arm/syscalls.list | 2 -- sysdeps/unix/sysv/linux/fanotify_mark.c | 36 +++++++++++++++++++ .../linux/generic/wordsize-32/syscalls.list | 1 - sysdeps/unix/sysv/linux/hppa/fanotify_mark.c | 2 ++ sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 - sysdeps/unix/sysv/linux/i386/syscalls.list | 2 -- sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 - .../unix/sysv/linux/microblaze/syscalls.list | 1 - .../unix/sysv/linux/mips/mips32/syscalls.list | 2 -- .../sysv/linux/mips/mips64/n32/syscalls.list | 2 -- .../sysv/linux/mips/mips64/n64/syscalls.list | 2 -- .../linux/powerpc/powerpc32/syscalls.list | 1 - .../sysv/linux/s390/s390-32/syscalls.list | 1 - sysdeps/unix/sysv/linux/sh/fanotify_mark.c | 2 ++ sysdeps/unix/sysv/linux/sh/syscalls.list | 2 -- .../sysv/linux/sparc/sparc32/syscalls.list | 1 - .../unix/sysv/linux/wordsize-64/syscalls.list | 2 -- 18 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/fanotify_mark.c create mode 100644 sysdeps/unix/sysv/linux/hppa/fanotify_mark.c create mode 100644 sysdeps/unix/sysv/linux/sh/fanotify_mark.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 76ad06361c..c5b4f249cc 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -66,7 +66,8 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ fxstatat fxstatat64 \ xmknod xmknodat convert_scm_timestamps \ closefrom_fallback \ - clone3 clone-internal + clone3 clone-internal \ + fanotify_mark \ CFLAGS-gethostid.c = -fexceptions CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list index 10c3ae9dae..fa26876f90 100644 --- a/sysdeps/unix/sysv/linux/arm/syscalls.list +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list @@ -17,8 +17,6 @@ setfsuid - setfsuid32 Ei:i setfsuid prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark - personality EXTRA personality Ei:i __personality personality # proper socket implementations: diff --git a/sysdeps/unix/sysv/linux/fanotify_mark.c b/sysdeps/unix/sysv/linux/fanotify_mark.c new file mode 100644 index 0000000000..6f8fd2e9cf --- /dev/null +++ b/sysdeps/unix/sysv/linux/fanotify_mark.c @@ -0,0 +1,36 @@ +/* Add, remove, or modify an fanotify mark on a filesystem object. + Linux specific syscall. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 +#include + +int +__fanotify_mark (int fd, unsigned int flags, uint64_t mask, int dirfd, + const char *pathname) +{ + return INLINE_SYSCALL_CALL (fanotify_mark, fd, flags, SYSCALL_LL64 (mask), + dirfd, pathname); +} +#ifdef VERSION_fanotify_mark +# include +versioned_symbol (libc, __fanotify_mark, fanotify_mark, + VERSION_fanotify_mark); +#else +weak_alias (__fanotify_mark, fanotify_mark) +#endif diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list index b775008a37..736edbe654 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list @@ -2,4 +2,3 @@ # rlimit APIs prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark diff --git a/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c new file mode 100644 index 0000000000..ce347a4261 --- /dev/null +++ b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c @@ -0,0 +1,2 @@ +#define VERSION_fanotify_mark GLIBC_2_19 +#include diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list index 043d884bf9..cc5305a585 100644 --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list @@ -10,5 +10,4 @@ socket - socket i:iii __socket socket socketpair - socketpair i:iiif __socketpair socketpair prlimit64 EXTRA prlimit64 i:iipp __prlimit64 prlimit64@@GLIBC_2.17 -fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.19 personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list index 58020dfae5..d3eaabe61b 100644 --- a/sysdeps/unix/sysv/linux/i386/syscalls.list +++ b/sysdeps/unix/sysv/linux/i386/syscalls.list @@ -21,6 +21,4 @@ vm86 - vm86 i:ip __vm86 vm86@@GLIBC_2.3.4 prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark - personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list index 55a377b841..44c84bf626 100644 --- a/sysdeps/unix/sysv/linux/m68k/syscalls.list +++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list @@ -17,5 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list index 932c9cccc8..0abdc38bf3 100644 --- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list +++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list @@ -3,5 +3,4 @@ cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list index f357b5c918..dbeb184d73 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list @@ -1,5 +1,3 @@ # File name Caller Syscall name # args Strong name Weak names prlimit64 EXTRA prlimit64 i:iipp prlimit64 - -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list index 9e6a584685..848028f125 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list @@ -6,6 +6,4 @@ lseek64 - lseek i:iii __lseek64 __libc_lseek64 lseek64@@GLIBC_2.2 llseek@GLIBC prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark - personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list index e4e16dfa49..84f348c8e5 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list @@ -2,6 +2,4 @@ prlimit EXTRA prlimit64 i:iipp prlimit prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark - sendfile - sendfile i:iipi sendfile sendfile64 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list index 966856e64a..d31303250d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list @@ -4,4 +4,3 @@ chown - chown i:sii __chown chown@@GLIBC_2.1 lchown - lchown i:sii __lchown lchown@@GLIBC_2.0 chown@GLIBC_2.0 prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list index 300b13dd01..8e9b7c4b71 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list @@ -16,5 +16,4 @@ setfsgid - setfsgid32 Ei:i setfsgid setfsuid - setfsuid32 Ei:i setfsuid prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/sh/fanotify_mark.c b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c new file mode 100644 index 0000000000..3662f21b60 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c @@ -0,0 +1,2 @@ +#define VERSION_fanotify_mark GLIBC_2_16 +#include diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list index 32badd1ee0..6ff3e8eb8a 100644 --- a/sysdeps/unix/sysv/linux/sh/syscalls.list +++ b/sysdeps/unix/sysv/linux/sh/syscalls.list @@ -17,6 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.16 - personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list index 0b6095ffab..4fcae65451 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list @@ -16,4 +16,3 @@ setfsgid - setfsgid32 Ei:i setfsgid setfsuid - setfsuid32 Ei:i setfsuid prlimit64 EXTRA prlimit64 i:iipp prlimit64 -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list index 68e3c60536..8d97a32344 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list @@ -2,6 +2,4 @@ sendfile - sendfile i:iipi sendfile sendfile64 prlimit EXTRA prlimit64 i:iipp prlimit prlimit64 - -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark personality EXTRA personality i:i __personality personality From patchwork Mon Nov 22 18:54:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 48005 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9812A385800D for ; Mon, 22 Nov 2021 18:56:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9812A385800D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637607393; bh=qNBXbs5tZkztNZpEWFr5Ejiwe3G3zriwYsMwiK6lx2s=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=gDcMGCdBlpdCw1OeErofD1tjfGWB+fEE4OiJ1b9XmEO7zw5GDdBwAM7y+N/tOlx9C oBCvOnYOimwbX02j7K+D02mQ8qFw3VsUNzbUdVi+RkYRPzE3OFTFRY+CrR6AQcldi+ DUJ3hEGdQpYOtlPqO/DU+k0hmWAC8POnbnfgMamo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) by sourceware.org (Postfix) with ESMTPS id 5CB6E3858D28 for ; Mon, 22 Nov 2021 18:54:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5CB6E3858D28 Received: by mail-ua1-x933.google.com with SMTP id b17so38722762uas.0 for ; Mon, 22 Nov 2021 10:54:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qNBXbs5tZkztNZpEWFr5Ejiwe3G3zriwYsMwiK6lx2s=; b=bAhrNygczTvhlSxoHbk9TSkN5+rPS9Znom+oVcWhNmWiET3+ms9tz3lSL5lUfcCf/B t1D5rF0jq+aCB2DXRabgGtD6b1rB3Q1SO3XDrvk4HHoQMhsS8nGnux4FvKUSORcW62aI AMAA7SlUAsD1k591weVMNEHupV8dGMuonxf4Fy3xvgPrfvKqm+POVPH8jMeOq1DTnCyR 4G/rHPfv7oDQKWrNT1J+m2uj2lB3xfO1maos8ebK8GG1Ry0k+W1thzXfk89xt+oMR9jl q94lpTU859OVx3ttHj1T29w+lVM3+QmmDT4Vmd78Ib85QxH65WsbtWAUzqHsy/zWvG+P 4Xaw== X-Gm-Message-State: AOAM530OjN+qyeUZBLLWA7W6l9cHnW9Uu517TasQtG+k1WzzSoWagr68 /sXWOeXLyVICsNJ64vGsOqH2nfl8t6DGjA== X-Google-Smtp-Source: ABdhPJwyjtAVxC4QVMRmfGt60e/f7FAju+WvWdCnvvtezJA7w/RTA+IaCCs6Dbt5WOhbkaWzWBSITQ== X-Received: by 2002:a05:6102:6d6:: with SMTP id m22mr139818965vsg.30.1637607283608; Mon, 22 Nov 2021 10:54:43 -0800 (PST) Received: from birita.. ([2804:431:c7cb:e054:bce6:bc54:280c:f077]) by smtp.gmail.com with ESMTPSA id g187sm5197166vsc.10.2021.11.22.10.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 10:54:43 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 2/6] linux: Add prlimit64 C implementation Date: Mon, 22 Nov 2021 15:54:33 -0300 Message-Id: <20211122185437.1934590-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The LFS prlimit64 requires a arch-specific implementation in syscalls.list. Instead add a generic one that handles the required symbol alias for __RLIM_T_MATCHES_RLIM64_T. HPPA is the only outlier which requires a different default symbol. Checked on x86_64-linux-gnu and with build for the affected ABIs. --- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/arm/syscalls.list | 2 - .../linux/generic/wordsize-32/syscalls.list | 4 -- sysdeps/unix/sysv/linux/hppa/prlimit64.c | 2 + sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 - sysdeps/unix/sysv/linux/i386/syscalls.list | 2 - sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 - .../unix/sysv/linux/microblaze/syscalls.list | 1 - .../unix/sysv/linux/mips/mips32/syscalls.list | 3 -- .../sysv/linux/mips/mips64/n32/syscalls.list | 2 - .../sysv/linux/mips/mips64/n64/syscalls.list | 2 - .../linux/powerpc/powerpc32/syscalls.list | 2 - sysdeps/unix/sysv/linux/prlimit.c | 2 + sysdeps/unix/sysv/linux/prlimit64.c | 39 +++++++++++++++++++ .../sysv/linux/s390/s390-32/syscalls.list | 1 - sysdeps/unix/sysv/linux/sh/syscalls.list | 2 - .../sysv/linux/sparc/sparc32/syscalls.list | 2 - .../unix/sysv/linux/wordsize-64/syscalls.list | 1 - 18 files changed, 44 insertions(+), 27 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list create mode 100644 sysdeps/unix/sysv/linux/hppa/prlimit64.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscalls.list create mode 100644 sysdeps/unix/sysv/linux/prlimit64.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index c5b4f249cc..aa10754b98 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -56,7 +56,7 @@ endif ifeq ($(subdir),misc) sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ setfsuid setfsgid epoll_pwait signalfd \ - eventfd eventfd_read eventfd_write prlimit \ + eventfd eventfd_read eventfd_write prlimit prlimit64 \ personality epoll_wait tee vmsplice splice \ open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \ timerfd_gettime timerfd_settime prctl \ diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list index fa26876f90..55fb065893 100644 --- a/sysdeps/unix/sysv/linux/arm/syscalls.list +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list @@ -15,8 +15,6 @@ getgroups - getgroups32 i:ip __getgroups getgroups setfsgid - setfsgid32 Ei:i setfsgid setfsuid - setfsuid32 Ei:i setfsuid -prlimit64 EXTRA prlimit64 i:iipp prlimit64 - personality EXTRA personality Ei:i __personality personality # proper socket implementations: diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list deleted file mode 100644 index 736edbe654..0000000000 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list +++ /dev/null @@ -1,4 +0,0 @@ -# File name Caller Syscall name # args Strong name Weak names - -# rlimit APIs -prlimit64 EXTRA prlimit64 i:iipp prlimit64 diff --git a/sysdeps/unix/sysv/linux/hppa/prlimit64.c b/sysdeps/unix/sysv/linux/hppa/prlimit64.c new file mode 100644 index 0000000000..4554c81dd9 --- /dev/null +++ b/sysdeps/unix/sysv/linux/hppa/prlimit64.c @@ -0,0 +1,2 @@ +#define VERSION_prlimit64 GLIBC_2_17 +#include diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list index cc5305a585..12e4adeccc 100644 --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list @@ -9,5 +9,4 @@ shutdown - shutdown i:ii __shutdown shutdown socket - socket i:iii __socket socket socketpair - socketpair i:iiif __socketpair socketpair -prlimit64 EXTRA prlimit64 i:iipp __prlimit64 prlimit64@@GLIBC_2.17 personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list index d3eaabe61b..c0ec1af8f3 100644 --- a/sysdeps/unix/sysv/linux/i386/syscalls.list +++ b/sysdeps/unix/sysv/linux/i386/syscalls.list @@ -19,6 +19,4 @@ modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt vm86old EXTRA vm86old i:p __vm86old vm86@GLIBC_2.0 vm86 - vm86 i:ip __vm86 vm86@@GLIBC_2.3.4 -prlimit64 EXTRA prlimit64 i:iipp prlimit64 - personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list index 44c84bf626..0fc117886c 100644 --- a/sysdeps/unix/sysv/linux/m68k/syscalls.list +++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list @@ -16,5 +16,4 @@ setfsgid - setfsgid32 Ei:i setfsgid setfsuid - setfsuid32 Ei:i setfsuid cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush -prlimit64 EXTRA prlimit64 i:iipp prlimit64 personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list index 0abdc38bf3..878ce7e6a2 100644 --- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list +++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list @@ -2,5 +2,4 @@ cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush -prlimit64 EXTRA prlimit64 i:iipp prlimit64 personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list deleted file mode 100644 index dbeb184d73..0000000000 --- a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list +++ /dev/null @@ -1,3 +0,0 @@ -# File name Caller Syscall name # args Strong name Weak names - -prlimit64 EXTRA prlimit64 i:iipp prlimit64 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list index 848028f125..c737eeadc5 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list @@ -4,6 +4,4 @@ # return value. lseek64 - lseek i:iii __lseek64 __libc_lseek64 lseek64@@GLIBC_2.2 llseek@GLIBC_2.0:GLIBC_2.28 -prlimit64 EXTRA prlimit64 i:iipp prlimit64 - personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list index 84f348c8e5..0924f245d4 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list @@ -1,5 +1,3 @@ # File name Caller Syscall name # args Strong name Weak names -prlimit EXTRA prlimit64 i:iipp prlimit prlimit64 - sendfile - sendfile i:iipi sendfile sendfile64 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list index d31303250d..5231da94b2 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list @@ -2,5 +2,3 @@ chown - chown i:sii __chown chown@@GLIBC_2.1 lchown - lchown i:sii __lchown lchown@@GLIBC_2.0 chown@GLIBC_2.0 - -prlimit64 EXTRA prlimit64 i:iipp prlimit64 diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c index c12de52693..f9d9911a04 100644 --- a/sysdeps/unix/sysv/linux/prlimit.c +++ b/sysdeps/unix/sysv/linux/prlimit.c @@ -18,6 +18,7 @@ #include #include +#if !__RLIM_T_MATCHES_RLIM64_T int prlimit (__pid_t pid, enum __rlimit_resource resource, const struct rlimit *new_rlimit, struct rlimit *old_rlimit) @@ -73,3 +74,4 @@ prlimit (__pid_t pid, enum __rlimit_resource resource, return res; } +#endif /* __RLIM_T_MATCHES_RLIM64_T */ diff --git a/sysdeps/unix/sysv/linux/prlimit64.c b/sysdeps/unix/sysv/linux/prlimit64.c new file mode 100644 index 0000000000..e3a8718b98 --- /dev/null +++ b/sysdeps/unix/sysv/linux/prlimit64.c @@ -0,0 +1,39 @@ +/* Get/set resource limits. Linux specific syscall. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#define prlimit __redirect_prlimit +#include +#undef prlimit +#include + +int +__prlimit64 (pid_t pid, enum __rlimit_resource resource, + const struct rlimit64 *new_rlimit, struct rlimit64 *old_rlimit) +{ + return INLINE_SYSCALL_CALL (prlimit64, pid, resource, new_rlimit, + old_rlimit); +} +#ifdef VERSION_prlimit64 +# include +versioned_symbol (libc, __prlimit64, prlimit64, VERSION_prlimit64); +#else +strong_alias (__prlimit64, prlimit64) +# if __RLIM_T_MATCHES_RLIM64_T +strong_alias (prlimit64, prlimit) +# endif +#endif diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list index 8e9b7c4b71..91d78d91ef 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list @@ -15,5 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups setfsgid - setfsgid32 Ei:i setfsgid setfsuid - setfsuid32 Ei:i setfsuid -prlimit64 EXTRA prlimit64 i:iipp prlimit64 personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list index 6ff3e8eb8a..78b2348c05 100644 --- a/sysdeps/unix/sysv/linux/sh/syscalls.list +++ b/sysdeps/unix/sysv/linux/sh/syscalls.list @@ -15,6 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups setfsgid - setfsgid32 Ei:i setfsgid setfsuid - setfsuid32 Ei:i setfsuid -prlimit64 EXTRA prlimit64 i:iipp prlimit64 - personality EXTRA personality Ei:i __personality personality diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list index 4fcae65451..9e4eb0a165 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list @@ -14,5 +14,3 @@ getgroups - getgroups32 i:ip __getgroups getgroups setfsgid - setfsgid32 Ei:i setfsgid setfsuid - setfsuid32 Ei:i setfsuid - -prlimit64 EXTRA prlimit64 i:iipp prlimit64 diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list index 8d97a32344..3232f11f51 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list @@ -1,5 +1,4 @@ # File name Caller Syscall name # args Strong name Weak names sendfile - sendfile i:iipi sendfile sendfile64 -prlimit EXTRA prlimit64 i:iipp prlimit prlimit64 personality EXTRA personality i:i __personality personality From patchwork Mon Nov 22 18:54:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 48006 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B17D53858400 for ; Mon, 22 Nov 2021 18:57:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B17D53858400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637607435; bh=LueJn0+/nQCEwSZ5MwBmXriupquIVtyCKAhleIiPmf8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=J+i1n6AQdywfIG6RJJ6NR3j5zIbfZBGhKHHplEOA8BbWktr3IL1/2RVXqjhI99U5x TaJSzzEBfxjw16bQuyrvyeoMC6/n41VCDHn/84z6O3Gu/vHUP80Ck8sGhm9MDIxCKD g5H9zECeFNIv1Y8rSm1AzLJIAll1RSSHXuSuwL6M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vk1-xa35.google.com (mail-vk1-xa35.google.com [IPv6:2607:f8b0:4864:20::a35]) by sourceware.org (Postfix) with ESMTPS id A7E8F3858415 for ; Mon, 22 Nov 2021 18:54:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A7E8F3858415 Received: by mail-vk1-xa35.google.com with SMTP id d130so10917461vke.0 for ; Mon, 22 Nov 2021 10:54:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LueJn0+/nQCEwSZ5MwBmXriupquIVtyCKAhleIiPmf8=; b=5FGTE0hfR4TqlbvULALQ2yupXV+qjyqpfzESKSh1zYuM4qn7yl1UrCzo97KUaHJeyj xvR1WB3rD6IJDy61/b7cUA+UNKUuE/b7+621SYJ/yqZw3qjDvNksWi+jxO0Z5qpLsxOP Il9bpoEHDineAzYkodojkkCeR9GKtFabcNgFiOswdbxAZtdIAsgfJa08mQMZdgm7QCRP Supltgr43axqgfr3OveX/oT7nYcmh4UW3fXP90KmiOYVgHC1RU48AKLRbS3wfnygna1o QkhGyuQGnnBideZj86ey7MJdMeCbp9MFOsNr8oBt9P8KahfRqwjrOu0eAleKb5NDK1Ei mB+Q== X-Gm-Message-State: AOAM531S3o2VkfxHdVPQRPzZIajH+gEZzYqcwAqSDEGPpPgVvb+rLasE Oro82Zomrctw6ydENp6BC7xjGXPZzjCPtw== X-Google-Smtp-Source: ABdhPJyhmCt3pKY3miGnnk/lcyA5Nh5pcAI2mAN1oeX+RVra86snqG5PPDUlsYjUrr3MtzWEv6BZSw== X-Received: by 2002:a1f:9041:: with SMTP id s62mr34274730vkd.6.1637607284893; Mon, 22 Nov 2021 10:54:44 -0800 (PST) Received: from birita.. ([2804:431:c7cb:e054:bce6:bc54:280c:f077]) by smtp.gmail.com with ESMTPSA id g187sm5197166vsc.10.2021.11.22.10.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 10:54:44 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 3/6] linux: Implement mremap in C Date: Mon, 22 Nov 2021 15:54:34 -0300 Message-Id: <20211122185437.1934590-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Variadic function calls in syscalls.list does not work for all ABIs (for instance where the argument are passed on the stack instead of registers) and might have underlying issues depending of the variadic type (for instance if a 64-bit argument is used). Checked on x86_64-linux-gnu. --- sysdeps/unix/sysv/linux/Makefile | 1 + sysdeps/unix/sysv/linux/mremap.c | 41 +++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/syscalls.list | 1 - 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/mremap.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index aa10754b98..1dd6ec9ef9 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -68,6 +68,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ closefrom_fallback \ clone3 clone-internal \ fanotify_mark \ + mremap \ CFLAGS-gethostid.c = -fexceptions CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables diff --git a/sysdeps/unix/sysv/linux/mremap.c b/sysdeps/unix/sysv/linux/mremap.c new file mode 100644 index 0000000000..83b4e95338 --- /dev/null +++ b/sysdeps/unix/sysv/linux/mremap.c @@ -0,0 +1,41 @@ +/* Remap a virtual memory address. Linux specific syscall. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 +#include +#include +#include + +void * +__mremap (void *addr, size_t old_len, size_t new_len, int flags, ...) +{ + va_list va; + void *new_addr = NULL; + + if (flags & MREMAP_FIXED) + { + va_start (va, flags); + new_addr = va_arg (va, void *); + va_end (va); + } + + return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags, + new_addr); +} +libc_hidden_def (__mremap) +weak_alias (__mremap, mremap) diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 29899eb264..2acd7551d3 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -35,7 +35,6 @@ mincore - mincore i:aUV mincore mlock - mlock i:bU mlock mlockall - mlockall i:i mlockall mount EXTRA mount i:sssUp __mount mount -mremap EXTRA mremap b:aUUip __mremap mremap munlock - munlock i:aU munlock munlockall - munlockall i: munlockall nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28 From patchwork Mon Nov 22 18:54:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 48007 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEC833858010 for ; Mon, 22 Nov 2021 18:57:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEC833858010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637607477; bh=Fnx9oF3ttlLjPaKWhDaXKymj57D6ka4hWCVHIRoI7Kc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=olC941yQAbUtiIR2hRsMY1k1CivS7oFuZyvMs68j1rQ3gOirfTl5/uABEa/cTgDQP 8Mr2lFO7IexlqH0YVca0x7SEqjBUHOejMqX5VMbgbokeAgiXobaRzKgTw/y3dyvesN jptgUj+JL10N4gsOoHwKaUndTozdZ+qgfk6RHK8c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua1-x932.google.com (mail-ua1-x932.google.com [IPv6:2607:f8b0:4864:20::932]) by sourceware.org (Postfix) with ESMTPS id CA0373858017 for ; Mon, 22 Nov 2021 18:54:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CA0373858017 Received: by mail-ua1-x932.google.com with SMTP id b17so38723107uas.0 for ; Mon, 22 Nov 2021 10:54:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fnx9oF3ttlLjPaKWhDaXKymj57D6ka4hWCVHIRoI7Kc=; b=HIgOYExEgMquRjDb25xoJck9nwv7fGY+yE+dE1yjuuvr8dxMLc6G575jITO3xaE9jA t9WJtq18BmPP0N1lSl2JH6P9ytB1uVys8E9qRZGZ/UDyL6WGg3cCvhYcL//9z6F05ANd D02TrNd7Tah1tZrmwTGwDRZZnyXCzgysWJo0T+SX2hqQZeG2PgcLTPnnSKz4AIH+PCtt iiNmXpSG/sgY1AGr6Kn+o7qRwHgn4cHl42FI0h++26FS3pIn5uBjt9Pwd0cqXWQOhfyJ d3T2ZYlky4+yS1cDE7UlosjpCUrBli5AyWRsyNe0NmcUAKIGQNGfpUOe3fGY5stHrkzh //WQ== X-Gm-Message-State: AOAM532gWSPyM35fnZVWrHRtlJKny+e7q1x9HHF89iQ7tMWsT/Hd8eyv +KyxJXC+CodBdnNWQlTL3Nb1t00m7PxdIw== X-Google-Smtp-Source: ABdhPJwKTzarI0i09NLtYAMKwyAAZRsiX/J8OGZVukZugM9A/fTZ150M8KYlIqed1mmbda2RmvWYmA== X-Received: by 2002:ab0:22d6:: with SMTP id z22mr87824395uam.65.1637607287133; Mon, 22 Nov 2021 10:54:47 -0800 (PST) Received: from birita.. ([2804:431:c7cb:e054:bce6:bc54:280c:f077]) by smtp.gmail.com with ESMTPSA id g187sm5197166vsc.10.2021.11.22.10.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 10:54:46 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2 Date: Mon, 22 Nov 2021 15:54:35 -0300 Message-Id: <20211122185437.1934590-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It removes the arch-specific implementation for alpha, ia64, mips, sh, and sparc which requires a different kernel ABI than the usual one. Checked on x86_64-linux-gnu and with a build for the affected ABIs. --- sysdeps/unix/alpha/pipe.S | 30 -------------- sysdeps/unix/mips/pipe.S | 31 --------------- sysdeps/unix/sysv/linux/alpha/pipe.S | 1 - sysdeps/unix/sysv/linux/ia64/pipe.S | 36 ----------------- sysdeps/unix/sysv/linux/mips/pipe.S | 1 - sysdeps/unix/sysv/linux/{generic => }/pipe.c | 5 ++- sysdeps/unix/sysv/linux/sh/pipe.S | 42 -------------------- sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 38 ------------------ sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 39 ------------------ sysdeps/unix/sysv/linux/syscalls.list | 1 - 10 files changed, 3 insertions(+), 221 deletions(-) delete mode 100644 sysdeps/unix/alpha/pipe.S delete mode 100644 sysdeps/unix/mips/pipe.S delete mode 100644 sysdeps/unix/sysv/linux/alpha/pipe.S delete mode 100644 sysdeps/unix/sysv/linux/ia64/pipe.S delete mode 100644 sysdeps/unix/sysv/linux/mips/pipe.S rename sysdeps/unix/sysv/linux/{generic => }/pipe.c (87%) delete mode 100644 sysdeps/unix/sysv/linux/sh/pipe.S delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S diff --git a/sysdeps/unix/alpha/pipe.S b/sysdeps/unix/alpha/pipe.S deleted file mode 100644 index 45944535cd..0000000000 --- a/sysdeps/unix/alpha/pipe.S +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 1993-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - . */ - -/* __pipe is a special syscall since it returns two values. */ - -#include - -PSEUDO (__pipe, pipe, 0) - stl r0, 0(a0) - stl r1, 4(a0) - mov zero, v0 - ret -PSEUDO_END(__pipe) - -libc_hidden_def (__pipe) -weak_alias (__pipe, pipe) diff --git a/sysdeps/unix/mips/pipe.S b/sysdeps/unix/mips/pipe.S deleted file mode 100644 index 6fbea01d44..0000000000 --- a/sysdeps/unix/mips/pipe.S +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 1992-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - -SYSCALL__ (pipe, 1) - /* Plop in the two descriptors. */ - sw v0, 0(a0) - sw v1, 4(a0) - - /* Go out with a clean status. */ - move v0, zero - j ra -PSEUDO_END(__pipe) - -libc_hidden_def (__pipe) -weak_alias (__pipe, pipe) diff --git a/sysdeps/unix/sysv/linux/alpha/pipe.S b/sysdeps/unix/sysv/linux/alpha/pipe.S deleted file mode 100644 index 1e7ec1c199..0000000000 --- a/sysdeps/unix/sysv/linux/alpha/pipe.S +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/ia64/pipe.S b/sysdeps/unix/sysv/linux/ia64/pipe.S deleted file mode 100644 index ffda712920..0000000000 --- a/sysdeps/unix/sysv/linux/ia64/pipe.S +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 1999-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - . */ - -/* __pipe is a special syscall since it returns two values. */ - -#include - -ENTRY(__pipe) - .regstk 1,0,0,0 - DO_CALL (SYS_ify (pipe)) - cmp.ne p6,p0=-1,r10 - ;; -(p6) st4 [in0]=r8,4 -(p6) mov ret0=0 - ;; -(p6) st4 [in0]=r9 -(p6) ret - br.cond.spnt.few __syscall_error -PSEUDO_END(__pipe) - -libc_hidden_def (__pipe) -weak_alias (__pipe, pipe) diff --git a/sysdeps/unix/sysv/linux/mips/pipe.S b/sysdeps/unix/sysv/linux/mips/pipe.S deleted file mode 100644 index 1708888da4..0000000000 --- a/sysdeps/unix/sysv/linux/mips/pipe.S +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/generic/pipe.c b/sysdeps/unix/sysv/linux/pipe.c similarity index 87% rename from sysdeps/unix/sysv/linux/generic/pipe.c rename to sysdeps/unix/sysv/linux/pipe.c index a73a4e89fc..c873bed11a 100644 --- a/sysdeps/unix/sysv/linux/generic/pipe.c +++ b/sysdeps/unix/sysv/linux/pipe.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2011-2021 Free Software Foundation, Inc. +/* Create create pipe. Linux generic version. + Copyright (C) 2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -25,7 +26,7 @@ int __pipe (int __pipedes[2]) { - return INLINE_SYSCALL (pipe2, 2, __pipedes, 0); + return INLINE_SYSCALL_CALL (pipe2, (int *) __pipedes, 0); } libc_hidden_def (__pipe) weak_alias (__pipe, pipe) diff --git a/sysdeps/unix/sysv/linux/sh/pipe.S b/sysdeps/unix/sysv/linux/sh/pipe.S deleted file mode 100644 index 0f3eb16588..0000000000 --- a/sysdeps/unix/sysv/linux/sh/pipe.S +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 1999-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - -ENTRY (__libc_pipe) - mov #+__NR_pipe, r3 - trapa #0x10 - mov r0, r3 - mov #-12, r2 - shad r2, r3 - not r3, r3 // r1=0 means r0 = -1 to -4095 - tst r3, r3 // i.e. error in linux - bt 1f - mov.l r0, @r4 - mov.l r1, @(4, r4) - rts - mov #0, r0 -1: - SYSCALL_ERROR_HANDLER -.Lpseudo_end: - rts - nop -PSEUDO_END (__libc_pipe) - -weak_alias (__libc_pipe, __pipe) -libc_hidden_def (__pipe) -weak_alias (__libc_pipe, pipe) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S deleted file mode 100644 index 0fa155fa61..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 1997-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - - .text - .globl __syscall_error -ENTRY(__libc_pipe) - mov %o0, %o2 /* Save PIPEDES. */ - mov SYS_ify(pipe),%g1 - ta 0x10 - bcc 1f - mov %o7, %g1 - call __syscall_error - mov %g1, %o7 -1: st %o0, [%o2] /* PIPEDES[0] = %o0; */ - st %o1, [%o2 + 4] /* PIPEDES[1] = %o1; */ - retl - clr %o0 -END(__libc_pipe) - -weak_alias (__libc_pipe, __pipe) -libc_hidden_def (__pipe) -weak_alias (__libc_pipe, pipe) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S deleted file mode 100644 index da6ea71729..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1997-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - - .text - - .globl __syscall_error -ENTRY(__libc_pipe) - mov %o0, %o2 /* Save PIPEDES. */ - LOADSYSCALL(pipe) - ta 0x6d - bcc,pt %xcc, 1f - mov %o7, %g1 - call __syscall_error - mov %g1, %o7 -1: st %o0, [%o2] /* PIPEDES[0] = %o0; */ - st %o1, [%o2 + 4] /* PIPEDES[1] = %o1; */ - retl - clr %o0 -END(__libc_pipe) - -weak_alias (__libc_pipe, __pipe) -libc_hidden_def (__pipe) -weak_alias (__libc_pipe, pipe) diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 2acd7551d3..8a32b354a9 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -38,7 +38,6 @@ mount EXTRA mount i:sssUp __mount mount munlock - munlock i:aU munlock munlockall - munlockall i: munlockall nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28 -pipe - pipe i:f __pipe pipe pipe2 - pipe2 i:fi __pipe2 pipe2 pivot_root EXTRA pivot_root i:ss pivot_root query_module EXTRA query_module i:sipip __compat_query_module query_module@GLIBC_2.0:GLIBC_2.23 From patchwork Mon Nov 22 18:54:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 48008 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C62A3858003 for ; Mon, 22 Nov 2021 18:58:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C62A3858003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637607525; bh=VJZ5uuNaiJWTsqLmudcWswLUjvMsVKUi7y5zfpl3kQ8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WmzPtwj74HmcR63g5tW+10SfRpXAO65neo38D4LAwLTk40yssME5MB3oaoPyviVt6 MgPEJvaIQz3rTKHPFuaDFfZa27zGeyy9b0xWAdA9zYs0JGUKeDaZLYSYyx2CaQc1lj s8juGHu3AP+6d0iUVc9VAsGEscZQ7gypsxiDsmu4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com [IPv6:2607:f8b0:4864:20::a2b]) by sourceware.org (Postfix) with ESMTPS id 03C1A385800B for ; Mon, 22 Nov 2021 18:54:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03C1A385800B Received: by mail-vk1-xa2b.google.com with SMTP id m19so10859184vko.12 for ; Mon, 22 Nov 2021 10:54:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VJZ5uuNaiJWTsqLmudcWswLUjvMsVKUi7y5zfpl3kQ8=; b=jAv5mBXr21xAQtU3ZohU8QmuuDL3gkDy0MRysgz9WbSrV/HYygadxjPT0NhoH6ScuM RkVpWeZbwAZQfZj7SpSq/DwB5f7CWXUiU39BLpAbtoAJXOm0kPDCGHK+Q4vGN+vKaXfb 6XcVSlbtPBSHDVweoSKsIMM06vCnDkqnvCz9wW1Yws24Oi9Cx896lUg9tmKyt8IaNv56 ckVE3jXTPJAAjtr/uVVtsOgpeVzhrNkSo/RZhXnh+bwKghJK3T/OtQPnzJ0hQ8etzt4O K0rSESU8eCmbUxF7LB5/GG3YPDOmIWBM+tYd6bK77w+GTDM5tdqf4ja7iI0rq0JuCgrs gKMQ== X-Gm-Message-State: AOAM530qIZnc1oAexCC6S6uJB4M+rClb6azpj6GcgerdhvGHhWOFQtcl 5mnR7swW8DHbKPjlF/ULu6gVxAXBH5zIHw== X-Google-Smtp-Source: ABdhPJxC+u7sDj3MGMTBUeeQDPaXppoG8O7jGjuJhCaIat3TxgeQwZUdnj0NWwYVcv1BDDCAsfi0QA== X-Received: by 2002:ac5:c55a:: with SMTP id d26mr166343311vkl.25.1637607288346; Mon, 22 Nov 2021 10:54:48 -0800 (PST) Received: from birita.. ([2804:431:c7cb:e054:bce6:bc54:280c:f077]) by smtp.gmail.com with ESMTPSA id g187sm5197166vsc.10.2021.11.22.10.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 10:54:48 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 5/6] linux: Add generic syscall implementation Date: Mon, 22 Nov 2021 15:54:36 -0300 Message-Id: <20211122185437.1934590-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It allows also to remove hppa specific implementation and simplify riscv implementation a bit. --- sysdeps/unix/sysdep.h | 20 ++++++++ sysdeps/unix/sysv/linux/hppa/syscall.c | 65 ------------------------- sysdeps/unix/sysv/linux/riscv/syscall.c | 4 +- sysdeps/unix/sysv/linux/syscall.c | 43 ++++++++++++++++ 4 files changed, 65 insertions(+), 67 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/hppa/syscall.c create mode 100644 sysdeps/unix/sysv/linux/syscall.c diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h index 664d093c05..0ecc653838 100644 --- a/sysdeps/unix/sysdep.h +++ b/sysdeps/unix/sysdep.h @@ -57,6 +57,26 @@ #define INTERNAL_SYSCALL_CALL(...) \ __INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL, __VA_ARGS__) +#define __INTERNAL_SYSCALL_NCS0(name) \ + INTERNAL_SYSCALL_NCS (name, 0) +#define __INTERNAL_SYSCALL_NCS1(name, a1) \ + INTERNAL_SYSCALL_NCS (name, 1, a1) +#define __INTERNAL_SYSCALL_NCS2(name, a1, a2) \ + INTERNAL_SYSCALL_NCS (name, 2, a1, a2) +#define __INTERNAL_SYSCALL_NCS3(name, a1, a2, a3) \ + INTERNAL_SYSCALL_NCS (name, 3, a1, a2, a3) +#define __INTERNAL_SYSCALL_NCS4(name, a1, a2, a3, a4) \ + INTERNAL_SYSCALL_NCS (name, 4, a1, a2, a3, a4) +#define __INTERNAL_SYSCALL_NCS5(name, a1, a2, a3, a4, a5) \ + INTERNAL_SYSCALL_NCS (name, 5, a1, a2, a3, a4, a5) +#define __INTERNAL_SYSCALL_NCS6(name, a1, a2, a3, a4, a5, a6) \ + INTERNAL_SYSCALL_NCS (name, 6, a1, a2, a3, a4, a5, a6) +#define __INTERNAL_SYSCALL_NCS7(name, a1, a2, a3, a4, a5, a6, a7) \ + INTERNAL_SYSCALL_NCS (name, 7, a1, a2, a3, a4, a5, a6, a7) + +#define INTERNAL_SYSCALL_NCS_CALL(...) \ + __INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL_NCS, __VA_ARGS__) + #define __INLINE_SYSCALL0(name) \ INLINE_SYSCALL (name, 0) #define __INLINE_SYSCALL1(name, a1) \ diff --git a/sysdeps/unix/sysv/linux/hppa/syscall.c b/sysdeps/unix/sysv/linux/hppa/syscall.c deleted file mode 100644 index bce8c5fa1d..0000000000 --- a/sysdeps/unix/sysv/linux/hppa/syscall.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 1997-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 -#include -#include - -/* HPPA implements syscall() in 'C'; the assembler version would - typically be in syscall.S. Also note that we have INLINE_SYSCALL, - INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers. - How often the function is used is unknown. */ - -long int -syscall (long int __sysno, ...) -{ - /* FIXME: Keep this matching INLINE_SYSCALL for hppa */ - va_list args; - long int arg0, arg1, arg2, arg3, arg4, arg5; - long int __sys_res; - - /* Load varargs */ - va_start (args, __sysno); - arg0 = va_arg (args, long int); - arg1 = va_arg (args, long int); - arg2 = va_arg (args, long int); - arg3 = va_arg (args, long int); - arg4 = va_arg (args, long int); - arg5 = va_arg (args, long int); - va_end (args); - - { - LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5) - register unsigned long int __res asm("r28"); - PIC_REG_DEF - LOAD_REGS_6 - asm volatile (SAVE_ASM_PIC - " ble 0x100(%%sr2, %%r0) \n" - " copy %1, %%r20 \n" - LOAD_ASM_PIC - : "=r" (__res) - : "r" (__sysno) PIC_REG_USE ASM_ARGS_6 - : "memory", CALL_CLOB_REGS CLOB_ARGS_6); - __sys_res = __res; - } - if ((unsigned long int) __sys_res >= (unsigned long int) -4095) - { - __set_errno (-__sys_res); - __sys_res = -1; - } - return __sys_res; -} diff --git a/sysdeps/unix/sysv/linux/riscv/syscall.c b/sysdeps/unix/sysv/linux/riscv/syscall.c index 2748afcd90..f46aa77b00 100644 --- a/sysdeps/unix/sysv/linux/riscv/syscall.c +++ b/sysdeps/unix/sysv/linux/riscv/syscall.c @@ -24,8 +24,8 @@ syscall (long int syscall_number, long int arg1, long int arg2, long int arg3, { long int ret; - ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4, - arg5, arg6, arg7); + ret = INTERNAL_SYSCALL_NCS_CALL (syscall_number, arg1, arg2, arg3, arg4, + arg5, arg6, arg7); if (INTERNAL_SYSCALL_ERROR_P (ret)) return __syscall_error (ret); diff --git a/sysdeps/unix/sysv/linux/syscall.c b/sysdeps/unix/sysv/linux/syscall.c new file mode 100644 index 0000000000..5d87428756 --- /dev/null +++ b/sysdeps/unix/sysv/linux/syscall.c @@ -0,0 +1,43 @@ +/* Indirect system call. Linux generic implementation. + Copyright (C) 1997-2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 +#include + +long int +syscall (long int number, ...) +{ + va_list args; + + va_start (args, number); + long int a0 = va_arg (args, long int); + long int a1 = va_arg (args, long int); + long int a2 = va_arg (args, long int); + long int a3 = va_arg (args, long int); + long int a4 = va_arg (args, long int); + long int a5 = va_arg (args, long int); + va_end (args); + + int r = INTERNAL_SYSCALL_NCS_CALL (number, a0, a1, a2, a3, a4, a5); + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r))) + { + __set_errno (-r); + return -1; + } + return r; +} From patchwork Mon Nov 22 18:54:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 48009 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5CE1F3858438 for ; Mon, 22 Nov 2021 18:59:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CE1F3858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637607567; bh=58UPkFEtvEB3RPhyhj7SHRGqE1cU0SC/Y4pr6nD0da4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eBjcTZ24+2r3l9JaPtuQuICTyTbbmCkwAA+0d1+G2uRhkq5G4kuVWhfUlpFLlzNB8 kpEagcF9hWURNDKNPJb8DoKb+4NRq1aTXUUTiudo6e+EGoQSTUkEnQddq1V5Vfw6zO QxIEa8CdXf/E80QbzMJ609jxdQIUvVuhmMG1jWEk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua1-x92c.google.com (mail-ua1-x92c.google.com [IPv6:2607:f8b0:4864:20::92c]) by sourceware.org (Postfix) with ESMTPS id D2743385840A for ; Mon, 22 Nov 2021 18:54:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D2743385840A Received: by mail-ua1-x92c.google.com with SMTP id p37so38587098uae.8 for ; Mon, 22 Nov 2021 10:54:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=58UPkFEtvEB3RPhyhj7SHRGqE1cU0SC/Y4pr6nD0da4=; b=oQAydzIvEtRyf0oNxRmn0+cC81HUR/0grIBf2rWPanYrT0qZTWdzgRAv1hbtLLtWhD 7vIogcYgUwiNxFDaSHxkXlz85YdBmnwy8GWKVGchk08mVi5NZ77x/WD/j5p3JYF8seza l/kYLITxbjytz6V5zALa9jgw9FZHPryVqBuPavyvcObAGctj3Z+0EE0Rszxr8KEoU/Rw 6dMa9Uo5L3UrvDJgp1felAVbL7Twb3EE8MPjWg7n4z0pczSqI/vPRvuNxEXHrOjXLgmz vX98TE8m0lqWBCEzHAS5KykAwbdef9sp59kJFpwml5ES3zaxPH/2ZiclSf70rh2zf3tt MyRg== X-Gm-Message-State: AOAM5314Zl/cc/qKxmhREoJ+/+DxQ3ckx4+y7G/WsOoA3OS9v7XDHhd7 JTNphfkUZUIxCNViJkc/5ECk8MdR5HraAw== X-Google-Smtp-Source: ABdhPJziu2VVuRjhvJLdglYdnaxIjYL7h2PWZ4RU7n5q1Uh40aTkDWrKHlvHvdpit3bTHXgSC7yk5g== X-Received: by 2002:a9f:30cf:: with SMTP id k15mr620864uab.21.1637607289709; Mon, 22 Nov 2021 10:54:49 -0800 (PST) Received: from birita.. ([2804:431:c7cb:e054:bce6:bc54:280c:f077]) by smtp.gmail.com with ESMTPSA id g187sm5197166vsc.10.2021.11.22.10.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 10:54:49 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 6/6] linux: Add generic ioctl implementation Date: Mon, 22 Nov 2021 15:54:37 -0300 Message-Id: <20211122185437.1934590-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> References: <20211122185437.1934590-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The powerpc is refactor to use the default implementation. --- sysdeps/unix/sysv/linux/internal-ioctl.h | 25 +++++++ sysdeps/unix/sysv/linux/ioctl.c | 49 +++++++++++++ .../unix/sysv/linux/powerpc/internal-ioctl.h | 46 +++++++++++++ sysdeps/unix/sysv/linux/powerpc/ioctl.c | 68 ------------------- 4 files changed, 120 insertions(+), 68 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/internal-ioctl.h create mode 100644 sysdeps/unix/sysv/linux/ioctl.c create mode 100644 sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h delete mode 100644 sysdeps/unix/sysv/linux/powerpc/ioctl.c diff --git a/sysdeps/unix/sysv/linux/internal-ioctl.h b/sysdeps/unix/sysv/linux/internal-ioctl.h new file mode 100644 index 0000000000..ecd48d5d6e --- /dev/null +++ b/sysdeps/unix/sysv/linux/internal-ioctl.h @@ -0,0 +1,25 @@ +/* Linux internal definitions for ioctl. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +/* Architecture ports may choose to override this default implementation + to provide architecture specific ioctl support. */ +static inline bool +__ioctl_arch (int *r, int fd, unsigned long request, void *arg) +{ + return false; +} diff --git a/sysdeps/unix/sysv/linux/ioctl.c b/sysdeps/unix/sysv/linux/ioctl.c new file mode 100644 index 0000000000..c4855d6302 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ioctl.c @@ -0,0 +1,49 @@ +/* Control device. Linux generic implementation. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 +#include +#include +#include + +int +__ioctl (int fd, unsigned long int request, ...) +{ + va_list args; + va_start (args, request); + void *arg = va_arg (args, void *); + va_end (args); + + int r; + if (!__ioctl_arch (&r, fd, request, arg)) + { + r = INTERNAL_SYSCALL_CALL (ioctl, fd, request, arg); + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r))) + { + __set_errno (-r); + return -1; + } + } + return r; +} +libc_hidden_def (__ioctl) +weak_alias (__ioctl, ioctl) + +#if __TIMESIZE != 64 +strong_alias (__ioctl, __ioctl_time64) +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h b/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h new file mode 100644 index 0000000000..3a2adce7c3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h @@ -0,0 +1,46 @@ +/* Linux internal definitions for ioctl. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + +static inline bool +__ioctl_arch (int *r, int fd, unsigned long request, void *arg) +{ + switch (request) + { + case TCGETS: + *r = __tcgetattr (fd, (struct termios *) arg); + break; + + case TCSETS: + *r = __tcsetattr (fd, TCSANOW, (struct termios *) arg); + break; + + case TCSETSW: + *r = __tcsetattr (fd, TCSADRAIN, (struct termios *) arg); + break; + + case TCSETSF: + *r = __tcsetattr (fd, TCSAFLUSH, (struct termios *) arg); + break; + + default: + return false; + } + return true; +} diff --git a/sysdeps/unix/sysv/linux/powerpc/ioctl.c b/sysdeps/unix/sysv/linux/powerpc/ioctl.c deleted file mode 100644 index a81c7ba54c..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/ioctl.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 1998-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 -#include -#include -#include -#include - -/* The user-visible size of struct termios has changed. Catch ioctl calls - using the new-style struct termios, and translate them to old-style. */ - -int -__ioctl (int fd, unsigned long int request, ...) -{ - void *arg; - va_list ap; - int result; - - va_start (ap, request); - arg = va_arg (ap, void *); - - switch (request) - { - case TCGETS: - result = __tcgetattr (fd, (struct termios *) arg); - break; - - case TCSETS: - result = __tcsetattr (fd, TCSANOW, (struct termios *) arg); - break; - - case TCSETSW: - result = __tcsetattr (fd, TCSADRAIN, (struct termios *) arg); - break; - - case TCSETSF: - result = __tcsetattr (fd, TCSAFLUSH, (struct termios *) arg); - break; - - default: - result = INLINE_SYSCALL (ioctl, 3, fd, request, arg); - break; - } - - va_end (ap); - - return result; -} -libc_hidden_def (__ioctl) -weak_alias (__ioctl, ioctl) -#if __TIMESIZE != 64 -weak_alias (__ioctl, __ioctl_time64) -#endif