[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11168 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11168 - in gnunet/src: include util |
Date: |
Mon, 3 May 2010 22:39:50 +0200 |
Author: grothoff
Date: 2010-05-03 22:39:50 +0200 (Mon, 03 May 2010)
New Revision: 11168
Modified:
gnunet/src/include/gnunet_time_lib.h
gnunet/src/util/time.c
Log:
time subtract
Modified: gnunet/src/include/gnunet_time_lib.h
===================================================================
--- gnunet/src/include/gnunet_time_lib.h 2010-05-03 20:27:55 UTC (rev
11167)
+++ gnunet/src/include/gnunet_time_lib.h 2010-05-03 20:39:50 UTC (rev
11168)
@@ -314,7 +314,23 @@
GNUNET_TIME_Relative
duration);
+
/**
+ * Subtract a given relative duration from the
+ * given start time.
+ *
+ * @param start some absolute time
+ * @param duration some relative time to subtract
+ * @return ZERO if start <= duration, or FOREVER if start time is FOREVER;
start-duration otherwise
+ */
+struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract (struct
+ GNUNET_TIME_Absolute
+ start,
+ struct
+ GNUNET_TIME_Relative
+ duration);
+
+/**
* Multiply relative time by a given factor.
*
* @param rel some duration
Modified: gnunet/src/util/time.c
===================================================================
--- gnunet/src/util/time.c 2010-05-03 20:27:55 UTC (rev 11167)
+++ gnunet/src/util/time.c 2010-05-03 20:39:50 UTC (rev 11168)
@@ -270,7 +270,34 @@
return ret;
}
+
/**
+ * Subtract a given relative duration from the
+ * given start time.
+ *
+ * @param start some absolute time
+ * @param duration some relative time to subtract
+ * @return ZERO if start <= duration, or FOREVER if start time is FOREVER;
start-duration otherwise
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_TIME_absolute_subtract (struct
+ GNUNET_TIME_Absolute
+ start,
+ struct
+ GNUNET_TIME_Relative
+ duration)
+{
+ struct GNUNET_TIME_Absolute ret;
+ if (start.value <= duration.value)
+ return GNUNET_TIME_UNIT_ZERO_ABS;
+ if (start.value == GNUNET_TIME_UNIT_FOREVER_ABS.value)
+ return GNUNET_TIME_UNIT_FOREVER_ABS;
+ ret.value = start.value - duration.value;
+ return ret;
+}
+
+
+/**
* Multiply relative time by a given factor.
*
* @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11168 - in gnunet/src: include util,
gnunet <=