Smallers steps to keep plugin running
[oweals/gnunet.git] / src / include / gnunet_time_lib.h
index 3b901f52658387e99302d429d0a9de56a7a33a44..aa4e8d5db745dfade311145b5b596586fea5a645 100644 (file)
@@ -204,6 +204,46 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct
                                                      struct
                                                      GNUNET_TIME_Relative t2);
 
+
+/**
+ * Return the maximum of two relative time values.
+ *
+ * @param t1 first timestamp
+ * @param t2 other timestamp
+ * @return timestamp that is larger
+ */
+struct GNUNET_TIME_Relative GNUNET_TIME_relative_max (struct
+                                                     GNUNET_TIME_Relative
+                                                     t1,
+                                                     struct
+                                                     GNUNET_TIME_Relative t2);
+
+/**
+ * Return the minimum of two absolute time values.
+ *
+ * @param t1 first timestamp
+ * @param t2 other timestamp
+ * @return timestamp that is smaller
+ */
+struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min (struct
+                                                     GNUNET_TIME_Absolute
+                                                     t1,
+                                                     struct
+                                                     GNUNET_TIME_Absolute t2);
+
+/**
+ * Return the maximum of two absolute time values.
+ *
+ * @param t1 first timestamp
+ * @param t2 other timestamp
+ * @return timestamp that is smaller
+ */
+struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max (struct
+                                                     GNUNET_TIME_Absolute
+                                                     t1,
+                                                     struct
+                                                     GNUNET_TIME_Absolute t2);
+
 /**
  * Given a timestamp in the future, how much time
  * remains until then?
@@ -274,6 +314,22 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct
                                                       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.
  *
@@ -287,6 +343,19 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct
                                                            unsigned int
                                                            factor);
 
+/**
+ * Divide relative time by a given factor.
+ *
+ * @param rel some duration
+ * @param factor integer to divide by
+ * @return FOREVER if rel=FOREVER or factor==0; otherwise rel/factor
+ */
+struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide (struct
+                                                        GNUNET_TIME_Relative
+                                                        rel,
+                                                        unsigned int
+                                                        factor);
+
 /**
  * Add relative times together.
  *
@@ -300,6 +369,17 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct
                                                       GNUNET_TIME_Relative
                                                       a2);
 
+/**
+ * Subtract relative timestamp from the other.
+ *
+ * @param a1 first timestamp
+ * @param a2 second timestamp
+ * @return ZERO if a2>=a1 (including both FOREVER), FOREVER if a1 is FOREVER, a1-a2 otherwise
+ */
+struct GNUNET_TIME_Relative
+GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1,
+                              struct GNUNET_TIME_Relative a2);
+
 
 /**
  * Convert relative time to network byte order.