emacs-devel
[Top][All Lists]
Advanced

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

Re: Proposal: block-based vector allocator


From: Andreas Schwab
Subject: Re: Proposal: block-based vector allocator
Date: Mon, 21 May 2012 17:07:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.97 (gnu/linux)

Dmitry Antipov <address@hidden> writes:

> On 05/21/2012 05:02 PM, Andreas Schwab wrote:
>
>> It doesn't make much sense to try to find such a trivial but non-std
>> macro in a system header.
>
> Hm, glibc provides some not-so-trivial bits (assuming gcc):
>
> # define roundup(x, y)  (__builtin_constant_p (y) && powerof2 (y)             
> \
>                          ? (((x) + (y) - 1) & ~((y) - 1))                     
> \
>                          : ((((x) + ((y) - 1)) / (y)) * (y)))
>
> It seems to be a very negligible optimization, but why not use it if 
> available?

Since you are always using a constant you can define your roundup macro
accordingly.  But note that the expansion is buggy for some types of
arguments, so one more reason not to use it.

Andreas.

-- 
Andreas Schwab, address@hidden
GPG 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]