This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: Aligning data in buffers with a macro?
From: "Carlos O'Donell" <carlos@systemhalted.org>
Date: Sun, 1 Apr 2012 15:12:48 -0400
> On Sun, Apr 1, 2012 at 12:30 PM, Marek Polacek <polacek@redhat.com> wrote:
>>> ?628 # elif _STACK_GROWS_UP
>>> ?629 ? ? ? ? ? char *guard = (char *) ALIGN_DOWN((uintptr_t) pd -
>>> guardsize, pagesize_m1);
>>> ?630 #endif
>>
>> To be honest, that doesn't make much difference to me. ?The second
>> variant is not shorter nor more readable I suspect. ?Also I have
>> a qualm about these changes--they might be quite error-prone.
>
> It is my opinion that using a macro with a clear purpose makes the
> code more understandable e.g. Are you aligning up, or down, and to
> what alignment?
I completely agree.
> I do *not* propose we go through and fixup everything.
However anyone who chooses to partake in such a cleanup should be
rewarded with punctual patch review from the rest of us.
GLIBC is less maintainable because of those by-hand alignment
expressions, I can't tell you how many times I had to peer over
the nptl stack alignment code to figure out what exactly it was
doing.
> I would rather learn to read through _ALIGND and _ALIGNU than have to
> do the masking operations mentally to figure out what the author
> intended.
Indeed.