From: Pavel Machek <pavel@ucw.cz>
To: "David S. Miller" <davem@davemloft.net>
Cc: drepper@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: ntohs/ntohl and bitops
Date: Thu, 12 Jan 2006 01:04:06 +0000 [thread overview]
Message-ID: <20060112010406.GA2367@ucw.cz> (raw)
In-Reply-To: <20060111.000020.25886635.davem@davemloft.net>
On Wed 11-01-06 00:00:20, David S. Miller wrote:
> From: Ulrich Drepper <drepper@redhat.com>
> Date: Tue, 10 Jan 2006 14:02:52 -0800
>
> > I just saw this in a patch:
> >
> > + if (ntohs(ih->frag_off) & IP_OFFSET)
> > + return EBT_NOMATCH;
> >
> > This isn't optimal, it requires a byte switch little endian machines.
> > The compiler isn't smart enough. It would be better to use
> >
> > if (ih->frag_off & ntohs(IP_OFFSET))
> >
> > where the byte-swap can be done at compile time. This is kind of ugly,
> > I guess, so maybe a dedicate macro
> >
> > net_host_bit_p(ih->frag_off, IP_OFFSET)
>
> The first suggestion isn't considered ugly, and the best form is:
>
> if (ih->frag_off & __constant_htons(IP_OFFSET))
>
> I'll fix that up when I get a chance, thanks for catching it Uli.
Could you possibly
#define IP_OFFSET htons(1234)
?
Noone should need it in native endianity, no?
--
Thanks, Sharp!
next prev parent reply other threads:[~2006-01-14 9:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-10 22:02 ntohs/ntohl and bitops Ulrich Drepper
2006-01-11 8:00 ` David S. Miller
2006-01-11 8:13 ` Arjan van de Ven
2006-01-11 8:36 ` David S. Miller
2006-01-11 8:36 ` Ulrich Drepper
2006-01-11 8:44 ` David S. Miller
2006-01-11 9:48 ` Jakub Jelinek
2006-01-11 18:35 ` Jan Engelhardt
2006-01-11 18:45 ` Ulrich Drepper
2006-01-11 20:19 ` David S. Miller
2006-01-12 1:04 ` Pavel Machek [this message]
2006-01-14 9:52 ` YOSHIFUJI Hideaki / 吉藤英明
2006-01-15 1:46 ` David S. Miller
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=20060112010406.GA2367@ucw.cz \
--to=pavel@ucw.cz \
--cc=davem@davemloft.net \
--cc=drepper@redhat.com \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.