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

Re: [PATCH v3 0/5] bswap.h: Rework ntohl handling

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 15, 2025, 22:36 UTC
Message-ID
<aHbX4hIKbjO6h1R5@fruit.crustytoothpaste.net>
In-Reply-To
<xmqqple1f7ge.fsf@gitster.g>
On 2025-07-15 at 21:52:01, Junio C Hamano wrote:
Show 5 quoted lines
> Thanks for updating the proposed log messages with typofixes.  I
> understand the patch text has no changes?
> 
> Cc'ed those who gave comments on the previous round.  How does this
> version look to you folks?
This seems fine to me.

I might go a little farther and simply say that recognizing the pattern and emitting the most efficient code, whether that's a single instruction or an optimized pattern of instructions, is a quality-of-implementation issue in the compiler's peephole optimizer[0] and that we don't really need to use the builtin functions or provide special cases for MSVC still, but I realize that is not a very popular opinion and I think this series is fine without that.

[0] Byte swapping, population count, and rotations are, in my view, the most frequently open-coded functions and thus every compiler with a peephole optimizer should recognize and handle them.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Junio C HamanoNext: Sebastian Andrzej Siewior
Message 8 of 9 in “bswap.h: Rework ntohl handling”
  1. 0/5 bswap.h: Rework ntohl handlingSebastian Andrzej Siewior, Jul 15, 2025
  2. 1/5 bswap.h: Add support for __BYTE_ORDER__Sebastian Andrzej Siewior, Jul 15, 2025
  3. 4/5 bswap.h: Remove optimized x86 version of bswap32/64Sebastian Andrzej Siewior, Jul 15, 2025
  4. 5/5 bswap.h: Provide a built-in based version of bswap32/64 if possibleSebastian Andrzej Siewior, Jul 15, 2025
  5. 2/5 bswap.h: Define GIT_LITTLE_ENDIAN on msvc as little endianSebastian Andrzej Siewior, Jul 15, 2025
  6. 3/5 bswap.h: Always overwrite ntohl/ ntohll macrosSebastian Andrzej Siewior, Jul 15, 2025
  7. Junio C HamanoJul 15, 2025
  8. brian m. carlsonJul 15, 2025
  9. Sebastian Andrzej SiewiorJul 16, 2025

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.