linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: David Jander <david@protonic.nl>
Cc: linux-can@vger.kernel.org,
	Wolfgang Grandegger <wg@grandegger.com>,
	Alexander Stein <alexander.stein@systec-electronic.com>
Subject: Re: [PATCH 02/14] can: rx-fifo: Increase MB size limit from 32 to 64
Date: Fri, 07 Nov 2014 09:40:36 +0100	[thread overview]
Message-ID: <545C8584.8000104@pengutronix.de> (raw)
In-Reply-To: <20141106172052.6299c1d1@archvile>

[-- Attachment #1: Type: text/plain, Size: 1614 bytes --]

On 11/06/2014 05:20 PM, David Jander wrote:
>>> Btw, there is a subtle bug in the line you linked to:
>>>
>>>> #define GENMASK_ULL(h, l)       (((U64_C(1) << ((h) - (l) + 1)) - 1) <<
>>>> (l))
>>>
>>> The _ULL in the name of the macro seems to hint to "unsigned long long",
>>> while the implementation seems to assume that it means U64_C. This is
>>> obviously wrong, although for most platforms that are currently capable of
>>> running Linux, those are probably equivalent...
>>
>> #define U64_C(x) x ## ULL
> 
> This line:
> 
> http://lxr.free-electrons.com/source/include/asm-generic/int-ll64.h#L4
> 
> ...seems to indicate, that it may not always be the case :-)
> AFAIK, C99 specifies that "long long" should at _least_ have 64 bit length,
> but says nothing about when it may be larger.
> OTOH, I have yet to find a machine/compiler combination that defines "long
> long" as more than 64bit... at least not running Linux.
> A correct definition should be trivial though:
> 
> #define GENMASK_ULL(h, l)       (((1ULL << ((h) - (l) + 1)) - 1) << (l))

That's what it does:

$ cat << EOF | gcc -xc -E -
#define U64_C(x) x ## ULL
#define GENMASK_ULL(h, l)   (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l))
GENMASK_ULL(foo, bar)
EOF

Results in:
(((1ULL << ((foo) - (bar) + 1)) - 1) << (bar))

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-11-07  8:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-06  8:33 [PATCH V4 00/14] CAN: Add rx-fifo support and port flexcan to it David Jander
2014-11-06  8:34 ` [PATCH 01/14] can: dev: add preliminary rx-fifo David Jander
2014-11-06  8:34 ` [PATCH 02/14] can: rx-fifo: Increase MB size limit from 32 to 64 David Jander
2014-11-06  8:41   ` Marc Kleine-Budde
2014-11-06 16:03     ` David Jander
2014-11-06 16:05       ` Marc Kleine-Budde
2014-11-06 16:20         ` David Jander
2014-11-07  8:40           ` Marc Kleine-Budde [this message]
2014-11-07 10:28             ` David Jander
2014-11-06  8:34 ` [PATCH 03/14] can: rx-fifo: Change to do controller off-load in interrupt and NAPI poll David Jander
2014-11-10 11:00   ` David Jander
2014-11-06  8:34 ` [PATCH 04/14] can: rx-fifo: fix long lines David Jander
2014-11-06  8:34 ` [PATCH 05/14] can: rx-fifo: Add can_rx_fifo_reset() function David Jander
2014-11-06  8:34 ` [PATCH 06/14] can: rx-fifo: remove obsolete comment David Jander
2014-11-06  8:34 ` [PATCH 07/14] can: rx-fifo: Add support for can state tracking and error polling David Jander
2014-11-06  8:34 ` [PATCH 08/14] can: rx-fifo: Add support for simple irq offloading David Jander
2014-11-06  8:34 ` [PATCH 09/14] can: rx-fifo: Add documentation to struct can_rx_fifo David Jander
2014-11-06  8:34 ` [PATCH 10/14] can: flexcan: add documentation about mailbox organizaiton David Jander
2014-11-06  8:34 ` [PATCH 11/14] can: flexcan: rename crl2 -> ctrl2 David Jander
2014-11-06  8:34 ` [PATCH 12/14] can: flexcan: replace open coded mailbox code by proper defines David Jander
2014-11-06  8:34 ` [PATCH 13/14] can: flexcan: Add support for RX-FIFO David Jander
2014-11-06  8:34 ` [PATCH 14/14] can: flexcan: Add MB/Fifo specific column to comment table of IP versions David Jander

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=545C8584.8000104@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=alexander.stein@systec-electronic.com \
    --cc=david@protonic.nl \
    --cc=linux-can@vger.kernel.org \
    --cc=wg@grandegger.com \
    /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).