From: Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
To: Gerd Hoffmann <kraxel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
arnd-r2nGTMty4D4@public.gmane.org,
"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>,
ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org,
tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
Subject: Re: [patch 143/166] preadv/pwritev: Add preadv and pwritev system calls.
Date: Fri, 3 Apr 2009 13:08:59 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.2.00.0904031303200.4015@localhost.localdomain> (raw)
In-Reply-To: <49D66A22.7090909-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On Fri, 3 Apr 2009, Gerd Hoffmann wrote:
>
> The whole point of the HALF_BITS thing is just to kill the gcc "hey your
> shift is greater than bitsize of $type" warning, right?
No, it's literally a corectness issue.
If you do
offset = ((loff_t) high) << BITS_IN_LONG;
then that is literally undefined behavior in C (if "loff_t" and "long" are
the same size), and a lot of C compilers will end up just optimizing it
away entirely.
Even if they don't optimize it away, and if they actually generate the
instruction for it, architectures will not actually do what you think they
do. At least on x86, shift counts are fundamentally limited to the low
bits, so if you do
movl $64,%ecx
shlq %ecx,reg
then an x86 will literally shift 'reg' by _zero_, because the count is
masked by 6 bits (or 5, in the 32-bit case).
So literally, if gcc were to generate the obvious (stupid) code, it would
give the wrong value.
With the double shift, we have well-defined behavior.
> I really like it. Except for the low/high ordering it is basically
> identical to the patch I've mailed.
>
> While hashing out all the issues I've learned alot about arch specific
> ABIs. I can't see possible trouble spots and don't expect vetos from
> arch maintainers.
Ok, a few more ack's, and I can commit it. Anybody disagree?
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-04-03 20:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-02 23:59 [patch 143/166] preadv/pwritev: Add preadv and pwritev system calls akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b
[not found] ` <200904022359.n32NxNYu022834-AB4EexQrvXRQetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
2009-04-03 1:43 ` Linus Torvalds
2009-04-03 8:35 ` Gerd Hoffmann
2009-04-03 9:25 ` Gerd Hoffmann
[not found] ` <49D5D609.7030400-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-04-03 11:53 ` Gerd Hoffmann
2009-04-03 15:03 ` Linus Torvalds
2009-04-03 19:57 ` Gerd Hoffmann
[not found] ` <49D66A22.7090909-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-04-03 20:08 ` Linus Torvalds [this message]
2009-04-04 17:38 ` Andrew Morton
2009-04-04 17:51 ` Linus Torvalds
[not found] ` <alpine.LFD.2.00.0904021839390.15441-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-04-03 16:57 ` H. Peter Anvin
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=alpine.LFD.2.00.0904031303200.4015@localhost.localdomain \
--to=torvalds-de/tnxtf+jlsfhdxvbkv3wd2fqjk+8+b@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=kraxel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-X9Un+BFzKDI@public.gmane.org \
--cc=ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.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).