From: Junio C Hamano <gitster@pobox.com>
To: Charles Bailey <cbailey32@bloomberg.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Detect endianness on more platforms that don't use BYTE_ORDER
Date: Fri, 02 May 2014 09:48:58 -0700 [thread overview]
Message-ID: <xmqqwqe4azyd.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1399017329-25645-1-git-send-email-cbailey32@bloomberg.net> (Charles Bailey's message of "Fri, 2 May 2014 08:55:29 +0100")
Charles Bailey <cbailey32@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
next prev parent reply other threads:[~2014-05-02 16:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-01 7:43 [PATCH] Add extra logic required to detect endianness on Solaris Charles Bailey
2014-05-01 18:58 ` Junio C Hamano
2014-05-01 19:18 ` Junio C Hamano
2014-05-01 19:22 ` Junio C Hamano
2014-05-02 7:49 ` Charles Bailey
2014-05-02 7:55 ` [PATCH] Detect endianness on more platforms that don't use BYTE_ORDER Charles Bailey
2014-05-02 16:48 ` Junio C Hamano [this message]
2014-05-02 16:58 ` Charles Bailey
2014-05-02 19:34 ` Junio C Hamano
2014-05-02 19:43 ` Junio C Hamano
2014-05-02 20:02 ` Charles Bailey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqwqe4azyd.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=cbailey32@bloomberg.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).