* defs.h (widen_to_long): Remove.
(truncate_klong_to_current_wordsize): New static inline function.
* aio.c (SYS_FUNC(io_submit), SYS_FUNC(io_getevents): Use it
instead of widen_to_long.
* linux/sparc64/get_syscall_args.c (get_syscall_args): Update comment.
* linux/x86_64/get_syscall_args.c (get_syscall_args): Likewise.
SYS_FUNC(io_submit)
{
- const long nr = widen_to_long(tcp->u_arg[1]);
+ const kernel_long_t nr =
+ truncate_klong_to_current_wordsize(tcp->u_arg[1]);
const kernel_ulong_t addr = tcp->u_arg[2];
kernel_ulong_t iocbp;
printaddr(tcp->u_arg[0]);
- tprintf(", %ld, ", nr);
+ tprintf(", %" PRI_kld ", ", nr);
if (nr < 0)
printaddr(addr);
{
if (entering(tcp)) {
printaddr(tcp->u_arg[0]);
- tprintf(", %ld, %ld, ",
- widen_to_long(tcp->u_arg[1]),
- widen_to_long(tcp->u_arg[2]));
+ tprintf(", %" PRI_kld ", %" PRI_kld ", ",
+ truncate_klong_to_current_wordsize(tcp->u_arg[1]),
+ truncate_klong_to_current_wordsize(tcp->u_arg[2]));
} else {
struct io_event buf;
print_array(tcp, tcp->u_arg[3], tcp->u_rval, &buf, sizeof(buf),
DECL_PRINTPAIR(int64);
#undef DECL_PRINTPAIR
-/* In many, many places we play fast and loose and use
- * tprintf("%d", (int) tcp->u_arg[N]) to print fds, pids etc.
- * We probably need to use widen_to_long() instead:
- */
-#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
-# define widen_to_long(v) (current_wordsize == 4 ? (long)(int32_t)(v) : (long)(v))
-#else
-# define widen_to_long(v) ((long)(v))
+static inline kernel_long_t
+truncate_klong_to_current_wordsize(const kernel_long_t v)
+{
+#if SIZEOF_KERNEL_LONG_T > 4 \
+ && (SIZEOF_LONG < SIZEOF_KERNEL_LONG_T || !defined current_wordsize)
+ if (current_wordsize < sizeof(v)) {
+ return (int) v;
+ } else
#endif
+ {
+ return v;
+ }
+}
static inline kernel_ulong_t
truncate_kulong_to_current_wordsize(const kernel_ulong_t v)
if (tcp->currpers == 1) {
/*
* Zero-extend from 32 bits.
- * Use widen_to_long(tcp->u_arg[N]) in syscall handlers
+ * Use truncate_klong_to_current_wordsize(tcp->u_arg[N])
+ * in syscall handlers
* if you need to use *sign-extended* parameter.
*/
tcp->u_arg[0] = (uint32_t) sparc_regs.u_regs[U_REG_O0 + 0];
if (tcp->s_ent->sys_flags & COMPAT_SYSCALL_TYPES) {
/*
* X32 compat syscall: zero-extend from 32 bits.
- * Use widen_to_long(tcp->u_arg[N]) in syscall handlers
+ * Use truncate_klong_to_current_wordsize(tcp->u_arg[N])
+ * in syscall handlers
* if you need to use *sign-extended* parameter.
*/
tcp->u_arg[0] = (uint32_t) x86_64_regs.rdi;
} else {
/*
* i386 ABI: zero-extend from 32 bits.
- * Use widen_to_long(tcp->u_arg[N]) in syscall handlers
+ * Use truncate_klong_to_current_wordsize(tcp->u_arg[N])
+ * in syscall handlers
* if you need to use *sign-extended* parameter.
*/
tcp->u_arg[0] = (uint32_t) i386_regs.ebx;