diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-09-25 22:10:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-09-25 22:10:51 +0000 |
commit | f1b9c5c115139b02cac1cae4f053792e1e5b1ccb (patch) | |
tree | cd9047d73ba498d05f67c7e06ae4bd5ed89511e7 /src/include/gnunet_time_lib.h | |
parent | c2d3d24cd9b4f552d7ca8ad6283f9819c1cfefc7 (diff) | |
download | gnunet-f1b9c5c115139b02cac1cae4f053792e1e5b1ccb.tar.gz gnunet-f1b9c5c115139b02cac1cae4f053792e1e5b1ccb.zip |
improving style and docs
Diffstat (limited to 'src/include/gnunet_time_lib.h')
-rw-r--r-- | src/include/gnunet_time_lib.h | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index e4b9dd970..3b901f526 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -43,6 +43,9 @@ extern "C" | |||
43 | */ | 43 | */ |
44 | struct GNUNET_TIME_Absolute | 44 | struct GNUNET_TIME_Absolute |
45 | { | 45 | { |
46 | /** | ||
47 | * The actual value. | ||
48 | */ | ||
46 | uint64_t value; | 49 | uint64_t value; |
47 | }; | 50 | }; |
48 | 51 | ||
@@ -52,6 +55,9 @@ struct GNUNET_TIME_Absolute | |||
52 | */ | 55 | */ |
53 | struct GNUNET_TIME_Relative | 56 | struct GNUNET_TIME_Relative |
54 | { | 57 | { |
58 | /** | ||
59 | * The actual value. | ||
60 | */ | ||
55 | uint64_t value; | 61 | uint64_t value; |
56 | }; | 62 | }; |
57 | 63 | ||
@@ -61,6 +67,9 @@ struct GNUNET_TIME_Relative | |||
61 | */ | 67 | */ |
62 | struct GNUNET_TIME_RelativeNBO | 68 | struct GNUNET_TIME_RelativeNBO |
63 | { | 69 | { |
70 | /** | ||
71 | * The actual value (in network byte order). | ||
72 | */ | ||
64 | uint64_t value__ GNUNET_PACKED; | 73 | uint64_t value__ GNUNET_PACKED; |
65 | }; | 74 | }; |
66 | 75 | ||
@@ -70,22 +79,61 @@ struct GNUNET_TIME_RelativeNBO | |||
70 | */ | 79 | */ |
71 | struct GNUNET_TIME_AbsoluteNBO | 80 | struct GNUNET_TIME_AbsoluteNBO |
72 | { | 81 | { |
82 | /** | ||
83 | * The actual value (in network byte order). | ||
84 | */ | ||
73 | uint64_t value__ GNUNET_PACKED; | 85 | uint64_t value__ GNUNET_PACKED; |
74 | }; | 86 | }; |
75 | 87 | ||
76 | 88 | ||
77 | /** | 89 | /** |
78 | * @brief constants to specify time | 90 | * Relative time zero. |
79 | */ | 91 | */ |
80 | #define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero() | 92 | #define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero() |
93 | |||
94 | /** | ||
95 | * Absolute time zero. | ||
96 | */ | ||
81 | #define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero() | 97 | #define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero() |
98 | |||
99 | /** | ||
100 | * One millisecond, our basic time unit. | ||
101 | */ | ||
82 | #define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit() | 102 | #define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit() |
103 | |||
104 | /** | ||
105 | * One second. | ||
106 | */ | ||
83 | #define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) | 107 | #define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) |
108 | |||
109 | /** | ||
110 | * One minute. | ||
111 | */ | ||
84 | #define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) | 112 | #define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) |
113 | |||
114 | /** | ||
115 | * One hour. | ||
116 | */ | ||
85 | #define GNUNET_TIME_UNIT_HOURS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 60) | 117 | #define GNUNET_TIME_UNIT_HOURS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 60) |
118 | |||
119 | /** | ||
120 | * One day. | ||
121 | */ | ||
86 | #define GNUNET_TIME_UNIT_DAYS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_HOURS, 24) | 122 | #define GNUNET_TIME_UNIT_DAYS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_HOURS, 24) |
123 | |||
124 | /** | ||
125 | * One week. | ||
126 | */ | ||
87 | #define GNUNET_TIME_UNIT_WEEKS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 7) | 127 | #define GNUNET_TIME_UNIT_WEEKS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 7) |
128 | |||
129 | /** | ||
130 | * One month (30 days). | ||
131 | */ | ||
88 | #define GNUNET_TIME_UNIT_MONTHS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 30) | 132 | #define GNUNET_TIME_UNIT_MONTHS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 30) |
133 | |||
134 | /** | ||
135 | * One year (365 days). | ||
136 | */ | ||
89 | #define GNUNET_TIME_UNIT_YEARS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 365) | 137 | #define GNUNET_TIME_UNIT_YEARS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 365) |
90 | 138 | ||
91 | /** | 139 | /** |
@@ -136,6 +184,7 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get (void); | |||
136 | * Convert relative time to an absolute time in the | 184 | * Convert relative time to an absolute time in the |
137 | * future. | 185 | * future. |
138 | * | 186 | * |
187 | * @param rel relative time to convert | ||
139 | * @return timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow) | 188 | * @return timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow) |
140 | */ | 189 | */ |
141 | struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct | 190 | struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct |
@@ -145,6 +194,8 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct | |||
145 | /** | 194 | /** |
146 | * Return the minimum of two relative time values. | 195 | * Return the minimum of two relative time values. |
147 | * | 196 | * |
197 | * @param t1 first timestamp | ||
198 | * @param t2 other timestamp | ||
148 | * @return timestamp that is smaller | 199 | * @return timestamp that is smaller |
149 | */ | 200 | */ |
150 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct | 201 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct |
@@ -157,6 +208,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct | |||
157 | * Given a timestamp in the future, how much time | 208 | * Given a timestamp in the future, how much time |
158 | * remains until then? | 209 | * remains until then? |
159 | * | 210 | * |
211 | * @param future some absolute time, typically in the future | ||
160 | * @return future - now, or 0 if now >= future, or FOREVER if future==FOREVER. | 212 | * @return future - now, or 0 if now >= future, or FOREVER if future==FOREVER. |
161 | */ | 213 | */ |
162 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining (struct | 214 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining (struct |
@@ -184,6 +236,8 @@ struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolu | |||
184 | * Use this function instead of actual subtraction to ensure that | 236 | * Use this function instead of actual subtraction to ensure that |
185 | * "FOREVER" and overflows are handeled correctly. | 237 | * "FOREVER" and overflows are handeled correctly. |
186 | * | 238 | * |
239 | * @param start some absolute time | ||
240 | * @param end some absolute time (typically larger or equal to start) | ||
187 | * @return 0 if start >= end; FOREVER if end==FOREVER; otherwise end - start | 241 | * @return 0 if start >= end; FOREVER if end==FOREVER; otherwise end - start |
188 | */ | 242 | */ |
189 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct | 243 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct |
@@ -197,6 +251,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct | |||
197 | * Get the duration of an operation as the | 251 | * Get the duration of an operation as the |
198 | * difference of the current time and the given start time "hence". | 252 | * difference of the current time and the given start time "hence". |
199 | * | 253 | * |
254 | * @param hence some absolute time, typically in the past | ||
200 | * @return aborts if hence==FOREVER, 0 if hence > now, otherwise now-hence. | 255 | * @return aborts if hence==FOREVER, 0 if hence > now, otherwise now-hence. |
201 | */ | 256 | */ |
202 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration (struct | 257 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration (struct |
@@ -208,6 +263,8 @@ struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration (struct | |||
208 | * Add a given relative duration to the | 263 | * Add a given relative duration to the |
209 | * given start time. | 264 | * given start time. |
210 | * | 265 | * |
266 | * @param start some absolute time | ||
267 | * @param duration some relative time to add | ||
211 | * @return FOREVER if either argument is FOREVER or on overflow; start+duration otherwise | 268 | * @return FOREVER if either argument is FOREVER or on overflow; start+duration otherwise |
212 | */ | 269 | */ |
213 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct | 270 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct |
@@ -220,6 +277,8 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct | |||
220 | /** | 277 | /** |
221 | * Multiply relative time by a given factor. | 278 | * Multiply relative time by a given factor. |
222 | * | 279 | * |
280 | * @param rel some duration | ||
281 | * @param factor integer to multiply with | ||
223 | * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor | 282 | * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor |
224 | */ | 283 | */ |
225 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct | 284 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct |
@@ -231,6 +290,8 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct | |||
231 | /** | 290 | /** |
232 | * Add relative times together. | 291 | * Add relative times together. |
233 | * | 292 | * |
293 | * @param a1 some relative time | ||
294 | * @param a2 some other relative time | ||
234 | * @return FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise | 295 | * @return FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise |
235 | */ | 296 | */ |
236 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct | 297 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct |
@@ -242,6 +303,9 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct | |||
242 | 303 | ||
243 | /** | 304 | /** |
244 | * Convert relative time to network byte order. | 305 | * Convert relative time to network byte order. |
306 | * | ||
307 | * @param a time to convert | ||
308 | * @return converted time value | ||
245 | */ | 309 | */ |
246 | struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct | 310 | struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct |
247 | GNUNET_TIME_Relative | 311 | GNUNET_TIME_Relative |
@@ -249,6 +313,9 @@ struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct | |||
249 | 313 | ||
250 | /** | 314 | /** |
251 | * Convert relative time from network byte order. | 315 | * Convert relative time from network byte order. |
316 | * | ||
317 | * @param a time to convert | ||
318 | * @return converted time value | ||
252 | */ | 319 | */ |
253 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct | 320 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct |
254 | GNUNET_TIME_RelativeNBO | 321 | GNUNET_TIME_RelativeNBO |
@@ -256,6 +323,9 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct | |||
256 | 323 | ||
257 | /** | 324 | /** |
258 | * Convert relative time to network byte order. | 325 | * Convert relative time to network byte order. |
326 | * | ||
327 | * @param a time to convert | ||
328 | * @return converted time value | ||
259 | */ | 329 | */ |
260 | struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct | 330 | struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct |
261 | GNUNET_TIME_Absolute | 331 | GNUNET_TIME_Absolute |
@@ -263,6 +333,9 @@ struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct | |||
263 | 333 | ||
264 | /** | 334 | /** |
265 | * Convert relative time from network byte order. | 335 | * Convert relative time from network byte order. |
336 | * | ||
337 | * @param a time to convert | ||
338 | * @return converted time value | ||
266 | */ | 339 | */ |
267 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct | 340 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct |
268 | GNUNET_TIME_AbsoluteNBO | 341 | GNUNET_TIME_AbsoluteNBO |