64-bit fun with cache.c
Mark Johnson <[email protected]>
| Newsgroups | gmane.network.djbdns |
|---|---|
| Message-ID | <[email protected]> |
Has anybody successfully hacked cache.c for 64-bit operation? I'm
screwing around with this now:
Index: cache.c
===================================================================
--- cache.c (revision 54)
+++ cache.c (working copy)
@@ -1,6 +1,7 @@
#include "alloc.h"
#include "byte.h"
#include "uint32.h"
+#include "uint64.h"
#include "exit.h"
#include "tai.h"
#include "cache.h"
@@ -8,11 +9,11 @@
uint64 cache_motion = 0;
static char *x = 0;
-static uint32 size;
-static uint32 hsize;
-static uint32 writer;
-static uint32 oldest;
-static uint32 unused;
+static uint64 size;
+static uint64 hsize;
+static uint64 writer;
+static uint64 oldest;
+static uint64 unused;
/*
100 <= size <= 4000000000.
@@ -48,13 +49,13 @@
_exit(111);
}
-static void set4(uint32 pos,uint32 u)
+static void set4(uint64 pos,uint32 u)
{
if (pos > size - 4) cache_impossible();
uint32_pack(x + pos,u);
}
-static uint32 get4(uint32 pos)
+static uint64 get4(uint64 pos)
{
uint32 result;
if (pos > size - 4) cache_impossible();
@@ -81,10 +82,10 @@
{
struct tai expire;
struct tai now;
- uint32 pos;
- uint32 prevpos;
- uint32 nextpos;
- uint32 u;
+ uint64 pos;
+ uint64 prevpos;
+ uint64 nextpos;
+ uint64 u;
unsigned int loop;
double d;
@@ -130,7 +131,7 @@
struct tai expire;
unsigned int entrylen;
unsigned int keyhash;
- uint32 pos;
+ uint64 pos;
if (!x) return;
if (keylen > MAXKEYLEN) return;
@@ -188,7 +189,7 @@
x = 0;
}
- if (cachesize > 4000000000UL) cachesize = 4000000000UL;
+ if (cachesize > 8000000000UL) cachesize = 8000000000UL;
if (cachesize < 100UL) cachesize = 100UL;
size = cachesize;
At first glance, cachetest.c seems to produce the correct output when
fed the input from rts.tests. Who has a large memory 64-bit machine
and wants to be a guinea pig?
I'm wondering how much of performance hit this would be on 32-bit
systems. I don't want to screw around with trying to detect whether
the build platform is 32-bit or 64-bit.
I'm toying around with the idea of eliminating the cachesize limit
altogether, though I wonder if some limit isn't in order to keep
somebody from fat fingering the requested size and immediately
thrashing the machine into the ground.