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

**To**:**tech-kern%NetBSD.org@localhost****Subject**:**Re: proposal: some pointer and arithmetic utilities****From**:**Alan Barrett <apb%cequrux.com@localhost>**- Date: Fri, 22 Mar 2013 09:08:55 +0200

On Thu, 21 Mar 2013, Taylor R Campbell wrote:

/* typeof-free roundup2/rounddown2 */ #define roundup2(x, m) (((x) + ((m) - 1)) & ~((m) - 1 + ((x) - (x)))) #define rounddown2(x,m) ((x) & ~((m) - 1 + ((x) - (x)))) /* multiple-evaluation-free roundup2/rounddown2 */ #define roundup2(x, m) ((((x) - 1) | ((m) - 1)) + 1) #define rounddown2(x,m) ((x) &~ ((typeof(x))((m) - 1))) #define offsetin(s, f) (((const char *)&(s).f) - ((const char *)&(s))) #define container_of(p, t, f) \ ((void)sizeof((p) - \ &((t *)(((char *)(p)) - offsetof(t, f)))->f), \ ((t *)(((char *)(p)) - offsetof(t, f))))

--apb (Alan Barrett)

**Follow-Ups**:**Re: proposal: some pointer and arithmetic utilities***From:*Dennis Ferguson

**Re: proposal: some pointer and arithmetic utilities***From:*Taylor R Campbell

**Re: proposal: some pointer and arithmetic utilities***From:*Daode

**References**:**proposal: some pointer and arithmetic utilities***From:*Taylor R Campbell

**Re: proposal: some pointer and arithmetic utilities***From:*Taylor R Campbell

- Prev by Date:
**Re: proposal: some pointer and arithmetic utilities** - Next by Date:
**Re: proposal: some pointer and arithmetic utilities** - Previous by Thread:
**Re: proposal: some pointer and arithmetic utilities** - Next by Thread:
**Re: proposal: some pointer and arithmetic utilities** - Indexes: