From: Rick Richard <[email protected]> TARGET_BIG_ENDIAN and HOST_BIG_ENDIAN are always defined.
lseek and target_offset64() transpose upper and lower halves on 32-bit ABIs, -strace prints wrong off_t. Signed-off-by: Rick Richard <[email protected]> [ fixed defined() too ] Reviewed-by: Warner Losh <[email protected]> Signed-off-by: Warner Losh <[email protected]> --- bsd-user/bsd-file.h | 2 +- bsd-user/freebsd/os-misc.h | 2 +- bsd-user/freebsd/os-thread.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 0fefc07232..a2c2e38e50 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -986,7 +986,7 @@ static abi_long do_bsd_lseek(CPUArchState *env, abi_long arg1, abi_long arg2, ret = get_errno(res); set_second_rval(env, 0xFFFFFFFF); } else { -#ifdef TARGET_BIG_ENDIAN +#if TARGET_BIG_ENDIAN ret = ((res >> 32) & 0xFFFFFFFF); set_second_rval(env, res & 0xFFFFFFFF); #else diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h index 0f87b21cc8..e9f9eed4b4 100644 --- a/bsd-user/freebsd/os-misc.h +++ b/bsd-user/freebsd/os-misc.h @@ -336,7 +336,7 @@ static inline abi_long do_freebsd_kldsym(abi_long fileid, abi_long cmd, #if TARGET_ABI_BITS == 32 static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) { -#ifdef TARGET_BIG_ENDIAN +#if TARGET_BIG_ENDIAN return ((uint64_t)word0 << 32) | word1; #else return ((uint64_t)word1 << 32) | word0; diff --git a/bsd-user/freebsd/os-thread.h b/bsd-user/freebsd/os-thread.h index 4258b24095..6552c60337 100644 --- a/bsd-user/freebsd/os-thread.h +++ b/bsd-user/freebsd/os-thread.h @@ -18,7 +18,7 @@ int safe_thr_suspend(struct timespec *timeout); int safe__umtx_op(void *, int, unsigned long, void *, void *); -#if defined(HOST_BIG_ENDIAN) == defined(TARGET_BIG_ENDIAN) && \ +#if HOST_BIG_ENDIAN == TARGET_BIG_ENDIAN && \ (TARGET_ABI_BITS == HOST_LONG_BITS || defined(UMTX_OP__32BIT)) #define _UMTX_OPTIMIZED #if defined(TARGET_ABI32) -- 2.55.0
