[PATCH V2] Cygwin: Update _endian.h to handle unsupported arch

Thirumalai Nagalingam thirumalai.nagalingam@multicorewareinc.com
Fri Jan 9 09:10:58 GMT 2026


Hi Corinna,

> can you check your patch again?  It fails to apply for me against current main.

Please accept my apologies for the previous patch. I had generated it from a
diff branch in my fork, which caused it not to apply cleanly. I've now
regenerated the patch against the current main, and it should apply cleanly.

> Also, would you mind to add a Fixes: tag?

I've also added the appropriate Fixes tag & realized I forgot to include the
Signed-off-by line in the previous version, that's been corrected now.

Thanks,
Thiru

In-Lined patch:

diff --git a/winsup/cygwin/include/machine/_endian.h b/winsup/cygwin/include/machine/_endian.h
index 622d7a2e9..48ff242b5 100644
--- a/winsup/cygwin/include/machine/_endian.h
+++ b/winsup/cygwin/include/machine/_endian.h
@@ -28,8 +28,10 @@ __ntohl(__uint32_t _x)
 {
 #if defined(__x86_64__)
        __asm__("bswap %0" : "=r" (_x) : "0" (_x));
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
        __asm__("rev %w0, %w0" : "=r" (_x) : "0" (_x));
+#else
+#error "unsupported architecture"
 #endif
        return _x;
 }
@@ -41,10 +43,12 @@ __ntohs(__uint16_t _x)
        __asm__("xchgb %b0,%h0"         /* swap bytes           */
                : "=Q" (_x)
                :  "0" (_x));
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
        __asm__("uxth %w0, %w0\n\t"
                "rev16 %w0, %w0"
                : "+r" (_x));
+#else
+#error "unsupported architecture"
 #endif
        return _x;
 }
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Cygwin-Update-_endian.h-to-handle-unsupported-arch.patch
Type: application/octet-stream
Size: 1701 bytes
Desc: 0001-Cygwin-Update-_endian.h-to-handle-unsupported-arch.patch
URL: <https://cygwin.com/pipermail/cygwin-patches/attachments/20260109/7ddfe1d8/attachment.obj>


More information about the Cygwin-patches mailing list