bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mremap


From: Thomas Schwinge
Subject: mremap
Date: Sun, 26 Apr 2009 12:53:19 +0200
User-agent: Mutt/1.5.11

Hello!

    /home/thomas/tmp/source/glibc/work.new.build.gnu-1/locale/locarchive.o: In 
function `file_data_available_p':
    /home/thomas/tmp/source/glibc/work.new/locale/programs/locarchive.c:263: 
undefined reference to `mremap'
    /home/thomas/tmp/source/glibc/work.new.build.gnu-1/locale/locarchive.o: In 
function `enlarge_archive':
    /home/thomas/tmp/source/glibc/work.new/locale/programs/locarchive.c:315: 
undefined reference to `mremap'

That is, glibc is now unconditionally using mremap (in locale code).
However, mremap is not available on GNU/Hurd.  It is a syscall for Linux.

Why isn't there a generic ENOSYS stub for mremap?  I attached one.  How
to do symbol versioning?  sysdeps/unix/sysv/linux/Versions has it defined
for GLIBC_2.0.  What to do now in misc/Versions?

Other uses of mremap: in the malloc code, #if linux is used.  The other
use of mremap in libio/fileops.c is protected by _G_HAVE_MREMAP.  This
definition (previously also #if linux) was introduced by Marcus in 2004,
c.f. <http://sourceware.org/ml/libc-alpha/2004-11/msg00065.html>.  This
definiton of _G_HAVE_MREMAP still is the only difference between
sysdeps/gnu/_G_config.h and the then-introduced
sysdeps/mach/hurd/_G_config.h.  In libio/fileops.c, if _G_HAVE_MREMAP is
not defined, a fallback code-path of munmap followed by mmap is chosen.
Wouldn't it be possible to generalize this (for the MREMAP_MAYMOVE case)
in the otherwise-ENOSYS stub?


2009-04-26  Thomas Schwinge  <tschwinge@gnu.org>

        * misc/Makefile (routines): Add mremap.
        * misc/Versions: TODO.
        * misc/mremap.c: New file.

diff --git a/misc/Makefile b/misc/Makefile
index 1357634..240ac79 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -55,7 +55,8 @@ routines := brk sbrk sstk ioctl \
            chflags fchflags \
            insremque getttyent getusershell getpass ttyslot \
            syslog syscall daemon \
-           mmap mmap64 munmap mprotect msync madvise mincore remap_file_pages\
+           mmap mmap64 munmap mprotect msync madvise mincore mremap \
+           remap_file_pages \
            mlock munlock mlockall munlockall \
            efgcvt efgcvt_r qefgcvt qefgcvt_r \
            hsearch hsearch_r tsearch lsearch \
diff --git a/misc/mremap.c b/misc/mremap.c
index e69de29..7d40f0b 100644
--- a/misc/mremap.c
+++ b/misc/mremap.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2009 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+/* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length
+   NEW_LEN.  If MREMAP_MAYMOVE is set in FLAGS the returned address
+   may differ from ADDR.  If MREMAP_FIXED is set in FLAGS the function
+   takes another paramter which is a fixed address at which the block
+   resides after a successful call.  */
+void *
+__mremap (void *__addr, size_t __old_len, size_t __new_len,
+       int __flags, ...)
+{
+  __set_errno (ENOSYS);
+  return MAP_FAILED;
+}
+
+stub_warning (mremap)
+#include <stub-tag.h>
+weak_alias (__mremap, mremap)


Regards,
 Thomas

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]