mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
libbpf: Fix endianness macro usage for some compilers
Using endian.h and its endianness macros makes this code build in a wider range of compilers, as some don't have those macros (__BYTE_ORDER__, __ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__), so use instead endian.h's macros (__BYTE_ORDER, __LITTLE_ENDIAN, __BIG_ENDIAN) which makes this code even shorter :-) Acked-by: Andrii Nakryiko <andriin@fb.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Fixes:12ef5634a8
("libbpf: simplify endianness check") Fixes:e6c64855fd
("libbpf: add btf__parse_elf API to load .BTF and .BTF.ext") Link: https://lkml.kernel.org/n/tip-eep5n8vgwcdphw3uc058k03u@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
57ebc6230f
commit
cdb2f92071
2 changed files with 6 additions and 4 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <endian.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <asm/unistd.h>
|
||||
|
@ -612,10 +613,10 @@ errout:
|
|||
|
||||
static int bpf_object__check_endianness(struct bpf_object *obj)
|
||||
{
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2LSB)
|
||||
return 0;
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
if (obj->efile.ehdr.e_ident[EI_DATA] == ELFDATA2MSB)
|
||||
return 0;
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue