Skip to contentSkip to conversation

PTR_ALIGN

PATCH In review Matthew Wilcox 2 participants 2 messages Aug 23, 2007 – Sep 10, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PTR_ALIGN

The AdvanSys driver wants to align some pointers, and the ALIGN macro doesn't work for pointers. Rather than try to make it work, add a new PTR_ALIGN macro which is typesafe.

include/linux/kernel.h +1 -0
index f592df7..47160fe 100644
@@ -34,6 +34,7 @@ extern const char linux_proc_banner[];
 
 #define ALIGN(x,a)		__ALIGN_MASK(x,(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
+#define PTR_ALIGN(p, a)		((typeof(p))ALIGN((unsigned long)(p), (a)))
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 
Signature · 3 lines
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
#1 lore raw
Quoted 12 lines · On Thu, 23 Aug 2007 05:47:03 -0600 Matthew Wilcox <[email protected]> wrote:

The AdvanSys driver wants to align some pointers, and the ALIGN macro doesn't work for pointers. Rather than try to make it work, add a new PTR_ALIGN macro which is typesafe.

include/linux/kernel.h +0 -0
index f592df7..47160fe 100644

include/linux/kernel.h extern const char linux_proc_banner[]; · line 40

Quoted 7 lines
include/linux/kernel.h +1 -0
@@ -34,6 +34,7 @@ extern const char linux_proc_banner[];
 
 #define ALIGN(x,a)		__ALIGN_MASK(x,(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
+#define PTR_ALIGN(p, a)		((typeof(p))ALIGN((unsigned long)(p), (a)))
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 

I'll plan on getting this thing of beauty into mainline in the next week or so, so you can get those advansys changes into James's tree.