1 /*
2 * Copyright (c) 2015-2021 The strace developers.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8 static void
9 arch_get_error(struct tcb *tcp, const bool check_errno)
10 {
11 /*
12 * The system call convention specifies that r2 contains the return
13 * value on success or a positive error number on failure. A flag
14 * indicating successful completion is written to r7; r7=0 indicates
15 * the system call success, r7=1 indicates an error. The positive
16 * errno value written in r2.
17 */
18 if (nios2_regs.regs[7]) {
19 tcp->u_rval = -1;
20 tcp->u_error = nios2_regs.regs[2];
21 } else {
22 tcp->u_rval = nios2_regs.regs[2];
23 }
24 }