• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "negated_errno.h"
2 
3 static void
get_error(struct tcb * tcp,const bool check_errno)4 get_error(struct tcb *tcp, const bool check_errno)
5 {
6 	/*
7 	 * In X32, return value is 64-bit (llseek uses one).
8 	 * Using merely "long rax" would not work.
9 	 */
10 	long long rax;
11 
12 	if (x86_io.iov_len == sizeof(i386_regs)) {
13 		/* Sign extend from 32 bits */
14 		rax = (int32_t) i386_regs.eax;
15 	} else {
16 		rax = x86_64_regs.rax;
17 	}
18 
19 	if (check_errno && is_negated_errno(rax)) {
20 		tcp->u_rval = -1;
21 		tcp->u_error = -rax;
22 	} else {
23 		if (x86_io.iov_len == sizeof(i386_regs))
24 			tcp->u_rval = (uint32_t) rax;
25 		else
26 			tcp->u_rval = rax;
27 	}
28 }
29