summaryrefslogtreecommitdiffstats
path: root/app/abs.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/abs.c')
-rw-r--r--app/abs.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/app/abs.c b/app/abs.c
index 769da7a..a91787c 100644
--- a/app/abs.c
+++ b/app/abs.c
@@ -3,28 +3,55 @@
static uint32_t high_tick;
+#define QUARTER (1UL << 29)
+#define HALF (1UL << 30)
+#define THREE_QUARTERS (HALF+QUARTER)
+#define ONE (~(uint32_t)0)
uint64_t abs_extend (uint32_t now)
{
- static uint32_t then;
+ static int m;
+ uint64_t ret;
- uint64_t ret;
+ if (!m) {
+ ret = high_tick;
+ ret <<= 32;
+ ret |= now;
- if (now < then)
- high_tick++;
+ if ((now>THREE_QUARTERS) &&( now<=ONE)) {
+ high_tick++;
+ m=1;
+ }
- then = now;
+ } else {
- ret = high_tick;
- ret <<= 32;
- ret |= now;
+ if (now<HALF) {
+ ret = high_tick;
+ ret <<= 32;
+ ret |= now;
+ } else {
+ ret = high_tick-1;
+ ret <<= 32;
+ ret |= now;
+ }
- return ret;
+ if ((now>QUARTER) &&( now<HALF))
+ m=0;
}
+ return ret;
+}
+
+
+void abs_meh(void)
+{
+printf("HT %d\n",(int) high_tick);
+}
+
+