aboutsummaryrefslogtreecommitdiff
path: root/src/util/time.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-11-01 20:47:52 +0000
committerChristian Grothoff <christian@grothoff.org>2009-11-01 20:47:52 +0000
commit652e89b59ed2207c2c12172fdabcd6e659995c81 (patch)
treef054c819d483c1056e18c1099afd4c7fcd2582a0 /src/util/time.c
parent5e4113e83368849500792e57946c3d8dd9e548d8 (diff)
downloadgnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.tar.gz
gnunet-652e89b59ed2207c2c12172fdabcd6e659995c81.zip
fixing bio testcase and a bug in bio.c, also indenting
Diffstat (limited to 'src/util/time.c')
-rw-r--r--src/util/time.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/util/time.c b/src/util/time.c
index 90351138a..6411de662 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -40,7 +40,9 @@ GNUNET_TIME_absolute_get ()
40 struct timeval tv; 40 struct timeval tv;
41 41
42 GETTIMEOFDAY (&tv, NULL); 42 GETTIMEOFDAY (&tv, NULL);
43 ret.value = (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) + ((uint64_t) tv.tv_usec / 1000LL)); 43 ret.value =
44 (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) +
45 ((uint64_t) tv.tv_usec / 1000LL));
44 return ret; 46 return ret;
45} 47}
46 48
@@ -106,7 +108,7 @@ struct GNUNET_TIME_Absolute
106GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) 108GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
107{ 109{
108 struct GNUNET_TIME_Absolute ret; 110 struct GNUNET_TIME_Absolute ret;
109 if (rel.value == (uint64_t) -1LL) 111 if (rel.value == (uint64_t) - 1LL)
110 return GNUNET_TIME_absolute_get_forever (); 112 return GNUNET_TIME_absolute_get_forever ();
111 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 113 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
112 if (rel.value + now.value < rel.value) 114 if (rel.value + now.value < rel.value)
@@ -126,11 +128,10 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
126 * @param t2 other timestamp 128 * @param t2 other timestamp
127 * @return timestamp that is smaller 129 * @return timestamp that is smaller
128 */ 130 */
129struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct 131struct GNUNET_TIME_Relative
130 GNUNET_TIME_Relative 132GNUNET_TIME_relative_min (struct
131 t1, 133 GNUNET_TIME_Relative
132 struct 134 t1, struct GNUNET_TIME_Relative t2)
133 GNUNET_TIME_Relative t2)
134{ 135{
135 return (t1.value < t2.value) ? t1 : t2; 136 return (t1.value < t2.value) ? t1 : t2;
136} 137}
@@ -144,11 +145,10 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct
144 * @param t2 other timestamp 145 * @param t2 other timestamp
145 * @return timestamp that is smaller 146 * @return timestamp that is smaller
146 */ 147 */
147struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min (struct 148struct GNUNET_TIME_Absolute
148 GNUNET_TIME_Absolute 149GNUNET_TIME_absolute_min (struct
149 t1, 150 GNUNET_TIME_Absolute
150 struct 151 t1, struct GNUNET_TIME_Absolute t2)
151 GNUNET_TIME_Absolute t2)
152{ 152{
153 return (t1.value < t2.value) ? t1 : t2; 153 return (t1.value < t2.value) ? t1 : t2;
154} 154}
@@ -254,7 +254,7 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
254 { 254 {
255 GNUNET_break (0); 255 GNUNET_break (0);
256 return GNUNET_TIME_relative_get_forever (); 256 return GNUNET_TIME_relative_get_forever ();
257 } 257 }
258 return ret; 258 return ret;
259} 259}
260 260
@@ -269,9 +269,9 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
269 * @return remaining duration for the operation, 269 * @return remaining duration for the operation,
270 * assuming it continues at the same speed 270 * assuming it continues at the same speed
271 */ 271 */
272struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, 272struct GNUNET_TIME_Relative
273 uint64_t finished, 273GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start,
274 uint64_t total) 274 uint64_t finished, uint64_t total)
275{ 275{
276 struct GNUNET_TIME_Relative dur; 276 struct GNUNET_TIME_Relative dur;
277 double exp; 277 double exp;
@@ -283,7 +283,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolu
283 if (finished == 0) 283 if (finished == 0)
284 return GNUNET_TIME_UNIT_FOREVER_REL; 284 return GNUNET_TIME_UNIT_FOREVER_REL;
285 dur = GNUNET_TIME_absolute_get_duration (start); 285 dur = GNUNET_TIME_absolute_get_duration (start);
286 exp = ((double)dur.value) * ((double) total) / ((double)finished); 286 exp = ((double) dur.value) * ((double) total) / ((double) finished);
287 ret.value = ((uint64_t) exp) - dur.value; 287 ret.value = ((uint64_t) exp) - dur.value;
288 return ret; 288 return ret;
289} 289}