git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] compat/bswap.h: Detect endianness from XL C compiler macros

From
David Michael <fedora.dm0@gmail.com>
Date
Oct 26, 2014, 17:34 UTC
Message-ID
<87k33mag65.fsf@gmail.com>

There is no /usr/include/endian.h equivalent on z/OS, but the compiler will define macros to indicate endianness on host and target hardware. This adds a test for these macros as a last resort for determining byte order.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
---
 compat/bswap.h | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/compat/bswap.h b/compat/bswap.h
index f6fd9a6..7fed637 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -122,6 +122,10 @@ static inline uint64_t git_bswap64(uint64_t x)
 #  define GIT_BYTE_ORDER GIT_BIG_ENDIAN
 # elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
 #  define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN
+# elif defined(__THW_BIG_ENDIAN__) && !defined(__THW_LITTLE_ENDIAN__)
+#  define GIT_BYTE_ORDER GIT_BIG_ENDIAN
+# elif defined(__THW_LITTLE_ENDIAN__) && !defined(__THW_BIG_ENDIAN__)
+#  define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN
 # else
 #  error "Cannot determine endianness"
 # endif
-- 
1.9.3
Next: Jeff King
Message 1 of 4 in “compat/bswap.h: Detect endianness from XL C compiler macros”
  1. 3/3 compat/bswap.h: Detect endianness from XL C compiler macrosDavid Michael, Oct 26, 2014
  2. Jeff KingOct 26, 2014
  3. David MichaelOct 26, 2014
  4. Jeff KingOct 27, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.