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

Re: [PATCH] Fix git-pack-objects for 64-bit platforms

From
Linus Torvalds <torvalds@osdl.org>
Date
May 11, 2006, 17:58 UTC
Message-ID
<Pine.LNX.4.64.0605111054290.3866@g5.osdl.org>
In-Reply-To
<20060511173632.G60c08b4@leonov.stosberg.net>
On Thu, 11 May 2006, Dennis Stosberg wrote:
Show 7 quoted lines
> 
> I am not sure whether an int cast or an int32_t cast is more
> appropriate here.  An int is not guaranteed to be four bytes wide,
> but I don't know of any modern platform where that's not the case.
> On the other hand int32_t is not necessarily available before C99.
> 
> Any opinions?  I wonder why no one has hit this on x86_64...

I think the "ntohl()" hides it. It loads a 64-bit value, but since x86-64 is little-endian, the low 32 bits are correct. The htonl() will then strip the high bits and make it all be big-endian.

And while I actually run a 64-bit big-endian machine myself (G5 ppc64), my user space is all 32-bit by default, so it never showed up on linux-ppc64 either.

Anyway, the correct type to use is "uint32_t" in this case. That's what htonl() takes.

		Linus
Previous: Dennis StosbergNext: Junio C Hamano
Message 2 of 10 in “Fix git-pack-objects for 64-bit platforms”
  1. Fix git-pack-objects for 64-bit platformsDennis Stosberg, May 11, 2006
  2. Linus TorvaldsMay 11, 2006
  3. Junio C HamanoMay 11, 2006
  4. Linus TorvaldsMay 11, 2006
  5. Linus TorvaldsMay 11, 2006
  6. Junio C HamanoMay 13, 2006
  7. Ben CliffordMay 14, 2006
  8. include header to define uint32_t, necessary on Mac OS XBen Clifford, May 14, 2006
  9. Alex RiesenMay 20, 2006
  10. Linus TorvaldsMay 20, 2006

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.