[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memchr.c and memrchr.c portability fixes

From: Andreas Schwab
Subject: Re: memchr.c and memrchr.c portability fixes
Date: Thu, 29 Jul 2004 11:27:28 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Paul Eggert <address@hidden> writes:

>    /* Handle the first few characters by reading one character at a time.
>       Do this until CHAR_PTR is aligned on a longword boundary.  */
>    for (char_ptr = (const unsigned char *) s;
> -       n > 0 && ((unsigned long int) char_ptr
> -              & (sizeof (longword) - 1)) != 0;
> +       n > 0 && UNALIGNED_P (char_ptr);

This means that char_ptr may no longer be aligned to longword boundary
after the loop, which will degrade 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.


Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]