aboutsummaryrefslogtreecommitdiff
path: root/src/util/time.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-03-10 10:55:01 +0000
committerChristian Grothoff <christian@grothoff.org>2010-03-10 10:55:01 +0000
commitf6c1d5c870dadddc88c8f501448e2951b1c900b7 (patch)
treebf40faddf1ca8d96ab8fc2840507ef025a87c4f5 /src/util/time.c
parent02e738b91dff93aa75bfe38d5d58fdbd353f50be (diff)
downloadgnunet-f6c1d5c870dadddc88c8f501448e2951b1c900b7.tar.gz
gnunet-f6c1d5c870dadddc88c8f501448e2951b1c900b7.zip
keepalive PINGs
Diffstat (limited to 'src/util/time.c')
-rw-r--r--src/util/time.c36
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 */
147struct GNUNET_TIME_Relative
148GNUNET_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 */
302struct GNUNET_TIME_Relative
303GNUNET_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 *