Skip to content

Commit e16354b

Browse files
pbo-linarobonzini
authored andcommitted
exec/cpu-all: remove BSWAP_NEEDED
This identifier is poisoned, so it can't be used from common code anyway. We replace all occurrences with its definition directly. Signed-off-by: Pierrick Bouvier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 134ab17 commit e16354b

File tree

5 files changed

+8
-21
lines changed

5 files changed

+8
-21
lines changed

bsd-user/elfload.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static inline void memcpy_fromfs(void *to, const void *from, unsigned long n)
4444
memcpy(to, from, n);
4545
}
4646

47-
#ifdef BSWAP_NEEDED
47+
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
4848
static void bswap_ehdr(struct elfhdr *ehdr)
4949
{
5050
bswap16s(&ehdr->e_type); /* Object file type */
@@ -111,15 +111,15 @@ static void bswap_note(struct elf_note *en)
111111
bswap32s(&en->n_type);
112112
}
113113

114-
#else /* ! BSWAP_NEEDED */
114+
#else
115115

116116
static void bswap_ehdr(struct elfhdr *ehdr) { }
117117
static void bswap_phdr(struct elf_phdr *phdr, int phnum) { }
118118
static void bswap_shdr(struct elf_shdr *shdr, int shnum) { }
119119
static void bswap_sym(struct elf_sym *sym) { }
120120
static void bswap_note(struct elf_note *en) { }
121121

122-
#endif /* ! BSWAP_NEEDED */
122+
#endif /* HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN */
123123

124124
#include "elfcore.c"
125125

include/exec/cpu-all.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@
2626
#include "exec/tswap.h"
2727
#include "hw/core/cpu.h"
2828

29-
/* some important defines:
30-
*
31-
* HOST_BIG_ENDIAN : whether the host cpu is big endian and
32-
* otherwise little endian.
33-
*
34-
* TARGET_BIG_ENDIAN : same for the target cpu
35-
*/
36-
37-
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
38-
#define BSWAP_NEEDED
39-
#endif
40-
4129
/* Target-endianness CPU memory access functions. These fit into the
4230
* {ld,st}{type}{sign}{size}{endian}_p naming scheme described in bswap.h.
4331
*/

include/exec/poison.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#pragma GCC poison TARGET_NAME
3838
#pragma GCC poison TARGET_SUPPORTS_MTTCG
3939
#pragma GCC poison TARGET_BIG_ENDIAN
40-
#pragma GCC poison BSWAP_NEEDED
4140

4241
#pragma GCC poison TARGET_LONG_BITS
4342
#pragma GCC poison TARGET_FMT_lx

linux-user/elfload.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
21212121
memcpy(to, from, n);
21222122
}
21232123

2124-
#ifdef BSWAP_NEEDED
2124+
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
21252125
static void bswap_ehdr(struct elfhdr *ehdr)
21262126
{
21272127
bswap16s(&ehdr->e_type); /* Object file type */
@@ -3143,7 +3143,7 @@ static bool parse_elf_properties(const ImageSource *src,
31433143
* The contents of a valid PT_GNU_PROPERTY is a sequence of uint32_t.
31443144
* Swap most of them now, beyond the header and namesz.
31453145
*/
3146-
#ifdef BSWAP_NEEDED
3146+
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
31473147
for (int i = 4; i < n / 4; i++) {
31483148
bswap32s(note.data + i);
31493149
}
@@ -3999,7 +3999,7 @@ struct target_elf_prpsinfo {
39993999
char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
40004000
};
40014001

4002-
#ifdef BSWAP_NEEDED
4002+
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
40034003
static void bswap_prstatus(struct target_elf_prstatus *prstatus)
40044004
{
40054005
prstatus->pr_info.si_signo = tswap32(prstatus->pr_info.si_signo);
@@ -4038,7 +4038,7 @@ static void bswap_note(struct elf_note *en)
40384038
static inline void bswap_prstatus(struct target_elf_prstatus *p) { }
40394039
static inline void bswap_psinfo(struct target_elf_prpsinfo *p) {}
40404040
static inline void bswap_note(struct elf_note *en) { }
4041-
#endif /* BSWAP_NEEDED */
4041+
#endif /* HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN */
40424042

40434043
/*
40444044
* Calculate file (dump) size of given memory region.

linux-user/syscall_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ typedef struct {
462462
abi_ulong sig[TARGET_NSIG_WORDS];
463463
} target_sigset_t;
464464

465-
#ifdef BSWAP_NEEDED
465+
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN
466466
static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
467467
{
468468
int i;

0 commit comments

Comments
 (0)