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

Re: [PATCH lt/block-sha1 0/2 v3] block-sha1: avoid pointer conversion that violates alignment constraints

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 23, 2012, 05:42 UTC
Message-ID
<7vboj7nidc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120723052605.GA13728@burratino>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 17 quoted lines
> Junio C Hamano wrote:
>> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>>> The big-endian part was just my idiocy, sorry.
>>
>> Hrm, do we want an update log message for 1/2 then?
>
> Hm, I thought all the crazy had been eliminated already.
>
> *looks again*
>
> I guess "using a single 32-bit load" makes it sound like it's using a
> big-endian load instead of a load followed by twiddling in registers.
>
> Simplest fix would be to drop the phrase "by using a single 32-bit
> load", leaving "... and gcc takes full advantage, resulting in a whole
> bunch of unaligned access traps."

I was just being stupid, misread the original code and did not realize that the generic code quoted in your log message:

	#define get_be32(p) ( \
        	... byte-at-a-time implementation )

is not limited to big endian boxes [*1*]. So I think the message is fine as-is.

[Footnote]

*1* In other words, the ntohl(*(uint *)(p)) is used only on selected little endian boxes, but that does not mean the generic code was big-endian only. Little endian boxes that are not listed in #if block do use the generic byte-at-a-time macro.

Previous: Jonathan NiederNext: Jonathan Nieder
Message 8 of 9 in “block-sha1: avoid pointer conversion that violates alignment constraints”
  1. 0/2 block-sha1: avoid pointer conversion that violates alignment constraintsJonathan Nieder, Jul 22, 2012
  2. 1/2 block-sha1: avoid pointer conversion that violates alignment constraintsJonathan Nieder, Jul 22, 2012
  3. 2/2 block-sha1: put expanded macro parameters in parenthesesJonathan Nieder, Jul 22, 2012
  4. Junio C HamanoJul 23, 2012
  5. Jonathan NiederJul 23, 2012
  6. Junio C HamanoJul 23, 2012
  7. Jonathan NiederJul 23, 2012
  8. Junio C HamanoJul 23, 2012
  9. 3/1 Makefile: BLK_SHA1 does not require fast htonl() and unaligned loadsJonathan Nieder, Jul 23, 2012

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.