From 3a7060d519a3c7600f81cd5b874a2a7486e30caf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 29 Jul 2004 17:33:38 +0000 Subject: [PATCH] (UNALIGNED_P): Use sizeof, not alignof. --- lib/memchr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/memchr.c b/lib/memchr.c index 4cb1a8b..2b2932f 100644 --- a/lib/memchr.c +++ b/lib/memchr.c @@ -48,9 +48,11 @@ USA. */ # include #endif -#define alignof(type) offsetof (struct { char c; type x; }, x) +/* Use sizeof, not alignof, for better performance on some hosts. For + example, on m68k-linux alignof (type) will always be at most 2, but + you get better performance with a 4-byte aligned pointer. */ #ifdef UINTPTR_MAX -# define UNALIGNED_P(p) (((uintptr_t) p) % alignof (unsigned long int) != 0) +# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (unsigned long int) != 0) #else # define UNALIGNED_P(p) 1 #endif -- 2.7.4