All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaco Kroon <jaco@kroon.co.za>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] BIT macro cleanup
Date: Fri, 09 Feb 2007 17:55:18 +0000	[thread overview]
Message-ID: <45CCB586.1010709@kroon.co.za> (raw)
In-Reply-To: <45CADD09.70809@bfs.de>


[-- Attachment #1.1: Type: text/plain, Size: 1215 bytes --]

Milind Choudhary wrote:
> On 2/8/07, walter harms <wharms@bfs.de> wrote:
> 
>>
>>>There are different variants of BIT using (long|unsigned
>>>long|unsigned|unsigned char) etc.
>>>Do we need to create different macros for each type
>>>Or a single one which takes type as input?
>>
>>bit operations make only sense on integer, so why not stay with long
>>and cast it down if needed ? so you have only one function doing so.
> 
> 
> Michael Veeck  had submitted a patch for the same before
> http://lists.osdl.org/pipermail/kernel-janitors/2005-August/004737.html
> 
> there was some discussion on the list,which did not reach any
> conclusion I guess.
> so we have

> #define BIT(x) (1UL << (x) )
> #define BIT(x) (1UL << ((x) % BITS_PER_LONG))

These two are identical (on x86 hardware at least), except that
BITS_PER_LONG depends on the architecture, 32 on x86 and 64 on x86_64,
and the modulus applied by the CPU depends on the size of x ...

> #define BIT(x) (1ULL << (__builtin_constant_p(x) ? (x) : (x) % 64)

This won't compile (bracket mismatch), but I can't see why you'd want to
differentiate between x being a compiletime constant or a runtime
calculated value ... it just doesn't make sense for me.

Jaco

[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3233 bytes --]

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

  parent reply	other threads:[~2007-02-09 17:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08  8:19 [KJ] BIT macro cleanup walter harms
2007-02-09 17:45 ` Milind Choudhary
2007-02-09 17:55 ` Jaco Kroon [this message]
2007-02-20 18:28 ` Milind Choudhary
2007-02-20 19:33 ` Richard Knutsson
2007-02-20 20:30 ` Milind Choudhary
2007-02-21  5:56 ` Richard Knutsson
2007-02-21  9:24 ` Milind Choudhary
2007-02-21  9:39 ` Richard Knutsson
2007-02-21 10:46 ` Milind Choudhary
2007-02-21 11:28 ` Richard Knutsson
2007-02-21 11:59 ` Richard Knutsson
2007-02-21 12:02 ` Darren Jenkins
2007-02-21 12:04 ` Darren Jenkins
2007-02-21 13:26 ` Milind Choudhary
2007-02-21 14:02 ` Milind Choudhary
2007-02-21 14:45 ` Håkon Løvdal
2007-02-21 16:07 ` Richard Knutsson
  -- strict thread matches above, loose matches on Subject: below --
2007-02-07 15:30 Milind Choudhary

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=45CCB586.1010709@kroon.co.za \
    --to=jaco@kroon.co.za \
    --cc=kernel-janitors@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 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.