From c603bf2c606ca123aab6c5bf1e3be88b4f1ad798 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 17 Jun 2013 16:52:02 +0200 Subject: [PATCH 1/1] Make pools 64-bit clean --- lib/pools.c | 2 +- lib/pools.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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); -- 2.39.2