]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Eliminated VGP_DO_MMAP. Replaced it with VG_(mmap_native)(), which was
authorNicholas Nethercote <njn@valgrind.org>
Sun, 29 May 2005 18:46:38 +0000 (18:46 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 29 May 2005 18:46:38 +0000 (18:46 +0000)
derived from mmap_inner().

As a consequence, $PLATFORM/core_platform.h files are no longer necessary,
hooray!

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3813

coregrind/amd64-linux/Makefile.am
coregrind/amd64-linux/core_platform.h [deleted file]
coregrind/arm-linux/Makefile.am
coregrind/arm-linux/core_platform.h [deleted file]
coregrind/core.h
coregrind/m_aspacemgr/aspacemgr.c
coregrind/m_syscalls/syscalls.c
coregrind/vg_mylibc.c
coregrind/x86-linux/Makefile.am
coregrind/x86-linux/core_platform.h [deleted file]
docs/porting-HOWTO

index 96f3688d63ad047dfcd9e4d57512b04af470ff6f..c485764a82154fe673dccc7403e11d60b8eadb5e 100644 (file)
@@ -2,5 +2,4 @@ include $(top_srcdir)/Makefile.all.am
 include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
 
 noinst_HEADERS = \
-       core_platform.h \
        vki_unistd.h
diff --git a/coregrind/amd64-linux/core_platform.h b/coregrind/amd64-linux/core_platform.h
deleted file mode 100644 (file)
index 9ac384c..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Platform-specific stuff for the core.                        ---*/
-/*---                                  amd64-linux/core_platform.h ---*/
-/*--------------------------------------------------------------------*/
-
-/*
-   This file is part of Valgrind, a dynamic binary instrumentation
-   framework.
-
-   Copyright (C) 2000-2005 Nicholas Nethercote
-      njn@valgrind.org
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   This program 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
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307, USA.
-
-   The GNU General Public License is contained in the file COPYING.
-*/
-
-#ifndef __AMD64_LINUX_CORE_PLATFORM_H
-#define __AMD64_LINUX_CORE_PLATFORM_H
-
-/* ---------------------------------------------------------------------
-   mmap() stuff
-   ------------------------------------------------------------------ */
-
-#define VGP_DO_MMAP(ret, start, length, prot, flags, fd, offset) { \
-   ret = VG_(do_syscall6)(__NR_mmap, (UWord)(start), (length),          \
-                         (prot), (flags), (fd), (offset));              \
-} while (0)
-
-#endif   // __AMD64_LINUX_CORE_PLATFORM_H
-
-/*--------------------------------------------------------------------*/
-/*--- end                                                          ---*/
-/*--------------------------------------------------------------------*/
index 96f3688d63ad047dfcd9e4d57512b04af470ff6f..c485764a82154fe673dccc7403e11d60b8eadb5e 100644 (file)
@@ -2,5 +2,4 @@ include $(top_srcdir)/Makefile.all.am
 include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
 
 noinst_HEADERS = \
-       core_platform.h \
        vki_unistd.h
diff --git a/coregrind/arm-linux/core_platform.h b/coregrind/arm-linux/core_platform.h
deleted file mode 100644 (file)
index 8822c09..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Platform-specific stuff for the core.                        ---*/
-/*---                                    arm-linux/core_platform.h ---*/
-/*--------------------------------------------------------------------*/
-
-/*
-   This file is part of Valgrind, a dynamic binary instrumentation
-   framework.
-
-   Copyright (C) 2000-2005 Nicholas Nethercote
-      njn@valgrind.org
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   This program 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
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307, USA.
-
-   The GNU General Public License is contained in the file COPYING.
-*/
-
-#ifndef __ARM_LINUX_CORE_PLATFORM_H
-#define __ARM_LINUX_CORE_PLATFORM_H
-
-/* ---------------------------------------------------------------------
-   mmap() stuff
-   ------------------------------------------------------------------ */
-
-#define VGP_DO_MMAP(ret, start, length, prot, flags, fd, offset) { \
-   I_die_here; \
-} while (0)
-
-#endif   // __ARM_LINUX_CORE_PLATFORM_H
-
-/*--------------------------------------------------------------------*/
-/*--- end                                                          ---*/
-/*--------------------------------------------------------------------*/
index 104390cf968963e42f8ccd814573d25835456bac..0c7d2cec4978a2f4a9bcc41c625654295a620cf4 100644 (file)
@@ -35,8 +35,6 @@
 #include "tool.h"          // tool stuff
 #include "core_arch.h"     // arch-specific stuff,  eg. x86/core_arch.h
 
-#include "core_platform.h" // platform-specific stuff,
-                           //   eg. x86-linux/core_platform.h
 #include "core_os.h"       // OS-specific stuff,    eg. linux/core_os.h
 
 #include "pub_core_mallocfree.h"  // for type 'ArenaId'
@@ -442,10 +440,12 @@ extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
 extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout);
 
 /* system/mman.h */
-extern void* VG_(mmap)( void* start, SizeT length, UInt prot, UInt flags,
-                        UInt sf_flags, UInt fd, OffT offset );
-extern Int  VG_(munmap)( void* start, SizeT length );
-extern Int  VG_(mprotect)( void *start, SizeT length, UInt prot );
+extern void* VG_(mmap)       ( void* start, SizeT length, UInt prot, UInt flags,
+                               UInt sf_flags, UInt fd, OffT offset );
+extern void* VG_(mmap_native)( void* start, SizeT length, UInt prot, UInt flags,
+                                              UInt fd, OffT offset );
+extern Int VG_(munmap)       ( void* start, SizeT length );
+extern Int VG_(mprotect)       ( void *start, SizeT length, UInt prot );
 extern Int VG_(mprotect_native)( void *start, SizeT length, UInt prot );
 
 
index 26a969d3173ec04094fc76f9d6f30b0a48e7a66a..eb34a0c21f50b5d0422bd3111f5498ffc77e2e4f 100644 (file)
@@ -953,14 +953,14 @@ Addr VG_(find_map_space)(Addr addr, SizeT len, Bool for_client)
 void VG_(pad_address_space)(Addr start)
 {
    Addr     addr = (start == 0) ? VG_(client_base) : start;
-   Addr     ret;
+   void*    ret;
 
    Int      i = 0;
    Segment* s = i >= segments_used ? NULL : &segments[i];
    
    while (s && addr <= VG_(valgrind_last)) {
       if (addr < s->addr) {
-         VGP_DO_MMAP(ret, addr, s->addr - addr, 0,
+         ret = VG_(mmap_native)((void*)addr, s->addr - addr, 0,
                      VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS,
                      -1, 0);
       }
@@ -970,7 +970,7 @@ void VG_(pad_address_space)(Addr start)
    }
 
    if (addr <= VG_(valgrind_last)) {
-      VGP_DO_MMAP(ret, addr, VG_(valgrind_last) - addr + 1, 0,
+      ret = VG_(mmap_native)((void*)addr, VG_(valgrind_last) - addr + 1, 0,
                   VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS,
                   -1, 0);
    }
index fd00df6f6f7eff22f93c4bae2244128e7e8d6c96..b64b3e2d51ee7b2ce154e198261b62f66c256487 100644 (file)
@@ -4533,8 +4533,7 @@ PRE(old_mmap, Special)
    }
 
    if (RES != -VKI_ENOMEM) {
-      int res;
-      VGP_DO_MMAP(res, a1, a2, a3, a4, a5, a6);
+      Int res = (Int)VG_(mmap_native)((void*)a1, a2, a3, a4, a5, a6);
       SET_RESULT(res);
 
       if (!VG_(is_kerror)(RES)) {
index 206f1e84b89fa8c8e72165084576333b264b242a..231dac6a3e8a21e305a63bc6323713f6f4bdef0a 100644 (file)
@@ -288,19 +288,28 @@ Int VG_(gettid)(void)
    mmap/munmap, exit, fcntl
    ------------------------------------------------------------------ */
 
-static Int munmap_inner(void *start, SizeT length)
-{
-   return VG_(do_syscall2)(__NR_munmap, (UWord)start, length );
-}
-
-static Addr mmap_inner(void *start, SizeT length, UInt prot, UInt flags,
+void* VG_(mmap_native)(void *start, SizeT length, UInt prot, UInt flags,
                        UInt fd, OffT offset)
 {
-   Word ret;
-   
-   VGP_DO_MMAP(ret, start, length, prot,
-               flags & ~(VKI_MAP_NOSYMS|VKI_MAP_CLIENT), fd, offset);
-   return ret;
+   UWord ret;
+#if defined(VGP_x86_linux)
+   { 
+      UWord args[6];
+      args[0] = (UWord)start;
+      args[1] = length;
+      args[2] = prot;
+      args[3] = flags;
+      args[4] = fd;
+      args[5] = offset;
+      ret = VG_(do_syscall1)(__NR_mmap, (UWord)args );
+   }
+#elif defined(VGP_amd64_linux)
+   ret = VG_(do_syscall6)(__NR_mmap, (UWord)start, length, 
+                         prot, flags, fd, offset);
+#else
+#  error Unknown platform
+#endif
+   return VG_(is_kerror)(ret) ? (void*)-1 : (void*)ret;
 }
 
 /* Returns -1 on failure. */
@@ -317,10 +326,12 @@ void* VG_(mmap)( void* start, SizeT length,
    if (start == 0)
       return (void *)-1;
 
-   res = mmap_inner(start, length, prot, flags, fd, offset);
+   res = (Addr)VG_(mmap_native)(start, length, prot, 
+                                flags & ~(VKI_MAP_NOSYMS | VKI_MAP_CLIENT),
+                                fd, offset);
 
    // Check it ended up in the right place.
-   if (!VG_(is_kerror)(res)) {
+   if (res != (Addr)-1) {
       if (flags & VKI_MAP_CLIENT) {
          vg_assert(VG_(client_base) <= res && res+length <= VG_(client_end));
       } else {
@@ -337,29 +348,36 @@ void* VG_(mmap)( void* start, SizeT length,
       VG_(map_fd_segment)(res, length, prot, sf_flags, fd, offset, NULL);
    }
 
-   return VG_(is_kerror)(res) ? ((void*)(-1)) : (void*)res;
+   return (void*)res;
+}
+
+static Int munmap_native(void *start, SizeT length)
+{
+   Int res = VG_(do_syscall2)(__NR_munmap, (UWord)start, length );
+   return VG_(is_kerror)(res) ? -1 : 0;
 }
 
 /* Returns -1 on failure. */
 Int VG_(munmap)( void* start, SizeT length )
 {
-   Int res = munmap_inner(start, length);
-   if (!VG_(is_kerror)(res))
+   Int res = munmap_native(start, length);
+   if (0 == res)
       VG_(unmap_range)((Addr)start, length);
-   return VG_(is_kerror)(res) ? -1 : 0;
+   return res;
 }
 
-Int VG_(mprotect)( void *start, SizeT length, UInt prot )
+Int VG_(mprotect_native)( void *start, SizeT length, UInt prot )
 {
    Int res = VG_(do_syscall3)(__NR_mprotect, (UWord)start, length, prot );
-   if (!VG_(is_kerror)(res))
-      VG_(mprotect_range)((Addr)start, length, prot);
    return VG_(is_kerror)(res) ? -1 : 0;
 }
-Int VG_(mprotect_native)( void *start, SizeT length, UInt prot )
+
+Int VG_(mprotect)( void *start, SizeT length, UInt prot )
 {
-   Int res = VG_(do_syscall3)(__NR_mprotect, (UWord)start, length, prot );
-   return VG_(is_kerror)(res) ? -1 : 0;
+   Int res = VG_(mprotect_native)(start, length, prot);
+   if (0 == res)
+      VG_(mprotect_range)((Addr)start, length, prot);
+   return res;
 }
 
 /* Pull down the entire world */
index 96f3688d63ad047dfcd9e4d57512b04af470ff6f..c485764a82154fe673dccc7403e11d60b8eadb5e 100644 (file)
@@ -2,5 +2,4 @@ include $(top_srcdir)/Makefile.all.am
 include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
 
 noinst_HEADERS = \
-       core_platform.h \
        vki_unistd.h
diff --git a/coregrind/x86-linux/core_platform.h b/coregrind/x86-linux/core_platform.h
deleted file mode 100644 (file)
index 408611d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Platform-specific stuff for the core.                        ---*/
-/*---                                    x86-linux/core_platform.h ---*/
-/*--------------------------------------------------------------------*/
-
-/*
-   This file is part of Valgrind, a dynamic binary instrumentation
-   framework.
-
-   Copyright (C) 2000-2005 Nicholas Nethercote
-      njn@valgrind.org
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   This program 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
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307, USA.
-
-   The GNU General Public License is contained in the file COPYING.
-*/
-
-#ifndef __X86_LINUX_CORE_PLATFORM_H
-#define __X86_LINUX_CORE_PLATFORM_H
-
-/* ---------------------------------------------------------------------
-   mmap() stuff
-   ------------------------------------------------------------------ */
-
-#define VGP_DO_MMAP(ret, start, length, prot, flags, fd, offset) {      \
-   UWord __args[6];                                                     \
-                                                                        \
-   __args[0] = (UWord)(start);                                          \
-   __args[1] = (length);                                                \
-   __args[2] = (prot);                                                  \
-   __args[3] = (flags);                                                 \
-   __args[4] = (fd);                                                    \
-   __args[5] = (offset);                                                \
-                                                                        \
-   ret = VG_(do_syscall1)(__NR_mmap, (UWord)(&(__args[0])) );           \
-} while (0)
-
-#endif   // __X86_LINUX_CORE_PLATFORM_H
-
-/*--------------------------------------------------------------------*/
-/*--- end                                                          ---*/
-/*--------------------------------------------------------------------*/
index 22254055c870637772f07faa17af16773bca95ff..80dd289235dcc718b92172ce495b8c39fbddbf4c 100644 (file)
@@ -1,6 +1,9 @@
 This is a rough guide to porting Valgrind to a new architecture, or a new
 operating system.  It's quite preliminary, but should get you started.
 
+[29-May-2005: the stuff about the locations of files is now badly out of
+date.  --njn]
+
 -----------------------------------------------------------------------------
 Porting Valgrind to a new architecture
 -----------------------------------------------------------------------------