xref: /aosp_15_r20/external/strace/linux/powerpc/set_error.c (revision cf84ac9a129d8ea9952db616b4e9b904c4bdde56)
1*cf84ac9aSAndroid Build Coastguard Worker static int
arch_set_error(struct tcb * tcp)2*cf84ac9aSAndroid Build Coastguard Worker arch_set_error(struct tcb *tcp)
3*cf84ac9aSAndroid Build Coastguard Worker {
4*cf84ac9aSAndroid Build Coastguard Worker 	ppc_regs.gpr[3] = tcp->u_error;
5*cf84ac9aSAndroid Build Coastguard Worker 	ppc_regs.ccr |= 0x10000000;
6*cf84ac9aSAndroid Build Coastguard Worker #ifdef HAVE_GETREGS_OLD
7*cf84ac9aSAndroid Build Coastguard Worker 	return upoke(tcp, sizeof(long) * PT_CCR, ppc_regs.ccr) ||
8*cf84ac9aSAndroid Build Coastguard Worker 	       upoke(tcp, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]);
9*cf84ac9aSAndroid Build Coastguard Worker #else
10*cf84ac9aSAndroid Build Coastguard Worker 	return set_regs(tcp->pid);
11*cf84ac9aSAndroid Build Coastguard Worker #endif
12*cf84ac9aSAndroid Build Coastguard Worker }
13*cf84ac9aSAndroid Build Coastguard Worker 
14*cf84ac9aSAndroid Build Coastguard Worker static int
arch_set_success(struct tcb * tcp)15*cf84ac9aSAndroid Build Coastguard Worker arch_set_success(struct tcb *tcp)
16*cf84ac9aSAndroid Build Coastguard Worker {
17*cf84ac9aSAndroid Build Coastguard Worker 	ppc_regs.gpr[3] = tcp->u_rval;
18*cf84ac9aSAndroid Build Coastguard Worker 	ppc_regs.ccr &= ~0x10000000;
19*cf84ac9aSAndroid Build Coastguard Worker #ifdef HAVE_GETREGS_OLD
20*cf84ac9aSAndroid Build Coastguard Worker 	return upoke(tcp, sizeof(long) * PT_CCR, ppc_regs.ccr) ||
21*cf84ac9aSAndroid Build Coastguard Worker 	       upoke(tcp, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]);
22*cf84ac9aSAndroid Build Coastguard Worker #else
23*cf84ac9aSAndroid Build Coastguard Worker 	return set_regs(tcp->pid);
24*cf84ac9aSAndroid Build Coastguard Worker #endif
25*cf84ac9aSAndroid Build Coastguard Worker }
26