mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: linux-kernel@vger.kernel.org
Subject: Re: Kernel's X86 ffs() doesn't work on constants.
Date: 28 Nov 2001 15:00:38 -0800	[thread overview]
Message-ID: <9u3qam$75c$1@cesium.transmeta.com> (raw)
In-Reply-To: <200111282239.fASMdMY82422@aslan.scsiguy.com>

Followup to:  <200111282239.fASMdMY82422@aslan.scsiguy.com>
By author:    "Justin T. Gibbs" <gibbs@scsiguy.com>
In newsgroup: linux.dev.kernel
>
> If you attempt to call ffs(SOME_CONSTAT) in an x86 kernel under
> Linux, you get messages like this:
> 
> {standard input}: Assembler messages:
> {standard input}:14864: Error: suffix or operands invalid for `bsf'
> 
> I'm not enough of a GCC asm syntax guru to understand why the
> compiler/assembler doesn't handle this, but it is hightly anoying.
> 
> "Why not just code in the constant bit offset?", you ask?  If
> the constant the bit offset is based on is ever changed, I must
> recognize that the change occured and change the second constant.
> For constants that are maintained outside of my code, I'd rather
> code the dependency once and let the compiler ensure that the constants
> are in sync.
> 

Try changing the "g" in the definition of ffs() (asm/bitops.h) to
"rm"; the "g" constrains incorrectly allows immediate operands.

	-hpa
-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<amsp@zytor.com>

      reply	other threads:[~2001-11-28 23:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-28 22:39 Justin T. Gibbs
2001-11-28 23:00 ` H. Peter Anvin [this message]

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='9u3qam$75c$1@cesium.transmeta.com' \
    --to=hpa@zytor.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome