From patchwork Wed Jul 17 07:59:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1961465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=PqIPKqob; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WP7f25L3Wz1xqc for ; Wed, 17 Jul 2024 18:00:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A139385DDE8 for ; Wed, 17 Jul 2024 08:00:25 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by sourceware.org (Postfix) with ESMTPS id 12FCB3861000 for ; Wed, 17 Jul 2024 07:59:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12FCB3861000 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 12FCB3861000 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721203155; cv=none; b=UvdPgDK4W/Ckvm9RuDdFM3Z39CgJ+2bjrkJTbmzhJ7HcACeLPDrJO92lXYUw+6tXQt9mw6Zk/ENR1cQdX6t+UUeV90srdB3a226Q1FiqINeZiPdX4ooDu/HDZfSwNlbPFJmYLrwEsefihSslqQxEmOJ4yhUi7q3OdCDjBS1VRGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721203155; c=relaxed/simple; bh=ZTnjx/dq/wb+0f1G3F97JisWoMPqLhvkZVXT3aKdy1Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=QlRbzf5t/XzdySCN6b/QjhQn1rgnTisy5yD4tA4ciUZNb1UgkKPD28agW4h9rRBaIeVy/i/+uRv2/wdTWnx3vxVbNwvehoBHqS5eEo/TFHFLgy0oR8nQhwQxpMIWdlNXEk8EhJ5vQ1mg2K/Cjrzb7usCpM40XZUC9KVv4GP9cB8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-65f771485f2so39116637b3.0 for ; Wed, 17 Jul 2024 00:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721203150; x=1721807950; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=E4lE6YPiFsuWnZPTX+n/UxR2QhjzBcJuKRgmUSjcoSs=; b=PqIPKqobnZfjBkSSxNCbj6i9wZkKi2x6EvlAtl4ogBQwoXEzo2ell9tNvQNnHVH4Tb iF6q/YABA5GtnbGCNK3wYiwCIJAvzyJQHn5TwTmzTF3rtP72AgTt7g/gARr77E9mtuQN fsOgzC6XjG1A/RI5CfZkODoyGNx/ghCdharVbQTdCGlgOSnUgQWiiQIy0UEJOy69DWyB 4wKb+Ipc3776sPOqcMEfnXzt7l86Os17kg7IMgM9pon/oO86gkakCn0jyDuFcveBja6F GkBrwLnCKHipnDSM6Gtc2DH+ytRMgtRyysxReYkA3xH7s3dVZTnMEErZ08A0eo1Jig05 CISA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721203150; x=1721807950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E4lE6YPiFsuWnZPTX+n/UxR2QhjzBcJuKRgmUSjcoSs=; b=uNDFxaV8fUwiLEKIldBNRVw9h2v4aoEDji0Uv9rL6Yc53bZawwjD1hh0EiayixZJ5Y gkZtQqXTzk8rTz64HySDgIbQUBg6lrmCvaQk/+9mVZm1B84uFBVVprQQZQsNfSG2u4YU Paj1rbMGjUqZtyxSTDsGeCiImqHTnGFTPO1uX4a0oWN/7uniVn/sch6EXtyCrxNsqHDU 2AN1sDQS6C2kcAiz79XWGieUEU5RZX4GrdzDnBsimA8JfTf8Zk9HXkY4dfs0gmq/T2aS fhIRBPMO/EeqDMgBy5gNXU5jRo7YhWIwT+KS7bkobiI+/OiPt1ooDWUVaY+7URtlyBG5 iC0w== X-Gm-Message-State: AOJu0YyB6I/Qt8TcakYpEkxvzgKN7OSwTlgNAve8K/qmuxr5l0dxxrqY aXWtwWzAm6TyaTU5Ss/RuQ11NeZKDbf4GGjbez4e4x8XOmUiXUeU//z7c9+6zxVrRw== X-Google-Smtp-Source: AGHT+IHphnhk0SCBmvWxQKz4h5GsfsxZHklsfztsf5g8/vfiaCOvweV6QPvwVaOzgzVQlMWsQGukiw== X-Received: by 2002:a81:6e8b:0:b0:64b:4a9f:540d with SMTP id 00721157ae682-664ffcc457emr11426537b3.31.1721203150030; Wed, 17 Jul 2024 00:59:10 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.58.30.168]) by smtp.gmail.com with ESMTPSA id 00721157ae682-65fc445204csm14552417b3.127.2024.07.17.00.59.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jul 2024 00:59:09 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 2AB45C044B for ; Wed, 17 Jul 2024 00:59:05 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH v3 3/3] Add mremap tests Date: Wed, 17 Jul 2024 00:59:04 -0700 Message-ID: <20240717075904.2365688-4-hjl.tools@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717075904.2365688-1-hjl.tools@gmail.com> References: <20240717075904.2365688-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3019.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Add tests for MREMAP_MAYMOVE and MREMAP_FIXED. On Linux, also test MREMAP_DONTUNMAP. Since MREMAP_FIXED was added to Linux kernel 2.3.31 and MREMAP_DONTUNMAP was added to Linux kernel 5.7, mark test failure if MREMAP_FIXED and MREMAP_DONTUNMAP tests fail on supported Linux kernel. Signed-off-by: H.J. Lu --- misc/Makefile | 2 + misc/tst-mremap1.c | 46 ++++++++++++++ misc/tst-mremap2.c | 54 ++++++++++++++++ sysdeps/generic/mremap-failure.h | 26 ++++++++ sysdeps/unix/sysv/linux/Makefile | 9 +++ .../unix/sysv/linux/linux-kernel-version.c | 62 ++++++++++++++++++ sysdeps/unix/sysv/linux/linux-support.h | 38 +++++++++++ sysdeps/unix/sysv/linux/mremap-failure.h | 47 ++++++++++++++ sysdeps/unix/sysv/linux/tst-linux-mremap1.c | 63 +++++++++++++++++++ 9 files changed, 347 insertions(+) create mode 100644 misc/tst-mremap1.c create mode 100644 misc/tst-mremap2.c create mode 100644 sysdeps/generic/mremap-failure.h create mode 100644 sysdeps/unix/sysv/linux/linux-kernel-version.c create mode 100644 sysdeps/unix/sysv/linux/linux-support.h create mode 100644 sysdeps/unix/sysv/linux/mremap-failure.h create mode 100644 sysdeps/unix/sysv/linux/tst-linux-mremap1.c diff --git a/misc/Makefile b/misc/Makefile index 5d17c562fe..7b7f8351bf 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -257,6 +257,8 @@ tests := \ tst-mntent-blank-passno \ tst-mntent-escape \ tst-mntent2 \ + tst-mremap1 \ + tst-mremap2 \ tst-preadvwritev \ tst-preadvwritev2 \ tst-preadvwritev64 \ diff --git a/misc/tst-mremap1.c b/misc/tst-mremap1.c new file mode 100644 index 0000000000..0469991a6c --- /dev/null +++ b/misc/tst-mremap1.c @@ -0,0 +1,46 @@ +/* Test mremap with MREMAP_MAYMOVE. + Copyright (C) 2024 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 +#include + +static int +do_test (void) +{ + size_t old_size = getpagesize (); + char *old_addr = xmmap (NULL, old_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1); + old_addr[0] = 1; + old_addr[old_size - 1] = 2; + + /* Test MREMAP_MAYMOVE. */ + size_t new_size = old_size + old_size; + char *new_addr = mremap (old_addr, old_size, new_size, MREMAP_MAYMOVE); + TEST_VERIFY_EXIT (new_addr != MAP_FAILED); + new_addr[0] = 1; + new_addr[new_size - 1] = 2; + xmunmap (new_addr, new_size); + + return 0; +} + +#include diff --git a/misc/tst-mremap2.c b/misc/tst-mremap2.c new file mode 100644 index 0000000000..58591d43c3 --- /dev/null +++ b/misc/tst-mremap2.c @@ -0,0 +1,54 @@ +/* Test mremap with MREMAP_FIXED. + Copyright (C) 2024 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 +#include + +static int +do_test (void) +{ + size_t old_size = getpagesize (); + size_t new_size = old_size + old_size; + char *old_addr = xmmap (NULL, old_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1); + old_addr[0] = 1; + old_addr[old_size - 1] = 2; + + char *fixed_addr = xmmap (NULL, new_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1); + fixed_addr[0] = 1; + fixed_addr[new_size - 1] = 2; + + /* Test MREMAP_FIXED. */ + char *new_addr = mremap (old_addr, old_size, new_size, + MREMAP_FIXED | MREMAP_MAYMOVE, + fixed_addr); + if (new_addr == MAP_FAILED) + return mremap_failure_exit (errno, MREMAP_FIXED); + new_addr[0] = 1; + new_addr[new_size - 1] = 2; + xmunmap (new_addr, new_size); + + return 0; +} + +#include diff --git a/sysdeps/generic/mremap-failure.h b/sysdeps/generic/mremap-failure.h new file mode 100644 index 0000000000..139a6b1fa2 --- /dev/null +++ b/sysdeps/generic/mremap-failure.h @@ -0,0 +1,26 @@ +/* mremap failure handling. Generic version. + Copyright (C) 2024 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 + . */ + +/* Return exit value on mremap failure with errno ERR when FLAGS is + passed to mremap. */ + +static int +mremap_failure_exit (int err, int flags) +{ + return EXIT_FAILURE; +} diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 097b5a26fc..c464f85bb7 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -206,6 +206,7 @@ tests += \ tst-getauxval \ tst-gettid \ tst-gettid-kill \ + tst-linux-mremap1 \ tst-memfd_create \ tst-misalign-clone \ tst-mlock2 \ @@ -661,3 +662,11 @@ tests-internal += \ tst-rseq-nptl \ # tests-internal endif + +ifeq ($(subdir),support) +linux-support-routines += \ + linux-kernel-version \ +# linux-support-routines +libsupport-routines += $(linux-support-routines) +libsupport-static-only-routines += $(linux-support-routines) +endif diff --git a/sysdeps/unix/sysv/linux/linux-kernel-version.c b/sysdeps/unix/sysv/linux/linux-kernel-version.c new file mode 100644 index 0000000000..2968c528b6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/linux-kernel-version.c @@ -0,0 +1,62 @@ +/* Initialize CPU feature data. AArch64 version. + This file is part of the GNU C Library. + Copyright (C) 2017-2024 Free Software Foundation, Inc. + + 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 + +unsigned int +make_linux_kernel_version (unsigned int version, unsigned int patch, + unsigned int sub) +{ + TEST_VERIFY_EXIT (version <= 0xff); + TEST_VERIFY_EXIT (patch <= 0xff); + TEST_VERIFY_EXIT (sub <= 0xffff); + /* Return an unsigned int with VVPPSSSS. */ + return (version << 24) | (patch << 16) | sub; +} + +unsigned int +get_linux_kernel_version (void) +{ + struct utsname buf; + const char *p = &buf.release[0]; + unsigned int version; + unsigned int patch; + unsigned int sub; + + TEST_VERIFY_EXIT (uname (&buf) == 0); + + /* Get kernel version. */ + for (version = 0; *p >= '0' && *p <= '9'; p++) + version = version * 10 + *p - '0'; + TEST_VERIFY_EXIT (*p == '.'); + p++; + + /* Get kernel patch level. */ + for (patch = 0; *p >= '0' && *p <= '9'; p++) + patch = patch * 10 + *p - '0'; + TEST_VERIFY_EXIT (*p == '.'); + p++; + + /* Get kernel sub level. */ + for (sub = 0; *p >= '0' && *p <= '9'; p++) + sub = sub * 10 + *p - '0'; + + return make_linux_kernel_version (version, patch, sub); +} diff --git a/sysdeps/unix/sysv/linux/linux-support.h b/sysdeps/unix/sysv/linux/linux-support.h new file mode 100644 index 0000000000..a7c03040b1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/linux-support.h @@ -0,0 +1,38 @@ +/* Linux-specific support functions. + Copyright (C) 2024 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 + . */ + +#ifndef LINUX_SUPPORT_H +#define LINUX_SUPPORT_H + +#include + +__BEGIN_DECLS + +/* Return an unsigned int from version, patch level and sub level of + Linux kernel. */ +extern unsigned int make_linux_kernel_version (unsigned int __version, + unsigned int __patch, + unsigned int __sub); + +/* Similar to make_linux_kernel_version, but version, patch level and + sub level are retrieved from the uname system call. */ +extern unsigned int get_linux_kernel_version (void); + +__END_DECLS + +#endif /* LINUX_SUPPORT_H */ diff --git a/sysdeps/unix/sysv/linux/mremap-failure.h b/sysdeps/unix/sysv/linux/mremap-failure.h new file mode 100644 index 0000000000..bf6ffb819c --- /dev/null +++ b/sysdeps/unix/sysv/linux/mremap-failure.h @@ -0,0 +1,47 @@ +/* mremap failure handling. Linux version. + Copyright (C) 2024 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 + +/* Return exit value on mremap failure with errno ERR when FLAGS is + passed to mremap. */ + +static int +mremap_failure_exit (int err, int flags) +{ + if (err != EINVAL) + return EXIT_FAILURE; + + unsigned int kernel = get_linux_kernel_version (); + TEST_VERIFY_EXIT (kernel != 0); + + /* Since MREMAP_FIXED was added to Linux kernel 2.3.31, return + EXIT_FAILURE if the kernel is 2.3.31 or newer. */ + if (flags == MREMAP_FIXED + && kernel >= make_linux_kernel_version (2, 3, 31)) + return EXIT_FAILURE; + + /* Since MREMAP_DONTUNMAP was added to Linux kernel 5.7, return + EXIT_FAILURE if the kernel is 5.7 or newer. */ + if (flags == MREMAP_DONTUNMAP + && kernel >= make_linux_kernel_version (5, 7, 0)) + return EXIT_FAILURE; + + return EXIT_UNSUPPORTED; +} diff --git a/sysdeps/unix/sysv/linux/tst-linux-mremap1.c b/sysdeps/unix/sysv/linux/tst-linux-mremap1.c new file mode 100644 index 0000000000..599f6a6009 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-linux-mremap1.c @@ -0,0 +1,63 @@ +/* Test mremap with MREMAP_DONTUNMAP. + Copyright (C) 2024 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 +#include +#include + +static int +do_test (void) +{ + size_t old_size = getpagesize (); + size_t new_size = old_size; + char *old_addr = xmmap (NULL, old_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1); + old_addr[0] = 1; + old_addr[old_size - 1] = 2; + + /* Create an available 64-page mmap region. */ + size_t fixed_size = old_size * 64; + char *fixed_addr = xmmap (NULL, fixed_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1); + xmunmap (fixed_addr, fixed_size); + + /* Add 3 * pagesize. */ + fixed_size += 3 * old_size; + + /* Test MREMAP_DONTUNMAP. It should return FIXED_ADDR created above. */ + char *new_addr = mremap (old_addr, old_size, new_size, + MREMAP_DONTUNMAP | MREMAP_MAYMOVE, + fixed_addr); + if (new_addr == MAP_FAILED) + return mremap_failure_exit (errno, MREMAP_DONTUNMAP); + TEST_VERIFY_EXIT (fixed_addr == new_addr); + old_addr[0] = 3; + old_addr[old_size - 1] = 4; + new_addr[0] = 1; + new_addr[new_size - 1] = 2; + xmunmap (new_addr, new_size); + xmunmap (old_addr, old_size); + + return 0; +} + +#include