summaryrefslogtreecommitdiffhomepage
path: root/src/timer-ns.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-01 17:34:04 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-01 17:34:04 +0100
commit10e22ed4fb0bd21d9d268c5c6f1ac1c7d9e4b621 (patch)
tree56e4c085cb9d29f4d2db19e208d57e983a1aa318 /src/timer-ns.cpp
parent9a0399ae67ad378d2f746114dd297230104cf018 (diff)
w
Diffstat (limited to 'src/timer-ns.cpp')
-rw-r--r--src/timer-ns.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/timer-ns.cpp b/src/timer-ns.cpp
index a940e1f5..7a2fe087 100644
--- a/src/timer-ns.cpp
+++ b/src/timer-ns.cpp
@@ -1,11 +1,12 @@
#include "timer.hpp"
#include "compat/assert.hpp"
+#include <cr/Debug.h>
namespace floormat {
namespace {
-#if 1
+#if 0
constexpr auto MAX = (uint64_t)-1, HALF = MAX/2;
static_assert(MAX - (MAX-0) <= 0);
@@ -44,7 +45,13 @@ Ns operator*(const Ns& lhs, uint64_t b)
auto x = a * b;
//fm_assert(!(a != 0 && x / a != b));
fm_assert(a == 0 || x / a == b);
- return Ns{a * b};
+ return Ns{x};
+}
+
+Ns operator*(uint64_t a, const Ns& rhs)
+{
+ auto b = rhs.stamp;
+ return Ns{a} * b;
}
uint64_t operator/(const Ns& lhs, const Ns& rhs)
@@ -54,6 +61,20 @@ uint64_t operator/(const Ns& lhs, const Ns& rhs)
return a / b;
}
+Ns operator/(const Ns& lhs, uint64_t b)
+{
+ auto a = lhs.stamp;
+ fm_assert(b != 0);
+ return Ns{a / b};
+}
+
+uint64_t operator%(const Ns& lhs, const Ns& rhs)
+{
+ auto a = lhs.stamp, b = rhs.stamp;
+ fm_assert(b != 0);
+ return a % b;
+}
+
Ns operator%(const Ns& lhs, uint64_t b)
{
auto a = lhs.stamp;