From patchwork Wed Nov 18 19:55:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 41120 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 533BA3947C0B; Wed, 18 Nov 2020 19:56:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 533BA3947C0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605729392; bh=1NuOsrUAWLQZ0uayx/c3FKkgqZiYDqVU2UysWnIppJ4=; 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=QQTk96NWHN74WqvJQCoruDneemFmWYsudYB5fQFZfMGpTLaH23ev93zGIGlPuZTdE 4ZT9qgRNHVA1t+xWuhN/zpmk3WDLHB4RnJr/UhC6QdV+yor5fBJEm7mZdLyUbDjMky HN4bhQ0R/XI0Yw0z/i4ywtPH3ErMpPAo/oD7PeMw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by sourceware.org (Postfix) with ESMTPS id 37C413945C15 for ; Wed, 18 Nov 2020 19:56:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 37C413945C15 Received: by mail-qk1-x741.google.com with SMTP id d28so3038870qka.11 for ; Wed, 18 Nov 2020 11:56:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1NuOsrUAWLQZ0uayx/c3FKkgqZiYDqVU2UysWnIppJ4=; b=k54I+jhHB9O06/ppIhWkqk0LM1r51+/FM3LYCmqA0FRAry2xYmzFcVru+U0d/p17F7 tPXp1kBCi1JPzmAJwvb/xYMsVtrthYcZtL6eczxqesreg9n2kwyp6vSCf8FLDdNf5fWD pcyR5Had+P511op9jssKqKVS0ogfyKo9ytfijtmAuOzI1hRc43ruZyQevqfbwIs62v30 RXQxspAbWTxRLOB2sBuJfP6Zl0bTMTnkCnJpL4EdMGVTuGJkwMEmbBowJU0jZ2sqT7D0 PsYIwrTycXR0oG+oRVaaSYv1yV8gtnzifnnotIzZJLzaV9YlxyqgfBP7YPaMh4zu8TNC Wing== X-Gm-Message-State: AOAM5327ZmSfadiLDanUK/mnME+jV1MrTz8e7OaC16fJGPjqjAVKNQdG ZySq6X0xOCOUxnRftEervlAjNvV606f46A== X-Google-Smtp-Source: ABdhPJx5CbVfvonZs6t+dhYU1Du85JaLK1BtAKxKIgfuH26JRFbcG1v3lZs4WecTFPql5OPGD+0jXg== X-Received: by 2002:a05:620a:218b:: with SMTP id g11mr6965221qka.190.1605729387467; Wed, 18 Nov 2020 11:56:27 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id f27sm6538775qtv.95.2020.11.18.11.56.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 11:56:27 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 21/28] linux: Implement mremap in C Date: Wed, 18 Nov 2020 16:55:45 -0300 Message-Id: <20201118195552.2687336-22-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201118195552.2687336-1-adhemerval.zanella@linaro.org> References: <20201118195552.2687336-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@sourceware.org Sender: "Libc-alpha" This avoid variadic function in syscalls.list and the possible mismatch between the asm syscall macros the required ABI to handle the variadic argument. Checked on x86_64-linux-gnu. --- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/mremap.c | 41 +++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/syscalls.list | 1 - 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/mremap.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index c3b24f9332..68818862dd 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -61,7 +61,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \ timerfd_gettime timerfd_settime prctl \ process_vm_readv process_vm_writev clock_adjtime \ - time64-support pselect32 fanotify_mark + time64-support pselect32 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 01ec2bfa95..7a0172a422 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