aboutsummaryrefslogtreecommitdiff
path: root/src/util/time.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
commit83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch)
treed0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/util/time.c
parent28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff)
downloadgnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz
gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip
curly wars / auto-indentation
Diffstat (limited to 'src/util/time.c')
-rw-r--r--src/util/time.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/util/time.c b/src/util/time.c
index e48377fa3..3ee15516a 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -55,8 +55,8 @@ GNUNET_TIME_absolute_get ()
55 55
56 GETTIMEOFDAY (&tv, NULL); 56 GETTIMEOFDAY (&tv, NULL);
57 ret.abs_value = 57 ret.abs_value =
58 (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) + 58 (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) +
59 ((uint64_t) tv.tv_usec / 1000LL)) + timestamp_offset; 59 ((uint64_t) tv.tv_usec / 1000LL)) + timestamp_offset;
60 return ret; 60 return ret;
61} 61}
62 62
@@ -130,10 +130,10 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
130 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 130 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
131 131
132 if (rel.rel_value + now.abs_value < rel.rel_value) 132 if (rel.rel_value + now.abs_value < rel.rel_value)
133 { 133 {
134 GNUNET_break (0); /* overflow... */ 134 GNUNET_break (0); /* overflow... */
135 return GNUNET_TIME_absolute_get_forever (); 135 return GNUNET_TIME_absolute_get_forever ();
136 } 136 }
137 ret.abs_value = rel.rel_value + now.abs_value; 137 ret.abs_value = rel.rel_value + now.abs_value;
138 return ret; 138 return ret;
139} 139}
@@ -148,7 +148,7 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
148 */ 148 */
149struct GNUNET_TIME_Relative 149struct GNUNET_TIME_Relative
150GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, 150GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1,
151 struct GNUNET_TIME_Relative t2) 151 struct GNUNET_TIME_Relative t2)
152{ 152{
153 return (t1.rel_value < t2.rel_value) ? t1 : t2; 153 return (t1.rel_value < t2.rel_value) ? t1 : t2;
154} 154}
@@ -163,7 +163,7 @@ GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1,
163 */ 163 */
164struct GNUNET_TIME_Relative 164struct GNUNET_TIME_Relative
165GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, 165GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1,
166 struct GNUNET_TIME_Relative t2) 166 struct GNUNET_TIME_Relative t2)
167{ 167{
168 return (t1.rel_value > t2.rel_value) ? t1 : t2; 168 return (t1.rel_value > t2.rel_value) ? t1 : t2;
169} 169}
@@ -179,7 +179,7 @@ GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1,
179 */ 179 */
180struct GNUNET_TIME_Absolute 180struct GNUNET_TIME_Absolute
181GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, 181GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1,
182 struct GNUNET_TIME_Absolute t2) 182 struct GNUNET_TIME_Absolute t2)
183{ 183{
184 return (t1.abs_value < t2.abs_value) ? t1 : t2; 184 return (t1.abs_value < t2.abs_value) ? t1 : t2;
185} 185}
@@ -194,7 +194,7 @@ GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1,
194 */ 194 */
195struct GNUNET_TIME_Absolute 195struct GNUNET_TIME_Absolute
196GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, 196GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1,
197 struct GNUNET_TIME_Absolute t2) 197 struct GNUNET_TIME_Absolute t2)
198{ 198{
199 return (t1.abs_value > t2.abs_value) ? t1 : t2; 199 return (t1.abs_value > t2.abs_value) ? t1 : t2;
200} 200}
@@ -230,7 +230,7 @@ GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future)
230 */ 230 */
231struct GNUNET_TIME_Relative 231struct GNUNET_TIME_Relative
232GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, 232GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start,
233 struct GNUNET_TIME_Absolute end) 233 struct GNUNET_TIME_Absolute end)
234{ 234{
235 struct GNUNET_TIME_Relative ret; 235 struct GNUNET_TIME_Relative ret;
236 236
@@ -271,17 +271,17 @@ GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute whence)
271 */ 271 */
272struct GNUNET_TIME_Absolute 272struct GNUNET_TIME_Absolute
273GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, 273GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start,
274 struct GNUNET_TIME_Relative duration) 274 struct GNUNET_TIME_Relative duration)
275{ 275{
276 struct GNUNET_TIME_Absolute ret; 276 struct GNUNET_TIME_Absolute ret;
277 277
278 if ((start.abs_value == UINT64_MAX) || (duration.rel_value == UINT64_MAX)) 278 if ((start.abs_value == UINT64_MAX) || (duration.rel_value == UINT64_MAX))
279 return GNUNET_TIME_absolute_get_forever (); 279 return GNUNET_TIME_absolute_get_forever ();
280 if (start.abs_value + duration.rel_value < start.abs_value) 280 if (start.abs_value + duration.rel_value < start.abs_value)
281 { 281 {
282 GNUNET_break (0); 282 GNUNET_break (0);
283 return GNUNET_TIME_absolute_get_forever (); 283 return GNUNET_TIME_absolute_get_forever ();
284 } 284 }
285 ret.abs_value = start.abs_value + duration.rel_value; 285 ret.abs_value = start.abs_value + duration.rel_value;
286 return ret; 286 return ret;
287} 287}
@@ -297,7 +297,7 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start,
297 */ 297 */
298struct GNUNET_TIME_Absolute 298struct GNUNET_TIME_Absolute
299GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, 299GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start,
300 struct GNUNET_TIME_Relative duration) 300 struct GNUNET_TIME_Relative duration)
301{ 301{
302 struct GNUNET_TIME_Absolute ret; 302 struct GNUNET_TIME_Absolute ret;
303 303
@@ -317,7 +317,7 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start,
317 */ 317 */
318struct GNUNET_TIME_Relative 318struct GNUNET_TIME_Relative
319GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, 319GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
320 unsigned int factor) 320 unsigned int factor)
321{ 321{
322 struct GNUNET_TIME_Relative ret; 322 struct GNUNET_TIME_Relative ret;
323 323
@@ -325,10 +325,10 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
325 return GNUNET_TIME_relative_get_zero (); 325 return GNUNET_TIME_relative_get_zero ();
326 ret.rel_value = rel.rel_value * (unsigned long long) factor; 326 ret.rel_value = rel.rel_value * (unsigned long long) factor;
327 if (ret.rel_value / factor != rel.rel_value) 327 if (ret.rel_value / factor != rel.rel_value)
328 { 328 {
329 GNUNET_break (0); 329 GNUNET_break (0);
330 return GNUNET_TIME_relative_get_forever (); 330 return GNUNET_TIME_relative_get_forever ();
331 } 331 }
332 return ret; 332 return ret;
333} 333}
334 334
@@ -342,7 +342,7 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
342 */ 342 */
343struct GNUNET_TIME_Relative 343struct GNUNET_TIME_Relative
344GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, 344GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel,
345 unsigned int factor) 345 unsigned int factor)
346{ 346{
347 struct GNUNET_TIME_Relative ret; 347 struct GNUNET_TIME_Relative ret;
348 348
@@ -365,8 +365,8 @@ GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel,
365 * assuming it continues at the same speed 365 * assuming it continues at the same speed
366 */ 366 */
367struct GNUNET_TIME_Relative 367struct GNUNET_TIME_Relative
368GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, 368GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished,
369 uint64_t finished, uint64_t total) 369 uint64_t total)
370{ 370{
371 struct GNUNET_TIME_Relative dur; 371 struct GNUNET_TIME_Relative dur;
372 double exp; 372 double exp;
@@ -393,17 +393,17 @@ GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start,
393 */ 393 */
394struct GNUNET_TIME_Relative 394struct GNUNET_TIME_Relative
395GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, 395GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1,
396 struct GNUNET_TIME_Relative a2) 396 struct GNUNET_TIME_Relative a2)
397{ 397{
398 struct GNUNET_TIME_Relative ret; 398 struct GNUNET_TIME_Relative ret;
399 399
400 if ((a1.rel_value == UINT64_MAX) || (a2.rel_value == UINT64_MAX)) 400 if ((a1.rel_value == UINT64_MAX) || (a2.rel_value == UINT64_MAX))
401 return GNUNET_TIME_relative_get_forever (); 401 return GNUNET_TIME_relative_get_forever ();
402 if (a1.rel_value + a2.rel_value < a1.rel_value) 402 if (a1.rel_value + a2.rel_value < a1.rel_value)
403 { 403 {
404 GNUNET_break (0); 404 GNUNET_break (0);
405 return GNUNET_TIME_relative_get_forever (); 405 return GNUNET_TIME_relative_get_forever ();
406 } 406 }
407 ret.rel_value = a1.rel_value + a2.rel_value; 407 ret.rel_value = a1.rel_value + a2.rel_value;
408 return ret; 408 return ret;
409} 409}
@@ -418,7 +418,7 @@ GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1,
418 */ 418 */
419struct GNUNET_TIME_Relative 419struct GNUNET_TIME_Relative
420GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, 420GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1,
421 struct GNUNET_TIME_Relative a2) 421 struct GNUNET_TIME_Relative a2)
422{ 422{
423 struct GNUNET_TIME_Relative ret; 423 struct GNUNET_TIME_Relative ret;
424 424