-if (tcp->currpers == 1) {
+#define get_error arm_get_error
+#include "arm/get_error.c"
+#undef get_error
+
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (tcp->currpers == 0) {
+ arm_get_error(tcp, check_errno);
+ return;
+ }
+
if (check_errno && is_negated_errno(aarch64_regs.regs[0])) {
tcp->u_rval = -1;
tcp->u_error = -aarch64_regs.regs[0];
} else {
tcp->u_rval = aarch64_regs.regs[0];
}
-} else {
-#include "arm/get_error.c"
}
-if (check_errno && alpha_a3) {
- tcp->u_rval = -1;
- tcp->u_error = alpha_r0;
-} else {
- tcp->u_rval = alpha_r0;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && alpha_a3) {
+ tcp->u_rval = -1;
+ tcp->u_error = alpha_r0;
+ } else {
+ tcp->u_rval = alpha_r0;
+ }
}
-if (check_errno && is_negated_errno(arc_regs.scratch.r0)) {
- tcp->u_rval = -1;
- tcp->u_error = -arc_regs.scratch.r0;
-} else {
- tcp->u_rval = arc_regs.scratch.r0;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(arc_regs.scratch.r0)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -arc_regs.scratch.r0;
+ } else {
+ tcp->u_rval = arc_regs.scratch.r0;
+ }
}
-if (check_errno && is_negated_errno(arm_regs.ARM_r0)) {
- tcp->u_rval = -1;
- tcp->u_error = -arm_regs.ARM_r0;
-} else {
- tcp->u_rval = arm_regs.ARM_r0;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(arm_regs.ARM_r0)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -arm_regs.ARM_r0;
+ } else {
+ tcp->u_rval = arm_regs.ARM_r0;
+ }
}
-if (check_errno && is_negated_errno(avr32_regs.r12)) {
- tcp->u_rval = -1;
- tcp->u_error = -avr32_regs.r12;
-} else {
- tcp->u_rval = avr32_regs.r12;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(avr32_regs.r12)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -avr32_regs.r12;
+ } else {
+ tcp->u_rval = avr32_regs.r12;
+ }
}
-if (check_errno && is_negated_errno(bfin_r0)) {
- tcp->u_rval = -1;
- tcp->u_error = -bfin_r0;
-} else {
- tcp->u_rval = bfin_r0;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(bfin_r0)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -bfin_r0;
+ } else {
+ tcp->u_rval = bfin_r0;
+ }
}
-if (check_errno && is_negated_errno(cris_r10)) {
- tcp->u_rval = -1;
- tcp->u_error = -cris_r10;
-} else {
- tcp->u_rval = cris_r10;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(cris_r10)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -cris_r10;
+ } else {
+ tcp->u_rval = cris_r10;
+ }
}
-if (check_errno && is_negated_errno(hppa_r28)) {
- tcp->u_rval = -1;
- tcp->u_error = -hppa_r28;
-} else {
- tcp->u_rval = hppa_r28;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(hppa_r28)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -hppa_r28;
+ } else {
+ tcp->u_rval = hppa_r28;
+ }
}
-if (check_errno && is_negated_errno(i386_regs.eax)) {
- tcp->u_rval = -1;
- tcp->u_error = -i386_regs.eax;
-} else {
- tcp->u_rval = i386_regs.eax;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(i386_regs.eax)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -i386_regs.eax;
+ } else {
+ tcp->u_rval = i386_regs.eax;
+ }
}
-if (ia64_ia32mode) {
- int err = ia64_regs.gr[8];
- if (check_errno && is_negated_errno(err)) {
- tcp->u_rval = -1;
- tcp->u_error = -err;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (ia64_ia32mode) {
+ int err = ia64_regs.gr[8];
+ if (check_errno && is_negated_errno(err)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -err;
+ } else {
+ tcp->u_rval = err;
+ }
} else {
- tcp->u_rval = err;
- }
-} else {
- if (check_errno && ia64_regs.gr[10]) {
- tcp->u_rval = -1;
- tcp->u_error = ia64_regs.gr[8];
- } else {
- tcp->u_rval = ia64_regs.gr[8];
+ if (check_errno && ia64_regs.gr[10]) {
+ tcp->u_rval = -1;
+ tcp->u_error = ia64_regs.gr[8];
+ } else {
+ tcp->u_rval = ia64_regs.gr[8];
+ }
}
}
-if (check_errno && is_negated_errno(m68k_d0)) {
- tcp->u_rval = -1;
- tcp->u_error = -m68k_d0;
-} else {
- tcp->u_rval = m68k_d0;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(m68k_d0)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -m68k_d0;
+ } else {
+ tcp->u_rval = m68k_d0;
+ }
}
-/* result pointer in D0Re0 (D0.0) */
-if (check_errno && is_negated_errno(metag_regs.dx[0][0])) {
- tcp->u_rval = -1;
- tcp->u_error = -metag_regs.dx[0][0];
-} else {
- tcp->u_rval = metag_regs.dx[0][0];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ /* result pointer in D0Re0 (D0.0) */
+ if (check_errno && is_negated_errno(metag_regs.dx[0][0])) {
+ tcp->u_rval = -1;
+ tcp->u_error = -metag_regs.dx[0][0];
+ } else {
+ tcp->u_rval = metag_regs.dx[0][0];
+ }
}
-if (check_errno && is_negated_errno(microblaze_r3)) {
- tcp->u_rval = -1;
- tcp->u_error = -microblaze_r3;
-} else {
- tcp->u_rval = microblaze_r3;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(microblaze_r3)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -microblaze_r3;
+ } else {
+ tcp->u_rval = microblaze_r3;
+ }
}
-if (check_errno && mips_REG_A3) {
- tcp->u_rval = -1;
- tcp->u_error = mips_REG_V0;
-} else {
-# if defined LINUX_MIPSN32
- tcp->u_lrval = mips_REG_V0;
-# endif
- tcp->u_rval = mips_REG_V0;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && mips_REG_A3) {
+ tcp->u_rval = -1;
+ tcp->u_error = mips_REG_V0;
+ } else {
+ tcp->u_rval = mips_REG_V0;
+#ifdef LINUX_MIPSN32
+ /* tcp->u_rval contains a truncated value */
+ tcp->u_lrval = mips_REG_V0;
+#endif
+ }
}
-/*
- * The system call convention specifies that r2 contains the return
- * value on success or a positive error number on failure. A flag
- * indicating successful completion is written to r7; r7=0 indicates
- * the system call success, r7=1 indicates an error. The positive
- * errno value written in r2.
- */
-if (check_errno && nios2_regs.regs[7]) {
- tcp->u_rval = -1;
- tcp->u_error = nios2_regs.regs[2];
-} else {
- tcp->u_rval = nios2_regs.regs[2];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ /*
+ * The system call convention specifies that r2 contains the return
+ * value on success or a positive error number on failure. A flag
+ * indicating successful completion is written to r7; r7=0 indicates
+ * the system call success, r7=1 indicates an error. The positive
+ * errno value written in r2.
+ */
+ if (check_errno && nios2_regs.regs[7]) {
+ tcp->u_rval = -1;
+ tcp->u_error = nios2_regs.regs[2];
+ } else {
+ tcp->u_rval = nios2_regs.regs[2];
+ }
}
-if (check_errno && is_negated_errno(or1k_regs.gpr[11])) {
- tcp->u_rval = -1;
- tcp->u_error = -or1k_regs.gpr[11];
-} else {
- tcp->u_rval = or1k_regs.gpr[11];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(or1k_regs.gpr[11])) {
+ tcp->u_rval = -1;
+ tcp->u_error = -or1k_regs.gpr[11];
+ } else {
+ tcp->u_rval = or1k_regs.gpr[11];
+ }
}
-if (check_errno && (ppc_regs.ccr & 0x10000000)) {
- tcp->u_rval = -1;
- tcp->u_error = ppc_regs.gpr[3];
-} else {
- tcp->u_rval = ppc_regs.gpr[3];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && (ppc_regs.ccr & 0x10000000)) {
+ tcp->u_rval = -1;
+ tcp->u_error = ppc_regs.gpr[3];
+ } else {
+ tcp->u_rval = ppc_regs.gpr[3];
+ }
}
-if (check_errno && is_negated_errno(s390_regset.gprs[2])) {
- tcp->u_rval = -1;
- tcp->u_error = -s390_regset.gprs[2];
-} else {
- tcp->u_rval = s390_regset.gprs[2];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(s390_regset.gprs[2])) {
+ tcp->u_rval = -1;
+ tcp->u_error = -s390_regset.gprs[2];
+ } else {
+ tcp->u_rval = s390_regset.gprs[2];
+ }
}
-if (check_errno && is_negated_errno(sh_r0)) {
- tcp->u_rval = -1;
- tcp->u_error = -sh_r0;
-} else {
- tcp->u_rval = sh_r0;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(sh_r0)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -sh_r0;
+ } else {
+ tcp->u_rval = sh_r0;
+ }
}
-if (check_errno && is_negated_errno(sh64_r9)) {
- tcp->u_rval = -1;
- tcp->u_error = -sh64_r9;
-} else {
- tcp->u_rval = sh64_r9;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(sh64_r9)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -sh64_r9;
+ } else {
+ tcp->u_rval = sh64_r9;
+ }
}
-if (check_errno && sparc_regs.psr & PSR_C) {
- tcp->u_rval = -1;
- tcp->u_error = sparc_regs.u_regs[U_REG_O0];
-} else {
- tcp->u_rval = sparc_regs.u_regs[U_REG_O0];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && sparc_regs.psr & PSR_C) {
+ tcp->u_rval = -1;
+ tcp->u_error = sparc_regs.u_regs[U_REG_O0];
+ } else {
+ tcp->u_rval = sparc_regs.u_regs[U_REG_O0];
+ }
}
-if (check_errno && sparc_regs.tstate & 0x1100000000UL) {
- tcp->u_rval = -1;
- tcp->u_error = sparc_regs.u_regs[U_REG_O0];
-} else {
- tcp->u_rval = sparc_regs.u_regs[U_REG_O0];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && sparc_regs.tstate & 0x1100000000UL) {
+ tcp->u_rval = -1;
+ tcp->u_error = sparc_regs.u_regs[U_REG_O0];
+ } else {
+ tcp->u_rval = sparc_regs.u_regs[U_REG_O0];
+ }
}
-/*
- * The standard tile calling convention returns the value (or negative
- * errno) in r0, and zero (or positive errno) in r1.
- * Until at least kernel 3.8, however, the r1 value is not reflected
- * in ptregs at this point, so we use r0 here.
- */
-if (check_errno && is_negated_errno(tile_regs.regs[0])) {
- tcp->u_rval = -1;
- tcp->u_error = -tile_regs.regs[0];
-} else {
- tcp->u_rval = tile_regs.regs[0];
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ /*
+ * The standard tile calling convention returns the value
+ * (or negative errno) in r0, and zero (or positive errno) in r1.
+ * Until at least kernel 3.8, however, the r1 value is not
+ * reflected in ptregs at this point, so we use r0 here.
+ */
+ if (check_errno && is_negated_errno(tile_regs.regs[0])) {
+ tcp->u_rval = -1;
+ tcp->u_error = -tile_regs.regs[0];
+ } else {
+ tcp->u_rval = tile_regs.regs[0];
+ }
}
-/*
- * In X32, return value is 64-bit (llseek uses one).
- * Using merely "long rax" would not work.
- */
-long long rax;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ /*
+ * In X32, return value is 64-bit (llseek uses one).
+ * Using merely "long rax" would not work.
+ */
+ long long rax;
-if (x86_io.iov_len == sizeof(i386_regs)) {
- /* Sign extend from 32 bits */
- rax = (int32_t) i386_regs.eax;
-} else {
- rax = x86_64_regs.rax;
-}
+ if (x86_io.iov_len == sizeof(i386_regs)) {
+ /* Sign extend from 32 bits */
+ rax = (int32_t) i386_regs.eax;
+ } else {
+ rax = x86_64_regs.rax;
+ }
-if (check_errno && is_negated_errno(rax)) {
- tcp->u_rval = -1;
- tcp->u_error = -rax;
-} else {
- tcp->u_rval = rax;
-# ifdef X32
- /* tcp->u_rval contains a truncated value */
- tcp->u_lrval = rax;
-# endif
+ if (check_errno && is_negated_errno(rax)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -rax;
+ } else {
+ tcp->u_rval = rax;
+#ifdef X32
+ /* tcp->u_rval contains a truncated value */
+ tcp->u_lrval = rax;
+#endif
+ }
}
-if (check_errno && is_negated_errno(xtensa_a2)) {
- tcp->u_rval = -1;
- tcp->u_error = -xtensa_a2;
-} else {
- tcp->u_rval = xtensa_a2;
+static void
+get_error(struct tcb *tcp, const bool check_errno)
+{
+ if (check_errno && is_negated_errno(xtensa_a2)) {
+ tcp->u_rval = -1;
+ tcp->u_error = -xtensa_a2;
+ } else {
+ tcp->u_rval = xtensa_a2;
+ }
}
return 1;
}
-static void
-get_error(struct tcb *tcp)
-{
- const bool check_errno = !(tcp->s_ent->sys_flags & SYSCALL_NEVER_FAILS);
- tcp->u_error = 0;
-
#include "get_error.c"
-}
/* Returns:
* 1: ok, continue in trace_syscall_exiting().
#else
# include "get_syscall_result.c"
#endif
- get_error(tcp);
+ tcp->u_error = 0;
+ get_error(tcp, !(tcp->s_ent->sys_flags & SYSCALL_NEVER_FAILS));
+
return 1;
}