OSDN Git Service

target/arm/arm-semi: Restrict use of TaskState*
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 16 Sep 2019 14:15:34 +0000 (15:15 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 15 Oct 2019 17:09:03 +0000 (18:09 +0100)
commit6ed6845532ef023ab9953e22f3aada6aa59657b9
treeb89846758c69eb739f29641c48b340ee5bedcdab
parent35e9a0a8ce4be12a86e5cedd1268ff22eeacdc9e
target/arm/arm-semi: Restrict use of TaskState*

The semihosting code needs accuss to the linux-user only
TaskState pointer so it can set the semihosting errno per-thread
for linux-user mode. At the moment we do this by having some
ifdefs so that we define a 'ts' local in do_arm_semihosting()
which is either a real TaskState * or just a CPUARMState *,
depending on which mode we're compiling for.

This is awkward if we want to refactor do_arm_semihosting()
into other functions which might need to be passed the TaskState.
Restrict usage of the TaskState local by:
 * making set_swi_errno() always take the CPUARMState pointer
   and (for the linux-user version) get TaskState from that
 * creating a new get_swi_errno() which reads the errno
 * having the two semihosting calls which need the TaskState
   for other purposes (SYS_GET_CMDLINE and SYS_HEAPINFO)
   define a variable with scope restricted to just that code

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190916141544.17540-6-peter.maydell@linaro.org
target/arm/arm-semi.c