summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjon <jonrevold@gmail.com>2020-04-04 14:11:54 +0200
committerjon <jonrevold@gmail.com>2020-04-04 14:11:54 +0200
commit70957d2b24c362f42a1dba5855f645124b923d62 (patch)
treebe10cfb5049de6a27e2ed07457b1267655274078
parent8c261693d340ce42c347149f2a4f19920f442dee (diff)
downloadct_sequence-70957d2b24c362f42a1dba5855f645124b923d62.tar.gz
-rw-r--r--src/main.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 1c34da7..d826972 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,10 +5,11 @@
#include <okelib2/okelib2.h>
#define U32_MAX ((1ULL<<32)-1)
+#define I32_MAX ((1ULL<<31)-1)
static ftimer_t ft;
-static uint32_t *h;
-static uint8_t *h_ext;
+static uint32_t *h_lo;
+static uint8_t *h_hi;
static void fuk(char const *str){
printf("error!( %s\n",str);
@@ -25,18 +26,27 @@ static void perse(int p){
}
static void init(uint64_t n){
- h = malloc(sizeof(uint32_t)*n);
- h_ext = malloc(sizeof(uint8_t)*n);
- if(!h || !h_ext) fuk("memory");
- memset(h, 0x00,sizeof(uint32_t)*n);
- memset(h_ext, 0x00,sizeof(uint8_t)*n);
+ h_lo = malloc(sizeof(uint32_t)*n);
+ h_hi = malloc(sizeof(uint8_t)*n);
+ if(!h_lo || !h_hi) fuk("memory");
+ memset(h_lo,0x00,sizeof(uint32_t)*n);
+ memset(h_hi,0x00,sizeof(uint8_t)*n);
}
static uint64_t load_store(uint64_t t,uint64_t in){
uint64_t r;
- r = h[t];
- h[t] = in;
+ r = h_lo[t];
+ if(r & 0x8000000000000000){
+ r &= 0x7FFFFFFFFFFFFFFF;
+ r |= (uint64_t)h_hi[t]<<31;
+ }
+
+ h_lo[t] = in;
+ if(in > I32_MAX){
+ h_lo[t] |= 0x8000000000000000;
+ h_hi[t] = in>>31;
+ }
return r;
}
@@ -54,7 +64,7 @@ int main(int argc,char **argv){
}
n = strtoull(argv[1],0,10);
- printf("n = %ju\n",n); fflush(stdout);
+ printf("n = %llu\n",n); fflush(stdout);
init(n);
t = 0;