From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Brdline
Date: Mon, 16 Jan 2006 20:35:27 -0500 [thread overview]
Message-ID: <ee9e417a0601161735g1961295bgee6af7cfb5021a31@mail.gmail.com> (raw)
In-Reply-To: <20060117005616.DEFB01140E3@dexter-peak.quanstro.net>
> likewise, seek takes a vlong "where"so that a -1 "don't care" value can be used.
> this was the source of the sign-extension issue p9p's GBIT64 macro.
seek takes a vlong so that you can seek backwards in a file.
if you replace seek with pread, then you're right, except that -1 doesn't
at all mean "don't care".
> this was the source of the sign-extension issue p9p's GBIT64 macro.
it wasn't. the original GBIT64 says:
#define GBIT64(p) ((vlong)((p)[0]|...|((p)[3]<<24)) |\
((vlong)((p)[4]|...|((p)[7]<<24)) << 32))
and you suggested:
#define GBIT64(p) ((vlong)((ulong)(p)[0]|...|((p)[3]<<24)) |\
((vlong)((ulong)(p)[4]|...|((p)[7]<<24)) << 32))
but that won't actually have any effect on systems where
int is 32 bits but long is 64. the problem is that ((p)[3]<<24)
is being (correctly) treated as a signed int, and then
(vlong)(...|((p)[3]<<24)) sign extends. Casting the (p)[0]
to (ulong) has the effect of making the whole 32-bit expression
unsigned on 32-bit systems, but if ulong is 64 bits, then
you'll still sign-extend ((p)[3]<<24) during the convertsion
from int to ulong.
the only way i see to fix this is to explicitly cast away the
top bits:
#define GBIT64(p) ((u32int)((p)[0]|...|((p)[3]<<24)) |\
((vlong)((p)[4]|...|((p)[7]<<24)) << 32))
this is now fixed on sources and cvs.
russ
next prev parent reply other threads:[~2006-01-17 1:35 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-16 11:35 Gorka guardiola
2006-01-16 12:30 ` Charles Forsyth
2006-01-16 13:27 ` Bruce Ellis
2006-01-16 13:37 ` Gorka guardiola
2006-01-16 13:57 ` Charles Forsyth
2006-01-16 14:24 ` Bruce Ellis
2006-01-17 0:56 ` erik quanstrom
2006-01-17 1:35 ` Russ Cox [this message]
2006-01-17 1:42 ` erik quanstrom
2006-01-17 1:47 ` Russ Cox
2006-01-17 10:01 ` Charles Forsyth
2006-01-17 16:45 ` Bruce Ellis
2006-01-18 5:38 ` Simon Williams
2006-01-18 5:49 ` Bruce Ellis
2006-01-18 5:54 ` Paul Lalonde
2006-01-18 6:11 ` Bruce Ellis
2006-01-18 14:25 ` Bruce Ellis
2006-01-18 15:26 ` Ronald G Minnich
2006-01-18 23:06 ` Adrian Tritschler
2006-01-19 1:20 ` Bruce Ellis
2006-01-18 15:45 ` Paul Lalonde
2006-01-18 16:41 ` Bruce Ellis
2006-01-18 16:47 ` Wes Kussmaul
2006-01-18 16:57 ` Bruce Ellis
2006-01-18 17:37 ` David Leimbach
2006-01-18 17:50 ` Bruce Ellis
2006-01-18 18:00 ` Sape Mullender
2006-01-18 17:01 ` Paul Lalonde
2006-01-18 17:30 ` Charles Forsyth
2006-01-18 18:04 ` Wes Kussmaul
2006-01-18 20:22 ` Skip Tavakkolian
2006-01-18 20:31 ` andrey mirtchovski
2006-01-18 23:01 ` Bruce Ellis
2006-01-18 22:56 ` Joel Salomon
2006-01-18 15:25 ` Brantley Coile
2006-01-18 16:35 ` Paul Lalonde
2006-01-17 9:59 ` [9fans] ulong Charles Forsyth
2006-01-17 12:30 ` Russ Cox
2006-01-17 16:55 ` Bruce Ellis
-- strict thread matches above, loose matches on Subject: below --
2005-02-02 0:37 [9fans] Brdline arisawa
2005-02-02 1:06 ` Russ Cox
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=ee9e417a0601161735g1961295bgee6af7cfb5021a31@mail.gmail.com \
--to=rsc@swtch.com \
--cc=9fans@cse.psu.edu \
/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).