[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1211230216.5915.90.camel@brick>
Date: Mon, 19 May 2008 13:50:16 -0700
From: Harvey Harrison <harvey.harrison@...il.com>
To: Peter Oberparleiter <peter.oberparleiter@...ibm.com>
Cc: linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Oberparleiter <oberparleiter@...glemail.com>
Subject: Re: [PATCH] consolidate all within() implementations
On Mon, 2008-05-19 at 10:45 +0200, Peter Oberparleiter wrote:
> From: Peter Oberparleiter <peter.oberparleiter@...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@...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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists