Re: Linux 2.5.8-pre2

Andrew Morton (akpm@zip.com.au)
Sun, 07 Apr 2002 03:50:21 -0700


Russell King wrote:
>
> (Oh, and a bugbear - people go running around adding checks for the
> return value of request_region and friends on embedded devices where
> there can't be the possibility of a clash waste memory needlessly.)

If you do:

#define request_region(start, n, name)
({
__request_region(start, n, name);
(struct resource *)1;
})
#define release_region(start, n) do { } while (0)

then the compiler will remove all those error checks for you,
as well as the release_region calls.

Of course if you actually want to use the innards of the
returned resource * then that's not so good.

However, you can make it:

#define request_region() \
({ \
struct resource *r; \
r = __request_region(); \
(struct resource *)((long)r | 1); \
})

and, amazingly, the compiler still knows that the value
is non-zero, and still will elide those tests. You'll
need to mask that bit off again to use the pointer.

Whether you'll stoop this low depends upon how much you
want those bytes back :)

-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/