unicore32: convert get_sp_from_cpustate from macro to inline
PATCH 1/1 unicore32: convert get_sp_from_cpustate from macro to inline
All other architectures define get_sp_from_cpustate as an inline function, only unicore32 uses a #define. With this, some usages are impossible, for example, enabling sigaltstack in linux-user/syscall.c results in
linux-user/syscall.c: In function ‘do_syscall’:linux-user/syscall.c:8299:39: error: dereferencing ‘void *’ pointer [-Werror]
get_sp_from_cpustate(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env));
^linux-user/syscall.c:8299:39: error: request for member ‘regs’ in something not a structure or union
--- linux-user/unicore32/target_signal.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/unicore32/target_signal.h +5 -1
@@ -21,6 +21,10 @@ typedef struct target_sigaltstack {#define TARGET_SS_ONSTACK 1#define TARGET_SS_DISABLE 2 -#define get_sp_from_cpustate (cpustate) (cpustate->regs[29]) +static inline abi_ulong get_sp_from_cpustate (CPUUniCore32State *state) +{ +return state->regs[29 ]; +} +#endif /* TARGET_SIGNAL_H */
Signature · 1 line
2.1.4
Quoted 9 lines · Michael Tokarev
All other architectures define
get_sp_from_cpustateas an inline function, only unicore32 uses a #define. With this, some usages are impossible, for example, enabling sigaltstack inlinux-user/syscall.cresults in
linux-user/syscall.c: In function ‘do_syscall’:linux-user/syscall.c:8299:39: error: dereferencing ‘void *’ pointer [-Werror]get_sp_from_cpustate(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env)); ^
linux-user/syscall.c:8299:39: error: request for member ‘regs’ in something not a structure or union
I think this is a bug in the macro implementation (lack of brackets around the macro argument on its RHS) rather than a macro being impossible to use for this, but I agree that the inline function is better both for consistency with other targets and as a style issue.
thanks
-- PMM