From: Stuart Brady <sdbrady@ntlworld.com>
To: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] Re: pa_memcpy: 2 small question
Date: Mon, 10 Jan 2005 20:02:18 +0000 [thread overview]
Message-ID: <20050110200218.GA4595@ntlworld.com> (raw)
In-Reply-To: <41DE941900000C83@mail-5-bnl.tiscali.it>
On Mon, Jan 10, 2005 at 06:12:24PM +0100, Joel Soete wrote:
> I still trying to understand the previous formula I found somewhere :
> ; NOTE: If a null char. exists, return 0.
> ; if ((x - 0x01010101) & ~x & 0x80808080)
> ; return 0;
> (here it comes from m32r/lib/useropcy.c)
It's subtracting one from each byte and checking for overflow. If the
most significant bit is set in x - 1, but not in x, then x must be 0.
The & with ~x is used to mask out the most significant bit in each
byte, if it was already set in x.
If a byte is equal to 0, bytes to the "left" of it will be affected by
the overflow, but that doesn't matter. Quite a neat trick, really.
--
Stuart Brady
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
next prev parent reply other threads:[~2005-01-10 20:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20050105055412.68E06495698@palinux.hppa>
2005-01-05 6:16 ` [parisc-linux] more cpup.c results Grant Grundler
2005-01-05 8:20 ` Joel Soete
2005-01-05 8:40 ` Ryan Bradetich
2005-01-05 16:02 ` Grant Grundler
[not found] ` <20050107095143.GN18497@tausq.org>
2005-01-09 19:07 ` [parisc-linux] pa_memcpy: 2 small question Joel Soete
2005-01-10 0:13 ` [parisc-linux] " Randolph Chung
2005-01-10 8:44 ` Joel Soete
2005-01-10 8:54 ` Randolph Chung
2005-01-10 17:12 ` Joel Soete
2005-01-10 17:17 ` Grant Grundler
2005-01-10 20:02 ` Stuart Brady [this message]
2005-01-11 18:14 ` Joel Soete
2005-01-12 1:49 ` Randolph Chung
2005-02-20 23:44 ` [parisc-linux] revisit copy_user_page_asm microbenchmarks Grant Grundler
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=20050110200218.GA4595@ntlworld.com \
--to=sdbrady@ntlworld.com \
--cc=parisc-linux@lists.parisc-linux.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