# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/strace/i860.patch.i860 # Copyright (C) 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- From: René Rebe Subject: [PATCH] add Linux/i860 support System call decoding, tampering through PTRACE_SET_SYSCALL_INFO and the test fixes for musl and the time64 only table. No -k: there is no unwinder for i860. Against upstream commit be6eb508a597e0418a670b54a7f159bab34d2db9 (doc: clarify injection option repetition rules). Branch i860 at cecc839dd. Tested in the MAME magicst2 model only, not on real hardware. Signed-off-by: René Rebe Co-Authored-By: Claude Opus 5.5 --- bundled/linux/include/uapi/linux/audit.h | 1 + configure.ac | 4 ++ src/Makefile.am | 13 ++++++ src/clone.c | 3 +- src/linux/i860/arch_defs_.h | 15 +++++++ src/linux/i860/arch_prstatus_regset.c | 52 ++++++++++++++++++++++++ src/linux/i860/arch_prstatus_regset.h | 15 +++++++ src/linux/i860/arch_regs.c | 11 +++++ src/linux/i860/get_error.c | 19 +++++++++ src/linux/i860/get_scno.c | 14 +++++++ src/linux/i860/get_syscall_args.c | 14 +++++++ src/linux/i860/ioctls_arch0.h | 1 + src/linux/i860/ioctls_inc0.h | 1 + src/linux/i860/raw_syscall.h | 29 +++++++++++++ src/linux/i860/set_error.c | 20 +++++++++ src/linux/i860/set_scno.c | 15 +++++++ src/linux/i860/syscallent.h | 11 +++++ src/syscall.c | 3 +- src/xlat/audit_arch.in | 1 + tests/cur_audit_arch.h | 4 ++ tests/delay.c | 8 ++++ tests/fallocate.c | 2 +- tests/perf_event_open.c | 2 +- tests/printclockname.c | 8 ++++ tests/ptrace.c | 42 ++++++++++++++++++- tests/readahead.c | 2 +- tests/sleep-timing.c | 20 +++++++-- tests/sleep.c | 19 +++++++-- tests/sync_file_range.c | 4 +- tests/sync_file_range2.c | 4 +- 30 files changed, 341 insertions(+), 16 deletions(-) diff --git a/bundled/linux/include/uapi/linux/audit.h b/bundled/linux/include/uapi/linux/audit.h index f1adcf313..e4f43b47c 100644 --- a/bundled/linux/include/uapi/linux/audit.h +++ b/bundled/linux/include/uapi/linux/audit.h @@ -409,6 +409,7 @@ enum { #define AUDIT_ARCH_H8300 (EM_H8_300) #define AUDIT_ARCH_HEXAGON (EM_HEXAGON) #define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_I860 (EM_860|__AUDIT_ARCH_LE) #define AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) #define AUDIT_ARCH_M32R (EM_M32R) #define AUDIT_ARCH_M68K (EM_68K) diff --git a/configure.ac b/configure.ac index cd4d4c72c..a5ea0455d 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,10 @@ hppa*|parisc*) karch=parisc AC_DEFINE([HPPA], 1, [Define for the HPPA architecture.]) ;; +i860*) + arch=i860 + AC_DEFINE([I860], 1, [Define for the i860 architecture.]) + ;; i[[3456]]86|pentium) arch=i386 karch=x86 diff --git a/src/Makefile.am b/src/Makefile.am index b3e50e0e1..cdd8d67dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -648,6 +648,19 @@ EXTRA_DIST = \ linux/hppa/signalent.h \ linux/hppa/syscallent.h \ linux/hppa/userent.h \ + linux/i860/arch_defs_.h \ + linux/i860/arch_prstatus_regset.c \ + linux/i860/arch_prstatus_regset.h \ + linux/i860/arch_regs.c \ + linux/i860/get_error.c \ + linux/i860/get_scno.c \ + linux/i860/get_syscall_args.c \ + linux/i860/ioctls_arch0.h \ + linux/i860/ioctls_inc0.h \ + linux/i860/raw_syscall.h \ + linux/i860/set_error.c \ + linux/i860/set_scno.c \ + linux/i860/syscallent.h \ linux/i386/arch_defs_.h \ linux/i386/arch_fpregset.c \ linux/i386/arch_fpregset.h \ diff --git a/src/clone.c b/src/clone.c index e9c75d722..70f0609b9 100644 --- a/src/clone.c +++ b/src/clone.c @@ -42,7 +42,8 @@ # define ARG_PTID 2 # define ARG_CTID ((current_personality != 1) ? 3 : 4) # define ARG_TLS ((current_personality != 1) ? 4 : 3) -#elif defined ALPHA || defined TILE || defined OR1K || defined CSKY +#elif defined ALPHA || defined TILE || defined OR1K || defined CSKY \ + || defined I860 # define ARG_FLAGS 0 # define ARG_STACK 1 # define ARG_PTID 2 diff --git a/src/linux/i860/arch_defs_.h b/src/linux/i860/arch_defs_.h new file mode 100644 index 000000000..f41c66e8d --- /dev/null +++ b/src/linux/i860/arch_defs_.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +/* The kernel table has no time32 ABI. */ +#define HAVE_ARCH_TIME32_SYSCALLS 0 + +/* __WORDSIZE of musl is only in and . */ +#define PERSONALITY_DESIGNATORS { "32" } +#define PERSONALITY_NAMES { "32 bit" } + +#define PERSONALITY0_AUDIT_ARCH { AUDIT_ARCH_I860, 0 } diff --git a/src/linux/i860/arch_prstatus_regset.c b/src/linux/i860/arch_prstatus_regset.c new file mode 100644 index 000000000..236468435 --- /dev/null +++ b/src/linux/i860/arch_prstatus_regset.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +static void +arch_decode_prstatus_regset(struct tcb *const tcp, + const kernel_ulong_t addr, + const kernel_ulong_t size) +{ + struct_prstatus_regset regs; + const size_t fetch_size = MIN(sizeof(regs), size); + + if (!size || size & 3) { + printaddr(addr); + } else if (!umoven_or_printaddr(tcp, addr, fetch_size, ®s)) { + tprint_struct_begin(); + PRINT_FIELD_ARRAY_UPTO(regs, gpr, fetch_size / 4, tcp, + print_xint_array_member); + const size_t offset_of_fpr = + offsetof(struct_prstatus_regset, fpr); + if (fetch_size > offset_of_fpr) { + tprint_struct_next(); + PRINT_FIELD_ARRAY_UPTO(regs, fpr, + (fetch_size - offset_of_fpr) / 4, + tcp, print_xint_array_member); + } + if (fetch_size > offsetof(struct_prstatus_regset, psr)) { + tprint_struct_next(); + PRINT_FIELD_X(regs, psr); + } + if (fetch_size > offsetof(struct_prstatus_regset, epsr)) { + tprint_struct_next(); + PRINT_FIELD_X(regs, epsr); + } + if (fetch_size > offsetof(struct_prstatus_regset, fir)) { + tprint_struct_next(); + PRINT_FIELD_X(regs, fir); + } + if (fetch_size > offsetof(struct_prstatus_regset, fsr)) { + tprint_struct_next(); + PRINT_FIELD_X(regs, fsr); + } + if (size > sizeof(regs)) { + tprint_struct_next(); + tprint_more_data_follows(); + } + tprint_struct_end(); + } +} diff --git a/src/linux/i860/arch_prstatus_regset.h b/src/linux/i860/arch_prstatus_regset.h new file mode 100644 index 000000000..17a0bca24 --- /dev/null +++ b/src/linux/i860/arch_prstatus_regset.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef STRACE_ARCH_PRSTATUS_REGSET_H +# define STRACE_ARCH_PRSTATUS_REGSET_H + +typedef struct user_regs_struct struct_prstatus_regset; + +# define HAVE_ARCH_PRSTATUS_REGSET 1 + +#endif /* !STRACE_ARCH_PRSTATUS_REGSET_H */ diff --git a/src/linux/i860/arch_regs.c b/src/linux/i860/arch_regs.c new file mode 100644 index 000000000..26780a82e --- /dev/null +++ b/src/linux/i860/arch_regs.c @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +static struct user_regs_struct i860_regs; +#define ARCH_REGS_FOR_GETREGSET i860_regs +#define ARCH_PC_REG i860_regs.fir +#define ARCH_SP_REG i860_regs.gpr[2] diff --git a/src/linux/i860/get_error.c b/src/linux/i860/get_error.c new file mode 100644 index 000000000..e4fd2240b --- /dev/null +++ b/src/linux/i860/get_error.c @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "negated_errno.h" + +static void +arch_get_error(struct tcb *tcp, const bool check_errno) +{ + if (check_errno && is_negated_errno(i860_regs.gpr[16])) { + tcp->u_rval = -1; + tcp->u_error = -i860_regs.gpr[16]; + } else { + tcp->u_rval = i860_regs.gpr[16]; + } +} diff --git a/src/linux/i860/get_scno.c b/src/linux/i860/get_scno.c new file mode 100644 index 000000000..324ab36cc --- /dev/null +++ b/src/linux/i860/get_scno.c @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +/* Return codes: 1 - ok, 0 - ignore, other - error. */ +static int +arch_get_scno(struct tcb *tcp) +{ + tcp->scno = i860_regs.gpr[28]; + return 1; +} diff --git a/src/linux/i860/get_syscall_args.c b/src/linux/i860/get_syscall_args.c new file mode 100644 index 000000000..9a7837ef5 --- /dev/null +++ b/src/linux/i860/get_syscall_args.c @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +static int +arch_get_syscall_args(struct tcb *tcp) +{ + for (unsigned int i = 0; i < 6; i++) + tcp->u_arg[i] = i860_regs.gpr[16 + i]; + return 1; +} diff --git a/src/linux/i860/ioctls_arch0.h b/src/linux/i860/ioctls_arch0.h new file mode 100644 index 000000000..624ca88b0 --- /dev/null +++ b/src/linux/i860/ioctls_arch0.h @@ -0,0 +1 @@ +/* Generated by ioctls_gen.sh from definitions found in $linux/arch/i860/include/ tree. */ diff --git a/src/linux/i860/ioctls_inc0.h b/src/linux/i860/ioctls_inc0.h new file mode 100644 index 000000000..a72f85c39 --- /dev/null +++ b/src/linux/i860/ioctls_inc0.h @@ -0,0 +1 @@ +#include "../32/ioctls_inc.h" diff --git a/src/linux/i860/raw_syscall.h b/src/linux/i860/raw_syscall.h new file mode 100644 index 000000000..7919449f2 --- /dev/null +++ b/src/linux/i860/raw_syscall.h @@ -0,0 +1,29 @@ +/* + * Raw syscalls. + * + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef STRACE_RAW_SYSCALL_H +# define STRACE_RAW_SYSCALL_H + +# include "kernel_types.h" + +static inline kernel_ulong_t +raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err) +{ + *err = 0; + register kernel_ulong_t r28 __asm__("r28") = nr; + register kernel_ulong_t r16 __asm__("r16"); + __asm__ __volatile__("trap %%r0,%%r0,%%r0" + : "=r"(r16), "+r"(r28) + : + : "memory"); + return r16; +} +# define raw_syscall_0 raw_syscall_0 + +#endif /* !STRACE_RAW_SYSCALL_H */ diff --git a/src/linux/i860/set_error.c b/src/linux/i860/set_error.c new file mode 100644 index 000000000..27c6df585 --- /dev/null +++ b/src/linux/i860/set_error.c @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +static int +arch_set_error(struct tcb *tcp) +{ + i860_regs.gpr[16] = -tcp->u_error; + return set_regs(tcp->pid); +} + +static int +arch_set_success(struct tcb *tcp) +{ + i860_regs.gpr[16] = tcp->u_rval; + return set_regs(tcp->pid); +} diff --git a/src/linux/i860/set_scno.c b/src/linux/i860/set_scno.c new file mode 100644 index 000000000..a94b6bf55 --- /dev/null +++ b/src/linux/i860/set_scno.c @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +static int +arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) +{ + if (ptrace_syscall_info_is_valid() && get_regs(tcp) < 0) + return -1; + i860_regs.gpr[28] = scno; + return set_regs(tcp->pid); +} diff --git a/src/linux/i860/syscallent.h b/src/linux/i860/syscallent.h new file mode 100644 index 000000000..a59d37374 --- /dev/null +++ b/src/linux/i860/syscallent.h @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2026 René Rebe + * All rights reserved. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#define sys_ARCH_mmap sys_mmap_pgoff +#include "../32/syscallent.h" +/* [244 ... 259] are arch specific */ +[244] = { 3, 0, SEN(printargs), "cacheflush" }, diff --git a/src/syscall.c b/src/syscall.c index 644c13843..abb157647 100644 --- a/src/syscall.c +++ b/src/syscall.c @@ -1577,7 +1577,8 @@ set_scno(struct tcb *tcp, kernel_ulong_t scno) { if (ptrace_set_syscall_info_supported && ptrace_syscall_info_is_entry()) { - ptrace_sci.entry.nr = scno; + /* The kernel takes a sign-extended int: -1 on a 32-bit tracer. */ + ptrace_sci.entry.nr = (kernel_long_t) scno; const size_t size = sizeof(ptrace_sci); if (ptrace(PTRACE_SET_SYSCALL_INFO, tcp->pid, (void *) size, &ptrace_sci) == 0) diff --git a/src/xlat/audit_arch.in b/src/xlat/audit_arch.in index b998090f6..5a533ebfb 100644 --- a/src/xlat/audit_arch.in +++ b/src/xlat/audit_arch.in @@ -26,6 +26,7 @@ AUDIT_ARCH_FRV (EM_FRV) AUDIT_ARCH_H8300 (EM_H8_300) /* Removed in v3.13-rc1~130^2~2 */ AUDIT_ARCH_HEXAGON (EM_HEXAGON) AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE) +AUDIT_ARCH_I860 (EM_860|__AUDIT_ARCH_LE) AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) AUDIT_ARCH_LOONGARCH32 (EM_LOONGARCH|__AUDIT_ARCH_LE) AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) diff --git a/tests/cur_audit_arch.h b/tests/cur_audit_arch.h index 77c0f8e52..270bb7d62 100644 --- a/tests/cur_audit_arch.h +++ b/tests/cur_audit_arch.h @@ -39,6 +39,10 @@ # define CUR_AUDIT_ARCH_STR "AUDIT_ARCH_ARCOMPACT" # endif +# elif defined __i860__ +# define CUR_AUDIT_ARCH AUDIT_ARCH_I860 +# define CUR_AUDIT_ARCH_STR "AUDIT_ARCH_I860" + # elif defined __arm64__ || defined __aarch64__ # define CUR_AUDIT_ARCH AUDIT_ARCH_AARCH64 # define CUR_AUDIT_ARCH_STR "AUDIT_ARCH_AARCH64" diff --git a/tests/delay.c b/tests/delay.c index 93c8e4c9a..03b36a786 100644 --- a/tests/delay.c +++ b/tests/delay.c @@ -21,6 +21,8 @@ #include "scno.h" #include "kernel_timeval.h" +#ifdef __NR_gettimeofday + static int64_t usecs_from_tv(const kernel_old_timeval_t *const tv) { @@ -186,3 +188,9 @@ main(int ac, char *av[]) return rc; } + +#else + +SKIP_MAIN_UNDEFINED("__NR_gettimeofday") + +#endif diff --git a/tests/fallocate.c b/tests/fallocate.c index 2c28ad85e..ed5d84fb0 100644 --- a/tests/fallocate.c +++ b/tests/fallocate.c @@ -18,7 +18,7 @@ # include # include -# ifndef FALLOC_FL_WRITE_ZEROES +# if !defined FALLOC_FL_WRITE_ZEROES || !defined FALLOC_FL_NO_HIDE_STALE /* Avoid conflicts between and . */ # undef FALLOC_FL_KEEP_SIZE # undef FALLOC_FL_PUNCH_HOLE diff --git a/tests/perf_event_open.c b/tests/perf_event_open.c index 6629416d8..f3a2a73fb 100644 --- a/tests/perf_event_open.c +++ b/tests/perf_event_open.c @@ -403,7 +403,7 @@ end: } /* These require aligned access, so no byte-grain checks possible */ -#if defined SPARC || defined SPARC64 || defined POWERPC || defined POWERPC64 || defined ARM || defined AARCH64 +#if defined SPARC || defined SPARC64 || defined POWERPC || defined POWERPC64 || defined ARM || defined AARCH64 || defined I860 # define ATTR_REC(sz) { tail_alloc((sz + 7) & ~7), sz } #else # define ATTR_REC(sz) { tail_alloc(sz), sz } diff --git a/tests/printclockname.c b/tests/printclockname.c index 6d54f45a4..b4ce0a0a9 100644 --- a/tests/printclockname.c +++ b/tests/printclockname.c @@ -11,6 +11,8 @@ #include "scno.h" #include "clock_ids_for_tests.h" +#ifdef __NR_clock_getres + #include #include @@ -69,3 +71,9 @@ main(void) puts("+++ exited with 0 +++"); return 0; } + +#else + +SKIP_MAIN_UNDEFINED("__NR_clock_getres") + +#endif diff --git a/tests/ptrace.c b/tests/ptrace.c index aee56d16c..c86c08418 100644 --- a/tests/ptrace.c +++ b/tests/ptrace.c @@ -263,7 +263,7 @@ typedef struct { } sparc32_regs; # define TRACEE_REGS_STRUCT sparc32_regs # endif -#elif defined __riscv +#elif defined __riscv || defined __i860__ # define TRACEE_REGS_STRUCT struct user_regs_struct #elif defined __mips__ typedef struct { @@ -702,6 +702,45 @@ print_prstatus_regset(const void *const rs, const size_t size) } # endif +# elif defined __i860__ + + const size_t ngpr = MIN(size, sizeof(regs->gpr)) / sizeof(regs->gpr[0]); + fputs("gpr=[", stdout); + for (size_t i = 0; i < ngpr; ++i) { + if (i) + fputs(", ", stdout); + PRINT_VAL_X(regs->gpr[i]); + } + fputs("]", stdout); + if (size > offsetof(TRACEE_REGS_STRUCT, fpr)) { + const size_t nfpr = + MIN(size - offsetof(TRACEE_REGS_STRUCT, fpr), + sizeof(regs->fpr)) / sizeof(regs->fpr[0]); + fputs(", fpr=[", stdout); + for (size_t i = 0; i < nfpr; ++i) { + if (i) + fputs(", ", stdout); + PRINT_VAL_X(regs->fpr[i]); + } + fputs("]", stdout); + } + if (size >= offsetofend(TRACEE_REGS_STRUCT, psr)) { + fputs(", ", stdout); + PRINT_FIELD_X(*regs, psr); + } + if (size >= offsetofend(TRACEE_REGS_STRUCT, epsr)) { + fputs(", ", stdout); + PRINT_FIELD_X(*regs, epsr); + } + if (size >= offsetofend(TRACEE_REGS_STRUCT, fir)) { + fputs(", ", stdout); + PRINT_FIELD_X(*regs, fir); + } + if (size >= offsetofend(TRACEE_REGS_STRUCT, fsr)) { + fputs(", ", stdout); + PRINT_FIELD_X(*regs, fsr); + } + # elif defined __riscv PRINT_FIELD_X(*regs, pc); @@ -913,6 +952,7 @@ print_prstatus_regset(const void *const rs, const size_t size) __arm64__ || __arm__ || __i386__ || + __i860__ || __loongarch__ || __mips__ || __powerpc64__ || diff --git a/tests/readahead.c b/tests/readahead.c index 10723785c..781f4f2ce 100644 --- a/tests/readahead.c +++ b/tests/readahead.c @@ -42,7 +42,7 @@ static const int fds[] = { 0x7fffffff, }; -static const off64_t offsets[] = { +static const long long offsets[] = { -0x8000000000000000LL, -0x5060708090a0b0c0LL, -1LL, diff --git a/tests/sleep-timing.c b/tests/sleep-timing.c index 60791a9e6..9e81f6f1e 100644 --- a/tests/sleep-timing.c +++ b/tests/sleep-timing.c @@ -10,14 +10,18 @@ #include "tests.h" #include "scno.h" -#ifdef __NR_nanosleep +#if defined __NR_nanosleep || defined __NR_clock_nanosleep_time64 # include # include # include # include -# include "kernel_old_timespec.h" +# ifdef __NR_nanosleep +# include "kernel_old_timespec.h" +# else +# include "kernel_timespec.h" +# endif static void timespec_sub(struct timespec *res, const struct timespec *a, @@ -74,7 +78,11 @@ main(int ac, char **av) requested_sec = atoi(av[1]); timing_file = av[2]; +# ifdef __NR_nanosleep kernel_old_timespec_t ts = { requested_sec, 0 }; +# else + kernel_timespec64_t ts = { requested_sec, 0 }; +# endif if (!chdir("")) error_msg_and_fail("chdir"); @@ -82,8 +90,14 @@ main(int ac, char **av) if (clock_gettime(CLOCK_MONOTONIC, &t0)) perror_msg_and_fail("clock_gettime"); +# ifdef __NR_nanosleep if (syscall(__NR_nanosleep, (unsigned long) &ts, 0)) perror_msg_and_fail("nanosleep"); +# else + if (syscall(__NR_clock_nanosleep_time64, CLOCK_REALTIME, 0, + (unsigned long) &ts, 0)) + perror_msg_and_fail("clock_nanosleep_time64"); +# endif if (clock_gettime(CLOCK_MONOTONIC, &t1)) perror_msg_and_fail("clock_gettime"); @@ -101,6 +115,6 @@ main(int ac, char **av) #else -SKIP_MAIN_UNDEFINED("__NR_nanosleep") +SKIP_MAIN_UNDEFINED("__NR_nanosleep || __NR_clock_nanosleep_time64") #endif diff --git a/tests/sleep.c b/tests/sleep.c index ddd738227..097eb74c3 100644 --- a/tests/sleep.c +++ b/tests/sleep.c @@ -11,12 +11,17 @@ #include "tests.h" #include "scno.h" -#ifdef __NR_nanosleep +#if defined __NR_nanosleep || defined __NR_clock_nanosleep_time64 # include +# include # include -# include "kernel_old_timespec.h" +# ifdef __NR_nanosleep +# include "kernel_old_timespec.h" +# else +# include "kernel_timespec.h" +# endif int main(int ac, char **av) @@ -27,16 +32,24 @@ main(int ac, char **av) if (ac > 2) error_msg_and_fail("extra operand"); +# ifdef __NR_nanosleep kernel_old_timespec_t ts = { atoi(av[1]), 0 }; if (syscall(__NR_nanosleep, (unsigned long) &ts, 0)) perror_msg_and_fail("nanosleep"); +# else + kernel_timespec64_t ts = { atoi(av[1]), 0 }; + + if (syscall(__NR_clock_nanosleep_time64, CLOCK_REALTIME, 0, + (unsigned long) &ts, 0)) + perror_msg_and_fail("clock_nanosleep_time64"); +# endif return 0; } #else -SKIP_MAIN_UNDEFINED("__NR_nanosleep") +SKIP_MAIN_UNDEFINED("__NR_nanosleep || __NR_clock_nanosleep_time64") #endif diff --git a/tests/sync_file_range.c b/tests/sync_file_range.c index e93ab6cf0..7d13069bb 100644 --- a/tests/sync_file_range.c +++ b/tests/sync_file_range.c @@ -20,8 +20,8 @@ int main(void) { const int fd = -1; - const off64_t offset = 0xdeadbeefbadc0dedULL; - const off64_t nbytes = 0xfacefeedcafef00dULL; + const long long offset = 0xdeadbeefbadc0dedULL; + const long long nbytes = 0xfacefeedcafef00dULL; const unsigned int flags = -1; int rc = sync_file_range(fd, offset, nbytes, flags); diff --git a/tests/sync_file_range2.c b/tests/sync_file_range2.c index b8dc71219..0fefd6789 100644 --- a/tests/sync_file_range2.c +++ b/tests/sync_file_range2.c @@ -20,8 +20,8 @@ int main(void) { const int fd = -1; - const off64_t offset = 0xdeadbeefbadc0ded; - const off64_t nbytes = 0xfacefeedcafef00d; + const long long offset = 0xdeadbeefbadc0ded; + const long long nbytes = 0xfacefeedcafef00d; const unsigned int flags = -1; int rc = sync_file_range(fd, offset, nbytes, flags);