diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-04-28 12:10:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-04-28 12:10:06 +0000 |
commit | ae300a58c5bdfcadca8837a1e23abe3e34032209 (patch) | |
tree | c90e62d0c32575dce3ac763fa1f67ca858823a5e /src/util/time.c | |
parent | 684476aafc7c225d565295fdac4a00ee8bfc207f (diff) | |
download | gnunet-ae300a58c5bdfcadca8837a1e23abe3e34032209.tar.gz gnunet-ae300a58c5bdfcadca8837a1e23abe3e34032209.zip |
adding availability probes for search results
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 ce2f9517f..6eccf4d9a 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -345,6 +345,8 @@ GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, | |||
345 | /** | 345 | /** |
346 | * Add relative times together. | 346 | * Add relative times together. |
347 | * | 347 | * |
348 | * @param a1 first timestamp | ||
349 | * @param a2 second timestamp | ||
348 | * @return FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise | 350 | * @return FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise |
349 | */ | 351 | */ |
350 | struct GNUNET_TIME_Relative | 352 | struct GNUNET_TIME_Relative |
@@ -366,7 +368,32 @@ GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, | |||
366 | 368 | ||
367 | 369 | ||
368 | /** | 370 | /** |
371 | * Subtract relative timestamp from the other. | ||
372 | * | ||
373 | * @param a1 first timestamp | ||
374 | * @param a2 second timestamp | ||
375 | * @return ZERO if a2>=a1 (including both FOREVER), FOREVER if a1 is FOREVER, a1-a2 otherwise | ||
376 | */ | ||
377 | struct GNUNET_TIME_Relative | ||
378 | GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, | ||
379 | struct GNUNET_TIME_Relative a2) | ||
380 | { | ||
381 | struct GNUNET_TIME_Relative ret; | ||
382 | |||
383 | if (a2.value >= a1.value) | ||
384 | return GNUNET_TIME_relative_get_zero (); | ||
385 | if (a1.value == (uint64_t) - 1LL) | ||
386 | return GNUNET_TIME_relative_get_forever (); | ||
387 | ret.value = a1.value - a2.value; | ||
388 | return ret; | ||
389 | } | ||
390 | |||
391 | |||
392 | /** | ||
369 | * Convert relative time to network byte order. | 393 | * Convert relative time to network byte order. |
394 | * | ||
395 | * @param a time to convert | ||
396 | * @return time in network byte order | ||
370 | */ | 397 | */ |
371 | struct GNUNET_TIME_RelativeNBO | 398 | struct GNUNET_TIME_RelativeNBO |
372 | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) | 399 | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) |
@@ -378,6 +405,9 @@ GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) | |||
378 | 405 | ||
379 | /** | 406 | /** |
380 | * Convert relative time from network byte order. | 407 | * Convert relative time from network byte order. |
408 | * | ||
409 | * @param a time to convert | ||
410 | * @return time in host byte order | ||
381 | */ | 411 | */ |
382 | struct GNUNET_TIME_Relative | 412 | struct GNUNET_TIME_Relative |
383 | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) | 413 | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) |
@@ -390,6 +420,9 @@ GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) | |||
390 | 420 | ||
391 | /** | 421 | /** |
392 | * Convert absolute time to network byte order. | 422 | * Convert absolute time to network byte order. |
423 | * | ||
424 | * @param a time to convert | ||
425 | * @return time in network byte order | ||
393 | */ | 426 | */ |
394 | struct GNUNET_TIME_AbsoluteNBO | 427 | struct GNUNET_TIME_AbsoluteNBO |
395 | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) | 428 | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) |
@@ -401,6 +434,9 @@ GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) | |||
401 | 434 | ||
402 | /** | 435 | /** |
403 | * Convert absolute time from network byte order. | 436 | * Convert absolute time from network byte order. |
437 | * | ||
438 | * @param a time to convert | ||
439 | * @return time in host byte order | ||
404 | */ | 440 | */ |
405 | struct GNUNET_TIME_Absolute | 441 | struct GNUNET_TIME_Absolute |
406 | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) | 442 | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) |