From: Harvey Harrison <harvey.harrison@gmail.com>
To: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Peter Oberparleiter <oberparleiter@googlemail.com>
Subject: Re: [PATCH] consolidate all within() implementations
Date: Mon, 19 May 2008 13:50:16 -0700 [thread overview]
Message-ID: <1211230216.5915.90.camel@brick> (raw)
In-Reply-To: <48313E23.4030104@de.ibm.com>
On Mon, 2008-05-19 at 10:45 +0200, Peter Oberparleiter wrote:
> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
>
> This patch consolidates a number of different implementations of the
> within() function which checks whether an address is within a specified
> address range. Apart from parameter typing, existing implementations can
> be classified in two categories which differ in the way the range is
> specified:
>
> 1) by start and end address
> 2) by start and size
>
> These categories are covered by the within() macro (case 1) and the
> within_len() macro (case 2). Both macros can be used with any pointer
> or pointer-equivalent type as parameter.
Would it be that hard to just make them static inlines taking unsigned
longs?
>
> Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
> ---
>
> /**
> + * within - check whether address is within a start-and-end address range
> + * @val: address
@addr perhaps
> + * @start: start address (included in range)
> + * @end: end address (excluded from range)
> + */
> +#define within(val, start, end) ({ \
How about:
static inline int addr_within(unsigned long addr, unsigned long start,
unsigned long end)
> + unsigned long __val = (unsigned long) (val); \
> + unsigned long __start = (unsigned long) (start); \
> + unsigned long __end = (unsigned long) (end); \
> + (__val >= __start) && (__val < __end); })
> +
> +/**
> + * within_len - check whether address is within a start-and-length address range
> + * @val: address
@addr
> + * @start: start of range
> + * @len: number of bytes in range
> + */
> +#define within_len(val, start, len) ({ \
static inline int addr_within_len(unsigned long addr, unsigned long start,
unsigned long len)
Just a thought.
Harvey
next prev parent reply other threads:[~2008-05-19 20:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-19 8:45 [PATCH] consolidate all within() implementations Peter Oberparleiter
2008-05-19 20:50 ` Harvey Harrison [this message]
2008-05-20 8:08 ` Peter Oberparleiter
2008-05-20 9:45 ` Andrew Morton
2008-05-20 15:42 ` Peter Oberparleiter
2008-05-21 10:04 ` Peter Zijlstra
2008-05-21 10:33 ` Peter 1 Oberparleiter
2008-05-21 10:48 ` Peter Zijlstra
2008-05-21 13:50 ` Peter 1 Oberparleiter
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=1211230216.5915.90.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oberparleiter@googlemail.com \
--cc=peter.oberparleiter@de.ibm.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