1 static void
get_error(struct tcb * tcp,const bool check_errno)2 get_error(struct tcb *tcp, const bool check_errno)
3 {
4 	/*
5 	 * The system call convention specifies that r2 contains the return
6 	 * value on success or a positive error number on failure.  A flag
7 	 * indicating successful completion is written to r7; r7=0 indicates
8 	 * the system call success, r7=1 indicates an error.  The positive
9 	 * errno value written in r2.
10 	 */
11 	if (nios2_regs.regs[7]) {
12 		tcp->u_rval = -1;
13 		tcp->u_error = nios2_regs.regs[2];
14 	} else {
15 		tcp->u_rval = nios2_regs.regs[2];
16 	}
17 }
18