Re: [PATCH 1/2] compat: move unaligned helpers to bswap.h
Jeff King wrote: Commit d60c49c (read-cache.c: allow unaligned mapping of the index file, 2012-04-03) introduced helpers to access unaligned data. Let's factor them out to make them more widely available. While we're at it, we'll give the helpers more readable names, add a helper for the ntohll form, and add the appropriate Makefile knob. Weird. Why wasn't git broken on the relevant platforms before (given that no one has been setting NEEDS_ALIGNED_ACCESS for them)? Puzzled, Jonathan -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] compat: move unaligned helpers to bswap.h
On Thu, Jan 23, 2014 at 11:41:18AM -0800, Jonathan Nieder wrote: Jeff King wrote: Commit d60c49c (read-cache.c: allow unaligned mapping of the index file, 2012-04-03) introduced helpers to access unaligned data. Let's factor them out to make them more widely available. While we're at it, we'll give the helpers more readable names, add a helper for the ntohll form, and add the appropriate Makefile knob. Weird. Why wasn't git broken on the relevant platforms before (given that no one has been setting NEEDS_ALIGNED_ACCESS for them)? Because most of our data structures support aligned access. Thomas mentioned this as a potential issue earlier, and I said in a re-roll cover letter: I did not include the NEEDS_ALIGNED_ACCESS patch. I note that we do not even have a Makefile knob for this, and the code in read-cache.c has probably never actually been used. Are there real systems that have a problem? The read-cache code was in support of the index v4 experiment, which did away with the 8-byte padding. So it could be that we simply don't see it, because everything is currently aligned. I think it was a bug waiting to surface if index v4 ever got wide use. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] compat: move unaligned helpers to bswap.h
Jeff King wrote: I think it was a bug waiting to surface if index v4 ever got wide use. Ah, ok. In that case I think git-compat-util.h should include something like what block-sha1/sha1.c has: #if !defined(__i386__) !defined(__x86_64__) \ !defined(_M_IX86) !defined(_M_X64) \ !defined(__ppc__) !defined(__ppc64__) \ !defined(__powerpc__) !defined(__powerpc64__) \ !defined(__s390__) !defined(__s390x__) #define NEEDS_ALIGNED_ACCESS #endif Otherwise we are relying on the person building to know their own architecture intimately, which shouldn't be necessary. Meanwhile, as mentioned in the other message, I suspect the NEEDS_ALIGNED_ACCESS code path is broken for aggressive compilers anyway. Looking more. Thanks, Jonathan -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] compat: move unaligned helpers to bswap.h
On Thu, Jan 23, 2014 at 12:08:04PM -0800, Jonathan Nieder wrote: Jeff King wrote: On Thu, Jan 23, 2014 at 11:56:43AM -0800, Jonathan Nieder wrote: In that case I think git-compat-util.h should include something like what block-sha1/sha1.c has: #if !defined(__i386__) !defined(__x86_64__) \ !defined(_M_IX86) !defined(_M_X64) \ !defined(__ppc__) !defined(__ppc64__) \ !defined(__powerpc__) !defined(__powerpc64__) \ !defined(__s390__) !defined(__s390x__) #define NEEDS_ALIGNED_ACCESS #endif Otherwise we are relying on the person building to know their own architecture intimately, which shouldn't be necessary. Yeah, I agree it would be nice to autodetect. The nice thing is that false positives are harmless, modulo slowing down git a little if the compiler doesn't figure out how to optimize the NEEDS_ALIGNED_ACCESS codepath when on an unlisted platform that doesn't, in fact, need aligned access. OK, I'll refactor the knob. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] compat: move unaligned helpers to bswap.h
Jeff King wrote: On Thu, Jan 23, 2014 at 11:56:43AM -0800, Jonathan Nieder wrote: In that case I think git-compat-util.h should include something like what block-sha1/sha1.c has: #if !defined(__i386__) !defined(__x86_64__) \ !defined(_M_IX86) !defined(_M_X64) \ !defined(__ppc__) !defined(__ppc64__) \ !defined(__powerpc__) !defined(__powerpc64__) \ !defined(__s390__) !defined(__s390x__) #define NEEDS_ALIGNED_ACCESS #endif Otherwise we are relying on the person building to know their own architecture intimately, which shouldn't be necessary. Yeah, I agree it would be nice to autodetect. The nice thing is that false positives are harmless, modulo slowing down git a little if the compiler doesn't figure out how to optimize the NEEDS_ALIGNED_ACCESS codepath when on an unlisted platform that doesn't, in fact, need aligned access. In other words, it would work out of the box for everybody. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html