Skip to content

Commit c3b3367

Browse files
committed
kdumpid: Get rid of endian.h
This include file may conflict with the system <endian.h> (courtesy of Automake adding -I. to compiler flags). Move the content of endian.h to kdumpid.h, because it is included only from that one place anyway. Signed-off-by: Petr Tesarik <[email protected]>
1 parent b669f15 commit c3b3367

File tree

3 files changed

+40
-47
lines changed

3 files changed

+40
-47
lines changed

tools/kdumpid/Makefile.am

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ kdumpid_SOURCES = \
3737
x86.c
3838

3939
noinst_HEADERS = \
40-
kdumpid.h \
41-
endian.h
40+
kdumpid.h
4241

4342
bin_PROGRAMS = kdumpid
4443

tools/kdumpid/endian.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

tools/kdumpid/kdumpid.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,47 @@
55

66
#include <stdint.h>
77
#include <unistd.h>
8+
#include <endian.h>
89
#include <libkdumpfile/kdumpfile.h>
910

10-
#include "endian.h"
11+
/* Older glibc didn't have the byteorder macros */
12+
#ifndef be16toh
13+
14+
#include <byteswap.h>
15+
16+
# if __BYTE_ORDER == __LITTLE_ENDIAN
17+
# define htobe16(x) bswap_16(x)
18+
# define htole16(x) (x)
19+
# define be16toh(x) bswap_16(x)
20+
# define le16toh(x) (x)
21+
22+
# define htobe32(x) bswap_32(x)
23+
# define htole32(x) (x)
24+
# define be32toh(x) bswap_32(x)
25+
# define le32toh(x) (x)
26+
27+
# define htobe64(x) bswap_64(x)
28+
# define htole64(x) (x)
29+
# define be64toh(x) bswap_64(x)
30+
# define le64toh(x) (x)
31+
# else
32+
# define htobe16(x) (x)
33+
# define htole16(x) bswap_16(x)
34+
# define be16toh(x) (x)
35+
# define le16toh(x) bswap_16(x)
36+
37+
# define htobe32(x) (x)
38+
# define htole32(x) bswap_32(x)
39+
# define be32toh(x) (x)
40+
# define le32toh(x) bswap_32(x)
41+
42+
# define htobe64(x) (x)
43+
# define htole64(x) bswap_64(x)
44+
# define be64toh(x) (x)
45+
# define le64toh(x) bswap_64(x)
46+
# endif
47+
48+
#endif
1149

1250
#define INVALID_ADDR ((uint64_t)-1ULL)
1351

0 commit comments

Comments
 (0)