From: Julian Seward Date: Thu, 7 Aug 2008 20:29:55 +0000 (+0000) Subject: Tidy up the wrappers for pread64 and pwrite64, and make these two X-Git-Tag: svn/VALGRIND_3_4_0~291 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=832a3d400ba73e622f8c7f160977877346f46724;p=thirdparty%2Fvalgrind.git Tidy up the wrappers for pread64 and pwrite64, and make these two syscalls available on ppc64-linux. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8519 --- diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h index 8a9493c579..e673a0d921 100644 --- a/coregrind/m_syswrap/priv_syswrap-generic.h +++ b/coregrind/m_syswrap/priv_syswrap-generic.h @@ -178,8 +178,10 @@ DECL_TEMPLATE(generic, sys_fstatfs); // * L? DECL_TEMPLATE(generic, sys_iopl); // (x86/amd64) L DECL_TEMPLATE(generic, sys_ipc); // (x86) L DECL_TEMPLATE(generic, sys_newuname); // * P -DECL_TEMPLATE(generic, sys_pread64); // * (Unix98?) -DECL_TEMPLATE(generic, sys_pwrite64); // * (Unix98?) +DECL_TEMPLATE(generic, sys_pread64_on32bitplat); // * (Unix98?) +DECL_TEMPLATE(generic, sys_pread64_on64bitplat); // * (Unix98?) +DECL_TEMPLATE(generic, sys_pwrite64_on32bitplat); // * (Unix98?) +DECL_TEMPLATE(generic, sys_pwrite64_on64bitplat); // * (Unix98?) DECL_TEMPLATE(generic, sys_sigaltstack); // (x86) (XPG4-UNIX) DECL_TEMPLATE(generic, sys_getpmsg); // (?) (?) DECL_TEMPLATE(generic, sys_putpmsg); // (?) (?) diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index df98cc9a8a..73ea0c632d 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -371,8 +371,6 @@ DECL_TEMPLATE(amd64_linux, sys_shmdt); DECL_TEMPLATE(amd64_linux, sys_shmctl); DECL_TEMPLATE(amd64_linux, sys_arch_prctl); DECL_TEMPLATE(amd64_linux, sys_ptrace); -DECL_TEMPLATE(amd64_linux, sys_pread64); -DECL_TEMPLATE(amd64_linux, sys_pwrite64); DECL_TEMPLATE(amd64_linux, sys_fadvise64); DECL_TEMPLATE(amd64_linux, sys_mmap); DECL_TEMPLATE(amd64_linux, sys_syscall184); @@ -939,35 +937,6 @@ POST(sys_shmctl) ML_(generic_POST_sys_shmctl)(tid, RES,ARG1,ARG2,ARG3); } -PRE(sys_pread64) -{ - *flags |= SfMayBlock; - PRINT("sys_pread64 ( %ld, %#lx, %llu, %ld )", - ARG1, ARG2, (ULong)ARG3, ARG4); - PRE_REG_READ4(ssize_t, "pread64", - unsigned int, fd, char *, buf, - vki_size_t, count, vki_loff_t, offset); - PRE_MEM_WRITE( "pread64(buf)", ARG2, ARG3 ); -} -POST(sys_pread64) -{ - vg_assert(SUCCESS); - if (RES > 0) { - POST_MEM_WRITE( ARG2, RES ); - } -} - -PRE(sys_pwrite64) -{ - *flags |= SfMayBlock; - PRINT("sys_pwrite64 ( %ld, %#lx, %llu, %ld )", - ARG1, ARG2, (ULong)ARG3, ARG4); - PRE_REG_READ4(ssize_t, "pwrite64", - unsigned int, fd, const char *, buf, - vki_size_t, count, vki_loff_t, offset); - PRE_MEM_READ( "pwrite64(buf)", ARG2, ARG3 ); -} - PRE(sys_fadvise64) { PRINT("sys_fadvise64 ( %ld, %ld, %lu, %ld )", ARG1,ARG2,ARG3,ARG4); @@ -1066,8 +1035,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { PLAX_(__NR_rt_sigreturn, sys_rt_sigreturn), // 15 GENXY(__NR_ioctl, sys_ioctl), // 16 - PLAXY(__NR_pread64, sys_pread64), // 17 - PLAX_(__NR_pwrite64, sys_pwrite64), // 18 + GENXY(__NR_pread64, sys_pread64_on64bitplat), // 17 + GENX_(__NR_pwrite64, sys_pwrite64_on64bitplat), // 18 GENXY(__NR_readv, sys_readv), // 19 GENX_(__NR_writev, sys_writev), // 20 diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index ffd64e36d1..51ab4fe36b 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -2250,13 +2250,26 @@ PRE(sys_getpriority) PRE_REG_READ2(long, "getpriority", int, which, int, who); } +PRE(sys_pwrite64_on64bitplat) +{ + vg_assert(sizeof(UWord) == 8); + *flags |= SfMayBlock; + PRINT("sys_pwrite64 ( %ld, %#lx, %llu, %ld )", + ARG1, ARG2, (ULong)ARG3, ARG4); + PRE_REG_READ4(ssize_t, "pwrite64", + unsigned int, fd, const char *, buf, + vki_size_t, count, vki_loff_t, offset); + PRE_MEM_READ( "pwrite64(buf)", ARG2, ARG3 ); +} + // The actual kernel definition of this routine takes a // single 64 bit offset argument. This version is for 32 bit // platforms only and treats the offset as two values - the // kernel relies on stack based argument passing conventions // to merge the two together. -PRE(sys_pwrite64) +PRE(sys_pwrite64_on32bitplat) { + vg_assert(sizeof(UWord) == 4); *flags |= SfMayBlock; PRINT("sys_pwrite64 ( %ld, %#lx, %llu, %lld )", ARG1, ARG2, (ULong)ARG3, LOHI64(ARG4,ARG5)); @@ -2304,13 +2317,34 @@ PRE(sys_getsid) PRE_REG_READ1(long, "getsid", vki_pid_t, pid); } +PRE(sys_pread64_on64bitplat) +{ + vg_assert(sizeof(UWord) == 8); + *flags |= SfMayBlock; + PRINT("sys_pread64 ( %ld, %#lx, %llu, %ld )", + ARG1, ARG2, (ULong)ARG3, ARG4); + PRE_REG_READ4(ssize_t, "pread64", + unsigned int, fd, char *, buf, + vki_size_t, count, vki_loff_t, offset); + PRE_MEM_WRITE( "pread64(buf)", ARG2, ARG3 ); +} +POST(sys_pread64_on64bitplat) +{ + vg_assert(sizeof(UWord) == 8); + vg_assert(SUCCESS); + if (RES > 0) { + POST_MEM_WRITE( ARG2, RES ); + } +} + // The actual kernel definition of this routine takes a // single 64 bit offset argument. This version is for 32 bit // platforms only and treats the offset as two values - the // kernel relies on stack based argument passing conventions // to merge the two together. -PRE(sys_pread64) +PRE(sys_pread64_on32bitplat) { + vg_assert(sizeof(UWord) == 4); *flags |= SfMayBlock; PRINT("sys_pread64 ( %ld, %#lx, %llu, %lld )", ARG1, ARG2, (ULong)ARG3, LOHI64(ARG4,ARG5)); @@ -2319,8 +2353,9 @@ PRE(sys_pread64) vki_u32, offset_low32, vki_u32, offset_high32); PRE_MEM_WRITE( "pread64(buf)", ARG2, ARG3 ); } -POST(sys_pread64) +POST(sys_pread64_on32bitplat) { + vg_assert(sizeof(UWord) == 4); vg_assert(SUCCESS); if (RES > 0) { POST_MEM_WRITE( ARG2, RES ); diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 861b5e3aa5..c2e056d6d5 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1687,8 +1687,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { LINXY(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo), // 177 LINX_(__NR_rt_sigsuspend, sys_rt_sigsuspend), // 178 - GENXY(__NR_pread64, sys_pread64), // 179 - GENX_(__NR_pwrite64, sys_pwrite64), // 180 + GENXY(__NR_pread64, sys_pread64_on32bitplat), // 179 + GENX_(__NR_pwrite64, sys_pwrite64_on32bitplat), // 180 GENX_(__NR_chown, sys_chown), // 181 GENXY(__NR_getcwd, sys_getcwd), // 182 //.. LINXY(__NR_capget, sys_capget), // 183 diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index f08ef31362..1aae5e2a7a 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1260,7 +1260,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_profil, sys_profil), // 98 GENXY(__NR_statfs, sys_statfs), // 99 -// _____(__NR_fstatfs, sys_fstatfs), // 100 + GENXY(__NR_fstatfs, sys_fstatfs), // 100 // _____(__NR_ioperm, sys_ioperm), // 101 PLAXY(__NR_socketcall, sys_socketcall), // 102 LINXY(__NR_syslog, sys_syslog), // 103 @@ -1354,7 +1354,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { LINXY(__NR_rt_sigtimedwait, sys_rt_sigtimedwait), // 176 // _____(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo), // 177 // _____(__NR_rt_sigsuspend, sys_rt_sigsuspend), // 178 -// _____(__NR_pread64, sys_pread64), // 179 + GENXY(__NR_pread64, sys_pread64_on64bitplat), // 179 // _____(__NR_pwrite64, sys_pwrite64), // 180 GENX_(__NR_chown, sys_chown), // 181 @@ -1382,7 +1382,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_pciconfig_iobase, sys_pciconfig_iobase), // 200 // _____(__NR_multiplexer, sys_multiplexer), // 201 -// _____(__NR_getdents64, sys_getdents64), // 202 + GENXY(__NR_getdents64, sys_getdents64), // 202 // _____(__NR_pivot_root, sys_pivot_root), // 203 GENXY(__NR_fcntl64, sys_fcntl64), // 204 !!!!?? 32bit only */ diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 196f07f8a6..3eb077a5ed 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -2057,8 +2057,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { LINXY(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo),// 178 LINX_(__NR_rt_sigsuspend, sys_rt_sigsuspend), // 179 - GENXY(__NR_pread64, sys_pread64), // 180 - GENX_(__NR_pwrite64, sys_pwrite64), // 181 + GENXY(__NR_pread64, sys_pread64_on32bitplat), // 180 + GENX_(__NR_pwrite64, sys_pwrite64_on32bitplat), // 181 LINX_(__NR_chown, sys_chown16), // 182 GENXY(__NR_getcwd, sys_getcwd), // 183 LINXY(__NR_capget, sys_capget), // 184