cleanup: make get_syscall_result.c files more readable

Make get_syscall_result.c files more self-contained.  While they are
still being included by syscall.c, the latter no longer provides
a function framework for them.

* linux/alpha/get_syscall_result.c (get_syscall_result_regs): Define.
* linux/bfin/get_syscall_result.c: Likewise.
* linux/crisv10/get_syscall_result.c: Likewise.
* linux/hppa/get_syscall_result.c: Likewise.
* linux/m68k/get_syscall_result.c: Likewise.
* linux/microblaze/get_syscall_result.c: Likewise.
* linux/sh/get_syscall_result.c: Likewise.
* linux/sh64/get_syscall_result.c: Likewise.
* linux/xtensa/get_syscall_result.c: Likewise.
* syscall.c [!ARCH_REGS_FOR_GETREGSET && !ARCH_REGS_FOR_GETREGS]:
Define USE_GET_SYSCALL_RESULT_REGS macro.
[USE_GET_SYSCALL_RESULT_REGS]: Include "get_syscall_result.c".
(get_syscall_result) [USE_GET_SYSCALL_RESULT_REGS]: Stop including
"get_syscall_result.c".  Call get_syscall_result_regs.

Requested-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Дмитрий Левин 2015-11-30 00:01:01 +00:00
parent 0c8c5c9f4e
commit f51aec6abf
10 changed files with 57 additions and 27 deletions

View File

@ -1,4 +1,6 @@
if (upeek(tcp->pid, REG_A3, &alpha_a3) < 0)
return -1;
if (upeek(tcp->pid, REG_R0, &alpha_r0) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
return (upeek(tcp->pid, REG_A3, &alpha_a3) < 0 ||
upeek(tcp->pid, REG_R0, &alpha_r0) < 0) ? -1 : 0;
}

View File

@ -1,2 +1,5 @@
if (upeek(tcp->pid, PT_R0, &bfin_r0) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, PT_R0, &bfin_r0) < 0 ? -1 : 0;
}

View File

@ -1,2 +1,5 @@
if (upeek(tcp->pid, 4*PT_R10, &cris_r10) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, 4 * PT_R10, &cris_r10) < 0 ? -1 : 0;
}

View File

@ -1,2 +1,5 @@
if (upeek(tcp->pid, PT_GR28, &hppa_r28) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, PT_GR28, &hppa_r28) < 0 ? -1 : 0;
}

View File

@ -1,2 +1,5 @@
if (upeek(tcp->pid, 4*PT_D0, &m68k_d0) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, 4 * PT_D0, &m68k_d0) < 0 ? -1 : 0;
}

View File

@ -1,2 +1,5 @@
if (upeek(tcp->pid, 3 * 4, &microblaze_r3) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, 3 * 4, &microblaze_r3) < 0 ? -1 : 0;
}

View File

@ -1,3 +1,6 @@
/* new syscall ABI returns result in R0 */
if (upeek(tcp->pid, 4*REG_REG0, (long *)&sh_r0) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
/* new syscall ABI returns result in R0 */
return upeek(tcp->pid, 4 * REG_REG0, (long *)&sh_r0) < 0 ? -1 : 0;
}

View File

@ -1,3 +1,6 @@
/* ABI defines result returned in r9 */
if (upeek(tcp->pid, REG_GENERAL(9), (long *)&sh64_r9) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
/* ABI defines result returned in r9 */
return upeek(tcp->pid, REG_GENERAL(9), (long *)&sh64_r9) < 0 ? -1 : 0;
}

View File

@ -1,2 +1,5 @@
if (upeek(tcp->pid, REG_A_BASE + 2, &xtensa_a2) < 0)
return -1;
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, REG_A_BASE + 2, &xtensa_a2) < 0 ? -1 : 0;
}

View File

@ -1253,6 +1253,7 @@ get_regset(pid_t pid)
void
get_regs(pid_t pid)
{
#undef USE_GET_SYSCALL_RESULT_REGS
#ifdef ARCH_REGS_FOR_GETREGSET
# ifdef X86_64
/* Try PTRACE_GETREGSET first, fallback to PTRACE_GETREGS. */
@ -1295,7 +1296,8 @@ get_regs(pid_t pid)
# endif
#else /* !ARCH_REGS_FOR_GETREGSET && !ARCH_REGS_FOR_GETREGS */
# warning get_regs is not implemented for this architecture yet
# define USE_GET_SYSCALL_RESULT_REGS 1
# warning get_regs is not implemented for this architecture yet
get_regs_error = 0;
#endif
}
@ -1343,6 +1345,9 @@ get_syscall_args(struct tcb *tcp)
return 1;
}
#ifdef USE_GET_SYSCALL_RESULT_REGS
# include "get_syscall_result.c"
#endif
#include "get_error.c"
/* Returns:
@ -1353,10 +1358,9 @@ get_syscall_args(struct tcb *tcp)
static int
get_syscall_result(struct tcb *tcp)
{
#if defined ARCH_REGS_FOR_GETREGSET || defined ARCH_REGS_FOR_GETREGS
/* already done by get_regs */
#else
# include "get_syscall_result.c"
#ifdef USE_GET_SYSCALL_RESULT_REGS
if (get_syscall_result_regs(tcp))
return -1;
#endif
tcp->u_error = 0;
get_error(tcp, !(tcp->s_ent->sys_flags & SYSCALL_NEVER_FAILS));