From: Martin Mares Date: Mon, 17 Jun 2013 14:52:02 +0000 (+0200) Subject: Make pools 64-bit clean X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=c603bf2c606ca123aab6c5bf1e3be88b4f1ad798;hp=f73dbd02b51b2c1bddddc7931e2d7e1e476a23e2;p=netgrind.git Make pools 64-bit clean --- diff --git a/lib/pools.c b/lib/pools.c index 8b7c372..be42d43 100644 --- a/lib/pools.c +++ b/lib/pools.c @@ -69,7 +69,7 @@ mp_alloc(struct mempool *p, uns s) { if (s <= p->threshold) { - byte *x = (byte *)(((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1)); + byte *x = (byte *)(((uintptr_t) p->free + POOL_ALIGN - 1) & ~((uintptr_t) POOL_ALIGN - 1)); if (x + s > p->last) { struct memchunk *c; diff --git a/lib/pools.h b/lib/pools.h index a055ef2..6c40ef0 100644 --- a/lib/pools.h +++ b/lib/pools.h @@ -14,6 +14,8 @@ #define POOL_ALIGN CPU_STRUCT_ALIGN #endif +#include + struct mempool { byte *free, *last; struct memchunk *first, *current, **plast; @@ -29,7 +31,7 @@ void *mp_alloc_zero(struct mempool *, uns); static inline void *mp_alloc_fast(struct mempool *p, uns l) { - byte *f = (void *) (((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1)); + byte *f = (void *) (((uintptr_t) p->free + POOL_ALIGN - 1) & ~((uintptr_t) POOL_ALIGN - 1)); byte *ee = f + l; if (ee > p->last) return mp_alloc(p, l);