[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0611261208550.3483@woody.osdl.org>
Date: Sun, 26 Nov 2006 12:11:29 -0800 (PST)
From: Linus Torvalds <torvalds@...l.org>
To: Andrew Morton <akpm@...l.org>
cc: Roland Dreier <rdreier@...co.com>,
David Miller <davem@...emloft.net>,
linux-kernel@...r.kernel.org, openib-general@...nib.org,
tom@...ngridcomputing.com, Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH] Avoid truncating to 'long' in ALIGN() macro
On Sun, 26 Nov 2006, Andrew Morton wrote:
>
> I'd be inclined to merge it for 2.6.19. Is everyone OK with it?
I'd _much_ rather make it more readable while at it. Something like this
instead, which has just _one_ "typeof" cast, and at least to me makes it a
lot more obvious what is going on (aka "to align something, use a mask
that is of the same type as the thing to be aligned..").
Maybe it's just me, but I prefer to separate out the actual "action" from
the "type fluff" around it.
Linus
---
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 24b6111..b9b5e4b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -30,8 +30,10 @@ extern const char linux_banner[];
#define STACK_MAGIC 0xdeadbeef
+#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
+#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL))
#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
-
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