Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Feb 2023 03:16:40 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: bae5c73a5ffa - releng/13.2 - sys/_endian.h: Move powerpc workaround into _endian.h
Message-ID:  <202302190316.31J3Ge2V084020@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/13.2 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=bae5c73a5ffa237e437605bbf2216a574d1dbda2

commit bae5c73a5ffa237e437605bbf2216a574d1dbda2
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-02-16 16:58:33 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-19 03:14:36 +0000

    sys/_endian.h: Move powerpc workaround into _endian.h
    
    Powerpc compilers often define _BIG_ENDIAN or _LITTLE_ENDIAN depending
    on the byte order of the target. This interfers with the endian.h and
    sys/endian.h APIs which expect those two to be 4321 or 1234.
    Unconditionally undefine these two before we define them to work around
    this issue. By including endian.h, the programmer is saying they want
    this API not the native one. This matches historic practice as well.
    
    Fixes:          e35448a901aa
    Sponsored by:   Netflix
    Noticed by:     powerpc, powerpc64 CI jobs
    Approved by:    re (cperciva)
    
    (cherry picked from commit 6f23df1ae7f6ec3cd06a15c87f0aaaa770b2941b)
    (cherry picked from commit 07e39710b170859ef6a57185f9a775973f3eeffe)
---
 sys/sys/_endian.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/sys/_endian.h b/sys/sys/_endian.h
index ff909f532663..7ac39386e2e1 100644
--- a/sys/sys/_endian.h
+++ b/sys/sys/_endian.h
@@ -41,9 +41,13 @@
 
 /*
  * Definitions for byte order, according to byte significance from low
- * address to high.
+ * address to high. We undefine any prior definition of them because
+ * powerpc compilers define _LITTLE_ENDIAN and _BIG_ENDIAN to mean
+ * something else.
  */
+#undef _LITTLE_ENDIAN
 #define	_LITTLE_ENDIAN	__ORDER_LITTLE_ENDIAN__ /* LSB first: 1234 */
+#undef _BIG_ENDIAN
 #define	_BIG_ENDIAN	__ORDER_BIG_ENDIAN__    /* MSB first: 4321 */
 #define	_PDP_ENDIAN	__ORDER_PDP_ENDIAN__    /* LSB first in word,
 						 * MSW first in long: 3412 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302190316.31J3Ge2V084020>