[Top][All Lists]
[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."
- Re: Proposal: block-based vector allocator, Dmitry Antipov, 2012/05/17
- Re: Proposal: block-based vector allocator, Stefan Monnier, 2012/05/18
- Re: Proposal: block-based vector allocator, Stefan Monnier, 2012/05/21
- Re: Proposal: block-based vector allocator, Dmitry Antipov, 2012/05/22
- Re: Proposal: block-based vector allocator, Dmitry Antipov, 2012/05/31
- Re: Proposal: block-based vector allocator, Paul Eggert, 2012/05/31
- Re: Proposal: block-based vector allocator, Stefan Monnier, 2012/05/31