From: "Joel Soete" <jsoe0708@tiscali.be>
To: "James Bottomley" <James.Bottomley@steeleye.com>,
"LaMont Jones" <lamont@hp.com>
Cc: parisc-linux@parisc-linux.org
Subject: Re: [parisc-linux] backport bitops.h stuff
Date: Mon, 4 Aug 2003 19:04:31 +0200 [thread overview]
Message-ID: <3F29178A00000CBA@ocpmta7.freegates.net> (raw)
In-Reply-To: <1060013284.1983.32.camel@fuzzy>
James,
Many thanks for those clear explanation,
Joel
> -- Original Message --
> From: James Bottomley <James.Bottomley@steeleye.com>
> To: LaMont Jones <lamont@hp.com>
> Cc: Joel Soete <jsoe0708@tiscali.be>, parisc-linux@parisc-linux.org
> Date: 04 Aug 2003 11:08:01 -0500
> Subject: Re: [parisc-linux] backport bitops.h stuff
>
>
> Let me try to clarify, since there are two differently defined macros in
the kernel (off by one) that would appear to have the same interface,
but which in fact have different semantics (I know, recipe for
disaster): ffs and ffz (meaning find first
> set and find first zero).
Both tend to have machine code implementations for architectures that
support them. The difference is that ffz counts bit zero as zero, but
ffz counts bit zero as one.
They also have different requirements for the err
> r case (no bit set for
ffs and no bit zero for ffz). For ffs, this is defined to be 32. For
ffz, this is undefined.
The reason for all of this is that on x86 there is an instruction bsfl
that actually finds first set bit (but counting from zero
> not one), but
the O(1) scheduler needed to find clear bits for the arrays, so ffz was
implemented as the complement of this.
ffs has been around a long time (inherited from BSD). The differing
semantics are because "damnit, computers count from
> zero not one for
fast operations".
i.e.
ffs(0) == 0
ffz(0) == 0
ffs(1) == 1
ffz(~1) == 0 (same as above ffz, bit zero clear)
ffs(2) == 2
ffz(~3) == 1
[...]
ffs(0x8000000) == 32
ffz(0x7ffffff) == 31
ffz(0xffffffff) == could be
> anything
Some machine architectures have an __ffs() (usually mirroring a machine
instruction) whose semantics are identical to ffs() except that it also
is undefined in the error case (so ffs can simply be implemented as if
not error case, do __f
> s()).
James
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
------------------------------------------------------
Soldes Tiscali ADSL : 27,50 euros/mois jusque fin 2003.
On s'habitue vite à payer son ADSL moins cher!
Plus d'info? Cliquez ici... http://reg.tiscali.be/default.asp?lg=fr
next prev parent reply other threads:[~2003-08-04 17:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-01 15:28 [parisc-linux] backport bitops.h stuff Joel Soete
2003-08-01 15:35 ` Joel Soete
2003-08-01 15:59 ` James Bottomley
2003-08-01 17:09 ` Joel Soete
2003-08-01 17:14 ` LaMont Jones
2003-08-01 17:25 ` Joel Soete
2003-08-01 17:33 ` James Bottomley
2003-08-04 10:43 ` Joel Soete
2003-08-04 15:14 ` LaMont Jones
2003-08-04 16:08 ` James Bottomley
2003-08-04 17:04 ` Joel Soete [this message]
2003-08-04 16:53 ` Joel Soete
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=3F29178A00000CBA@ocpmta7.freegates.net \
--to=jsoe0708@tiscali.be \
--cc=James.Bottomley@steeleye.com \
--cc=lamont@hp.com \
--cc=parisc-linux@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 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.