pixz: Fix build on big-endian/musl systems

(From OE-Core rev: 364f625480dca41d2902e209e4bfb675b1a93dce)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Khem Raj 2016-03-22 07:56:17 +00:00 committed by Richard Purdie
parent 421289cbcc
commit af1f77a1eb
3 changed files with 103 additions and 2 deletions

View File

@ -0,0 +1,51 @@
From c84480be8df6966c538d1fb67ccae2f42cc46421 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 22 Mar 2016 07:36:54 +0000
Subject: [PATCH 1/2] configure: Detect headers before using them
Current logic does not work when system does not have
sys/endian.h, since it tried to reuse the cached results
from first try of detecting htole64 in sys/endian.h which is
'no' and hence the second try to look into endian.h also
comes out negative.
So we check for header and then run the test for symbols
and these symbols are not standard and we need to define _GNU_SOURCE
for it to work, this issue is exposed by systems using musl e.g.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Submitted
configure.ac | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4cb56bc..5e23c50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,12 +69,17 @@ AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memchr memmove memset strerror strtol])
-AC_CHECK_DECLS([htole64, le64toh],
- [],
+AC_CHECK_HEADER([sys/endian.h],
[
- AC_CHECK_DECLS([htole64, le64toh], [], [], [#include <endian.h>])
+ AC_CHECK_DECLS([htole64, le64toh], [], [], [#define _GNU_SOURCE 1 #include <sys/endian.h>])
],
- [#include <sys/endian.h>])
+ [], [])
+
+AC_CHECK_HEADER([endian.h],
+ [
+ AC_CHECK_DECLS([htole64, le64toh], [], [], [#define _GNU_SOURCE 1 #include <endian.h>])
+ ],
+ [], [])
AC_CONFIG_FILES([Makefile
src/Makefile
--
1.8.3.1

View File

@ -0,0 +1,47 @@
From 5f3a535987bae4c3e3d9e9079c7526e399f7aecd Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 22 Mar 2016 07:42:39 +0000
Subject: [PATCH 2/2] endian: Use macro bswap_64 instead of __bswap_64
byteswap.h defines then as public APIs on all libc
on linux including musl
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Submitted
src/endian.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/endian.c b/src/endian.c
index b7724f3..51aea58 100644
--- a/src/endian.c
+++ b/src/endian.c
@@ -15,6 +15,7 @@ void xle64enc(uint8_t *d, uint64_t n) {
#include <stdint.h>
#ifdef __linux__
#include <endian.h>
+ #include <byteswap.h>
#else
#include <sys/endian.h>
#endif
@@ -23,7 +24,7 @@ void xle64enc(uint8_t *d, uint64_t n) {
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define htole64(x) (x)
# else
-# define htole64(x) __bswap_64 (x)
+# define htole64(x) bswap_64 (x)
# endif
#endif
@@ -31,7 +32,7 @@ void xle64enc(uint8_t *d, uint64_t n) {
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define le64toh(x) (x)
# else
-# define le64toh(x) __bswap_64 (x)
+# define le64toh(x) bswap_64 (x)
# endif
#endif
--
1.8.3.1

View File

@ -9,11 +9,14 @@ SRC_URI[sha256sum] = "02c50746b134fa1b1aae41fcc314d7c6f1919b3d48bcdea01bf11769f8
LICENSE = "BSD-2-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=5cf6d164086105f1512ccb81bfff1926"
SRC_URI += "file://936d8068ae19d95260d3058f41dd6cf718101cd6.patch"
SRC_URI += "file://936d8068ae19d95260d3058f41dd6cf718101cd6.patch \
file://0001-configure-Detect-headers-before-using-them.patch \
file://0002-endian-Use-macro-bswap_64-instead-of-__bswap_64.patch \
"
UPSTREAM_CHECK_URI = "https://github.com/vasi/pixz/releases"
EXTRA_OECONF += "--without-manpage"
CFLAGS_append_libc-musl = " -D_GNU_SOURCE"
CACHED_CONFIGUREVARS += "ac_cv_file_src_pixz_1=no"
inherit autotools pkgconfig