* [PATCH v1 1/1] erofs-utils: fix endiannes issue
@ 2025-04-29 7:30 Alexander Egorenkov
2025-04-29 8:30 ` Hongbo Li
2025-04-29 13:54 ` Gao Xiang
0 siblings, 2 replies; 5+ messages in thread
From: Alexander Egorenkov @ 2025-04-29 7:30 UTC (permalink / raw)
To: hsiangkao; +Cc: linux-erofs
From: Super User <root@a8345034.lnxne.boe>
Macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined in
user space header 'endian.h'. Not including this header results in
the condition #if __BYTE_ORDER == __LITTLE_ENDIAN being always true, even on
BE architectures (e.g. s390x). Due to this bug the compressor library was
built for LE byte-order on BE arch s390x.
Fixes: bc99c763e3fe ("erofs-utils: switch to effective unaligned access")
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
---
include/erofs/defs.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/erofs/defs.h b/include/erofs/defs.h
index 051a270531ca..196dfa8191a8 100644
--- a/include/erofs/defs.h
+++ b/include/erofs/defs.h
@@ -19,6 +19,7 @@ extern "C"
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
+#include <endian.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v1 1/1] erofs-utils: fix endiannes issue 2025-04-29 7:30 [PATCH v1 1/1] erofs-utils: fix endiannes issue Alexander Egorenkov @ 2025-04-29 8:30 ` Hongbo Li 2025-04-29 11:07 ` Ian Kent 2025-04-29 13:54 ` Gao Xiang 1 sibling, 1 reply; 5+ messages in thread From: Hongbo Li @ 2025-04-29 8:30 UTC (permalink / raw) To: linux-erofs On 2025/4/29 15:30, Alexander Egorenkov wrote: > From: Super User <root@a8345034.lnxne.boe> > > Macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined in > user space header 'endian.h'. Not including this header results in > the condition #if __BYTE_ORDER == __LITTLE_ENDIAN being always true, even on > BE architectures (e.g. s390x). Due to this bug the compressor library was > built for LE byte-order on BE arch s390x. > > Fixes: bc99c763e3fe ("erofs-utils: switch to effective unaligned access") > Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> > --- > include/erofs/defs.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/erofs/defs.h b/include/erofs/defs.h > index 051a270531ca..196dfa8191a8 100644 > --- a/include/erofs/defs.h > +++ b/include/erofs/defs.h > @@ -19,6 +19,7 @@ extern "C" > #include <inttypes.h> > #include <limits.h> > #include <stdbool.h> > +#include <endian.h> > Reviewed-by: Hongbo Li <lihongbo22@huawei.com> > #ifdef HAVE_CONFIG_H > #include <config.h> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] erofs-utils: fix endiannes issue 2025-04-29 8:30 ` Hongbo Li @ 2025-04-29 11:07 ` Ian Kent 0 siblings, 0 replies; 5+ messages in thread From: Ian Kent @ 2025-04-29 11:07 UTC (permalink / raw) To: linux-erofs On 29/4/25 16:30, Hongbo Li wrote: > > > On 2025/4/29 15:30, Alexander Egorenkov wrote: >> From: Super User <root@a8345034.lnxne.boe> >> >> Macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined in >> user space header 'endian.h'. Not including this header results in >> the condition #if __BYTE_ORDER == __LITTLE_ENDIAN being always true, >> even on >> BE architectures (e.g. s390x). Due to this bug the compressor library >> was >> built for LE byte-order on BE arch s390x. >> >> Fixes: bc99c763e3fe ("erofs-utils: switch to effective unaligned >> access") >> Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> >> --- >> include/erofs/defs.h | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/include/erofs/defs.h b/include/erofs/defs.h >> index 051a270531ca..196dfa8191a8 100644 >> --- a/include/erofs/defs.h >> +++ b/include/erofs/defs.h >> @@ -19,6 +19,7 @@ extern "C" >> #include <inttypes.h> >> #include <limits.h> >> #include <stdbool.h> >> +#include <endian.h> > > Reviewed-by: Hongbo Li <lihongbo22@huawei.com> Yes, it makes sense. Reviewed-by: Ian Kent <raven@themaw.net> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] erofs-utils: fix endiannes issue 2025-04-29 7:30 [PATCH v1 1/1] erofs-utils: fix endiannes issue Alexander Egorenkov 2025-04-29 8:30 ` Hongbo Li @ 2025-04-29 13:54 ` Gao Xiang 2025-04-29 14:00 ` Alexander Egorenkov 1 sibling, 1 reply; 5+ messages in thread From: Gao Xiang @ 2025-04-29 13:54 UTC (permalink / raw) To: Alexander Egorenkov; +Cc: hsiangkao, linux-erofs Hi Alexander, On Tue, Apr 29, 2025 at 09:30:52AM +0200, Alexander Egorenkov wrote: > From: Super User <root@a8345034.lnxne.boe> Thanks for catching this, the "From:" line seems invalid, so I change it as "From: Alexander Egorenkov <egorenar@linux.ibm.com>" > > Macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined in > user space header 'endian.h'. Not including this header results in > the condition #if __BYTE_ORDER == __LITTLE_ENDIAN being always true, even on > BE architectures (e.g. s390x). Due to this bug the compressor library was > built for LE byte-order on BE arch s390x. > > Fixes: bc99c763e3fe ("erofs-utils: switch to effective unaligned access") > Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> > --- > include/erofs/defs.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/erofs/defs.h b/include/erofs/defs.h > index 051a270531ca..196dfa8191a8 100644 > --- a/include/erofs/defs.h > +++ b/include/erofs/defs.h > @@ -19,6 +19,7 @@ extern "C" > #include <inttypes.h> > #include <limits.h> > #include <stdbool.h> > +#include <endian.h> I guess it could break MacOS compilation, so I update as below: From d55344291092b69a2ba6f11dbcda52fa534ac124 Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov <egorenar@linux.ibm.com> Date: Tue, 29 Apr 2025 09:30:52 +0200 Subject: [PATCH] erofs-utils: fix endiannes issue Macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined in user space header 'endian.h'. Not including this header results in the condition #if __BYTE_ORDER == __LITTLE_ENDIAN being always true, even on BE architectures (e.g. s390x). Due to this bug the compressor library was built for LE byte-order on BE arch s390x. Fixes: bc99c763e3fe ("erofs-utils: switch to effective unaligned access") Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Reviewed-by: Ian Kent <raven@themaw.net> Reviewed-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> --- configure.ac | 1 + include/erofs/defs.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/configure.ac b/configure.ac index 6e1e7a1..88f1cbe 100644 --- a/configure.ac +++ b/configure.ac @@ -194,6 +194,7 @@ AC_ARG_WITH(selinux, AC_CHECK_HEADERS(m4_flatten([ dirent.h execinfo.h + endian.h fcntl.h getopt.h inttypes.h diff --git a/include/erofs/defs.h b/include/erofs/defs.h index 051a270..21e0f09 100644 --- a/include/erofs/defs.h +++ b/include/erofs/defs.h @@ -24,6 +24,21 @@ extern "C" #include <config.h> #endif +#ifdef HAVE_ENDIAN_H +#include <endian.h> +#else +/* Use GNU C predefined macros as a fallback */ +#ifndef __BYTE_ORDER +#define __BYTE_ORDER __BYTE_ORDER__ +#endif +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +#endif +#ifndef __BIG_ENDIAN +#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__ +#endif +#endif + #ifdef HAVE_LINUX_TYPES_H #include <linux/types.h> #endif -- 2.30.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] erofs-utils: fix endiannes issue 2025-04-29 13:54 ` Gao Xiang @ 2025-04-29 14:00 ` Alexander Egorenkov 0 siblings, 0 replies; 5+ messages in thread From: Alexander Egorenkov @ 2025-04-29 14:00 UTC (permalink / raw) To: Gao Xiang; +Cc: hsiangkao, linux-erofs Hi, Gao Xiang <xiang@kernel.org> writes: > Hi Alexander, > > On Tue, Apr 29, 2025 at 09:30:52AM +0200, Alexander Egorenkov wrote: >> From: Super User <root@a8345034.lnxne.boe> > > Thanks for catching this, the "From:" line seems invalid, so > I change it as "From: Alexander Egorenkov <egorenar@linux.ibm.com>" > Thanks! Argh, sorry for the wrong From field. > > I guess it could break MacOS compilation, so I update as below: > > From d55344291092b69a2ba6f11dbcda52fa534ac124 Mon Sep 17 00:00:00 2001 > From: Alexander Egorenkov <egorenar@linux.ibm.com> > Date: Tue, 29 Apr 2025 09:30:52 +0200 > Subject: [PATCH] erofs-utils: fix endiannes issue > > Macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined in > user space header 'endian.h'. Not including this header results in > the condition #if __BYTE_ORDER == __LITTLE_ENDIAN being always true, > even on BE architectures (e.g. s390x). Due to this bug the compressor > library was built for LE byte-order on BE arch s390x. > > Fixes: bc99c763e3fe ("erofs-utils: switch to effective unaligned access") > Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> > Reviewed-by: Ian Kent <raven@themaw.net> > Reviewed-by: Hongbo Li <lihongbo22@huawei.com> > Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> > --- > configure.ac | 1 + > include/erofs/defs.h | 15 +++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/configure.ac b/configure.ac > index 6e1e7a1..88f1cbe 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -194,6 +194,7 @@ AC_ARG_WITH(selinux, > AC_CHECK_HEADERS(m4_flatten([ > dirent.h > execinfo.h > + endian.h > fcntl.h > getopt.h > inttypes.h > diff --git a/include/erofs/defs.h b/include/erofs/defs.h > index 051a270..21e0f09 100644 > --- a/include/erofs/defs.h > +++ b/include/erofs/defs.h > @@ -24,6 +24,21 @@ extern "C" > #include <config.h> > #endif > > +#ifdef HAVE_ENDIAN_H > +#include <endian.h> > +#else > +/* Use GNU C predefined macros as a fallback */ > +#ifndef __BYTE_ORDER > +#define __BYTE_ORDER __BYTE_ORDER__ > +#endif > +#ifndef __LITTLE_ENDIAN > +#define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ > +#endif > +#ifndef __BIG_ENDIAN > +#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__ > +#endif > +#endif > + > #ifdef HAVE_LINUX_TYPES_H > #include <linux/types.h> > #endif > -- > 2.30.2 Thanks! Regards Alex ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-29 14:00 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-04-29 7:30 [PATCH v1 1/1] erofs-utils: fix endiannes issue Alexander Egorenkov 2025-04-29 8:30 ` Hongbo Li 2025-04-29 11:07 ` Ian Kent 2025-04-29 13:54 ` Gao Xiang 2025-04-29 14:00 ` Alexander Egorenkov
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.