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


Mike Frysinger <vapier@gentoo.org> writes:

> On Tuesday 04 June 2013 06:49:00 Rasmus Villemoes wrote:
>> I'm afraid one would have to deal with types anyway, as recently seen
>> in the kernel http://lwn.net/Articles/548336/.
>
> this is easily solved in the macro form:
> 	#define ALIGN_DOWN(base, size) ((base) & ~((__typeof__(base))(size) - 1))
>
> which isn't easily achievable with inline funcs

(I wasn't trying to argue for inline funcs.)

Yes, this seems to work. At first I thought one would have the
opposite problem when typeof(base) was narrower than typeof(size) in
the case of ALIGN_UP. But in that case the __typeof__ is actually
applied to ((base)+(size)-1), which is of course sufficiently wide.

Is the extra expansion of size in ALIGN_UP a problem? 

Rasmus


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