Thread (6 messages) flat view 6 messages, 4 authors, 2020-11-10

Re: [PATCH] compat/bswap.h: detect ARM64 when using MSVC

From: brian m. carlson <hidden>
Date: 2020-11-10 23:39:29

On 2020-11-10 at 13:58:21, Johannes Schindelin wrote:
The biggest question now is: are we certain that `_M_ARM64` implies
little-endian?
For Windows?  Yes.  I'm almost certain Windows has only supported
little-endian architectures, possibly with the exception of gaming
consoles.
I remember that ARM (the 32-bit variety, that is) has support for
switching endianness on the fly. Happily, MSVC talks specifically about
_not_ supporting that:
https://docs.microsoft.com/en-us/cpp/build/overview-of-arm-abi-conventions

Likewise, it says the same about ARM64 (mentioning that it would be much
harder to switch endianness there to begin with):
https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions

So does that make us confident that we can just add that `_M_ARM64` part?
Yes. Does it make me confident that we can just drop all of the
architecture-dependent conditions? No, it does not. There _were_ versions
of MSVC that could compile code for PowerPC, for example, which _is_
big-endian.
PowerPC can actually be either.  Most 64-bit PowerPC machines these days
are run as little endian, and Windows has always run it in little-endian
mode.  Macs ran it in big-endian mode.
quoted
As far as I know, Windows has always run on little-endian hardware.
I think that depends on your point of view... IIRC an early version of
Windows NT (or was it still VMS Plus?) ran on DEC Alpha, which I seem to
_vaguely_ remember was big-endian.
Alpha appears to have supported both, but as far as I know, both Windows
and Linux used it in little-endian mode.
quoted
[0] Wikipedia does not specify the endiannesses supported by the MIPS
edition.
I have another vague memory about MIPS (a wonderful SGI machine I had the
pleasure of banging my head against, for lack of Python support and Git
requiring Python back then) being big-endian, too.
Another architecture that supports both endiannesses.  Debian supports
both, but I believe Windows only supported the little-endian version.  I
have a small MIPS board that uses the little endian port for Debian.
Short version: while I managed to convince myself that _currently_ there
are no big-endian platforms that we can support via MSVC, I would like to
stay within the boundaries of caution and _not_ drop those `defined(_M_*)`
parts.
While I'm confident in my statements, you're the relevant subsystem
maintainer here, so I'm happy to defer to your judgment.  I think Junio
can just pick up the earlier patch version and we should be good to go,
since that patch seemed to meet everyone's needs.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help