From: Randy Dunlap <randy.dunlap@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: Jiri Kosina <trivial@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] treewide: Add and use ADD_MOD macro
Date: Mon, 29 Mar 2010 12:47:08 -0700 [thread overview]
Message-ID: <20100329124708.898b617c.randy.dunlap@oracle.com> (raw)
In-Reply-To: <1269813447.1500.69.camel@Joe-Laptop.home>
On Sun, 28 Mar 2010 14:57:27 -0700 Joe Perches wrote:
> Add a macro for the somewhat common use of
>
> (something + value) % value
>
> drivers/net/sundance.c includes a change from
> a for(;test;add) loop to while (test) {... add};
> because the test uses ADD_MOD
>
> Compile tested only
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> include/linux/kernel.h | 1 +
> drivers/ata/libata-eh.c | 2 +-
> drivers/media/video/ov511.c | 2 +-
> drivers/media/video/usbvideo/usbvideo.c | 2 +-
> drivers/net/dl2k.c | 8 ++++----
> drivers/net/sundance.c | 4 ++--
> drivers/pci/dmar.c | 6 +++---
> drivers/scsi/3w-9xxx.c | 2 +-
> drivers/staging/wavelan/wavelan_cs.c | 10 +++++-----
> drivers/usb/misc/sisusbvga/sisusb_con.c | 4 ++--
> drivers/video/console/vgacon.c | 4 ++--
> sound/oss/vwsnd.c | 6 +++---
> 12 files changed, 26 insertions(+), 25 deletions(-)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 7f07074..c96b1ac 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -63,6 +63,7 @@ extern const char linux_proc_banner[];
> (((x) + ((__divisor) / 2)) / (__divisor)); \
> } \
> )
> +#define ADD_MOD(x, y) (((x) + (y)) % (y))
>
> #define _RET_IP_ (unsigned long)__builtin_return_address(0)
> #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
It would be better not to evaluate y more than one time.
Also it's not safe for 64-bit 'y' on i386, right?
Looks like it would cause missing reference to __imoddi3 or whatever it is called.
so it can easily be misused IMO.
---
~Randy
next prev parent reply other threads:[~2010-03-29 19:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-28 21:57 [PATCH] treewide: Add and use ADD_MOD macro Joe Perches
2010-03-29 19:47 ` Randy Dunlap [this message]
2010-03-29 20:00 ` Joe Perches
2010-03-29 21:09 ` [PATCH] kernel.h: Convert rounding macros to statement expressions, add ADD_MOD Joe Perches
2010-03-29 21:49 ` Randy Dunlap
2010-03-29 22:18 ` [PATCH V2] " Joe Perches
2010-04-05 22:12 ` Andrew Morton
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=20100329124708.898b617c.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@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