diff options
Diffstat (limited to 'src/util/time.c')
-rw-r--r-- | src/util/time.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/util/time.c b/src/util/time.c index 36a3c8631..ce2f9517f 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -137,6 +137,22 @@ GNUNET_TIME_relative_min (struct | |||
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | /** | ||
141 | * Return the maximum of two relative time values. | ||
142 | * | ||
143 | * @param t1 first timestamp | ||
144 | * @param t2 other timestamp | ||
145 | * @return timestamp that is larger | ||
146 | */ | ||
147 | struct GNUNET_TIME_Relative | ||
148 | GNUNET_TIME_relative_max (struct | ||
149 | GNUNET_TIME_Relative | ||
150 | t1, struct GNUNET_TIME_Relative t2) | ||
151 | { | ||
152 | return (t1.value > t2.value) ? t1 : t2; | ||
153 | } | ||
154 | |||
155 | |||
140 | 156 | ||
141 | /** | 157 | /** |
142 | * Return the minimum of two relative time values. | 158 | * Return the minimum of two relative time values. |
@@ -277,6 +293,26 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, | |||
277 | 293 | ||
278 | 294 | ||
279 | /** | 295 | /** |
296 | * Divide relative time by a given factor. | ||
297 | * | ||
298 | * @param rel some duration | ||
299 | * @param factor integer to divide by | ||
300 | * @return FOREVER if rel=FOREVER or factor==0; otherwise rel/factor | ||
301 | */ | ||
302 | struct GNUNET_TIME_Relative | ||
303 | GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, | ||
304 | unsigned int factor) | ||
305 | { | ||
306 | struct GNUNET_TIME_Relative ret; | ||
307 | if ( (factor == 0) || | ||
308 | (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value) ) | ||
309 | return GNUNET_TIME_UNIT_FOREVER_REL; | ||
310 | ret.value = rel.value / (unsigned long long) factor; | ||
311 | return ret; | ||
312 | } | ||
313 | |||
314 | |||
315 | /** | ||
280 | * Calculate the estimate time of arrival/completion | 316 | * Calculate the estimate time of arrival/completion |
281 | * for an operation. | 317 | * for an operation. |
282 | * | 318 | * |