public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/syscall-refactor] Linux: Implement remap in C
@ 2020-06-29 21:47 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2020-06-29 21:47 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d414f734633f73e69e7301fba26b182f4ab29e4e

commit d414f734633f73e69e7301fba26b182f4ab29e4e
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jun 17 09:29:07 2020 -0300

    Linux: Implement remap in C

Diff:
---
 sysdeps/unix/sysv/linux/Makefile |  2 +-
 sysdeps/unix/sysv/linux/mremap.c | 41 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index daa55eb9bf..b298f05e4e 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 \
-		   fanotify_mark
+		   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..f8a62ce225
--- /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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/mman.h>
+#include <sysdep.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+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 (__NR_mremap, addr, old_len, new_len, flags,
+				  new_addr);
+}
+libc_hidden_def (__mremap)
+weak_alias (__mremap, mremap)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-29 21:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 21:47 [glibc/azanella/syscall-refactor] Linux: Implement remap in C Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).