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

Re: [PATCH v2] compat/bswap.h: simplify MSVC endianness detection

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 10, 2020, 17:30 UTC
Message-ID
<xmqqtutx6rwc.fsf@gitster.c.googlers.com>
In-Reply-To
<xmqqy2j96sd4.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 46 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>> As a maintainer, I am less concerned about the "result today" than I am
>> about keeping things easy and effortless to maintain. One of your patches
>> accomplishes that. The other one made it into `next`:
>> https://github.com/git/git/commit/91a67b86f77
>
> I do not think reverting it and requeuing
>
> https://lore.kernel.org/git/20201107221916.1428757-1-dgurney99@gmail.com/
>
> would help future folks why we ignore _MSC_VER as any sign usable to
> detect endianness, so I'd prefer to see a patch *on top* of 1af265f0
> (compat/bswap.h: simplify MSVC endianness detection, 2020-11-08),
> which is 91a67b86f77^2, that explains why we prefer to list archs
> explicitly in its log message, which would be the primary value of
> that commit.
>
> Something along this line, perhaps?
>
> -- >8 --
>
> Subject: compat/bswap.h: do not assume MSVC is little-endian only
>
> Earlier, with 1af265f0 (compat/bswap.h: simplify MSVC endianness
> detection, 2020-11-08), we tried to simplify endianness detection
> used in compat/bswap.h by assuming that any version Git compiled by
> MSVC (detected by _MSC_VER preprocessor macro) is meant to run on
> little endian boxes, as the versions of old MSVC that support m68k
> and MIPS do not support some C99 features used in the codebase
> anyway.
>
> While it might hold true that modern versions of Windows are all
> little-endian, MSVC is and/or can be ported to build for big-endian
> boxes, so tying _MSC_VER with endianness is a bit too restrictive.
>
> Let's go back to the old way to use _MSC_VER to learn what
> preprocessor macros compiler uses to tell us which arch we are
> building for, and list these arches that are little-endian
> explicitly.
>
> ... signed-off-by from you and helped-by from others ...
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>     diffstat
>     patch

Daniel's patch adds _M_ARM64 to the list, but do we need to do anything further to tell the endian on such a bi-endian arch, or does MSVC only support little-endian for that architecture?

Just double-checking as the "confusion" that started this thread came from an assumption that MSVC == Windows == big-endian, and you told us MSVC != Windows. Now the patch assumes ARM64-on-MSVC is little-endian only and we want to make sure that assumption is true.

And perhaps it is worth documenting in the log, perhaps
	... that are little-endian explicitly.  Note that ARM64 is
	bi-endian in nature but we treat it little-endian as MSVC
	does not treat the arch as bi-endian.

or something like that at the end (I do not know what MSVC actually does---just illustrating the level of details I expect in the explanation).

Thanks.
Previous: Junio C HamanoNext: Johannes Schindelin
Message 11 of 13 in “compat/bswap.h: Simplify MSVC endianness detection”
  1. compat/bswap.h: Simplify MSVC endianness detectionDaniel Gurney, Nov 7, 2020
  2. brian m. carlsonNov 8, 2020
  3. compat/bswap.h: simplify MSVC endianness detectionDaniel Gurney, Nov 8, 2020
  4. Jeff KingNov 10, 2020
  5. brian m. carlsonNov 10, 2020
  6. Junio C HamanoNov 10, 2020
  7. Johannes SchindelinNov 10, 2020
  8. Daniel GurneyNov 10, 2020
  9. Johannes SchindelinNov 10, 2020
  10. Junio C HamanoNov 10, 2020
  11. Junio C HamanoNov 10, 2020
  12. Johannes SchindelinNov 10, 2020
  13. Jeff KingNov 10, 2020

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.