@@ -219,7 +219,8 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
])
AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struct __kernel_timespec,
- struct __kernel_old_itimerspec, struct __kernel_itimerspec],,,[#include <sys/socket.h>])
+ struct __kernel_old_itimerspec, struct __kernel_itimerspec,
+ struct __kernel_old_itimerval],,,[#include <sys/socket.h>])
AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>])
AC_CHECK_TYPES([struct mount_attr],,,[
@@ -135,6 +135,13 @@ struct __kernel_itimerspec {
struct __kernel_timespec it_value; /* timer expiration */
};
#endif
+
+#ifndef HAVE_STRUCT___KERNEL_OLD_ITIMERVAL
+struct __kernel_old_itimerval {
+ struct __kernel_old_timeval it_interval; /* timer interval */
+ struct __kernel_old_timeval it_value; /* current value */
+};
+#endif
#endif
enum tst_ts_type {
@@ -370,6 +377,11 @@ static inline int sys_timerfd_settime64(int fd, int flags, void *its,
return tst_syscall(__NR_timerfd_settime64, fd, flags, its, old_its);
}
+static inline int sys_setitimer(int which, void *new_value, void *old_value)
+{
+ return tst_syscall(__NR_setitimer, which, new_value, old_value);
+}
+
/*
* Returns tst_ts seconds.
*/
@@ -20,9 +20,10 @@
#include "tst_test.h"
#include "lapi/syscalls.h"
#include "tst_safe_clocks.h"
+#include "tst_timer.h"
static struct timeval tv;
-static struct itimerval *value, *ovalue;
+static struct __kernel_old_itimerval *value, *ovalue;
static volatile unsigned long sigcnt;
static long time_step;
static long time_sec;
@@ -38,11 +39,6 @@ static struct tcase {
{ITIMER_PROF, "ITIMER_PROF", SIGPROF},
};
-static int sys_setitimer(int which, void *new_value, void *old_value)
-{
- return tst_syscall(__NR_setitimer, which, new_value, old_value);
-}
-
static void sig_routine(int signo LTP_ATTRIBUTE_UNUSED)
{
sigcnt++;
@@ -19,13 +19,9 @@
#include <stdlib.h>
#include "tst_test.h"
#include "lapi/syscalls.h"
+#include "tst_timer.h"
-static struct itimerval *value, *ovalue;
-
-static int sys_setitimer(int which, void *new_value, void *old_value)
-{
- return tst_syscall(__NR_setitimer, which, new_value, old_value);
-}
+static struct __kernel_old_itimerval *value, *ovalue;
static void verify_setitimer(unsigned int i)
{
@@ -55,8 +51,8 @@ static struct tst_test test = {
.test = verify_setitimer,
.setup = setup,
.bufs = (struct tst_buffers[]) {
- {&value, .size = sizeof(struct itimerval)},
- {&ovalue, .size = sizeof(struct itimerval)},
+ {&value, .size = sizeof(struct __kernel_old_itimerval)},
+ {&ovalue, .size = sizeof(struct __kernel_old_itimerval)},
{}
}
};
The setitimer01 tests fail on RV32 due to incompatible parameter definitions. 'value' and 'ovalue' are defined by glibc as itimerval (64-bit time_t on RV32), while the kernel expects __kernel_old_itimerval (32-bit time_t on RV32) for the setitimer syscall[1]. This discrepancy leads to incorrect 'ovalue' and test failures. Thus, the kernel-defined __kernel_old_itimerval should be used. [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=a51e03588937ad804a9f583ea3d0fc0a4d088c33 Signed-off-by: Hui Min Mina Chou <minachou@andestech.com> --- configure.ac | 3 ++- include/tst_timer.h | 12 ++++++++++++ testcases/kernel/syscalls/setitimer/setitimer01.c | 8 ++------ testcases/kernel/syscalls/setitimer/setitimer02.c | 12 ++++-------- 4 files changed, 20 insertions(+), 15 deletions(-)