From: Jonathan Nieder <jrnieder@gmail.com>
To: Brian Gernhardt <brian@gernhardtsoftware.com>
Cc: Git List <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] Ensure __BYTE_ORDER is always set
Date: Thu, 30 Jan 2014 14:02:33 -0800 [thread overview]
Message-ID: <20140130220233.GH27577@google.com> (raw)
In-Reply-To: <1391111741-28994-1-git-send-email-brian@gernhardtsoftware.com>
Hi,
Brian Gernhardt wrote:
> a201c20 (ewah: support platforms that require aligned reads) added a
> reliance on the existence of __BYTE_ORDER and __BIG_ENDIAN. However,
> these macros are spelled without the leading __ on some platforms (OS
> X at least). In this case, the endian-swapping code was added even
> when unnecessary, which caused assertion failures in
> t5310-pack-bitmaps.sh as the code that used the bitmap would read past
> the end.
>
> We already had code to handle this case in compat/bswap.h, but it was
> only used if we couldn't already find a reasonable version of bswap64.
Makes sense. Sorry I missed this.
In an ideal world I would prefer to just rely on ntohll when it's
decent (meaning that the '#if __BYTE_ORDER != __BIG_ENDIAN' block
could be written as
if (ntohll(1) != 1) {
...
}
or
if (ntohll(1) == 1)
; /* Big endian. Nothing to do.
else {
...
}
). But compat/bswap.h already relies on knowing the endianness at
preprocessing time so that wouldn't buy anything.
Another "in an ideal world" option: make the loop unconditional after
checking that optimizers on big-endian systems realize it's a noop.
In any event, in the real world your patch looks like the right thing
to do.
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
next prev parent reply other threads:[~2014-01-30 22:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-30 19:55 [PATCH] Ensure __BYTE_ORDER is always set Brian Gernhardt
2014-01-30 20:45 ` Jeff King
2014-01-30 21:50 ` Jeff King
2014-01-31 2:35 ` Eric Sunshine
2014-01-30 22:12 ` Jonathan Nieder
2014-01-30 22:48 ` Jeff King
2014-01-30 23:24 ` Brian Gernhardt
2014-01-30 22:02 ` Jonathan Nieder [this message]
2014-01-30 22:46 ` Jeff King
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=20140130220233.GH27577@google.com \
--to=jrnieder@gmail.com \
--cc=brian@gernhardtsoftware.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).