[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: add GNUNET_TIME_absolute_round_down() fu
From: |
gnunet |
Subject: |
[gnunet] branch master updated: add GNUNET_TIME_absolute_round_down() function |
Date: |
Sat, 26 Mar 2022 07:17:40 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new e598ffe0a add GNUNET_TIME_absolute_round_down() function
e598ffe0a is described below
commit e598ffe0a3a3d3db0df1fcc04f52bbefe93d3779
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sat Mar 26 07:17:12 2022 +0100
add GNUNET_TIME_absolute_round_down() function
---
src/include/gnunet_time_lib.h | 12 ++++++++++++
src/util/time.c | 14 ++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h
index 55af62b72..d59eb984d 100644
--- a/src/include/gnunet_time_lib.h
+++ b/src/include/gnunet_time_lib.h
@@ -481,6 +481,18 @@ GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1,
struct GNUNET_TIME_Absolute t2);
+/**
+ * Round down absolute time @a at to multiple of @a rt.
+ *
+ * @param at absolute time to round
+ * @param rt multiple to round to (non-zero)
+ * @return rounded time
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_TIME_absolute_round_down (struct GNUNET_TIME_Absolute at,
+ struct GNUNET_TIME_Relative rt);
+
+
/**
* Return the maximum of two timestamps.
*
diff --git a/src/util/time.c b/src/util/time.c
index aeec2b3f9..cf072aebf 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -386,6 +386,20 @@ GNUNET_TIME_timestamp_min (struct GNUNET_TIME_Timestamp t1,
}
+struct GNUNET_TIME_Absolute
+GNUNET_TIME_absolute_round_down (struct GNUNET_TIME_Absolute at,
+ struct GNUNET_TIME_Relative rt)
+{
+ struct GNUNET_TIME_Absolute ret;
+
+ GNUNET_assert (! GNUNET_TIME_relative_is_zero (rt));
+ ret.abs_value_us
+ = at.abs_value_us
+ - at.abs_value_us % rt.rel_value_us;
+ return ret;
+}
+
+
struct GNUNET_TIME_Relative
GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future)
{
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: add GNUNET_TIME_absolute_round_down() function,
gnunet <=