Skip to content

Commit e03b568

Browse files
elmarcobonzini
authored andcommitted
Replace config-time define HOST_WORDS_BIGENDIAN
Replace a config-time define with a compile time condition define (compatible with clang and gcc) that must be declared prior to its usage. This avoids having a global configure time define, but also prevents from bad usage, if the config header wasn't included before. This can help to make some code independent from qemu too. gcc supports __BYTE_ORDER__ from about 4.6 and clang from 3.2. Signed-off-by: Marc-André Lureau <[email protected]> [ For the s390x parts I'm involved in ] Acked-by: Halil Pasic <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 3f6c2e8 commit e03b568

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+173
-174
lines changed

accel/kvm/kvm-all.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,8 @@ void kvm_hwpoison_page_add(ram_addr_t ram_addr)
12021202

12031203
static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size)
12041204
{
1205-
#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
1206-
/* The kernel expects ioeventfd values in HOST_WORDS_BIGENDIAN
1205+
#if HOST_BIG_ENDIAN != defined(TARGET_WORDS_BIGENDIAN)
1206+
/* The kernel expects ioeventfd values in HOST_BIG_ENDIAN
12071207
* endianness, but the memory core hands them in target endianness.
12081208
* For example, PPC is always treated as big-endian even if running
12091209
* on KVM and on PPC64LE. Correct here.

accel/tcg/atomic_template.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
the ATOMIC_NAME macro, and redefined below. */
6464
#if DATA_SIZE == 1
6565
# define END
66-
#elif defined(HOST_WORDS_BIGENDIAN)
66+
#elif HOST_BIG_ENDIAN
6767
# define END _be
6868
#else
6969
# define END _le
@@ -196,7 +196,7 @@ GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)
196196

197197
/* Define reverse-host-endian atomic operations. Note that END is used
198198
within the ATOMIC_NAME macro. */
199-
#ifdef HOST_WORDS_BIGENDIAN
199+
#if HOST_BIG_ENDIAN
200200
# define END _le
201201
#else
202202
# define END _be

audio/audio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
typedef void (*audio_callback_fn) (void *opaque, int avail);
3434

35-
#ifdef HOST_WORDS_BIGENDIAN
35+
#if HOST_BIG_ENDIAN
3636
#define AUDIO_HOST_ENDIANNESS 1
3737
#else
3838
#define AUDIO_HOST_ENDIANNESS 0

audio/dbusaudio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static size_t dbus_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
122122
return size;
123123
}
124124

125-
#ifdef HOST_WORDS_BIGENDIAN
125+
#if HOST_BIG_ENDIAN
126126
#define AUDIO_HOST_BE TRUE
127127
#else
128128
#define AUDIO_HOST_BE FALSE

disas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static void initialize_debug_host(CPUDebug *s)
144144

145145
s->info.read_memory_func = host_read_memory;
146146
s->info.print_address_func = host_print_address;
147-
#ifdef HOST_WORDS_BIGENDIAN
147+
#if HOST_BIG_ENDIAN
148148
s->info.endian = BFD_ENDIAN_BIG;
149149
#else
150150
s->info.endian = BFD_ENDIAN_LITTLE;

hw/core/loader.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ ssize_t load_elf_ram_sym(const char *filename,
474474
ret = ELF_LOAD_NOT_ELF;
475475
goto fail;
476476
}
477-
#ifdef HOST_WORDS_BIGENDIAN
477+
#if HOST_BIG_ENDIAN
478478
data_order = ELFDATA2MSB;
479479
#else
480480
data_order = ELFDATA2LSB;
@@ -511,7 +511,7 @@ ssize_t load_elf_ram_sym(const char *filename,
511511

512512
static void bswap_uboot_header(uboot_image_header_t *hdr)
513513
{
514-
#ifndef HOST_WORDS_BIGENDIAN
514+
#if !HOST_BIG_ENDIAN
515515
bswap32s(&hdr->ih_magic);
516516
bswap32s(&hdr->ih_hcrc);
517517
bswap32s(&hdr->ih_time);

hw/display/artist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define TYPE_ARTIST "artist"
2727
OBJECT_DECLARE_SIMPLE_TYPE(ARTISTState, ARTIST)
2828

29-
#ifdef HOST_WORDS_BIGENDIAN
29+
#if HOST_BIG_ENDIAN
3030
#define ROP8OFF(_i) (3 - (_i))
3131
#else
3232
#define ROP8OFF
@@ -712,7 +712,7 @@ static void combine_write_reg(hwaddr addr, uint64_t val, int size, void *out)
712712
* FIXME: is there a qemu helper for this?
713713
*/
714714

715-
#ifndef HOST_WORDS_BIGENDIAN
715+
#if !HOST_BIG_ENDIAN
716716
addr ^= 3;
717717
#endif
718718

@@ -1087,7 +1087,7 @@ static uint64_t combine_read_reg(hwaddr addr, int size, void *in)
10871087
* FIXME: is there a qemu helper for this?
10881088
*/
10891089

1090-
#ifndef HOST_WORDS_BIGENDIAN
1090+
#if !HOST_BIG_ENDIAN
10911091
addr ^= 3;
10921092
#endif
10931093

hw/display/pl110_template.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
#if ORDER == 0
1717
#define NAME glue(lblp_, BORDER)
18-
#ifdef HOST_WORDS_BIGENDIAN
18+
#if HOST_BIG_ENDIAN
1919
#define SWAP_WORDS 1
2020
#endif
2121
#elif ORDER == 1
2222
#define NAME glue(bbbp_, BORDER)
23-
#ifndef HOST_WORDS_BIGENDIAN
23+
#if !HOST_BIG_ENDIAN
2424
#define SWAP_WORDS 1
2525
#endif
2626
#else
2727
#define SWAP_PIXELS 1
2828
#define NAME glue(lbbp_, BORDER)
29-
#ifdef HOST_WORDS_BIGENDIAN
29+
#if HOST_BIG_ENDIAN
3030
#define SWAP_WORDS 1
3131
#endif
3232
#endif

hw/display/pxa2xx_lcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ typedef struct QEMU_PACKED {
199199
SKIP_PIXEL(to); \
200200
} while (0)
201201

202-
#ifdef HOST_WORDS_BIGENDIAN
202+
#if HOST_BIG_ENDIAN
203203
# define SWAP_WORDS 1
204204
#endif
205205

hw/display/vga.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,19 @@ const uint8_t gr_mask[16] = {
9494
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
9595
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) ))
9696

97-
#ifdef HOST_WORDS_BIGENDIAN
97+
#if HOST_BIG_ENDIAN
9898
#define PAT(x) cbswap_32(x)
9999
#else
100100
#define PAT(x) (x)
101101
#endif
102102

103-
#ifdef HOST_WORDS_BIGENDIAN
103+
#if HOST_BIG_ENDIAN
104104
#define BIG 1
105105
#else
106106
#define BIG 0
107107
#endif
108108

109-
#ifdef HOST_WORDS_BIGENDIAN
109+
#if HOST_BIG_ENDIAN
110110
#define GET_PLANE(data, p) (((data) >> (24 - (p) * 8)) & 0xff)
111111
#else
112112
#define GET_PLANE(data, p) (((data) >> ((p) * 8)) & 0xff)
@@ -133,7 +133,7 @@ static const uint32_t mask16[16] = {
133133

134134
#undef PAT
135135

136-
#ifdef HOST_WORDS_BIGENDIAN
136+
#if HOST_BIG_ENDIAN
137137
#define PAT(x) (x)
138138
#else
139139
#define PAT(x) cbswap_32(x)
@@ -1296,7 +1296,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12961296
if (cx > cx_max)
12971297
cx_max = cx;
12981298
*ch_attr_ptr = ch_attr;
1299-
#ifdef HOST_WORDS_BIGENDIAN
1299+
#if HOST_BIG_ENDIAN
13001300
ch = ch_attr >> 8;
13011301
cattr = ch_attr & 0xff;
13021302
#else
@@ -1477,7 +1477,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
14771477
vga_draw_line_func *vga_draw_line = NULL;
14781478
bool share_surface, force_shadow = false;
14791479
pixman_format_code_t format;
1480-
#ifdef HOST_WORDS_BIGENDIAN
1480+
#if HOST_BIG_ENDIAN
14811481
bool byteswap = !s->big_endian_fb;
14821482
#else
14831483
bool byteswap = s->big_endian_fb;

0 commit comments

Comments
 (0)