Author: njn
Date: 2005-05-29 19:46:38 +0100 (Sun, 29 May 2005)
New Revision: 3813
Removed:
trunk/coregrind/amd64-linux/core_platform.h
trunk/coregrind/arm-linux/core_platform.h
trunk/coregrind/x86-linux/core_platform.h
Modified:
trunk/coregrind/amd64-linux/Makefile.am
trunk/coregrind/arm-linux/Makefile.am
trunk/coregrind/core.h
trunk/coregrind/m_aspacemgr/aspacemgr.c
trunk/coregrind/m_syscalls/syscalls.c
trunk/coregrind/vg_mylibc.c
trunk/coregrind/x86-linux/Makefile.am
trunk/docs/porting-HOWTO
Log:
Eliminated VGP_DO_MMAP. Replaced it with VG_(mmap_native)(), which was
derived from mmap_inner().
As a consequence, $PLATFORM/core_platform.h files are no longer necessary=
,
hooray!
Modified: trunk/coregrind/amd64-linux/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/amd64-linux/Makefile.am 2005-05-29 17:50:40 UTC (rev =
3812)
+++ trunk/coregrind/amd64-linux/Makefile.am 2005-05-29 18:46:38 UTC (rev =
3813)
@@ -2,5 +2,4 @@
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
=20
noinst_HEADERS =3D \
- core_platform.h \
vki_unistd.h
Deleted: trunk/coregrind/amd64-linux/core_platform.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/amd64-linux/core_platform.h 2005-05-29 17:50:40 UTC (=
rev 3812)
+++ trunk/coregrind/amd64-linux/core_platform.h 2005-05-29 18:46:38 UTC (=
rev 3813)
@@ -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
- nj...@va...
-
- 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 =3D VG_(do_syscall6)(__NR_mmap, (UWord)(start), (length), =
\
- (prot), (flags), (fd), (offset)); =
\
-} while (0)
-
-#endif // __AMD64_LINUX_CORE_PLATFORM_H
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/arm-linux/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/arm-linux/Makefile.am 2005-05-29 17:50:40 UTC (rev 38=
12)
+++ trunk/coregrind/arm-linux/Makefile.am 2005-05-29 18:46:38 UTC (rev 38=
13)
@@ -2,5 +2,4 @@
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
=20
noinst_HEADERS =3D \
- core_platform.h \
vki_unistd.h
Deleted: trunk/coregrind/arm-linux/core_platform.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/arm-linux/core_platform.h 2005-05-29 17:50:40 UTC (re=
v 3812)
+++ trunk/coregrind/arm-linux/core_platform.h 2005-05-29 18:46:38 UTC (re=
v 3813)
@@ -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
- nj...@va...
-
- 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 ---*/
-/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/core.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/core.h 2005-05-29 17:50:40 UTC (rev 3812)
+++ trunk/coregrind/core.h 2005-05-29 18:46:38 UTC (rev 3813)
@@ -35,8 +35,6 @@
#include "tool.h" // tool stuff
#include "core_arch.h" // arch-specific stuff, eg. x86/core_arch.h
=20
-#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
=20
#include "pub_core_mallocfree.h" // for type 'ArenaId'
@@ -442,10 +440,12 @@
extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout);
=20
/* 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, UIn=
t flags,
+ UInt sf_flags, UInt fd, OffT offset );
+extern void* VG_(mmap_native)( void* start, SizeT length, UInt prot, UIn=
t 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 );
=20
=20
Modified: trunk/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-05-29 17:50:40 UTC (rev =
3812)
+++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-05-29 18:46:38 UTC (rev =
3813)
@@ -953,14 +953,14 @@
void VG_(pad_address_space)(Addr start)
{
Addr addr =3D (start =3D=3D 0) ? VG_(client_base) : start;
- Addr ret;
+ void* ret;
=20
Int i =3D 0;
Segment* s =3D i >=3D segments_used ? NULL : &segments[i];
=20
while (s && addr <=3D VG_(valgrind_last)) {
if (addr < s->addr) {
- VGP_DO_MMAP(ret, addr, s->addr - addr, 0,
+ ret =3D VG_(mmap_native)((void*)addr, s->addr - addr, 0,
VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS=
,
-1, 0);
}
@@ -970,7 +970,7 @@
}
=20
if (addr <=3D VG_(valgrind_last)) {
- VGP_DO_MMAP(ret, addr, VG_(valgrind_last) - addr + 1, 0,
+ ret =3D VG_(mmap_native)((void*)addr, VG_(valgrind_last) - addr + =
1, 0,
VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS,
-1, 0);
}
Modified: trunk/coregrind/m_syscalls/syscalls.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syscalls/syscalls.c 2005-05-29 17:50:40 UTC (rev 38=
12)
+++ trunk/coregrind/m_syscalls/syscalls.c 2005-05-29 18:46:38 UTC (rev 38=
13)
@@ -4533,8 +4533,7 @@
}
=20
if (RES !=3D -VKI_ENOMEM) {
- int res;
- VGP_DO_MMAP(res, a1, a2, a3, a4, a5, a6);
+ Int res =3D (Int)VG_(mmap_native)((void*)a1, a2, a3, a4, a5, a6);
SET_RESULT(res);
=20
if (!VG_(is_kerror)(RES)) {
Modified: trunk/coregrind/vg_mylibc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_mylibc.c 2005-05-29 17:50:40 UTC (rev 3812)
+++ trunk/coregrind/vg_mylibc.c 2005-05-29 18:46:38 UTC (rev 3813)
@@ -288,19 +288,28 @@
mmap/munmap, exit, fcntl
------------------------------------------------------------------ */
=20
-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;
- =20
- 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)
+ {=20
+ UWord args[6];
+ args[0] =3D (UWord)start;
+ args[1] =3D length;
+ args[2] =3D prot;
+ args[3] =3D flags;
+ args[4] =3D fd;
+ args[5] =3D offset;
+ ret =3D VG_(do_syscall1)(__NR_mmap, (UWord)args );
+ }
+#elif defined(VGP_amd64_linux)
+ ret =3D VG_(do_syscall6)(__NR_mmap, (UWord)start, length,=20
+ prot, flags, fd, offset);
+#else
+# error Unknown platform
+#endif
+ return VG_(is_kerror)(ret) ? (void*)-1 : (void*)ret;
}
=20
/* Returns -1 on failure. */
@@ -317,10 +326,12 @@
if (start =3D=3D 0)
return (void *)-1;
=20
- res =3D mmap_inner(start, length, prot, flags, fd, offset);
+ res =3D (Addr)VG_(mmap_native)(start, length, prot,=20
+ flags & ~(VKI_MAP_NOSYMS | VKI_MAP_CLIEN=
T),
+ fd, offset);
=20
// Check it ended up in the right place.
- if (!VG_(is_kerror)(res)) {
+ if (res !=3D (Addr)-1) {
if (flags & VKI_MAP_CLIENT) {
vg_assert(VG_(client_base) <=3D res && res+length <=3D VG_(clie=
nt_end));
} else {
@@ -337,29 +348,36 @@
VG_(map_fd_segment)(res, length, prot, sf_flags, fd, offset, NULL)=
;
}
=20
- return VG_(is_kerror)(res) ? ((void*)(-1)) : (void*)res;
+ return (void*)res;
}
=20
+static Int munmap_native(void *start, SizeT length)
+{
+ Int res =3D 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 =3D munmap_inner(start, length);
- if (!VG_(is_kerror)(res))
+ Int res =3D munmap_native(start, length);
+ if (0 =3D=3D res)
VG_(unmap_range)((Addr)start, length);
- return VG_(is_kerror)(res) ? -1 : 0;
+ return res;
}
=20
-Int VG_(mprotect)( void *start, SizeT length, UInt prot )
+Int VG_(mprotect_native)( void *start, SizeT length, UInt prot )
{
Int res =3D VG_(do_syscall3)(__NR_mprotect, (UWord)start, length, pro=
t );
- 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 =3D VG_(do_syscall3)(__NR_mprotect, (UWord)start, length, pro=
t );
- return VG_(is_kerror)(res) ? -1 : 0;
+ Int res =3D VG_(mprotect_native)(start, length, prot);
+ if (0 =3D=3D res)
+ VG_(mprotect_range)((Addr)start, length, prot);
+ return res;
}
=20
/* Pull down the entire world */
Modified: trunk/coregrind/x86-linux/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/x86-linux/Makefile.am 2005-05-29 17:50:40 UTC (rev 38=
12)
+++ trunk/coregrind/x86-linux/Makefile.am 2005-05-29 18:46:38 UTC (rev 38=
13)
@@ -2,5 +2,4 @@
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
=20
noinst_HEADERS =3D \
- core_platform.h \
vki_unistd.h
Deleted: trunk/coregrind/x86-linux/core_platform.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/x86-linux/core_platform.h 2005-05-29 17:50:40 UTC (re=
v 3812)
+++ trunk/coregrind/x86-linux/core_platform.h 2005-05-29 18:46:38 UTC (re=
v 3813)
@@ -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
- nj...@va...
-
- 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] =3D (UWord)(start); =
\
- __args[1] =3D (length); =
\
- __args[2] =3D (prot); =
\
- __args[3] =3D (flags); =
\
- __args[4] =3D (fd); =
\
- __args[5] =3D (offset); =
\
- =
\
- ret =3D VG_(do_syscall1)(__NR_mmap, (UWord)(&(__args[0])) ); =
\
-} while (0)
-
-#endif // __X86_LINUX_CORE_PLATFORM_H
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
Modified: trunk/docs/porting-HOWTO
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/docs/porting-HOWTO 2005-05-29 17:50:40 UTC (rev 3812)
+++ trunk/docs/porting-HOWTO 2005-05-29 18:46:38 UTC (rev 3813)
@@ -1,6 +1,9 @@
This is a rough guide to porting Valgrind to a new architecture, or a ne=
w
operating system. It's quite preliminary, but should get you started.
=20
+[29-May-2005: the stuff about the locations of files is now badly out of
+date. --njn]
+
------------------------------------------------------------------------=
-----
Porting Valgrind to a new architecture
------------------------------------------------------------------------=
-----
|