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 Netto 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 Netto 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