Re: [PATCH] Detect endianness on more platforms that don't use BYTE_ORDER
Charles Bailey cbaile...@bloomberg.net writes: --- Please sign-off your patches ;-) This swaps the precedence of BYTE_ORDER and __BYTE_ORDER from the original, which we may not want to. It is easy for me to swap the order of if/elif to restore it, so it is not a big deal, though. Thanks. compat/bswap.h | 33 - 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/compat/bswap.h b/compat/bswap.h index 120c6c1..f08a9fe 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -101,19 +101,34 @@ static inline uint64_t git_bswap64(uint64_t x) #undef ntohll #undef htonll -#if !defined(__BYTE_ORDER) -# if defined(BYTE_ORDER) defined(LITTLE_ENDIAN) defined(BIG_ENDIAN) -# define __BYTE_ORDER BYTE_ORDER -# define __LITTLE_ENDIAN LITTLE_ENDIAN -# define __BIG_ENDIAN BIG_ENDIAN +#if defined(BYTE_ORDER) defined(LITTLE_ENDIAN) defined(BIG_ENDIAN) + +# define GIT_BYTE_ORDER BYTE_ORDER +# define GIT_LITTLE_ENDIAN LITTLE_ENDIAN +# define GIT_BIG_ENDIAN BIG_ENDIAN + +#elif defined(__BYTE_ORDER) defined(__LITTLE_ENDIAN) defined(__BIG_ENDIAN) + +# define GIT_BYTE_ORDER __BYTE_ORDER +# define GIT_LITTLE_ENDIAN __LITTLE_ENDIAN +# define GIT_BIG_ENDIAN __BIG_ENDIAN + +#else + +# define GIT_BIG_ENDIAN 4321 +# define GIT_LITTLE_ENDIAN 1234 + +# if defined(_BIG_ENDIAN) !defined(_LITTLE_ENDIAN) +# define GIT_BYTE_ORDER GIT_BIG_ENDIAN +# elif defined(_BIG_ENDIAN) !defined(_LITTLE_ENDIAN) +# define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN +# else +# error Cannot determine endianness # endif -#endif -#if !defined(__BYTE_ORDER) -# error Cannot determine endianness #endif -#if __BYTE_ORDER == __BIG_ENDIAN +#if GIT_BYTE_ORDER == GIT_BIG_ENDIAN # define ntohll(n) (n) # define htonll(n) (n) #else -- 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] Detect endianness on more platforms that don't use BYTE_ORDER
On Fri, May 02, 2014 at 09:48:58AM -0700, Junio C Hamano wrote: Charles Bailey cbaile...@bloomberg.net writes: --- Please sign-off your patches ;-) Oops! Please consider this patch... Signed-off-by: Charles Bailey cbaile...@bloomberg.net This swaps the precedence of BYTE_ORDER and __BYTE_ORDER from the original, which we may not want to. It is easy for me to swap the order of if/elif to restore it, so it is not a big deal, though. I think I swapped the precedence (semi-deliberately) because I found a proposal to standardize the BYTE_ORDER variant. I claim that any platform which provides both but with differing senses is somewhat broken so I cannot see the precedence mattering much. I don't mind either way. Charles. -- 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] Detect endianness on more platforms that don't use BYTE_ORDER
Charles Bailey cbaile...@bloomberg.net writes: I claim that any platform which provides both but with differing senses is somewhat broken so I cannot see the precedence mattering much. I agree with that, and that is the reason why we shouldn't change the order all of a sudden. If it shouldn't matter, then there is only downside of a possiblity to break such an insane set-up that has been happily working by accident, without helping anybody if we change it, no? -- 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] Detect endianness on more platforms that don't use BYTE_ORDER
Junio C Hamano gits...@pobox.com writes: Charles Bailey cbaile...@bloomberg.net writes: I claim that any platform which provides both but with differing senses is somewhat broken so I cannot see the precedence mattering much. I agree with that, and that is the reason why we shouldn't change the order all of a sudden. If it shouldn't matter, then there is only downside of a possiblity to break such an insane set-up that has been happily working by accident, without helping anybody if we change it, no? So,... I am inclined to queue this on top of your patch at least for now, before I go into incommunicado-mode to finish preparing -rc2. -- 8 -- Subject: [PATCH] compat/bswap.h: restore preference __BIG_ENDIAN over BIG_ENDIAN The previous commit swaps the order we check the macros defined by the compiler and the system headers from the original. Since the order of check should not matter (i.e. it is insane to define both __BIG_ENDIAN and friends and BIG_ENDIAN and friends and in a conflicting way), it is the most conservative thing to do not to change it. Signed-off-by: Junio C Hamano gits...@pobox.com --- compat/bswap.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compat/bswap.h b/compat/bswap.h index f08a9fe..c4293db 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -101,18 +101,18 @@ static inline uint64_t git_bswap64(uint64_t x) #undef ntohll #undef htonll -#if defined(BYTE_ORDER) defined(LITTLE_ENDIAN) defined(BIG_ENDIAN) - -# define GIT_BYTE_ORDER BYTE_ORDER -# define GIT_LITTLE_ENDIAN LITTLE_ENDIAN -# define GIT_BIG_ENDIAN BIG_ENDIAN - -#elif defined(__BYTE_ORDER) defined(__LITTLE_ENDIAN) defined(__BIG_ENDIAN) +#if defined(__BYTE_ORDER) defined(__LITTLE_ENDIAN) defined(__BIG_ENDIAN) # define GIT_BYTE_ORDER __BYTE_ORDER # define GIT_LITTLE_ENDIAN __LITTLE_ENDIAN # define GIT_BIG_ENDIAN __BIG_ENDIAN +#elif defined(BYTE_ORDER) defined(LITTLE_ENDIAN) defined(BIG_ENDIAN) + +# define GIT_BYTE_ORDER BYTE_ORDER +# define GIT_LITTLE_ENDIAN LITTLE_ENDIAN +# define GIT_BIG_ENDIAN BIG_ENDIAN + #else # define GIT_BIG_ENDIAN 4321 -- 2.0.0-rc1-355-gd6d6511 -- 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] Detect endianness on more platforms that don't use BYTE_ORDER
On Fri, May 02, 2014 at 12:43:32PM -0700, Junio C Hamano wrote: So,... I am inclined to queue this on top of your patch at least for now, before I go into incommunicado-mode to finish preparing -rc2. Yes, I'd agree with that. -- 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