cjson: bump to version 1.4.3
[buildroot-gz.git] / package / skalibs / 0001-No-runtime-tests-for-endianness.patch
blob5f763c4261df1f2f4c4f69ec4b835b3ae6c17cad
1 From 6754b208e7ec3bd1d4265db18fa4c0e7961a77bf Mon Sep 17 00:00:00 2001
2 From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
3 Date: Mon, 20 Mar 2017 20:05:00 +0100
4 Subject: [PATCH] No runtime tests for endianness
6 Replace build and execution of runtime test programs for determining
7 the endianness of the target with compile time test programs.
9 This improves support for cross-compilation.
11 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
12 ---
13 configure | 15 +++++++++++----
14 src/sysdeps/trybigendian.c | 16 ++++++++++++++++
15 src/sysdeps/trylittleendian.c | 19 +++++++++++++++++++
16 3 files changed, 46 insertions(+), 4 deletions(-)
17 create mode 100644 src/sysdeps/trybigendian.c
18 create mode 100644 src/sysdeps/trylittleendian.c
20 diff --git a/configure b/configure
21 index 1579025..4da9c5e 100755
22 --- a/configure
23 +++ b/configure
24 @@ -463,13 +463,20 @@ EOF
26 exec 3>&-
28 - echo "Checking system endianness..."
29 - $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO -o tryendianness src/sysdeps/tryendianness.c
30 - endianness=$(./tryendianness) || fail "$0: unable to determine endianness"
31 + echo "Checking system endianness..."
32 + if $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO -o trybigendian src/sysdeps/trybigendian.c 2>/dev/null; then
33 + endianness=big
34 + else
35 + if $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO -o trylittleendian src/sysdeps/trylittleendian.c 2>/dev/null; then
36 + endianness=little
37 + else
38 + fail "$0: unable to determine endianness"
39 + fi
40 + fi
41 echo "endianness: $endianness" >> $sysdeps/sysdeps
42 echo "#define ${package_macro_name}_ENDIANNESS \"$endianness\"" >> $sysdeps/sysdeps.h
43 echo " ... $endianness"
44 - rm -f tryendianness
45 + rm -f trybigendian trylittleendian
47 trytypesize ushort USHORT "unsigned short"
48 trytypesize uint UINT "unsigned int"
49 diff --git a/src/sysdeps/trybigendian.c b/src/sysdeps/trybigendian.c
50 new file mode 100644
51 index 0000000..d857572
52 --- /dev/null
53 +++ b/src/sysdeps/trybigendian.c
54 @@ -0,0 +1,16 @@
55 +#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN) || \
56 + defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
57 + defined(__BIG_ENDIAN) || \
58 + defined(__ARMEB__) || \
59 + defined(__THUMBEB__) || \
60 + defined(__AARCH64EB__) || \
61 + defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
62 +#define YEAH
63 +#else
64 +#error "not big endian"
65 +#endif
67 +int main(void)
69 + return 0;
71 diff --git a/src/sysdeps/trylittleendian.c b/src/sysdeps/trylittleendian.c
72 new file mode 100644
73 index 0000000..68b93c1
74 --- /dev/null
75 +++ b/src/sysdeps/trylittleendian.c
76 @@ -0,0 +1,19 @@
77 +#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \
78 + defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
79 + defined(__LITTLE_ENDIAN) || \
80 + defined(__ARMEL__) || \
81 + defined(__THUMBEL__) || \
82 + defined(__AARCH64EL__) || \
83 + defined(__i386) || defined(__i386__) || \
84 + defined(__amd64) || defined(__amd64__) || \
85 + defined(__x86_64) || defined(__x86_64__) || \
86 + defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
87 +#define YEAH
88 +#else
89 +#error "not little endian"
90 +#endif
92 +int main(void)
94 + return 0;
96 --
97 2.1.4