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