|
From: Bart V. A. <bar...@gm...> - 2007-09-03 14:54:25
|
Can the patch below please be considered for inclusion in Valgrind on
the trunk ? It adds support for the getitimer() system call on ppc32,
and there is a test program included as well. This solves bug #145887.
Index: memcheck/tests/Makefile.am
===================================================================
--- memcheck/tests/Makefile.am (revision 6797)
+++ memcheck/tests/Makefile.am (working copy)
@@ -50,6 +50,7 @@
execve2.stderr.exp execve2.stderr.exp2 execve2.vgtest \
fprw.stderr.exp fprw.vgtest \
fwrite.stderr.exp fwrite.stderr.exp2 fwrite.vgtest \
+ getitimer.stderr.exp getitimer.vgtest \
inits.stderr.exp inits.vgtest \
inline.stderr.exp inline.stdout.exp inline.vgtest \
leak-0.vgtest leak-0.stderr.exp \
@@ -154,6 +155,7 @@
describe-block \
doublefree error_counts errs1 exitprog execve execve2 erringfds \
fprw fwrite hello inits inline \
+ getitimer \
=7965==leak-0 leak-cycle leak-pool leak-tree leak-regroot leakotron \
illed long_namespace_xml \
anassb@malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
Index: memcheck/tests/getitimer.stderr.exp
===================================================================
Index: memcheck/tests/getitimer.vgtest
===================================================================
--- memcheck/tests/getitimer.vgtest (revision 0)
+++ memcheck/tests/getitimer.vgtest (revision 0)
@@ -0,0 +1,2 @@
+prog: getitimer -q
+vgopts: -q
Index: memcheck/tests/getitimer.c
===================================================================
--- memcheck/tests/getitimer.c (revision 0)
+++ memcheck/tests/getitimer.c (revision 0)
@@ -0,0 +1,44 @@
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/time.h>
+
+
+#if defined NDEBUG
+#define VERIFY(e) (e)
+#else
+#define VERIFY(e) assert(e)
+#endif
+
+
+static double TimevalToDouble(const struct timeval TV)
+{
+ return TV.tv_sec + TV.tv_usec * 1e-6;
+}
+
+int main(int argc, char** argv)
+{
+ sigset_t alarm_mask;
+ struct itimerval ITV = { { 1, 0 }, { 1, 0 } };
+ struct itimerval ITV2;
+
+ sigemptyset(&alarm_mask);
+ sigaddset(&alarm_mask, SIGALRM);
+ sigprocmask(SIG_BLOCK, &alarm_mask, 0);
+
+ VERIFY(setitimer(ITIMER_REAL, &ITV, 0) == 0);
+ VERIFY(getitimer(ITIMER_REAL, &ITV2) == 0);
+ if (argc == 1)
+ {
+ printf("Result: interval = %g s, value = %g s.\n",
+ TimevalToDouble(ITV2.it_interval),
+ TimevalToDouble(ITV2.it_value));
+ }
+ assert(ITV.it_interval.tv_sec == ITV2.it_interval.tv_sec);
+ assert(ITV.it_interval.tv_usec == ITV2.it_interval.tv_usec);
+ memset(&ITV, 0, sizeof(ITV));
+ VERIFY(setitimer(ITIMER_REAL, &ITV, 0) == 0);
+
+ return 0;
+}
Index: coregrind/m_syswrap/syswrap-ppc32-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-ppc32-linux.c (revision 6797)
+++ coregrind/m_syswrap/syswrap-ppc32-linux.c (working copy)
@@ -1585,8 +1585,7 @@
PLAXY(__NR_socketcall, sys_socketcall), // 102
LINXY(__NR_syslog, sys_syslog), // 103
GENXY(__NR_setitimer, sys_setitimer), // 104
-//..
-//.. GENXY(__NR_getitimer, sys_getitimer), // 105
+ GENXY(__NR_getitimer, sys_getitimer), // 105
GENXY(__NR_stat, sys_newstat), // 106
GENXY(__NR_lstat, sys_newlstat), // 107
GENXY(__NR_fstat, sys_newfstat), // 108
|