This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2 v4] libc-internal.h: add ALIGN helper macros


On Wednesday 19 June 2013 12:32:51 Rasmus Villemoes wrote:
> Mike Frysinger <vapier@gentoo.org> writes:
> > On Wednesday 05 June 2013 08:15:12 Rasmus Villemoes wrote:
> >> Is the extra expansion of size in ALIGN_UP a problem?
> > 
> > if someone passes a value with side effects, then yes.  that seems a
> > bit unusual for these types of funcs (doing something like aligning
> > to val++).  i don't see a way past it short of not providing the
> > macro.
> 
> I don't know if gcc does the appropriate optimizations in the,
> presumably, common case where size is a literal, but something like
> 
> #define ALIGN_UP(base, size) ({ \
>   __typeof__((base)+(size)) ____mask = (size)-1; \
>   ((base)+____mask) & ~____mask; })
> 
> should work. But it may very well be too ugly.

true, it could be done if we didn't define ALIGN_UP in terms of ALIGN_DOWN.  i 
like Carlos's idea of documenting and waiting for someone to complain :).
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]