[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: proposal: some pointer and arithmetic utilities
Date: Thu, 21 Mar 2013 13:50:56 -0500
From: Eric Haszlakiewicz <erh%nimenees.com@localhost>
On Thu, Mar 21, 2013 at 06:42:16PM +0000, Taylor R Campbell wrote:
> Urk...sorry to self-reply, but ten-fingered copypasta invariably
> tastes wrong. Let's try asking the computer to make copypasta for me
> from the code that I actually tested:
> /* typeof-free roundup2/rounddown2 */
> #define roundup2(x, m) (((x) + ((m) - 1)) & ~((m) - 1 + ((x) - (x))))
> #define rounddown2(x,m) ((x) & ~((m) - 1 + ((x) - (x))))
If I remember correctly, we have at least a couple different sets of
macros that do things like this. Are you planning on replacing those,
or adding to them? Where are you proposing to add these?
We have roundup2 in <sys/param.h>. What I propose is to change its
definition there and to add rounddown2 in the same file, next to it.
For the others -- offsetin, container_of --, I think <sys/cdefs.h>
would be a reasonable place, but I haven't thought hard about that.
Main Index |
Thread Index |