]> mj.ucw.cz Git - netgrind.git/commitdiff
Make pools 64-bit clean
authorMartin Mares <mj@ucw.cz>
Mon, 17 Jun 2013 14:52:02 +0000 (16:52 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 17 Jun 2013 14:52:02 +0000 (16:52 +0200)
lib/pools.c
lib/pools.h

index 8b7c372518b232f1f28cf2bda6b2d43bf5264067..be42d43b9260115a255b7d2db5d5bccf1e8270dd 100644 (file)
@@ -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;
index a055ef2623763f2da93ca77632ca60d168df9c7d..6c40ef0497ccb719ee28593ae234906abef90960 100644 (file)
@@ -14,6 +14,8 @@
 #define POOL_ALIGN CPU_STRUCT_ALIGN
 #endif
 
+#include <stdint.h>
+
 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);