diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-27 09:21:14 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-27 09:21:14 +0000 |
commit | 71f77f1be3d6e2da1b88fe4a4fdd44c3c69b5325 (patch) | |
tree | 5570130fdab90ad02f4b5bfda414d13161f0f3d1 /src | |
parent | 1d7368a52af332af35ec6de22affef4f5f0c1da4 (diff) | |
download | gnunet-71f77f1be3d6e2da1b88fe4a4fdd44c3c69b5325.tar.gz gnunet-71f77f1be3d6e2da1b88fe4a4fdd44c3c69b5325.zip |
Changed GNUNET_TIME_Absolute and GNUNET_TIME_Relative to allow safe comparisons between time values
Diffstat (limited to 'src')
-rw-r--r-- | src/util/bandwidth.c | 16 | ||||
-rw-r--r-- | src/util/client.c | 8 | ||||
-rw-r--r-- | src/util/common_logging.c | 6 | ||||
-rw-r--r-- | src/util/configuration.c | 2 | ||||
-rw-r--r-- | src/util/connection.c | 6 | ||||
-rw-r--r-- | src/util/gnunet-service-resolver.c | 4 | ||||
-rw-r--r-- | src/util/load.c | 8 | ||||
-rw-r--r-- | src/util/network.c | 20 | ||||
-rw-r--r-- | src/util/perf_crypto_hash.c | 2 | ||||
-rw-r--r-- | src/util/scheduler.c | 22 | ||||
-rw-r--r-- | src/util/strings.c | 8 | ||||
-rw-r--r-- | src/util/test_configuration.c | 2 | ||||
-rw-r--r-- | src/util/test_crypto_ksk.c | 4 | ||||
-rw-r--r-- | src/util/test_crypto_rsa.c | 10 | ||||
-rw-r--r-- | src/util/test_scheduler_delay.c | 6 | ||||
-rw-r--r-- | src/util/test_strings.c | 2 | ||||
-rw-r--r-- | src/util/test_time.c | 152 | ||||
-rw-r--r-- | src/util/time.c | 80 |
18 files changed, 179 insertions, 179 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index 4e34f6f06..86181ec70 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c | |||
@@ -84,10 +84,10 @@ GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO b | |||
84 | #if DEBUG_BANDWIDTH | 84 | #if DEBUG_BANDWIDTH |
85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
86 | "Bandwidth has %llu bytes available until deadline in %llums\n", | 86 | "Bandwidth has %llu bytes available until deadline in %llums\n", |
87 | (unsigned long long) ((b * deadline.value + 500LL) / 1000LL), | 87 | (unsigned long long) ((b * deadline.abs_value + 500LL) / 1000LL), |
88 | deadline.value); | 88 | deadline.abs_value); |
89 | #endif | 89 | #endif |
90 | return (b * deadline.value + 500LL) / 1000LL; | 90 | return (b * deadline.rel_value + 500LL) / 1000LL; |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
@@ -115,11 +115,11 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, | |||
115 | #endif | 115 | #endif |
116 | return GNUNET_TIME_UNIT_FOREVER_REL; | 116 | return GNUNET_TIME_UNIT_FOREVER_REL; |
117 | } | 117 | } |
118 | ret.value = size * 1000LL / b; | 118 | ret.rel_value = size * 1000LL / b; |
119 | #if DEBUG_BANDWIDTH | 119 | #if DEBUG_BANDWIDTH |
120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
121 | "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n", | 121 | "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n", |
122 | (unsigned long long) ret.value, | 122 | (unsigned long long) ret.abs_value, |
123 | (unsigned long long) size); | 123 | (unsigned long long) size); |
124 | #endif | 124 | #endif |
125 | return ret; | 125 | return ret; |
@@ -175,7 +175,7 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av) | |||
175 | uint64_t max_carry; | 175 | uint64_t max_carry; |
176 | 176 | ||
177 | now = GNUNET_TIME_absolute_get (); | 177 | now = GNUNET_TIME_absolute_get (); |
178 | delta_time = now.value - av->last_update__.value; | 178 | delta_time = now.abs_value - av->last_update__.abs_value; |
179 | delta_avail = (delta_time * ((unsigned long long) av->available_bytes_per_s__) + 500LL) / 1000LL; | 179 | delta_avail = (delta_time * ((unsigned long long) av->available_bytes_per_s__) + 500LL) / 1000LL; |
180 | av->consumption_since_last_update__ -= delta_avail; | 180 | av->consumption_since_last_update__ -= delta_avail; |
181 | av->last_update__ = now; | 181 | av->last_update__ = now; |
@@ -291,13 +291,13 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, | |||
291 | #endif | 291 | #endif |
292 | return GNUNET_TIME_UNIT_ZERO; | 292 | return GNUNET_TIME_UNIT_ZERO; |
293 | } | 293 | } |
294 | ret.value = 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__; | 294 | ret.rel_value = 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__; |
295 | #if DEBUG_BANDWIDTH | 295 | #if DEBUG_BANDWIDTH |
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
297 | "Tracker %p delay for %u bytes is %llu ms\n", | 297 | "Tracker %p delay for %u bytes is %llu ms\n", |
298 | av, | 298 | av, |
299 | (unsigned int) size, | 299 | (unsigned int) size, |
300 | (unsigned long long) ret.value); | 300 | (unsigned long long) ret.abs_value); |
301 | #endif | 301 | #endif |
302 | return ret; | 302 | return ret; |
303 | } | 303 | } |
diff --git a/src/util/client.c b/src/util/client.c index 3431ac448..445cf1bf0 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -492,7 +492,7 @@ receive_helper (void *cls, | |||
492 | check_complete (conn); | 492 | check_complete (conn); |
493 | /* check for timeout */ | 493 | /* check for timeout */ |
494 | remaining = GNUNET_TIME_absolute_get_remaining (conn->receive_timeout); | 494 | remaining = GNUNET_TIME_absolute_get_remaining (conn->receive_timeout); |
495 | if (remaining.value == 0) | 495 | if (remaining.rel_value == 0) |
496 | { | 496 | { |
497 | /* signal timeout! */ | 497 | /* signal timeout! */ |
498 | conn->receiver_handler (conn->receiver_handler_cls, NULL); | 498 | conn->receiver_handler (conn->receiver_handler_cls, NULL); |
@@ -790,11 +790,11 @@ client_notify (void *cls, size_t size, void *buf) | |||
790 | if (buf == NULL) | 790 | if (buf == NULL) |
791 | { | 791 | { |
792 | delay = GNUNET_TIME_absolute_get_remaining (th->timeout); | 792 | delay = GNUNET_TIME_absolute_get_remaining (th->timeout); |
793 | delay.value /= 2; | 793 | delay.rel_value /= 2; |
794 | if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))) || | 794 | if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))) || |
795 | (GNUNET_YES != th->auto_retry) || | 795 | (GNUNET_YES != th->auto_retry) || |
796 | (0 == --th->attempts_left) || | 796 | (0 == --th->attempts_left) || |
797 | (delay.value < 1) ) | 797 | (delay.rel_value < 1) ) |
798 | { | 798 | { |
799 | #if DEBUG_CLIENT | 799 | #if DEBUG_CLIENT |
800 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 800 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -822,7 +822,7 @@ client_notify (void *cls, size_t size, void *buf) | |||
822 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 822 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
823 | "Transmission failed %u times, trying again in %llums.\n", | 823 | "Transmission failed %u times, trying again in %llums.\n", |
824 | MAX_ATTEMPTS - th->attempts_left, | 824 | MAX_ATTEMPTS - th->attempts_left, |
825 | (unsigned long long) delay.value); | 825 | (unsigned long long) delay.abs_value); |
826 | #endif | 826 | #endif |
827 | th->reconnect_task = GNUNET_SCHEDULER_add_delayed (th->sock->sched, | 827 | th->reconnect_task = GNUNET_SCHEDULER_add_delayed (th->sock->sched, |
828 | delay, | 828 | delay, |
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index b17501690..223c92218 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -289,7 +289,7 @@ flush_bulk (const char *datestr) | |||
289 | char *last; | 289 | char *last; |
290 | char *ft; | 290 | char *ft; |
291 | 291 | ||
292 | if ((last_bulk_time.value == 0) || (last_bulk_repeat == 0)) | 292 | if ((last_bulk_time.abs_value == 0) || (last_bulk_repeat == 0)) |
293 | return; | 293 | return; |
294 | rev = 0; | 294 | rev = 0; |
295 | last = memchr (last_bulk, '\0', BULK_TRACK_SIZE); | 295 | last = memchr (last_bulk, '\0', BULK_TRACK_SIZE); |
@@ -381,11 +381,11 @@ mylog (enum GNUNET_ErrorType kind, | |||
381 | else | 381 | else |
382 | strcpy (date, "localtime error"); | 382 | strcpy (date, "localtime error"); |
383 | if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && | 383 | if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && |
384 | (last_bulk_time.value != 0) && | 384 | (last_bulk_time.abs_value != 0) && |
385 | (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) | 385 | (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) |
386 | { | 386 | { |
387 | last_bulk_repeat++; | 387 | last_bulk_repeat++; |
388 | if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).value > | 388 | if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value > |
389 | BULK_DELAY_THRESHOLD) | 389 | BULK_DELAY_THRESHOLD) |
390 | || (last_bulk_repeat > BULK_REPEAT_THRESHOLD)) | 390 | || (last_bulk_repeat > BULK_REPEAT_THRESHOLD)) |
391 | flush_bulk (date); | 391 | flush_bulk (date); |
diff --git a/src/util/configuration.c b/src/util/configuration.c index 005a8f7d3..875fa2f4c 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -637,7 +637,7 @@ GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle | |||
637 | 637 | ||
638 | ret = GNUNET_CONFIGURATION_get_value_number (cfg, section, option, &num); | 638 | ret = GNUNET_CONFIGURATION_get_value_number (cfg, section, option, &num); |
639 | if (ret == GNUNET_OK) | 639 | if (ret == GNUNET_OK) |
640 | time->value = (uint64_t) num; | 640 | time->rel_value = (uint64_t) num; |
641 | return ret; | 641 | return ret; |
642 | } | 642 | } |
643 | 643 | ||
diff --git a/src/util/connection.c b/src/util/connection.c index 9e789eb58..ab04b13ef 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -1121,7 +1121,7 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1121 | return; | 1121 | return; |
1122 | } | 1122 | } |
1123 | now = GNUNET_TIME_absolute_get (); | 1123 | now = GNUNET_TIME_absolute_get (); |
1124 | if ((now.value > sh->receive_timeout.value) || | 1124 | if ((now.abs_value > sh->receive_timeout.abs_value) || |
1125 | (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) || | 1125 | (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) || |
1126 | (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) | 1126 | (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) |
1127 | { | 1127 | { |
@@ -1131,7 +1131,7 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1131 | "Receive from `%s' encounters error: time out by %llums... (%p)\n", | 1131 | "Receive from `%s' encounters error: time out by %llums... (%p)\n", |
1132 | GNUNET_a2s (sh->addr, sh->addrlen), | 1132 | GNUNET_a2s (sh->addr, sh->addrlen), |
1133 | GNUNET_TIME_absolute_get_duration (sh->receive_timeout). | 1133 | GNUNET_TIME_absolute_get_duration (sh->receive_timeout). |
1134 | value, sh); | 1134 | abs_value, sh); |
1135 | #endif | 1135 | #endif |
1136 | signal_timeout (sh); | 1136 | signal_timeout (sh); |
1137 | return; | 1137 | return; |
@@ -1200,7 +1200,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1200 | return; | 1200 | return; |
1201 | } | 1201 | } |
1202 | now = GNUNET_TIME_absolute_get (); | 1202 | now = GNUNET_TIME_absolute_get (); |
1203 | if ((now.value > sh->receive_timeout.value) || | 1203 | if ((now.abs_value > sh->receive_timeout.abs_value) || |
1204 | (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) | 1204 | (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) |
1205 | { | 1205 | { |
1206 | #if DEBUG_CONNECTION | 1206 | #if DEBUG_CONNECTION |
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c index 19dd6360a..b0e2f0be4 100644 --- a/src/util/gnunet-service-resolver.c +++ b/src/util/gnunet-service-resolver.c | |||
@@ -177,7 +177,7 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client, | |||
177 | while ((cache != NULL) && | 177 | while ((cache != NULL) && |
178 | ((cache->salen != salen) || (0 != memcmp (cache->sa, sa, salen)))) | 178 | ((cache->salen != salen) || (0 != memcmp (cache->sa, sa, salen)))) |
179 | { | 179 | { |
180 | if (GNUNET_TIME_absolute_get_duration (cache->last_request).value < | 180 | if (GNUNET_TIME_absolute_get_duration (cache->last_request).rel_value < |
181 | 60 * 60 * 1000) | 181 | 60 * 60 * 1000) |
182 | { | 182 | { |
183 | if (prev != NULL) | 183 | if (prev != NULL) |
@@ -204,7 +204,7 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client, | |||
204 | if (cache != NULL) | 204 | if (cache != NULL) |
205 | { | 205 | { |
206 | cache->last_request = now; | 206 | cache->last_request = now; |
207 | if (GNUNET_TIME_absolute_get_duration (cache->last_request).value < | 207 | if (GNUNET_TIME_absolute_get_duration (cache->last_request).rel_value < |
208 | 60 * 60 * 1000) | 208 | 60 * 60 * 1000) |
209 | { | 209 | { |
210 | GNUNET_free_non_null (cache->addr); | 210 | GNUNET_free_non_null (cache->addr); |
diff --git a/src/util/load.c b/src/util/load.c index 5bcf220be..9bbea6c14 100644 --- a/src/util/load.c +++ b/src/util/load.c | |||
@@ -86,18 +86,18 @@ internal_update (struct GNUNET_LOAD_Value *load) | |||
86 | struct GNUNET_TIME_Relative delta; | 86 | struct GNUNET_TIME_Relative delta; |
87 | unsigned int n; | 87 | unsigned int n; |
88 | 88 | ||
89 | if (load->autodecline.value == GNUNET_TIME_UNIT_FOREVER_REL.value) | 89 | if (load->autodecline.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
90 | return; | 90 | return; |
91 | delta = GNUNET_TIME_absolute_get_duration (load->last_update); | 91 | delta = GNUNET_TIME_absolute_get_duration (load->last_update); |
92 | if (delta.value < load->autodecline.value) | 92 | if (delta.rel_value < load->autodecline.rel_value) |
93 | return; | 93 | return; |
94 | if (load->autodecline.value == 0) | 94 | if (load->autodecline.rel_value == 0) |
95 | { | 95 | { |
96 | load->runavg_delay = 0.0; | 96 | load->runavg_delay = 0.0; |
97 | load->load = 0; | 97 | load->load = 0; |
98 | return; | 98 | return; |
99 | } | 99 | } |
100 | n = delta.value / load->autodecline.value; | 100 | n = delta.rel_value / load->autodecline.rel_value; |
101 | if (n > 16) | 101 | if (n > 16) |
102 | { | 102 | { |
103 | load->runavg_delay = 0.0; | 103 | load->runavg_delay = 0.0; |
diff --git a/src/util/network.c b/src/util/network.c index a1142d433..292e49976 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -161,9 +161,9 @@ socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h) | |||
161 | static void | 161 | static void |
162 | socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h) | 162 | socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h) |
163 | { | 163 | { |
164 | int value = 1; | 164 | int abs_value = 1; |
165 | if (0 != | 165 | if (0 != |
166 | setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof (value))) | 166 | setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, &abs_value, sizeof (abs_value))) |
167 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 167 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); |
168 | } | 168 | } |
169 | #endif | 169 | #endif |
@@ -184,8 +184,8 @@ socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h) | |||
184 | if (0 != setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, &value, sizeof (value))) | 184 | if (0 != setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, &value, sizeof (value))) |
185 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 185 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); |
186 | #else | 186 | #else |
187 | const char * value = "1"; | 187 | const char * abs_value = "1"; |
188 | if (0 != setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, value, sizeof (value))) | 188 | if (0 != setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, abs_value, sizeof (abs_value))) |
189 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); | 189 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); |
190 | #endif | 190 | #endif |
191 | } | 191 | } |
@@ -1010,10 +1010,10 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | struct timeval tv; | 1012 | struct timeval tv; |
1013 | tv.tv_sec = timeout.value / GNUNET_TIME_UNIT_SECONDS.value; | 1013 | tv.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value; |
1014 | tv.tv_usec = | 1014 | tv.tv_usec = |
1015 | 1000 * (timeout.value - (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.value)); | 1015 | 1000 * (timeout.rel_value - (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value)); |
1016 | if ((nfds == 0) && (timeout.value == GNUNET_TIME_UNIT_FOREVER_REL.value) | 1016 | if ((nfds == 0) && (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
1017 | #ifdef MINGW | 1017 | #ifdef MINGW |
1018 | && handles == 0 | 1018 | && handles == 0 |
1019 | #endif | 1019 | #endif |
@@ -1030,7 +1030,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1030 | (rfds != NULL) ? &rfds->sds : NULL, | 1030 | (rfds != NULL) ? &rfds->sds : NULL, |
1031 | (wfds != NULL) ? &wfds->sds : NULL, | 1031 | (wfds != NULL) ? &wfds->sds : NULL, |
1032 | (efds != NULL) ? &efds->sds : NULL, | 1032 | (efds != NULL) ? &efds->sds : NULL, |
1033 | (timeout.value == GNUNET_TIME_UNIT_FOREVER_REL.value) | 1033 | (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
1034 | ? NULL : &tv); | 1034 | ? NULL : &tv); |
1035 | 1035 | ||
1036 | #else | 1036 | #else |
@@ -1048,11 +1048,11 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1048 | #define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set)) | 1048 | #define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set)) |
1049 | 1049 | ||
1050 | /* calculate how long we need to wait in milliseconds */ | 1050 | /* calculate how long we need to wait in milliseconds */ |
1051 | if (timeout.value == GNUNET_TIME_UNIT_FOREVER_REL.value) | 1051 | if (timeout.abs_value == GNUNET_TIME_UNIT_FOREVER_REL.abs_value) |
1052 | ms_total = INFINITE; | 1052 | ms_total = INFINITE; |
1053 | 1053 | ||
1054 | else | 1054 | else |
1055 | ms_total = timeout.value / GNUNET_TIME_UNIT_MILLISECONDS.value; | 1055 | ms_total = timeout.abs_value / GNUNET_TIME_UNIT_MILLISECONDS.abs_value; |
1056 | 1056 | ||
1057 | /* select() may be used as a portable way to sleep */ | 1057 | /* select() may be used as a portable way to sleep */ |
1058 | if (!(rfds || wfds || efds)) | 1058 | if (!(rfds || wfds || efds)) |
diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c index 82170223f..579d9afca 100644 --- a/src/util/perf_crypto_hash.c +++ b/src/util/perf_crypto_hash.c | |||
@@ -58,7 +58,7 @@ main (int argc, char *argv[]) | |||
58 | perfHash (); | 58 | perfHash (); |
59 | printf ("Hash perf took %llu ms\n", | 59 | printf ("Hash perf took %llu ms\n", |
60 | (unsigned long long) | 60 | (unsigned long long) |
61 | GNUNET_TIME_absolute_get_duration (start).value); | 61 | GNUNET_TIME_absolute_get_duration (start).rel_value); |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | 64 | ||
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index d58212aec..4df5099c9 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -338,7 +338,7 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched, | |||
338 | if (pos != NULL) | 338 | if (pos != NULL) |
339 | { | 339 | { |
340 | to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); | 340 | to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); |
341 | if (timeout->value > to.value) | 341 | if (timeout->rel_value > to.rel_value) |
342 | *timeout = to; | 342 | *timeout = to; |
343 | if (pos->reason != 0) | 343 | if (pos->reason != 0) |
344 | *timeout = GNUNET_TIME_UNIT_ZERO; | 344 | *timeout = GNUNET_TIME_UNIT_ZERO; |
@@ -352,10 +352,10 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched, | |||
352 | pos = pos->next; | 352 | pos = pos->next; |
353 | continue; | 353 | continue; |
354 | } | 354 | } |
355 | if (pos->timeout.value != GNUNET_TIME_UNIT_FOREVER_ABS.value) | 355 | if (pos->timeout.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) |
356 | { | 356 | { |
357 | to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); | 357 | to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); |
358 | if (timeout->value > to.value) | 358 | if (timeout->rel_value > to.rel_value) |
359 | *timeout = to; | 359 | *timeout = to; |
360 | } | 360 | } |
361 | if (pos->read_fd != -1) | 361 | if (pos->read_fd != -1) |
@@ -420,7 +420,7 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched, | |||
420 | enum GNUNET_SCHEDULER_Reason reason; | 420 | enum GNUNET_SCHEDULER_Reason reason; |
421 | 421 | ||
422 | reason = task->reason; | 422 | reason = task->reason; |
423 | if (now.value >= task->timeout.value) | 423 | if (now.abs_value >= task->timeout.abs_value) |
424 | reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; | 424 | reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; |
425 | if ( (0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) && | 425 | if ( (0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) && |
426 | ( ( (task->read_fd != -1) && | 426 | ( ( (task->read_fd != -1) && |
@@ -491,7 +491,7 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle, | |||
491 | while (pos != NULL) | 491 | while (pos != NULL) |
492 | { | 492 | { |
493 | next = pos->next; | 493 | next = pos->next; |
494 | if (now.value >= pos->timeout.value) | 494 | if (now.abs_value >= pos->timeout.abs_value) |
495 | pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; | 495 | pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; |
496 | if (0 == pos->reason) | 496 | if (0 == pos->reason) |
497 | break; | 497 | break; |
@@ -637,13 +637,13 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched, | |||
637 | } | 637 | } |
638 | sched->active_task = pos; | 638 | sched->active_task = pos; |
639 | #if PROFILE_DELAYS | 639 | #if PROFILE_DELAYS |
640 | if (GNUNET_TIME_absolute_get_duration (pos->start_time).value > | 640 | if (GNUNET_TIME_absolute_get_duration (pos->start_time).abs_value > |
641 | DELAY_THRESHOLD.value) | 641 | DELAY_THRESHOLD.abs_value) |
642 | { | 642 | { |
643 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 643 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
644 | "Task %u took %llums to be scheduled\n", | 644 | "Task %u took %llums to be scheduled\n", |
645 | pos->id, | 645 | pos->id, |
646 | (unsigned long long) GNUNET_TIME_absolute_get_duration (pos->start_time).value); | 646 | (unsigned long long) GNUNET_TIME_absolute_get_duration (pos->start_time).abs_value); |
647 | } | 647 | } |
648 | #endif | 648 | #endif |
649 | tc.sched = sched; | 649 | tc.sched = sched; |
@@ -803,7 +803,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
803 | abort (); | 803 | abort (); |
804 | break; | 804 | break; |
805 | } | 805 | } |
806 | if ((ret == 0) && (timeout.value == 0) && (busy_wait_warning > 16)) | 806 | if ((ret == 0) && (timeout.rel_value == 0) && (busy_wait_warning > 16)) |
807 | { | 807 | { |
808 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 808 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
809 | _("Looks like we're busy waiting...\n")); | 809 | _("Looks like we're busy waiting...\n")); |
@@ -1130,7 +1130,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, | |||
1130 | prev = sched->pending_timeout_last; | 1130 | prev = sched->pending_timeout_last; |
1131 | if (prev != NULL) | 1131 | if (prev != NULL) |
1132 | { | 1132 | { |
1133 | if (prev->timeout.value > t->timeout.value) | 1133 | if (prev->timeout.abs_value > t->timeout.abs_value) |
1134 | prev = NULL; | 1134 | prev = NULL; |
1135 | else | 1135 | else |
1136 | pos = prev->next; /* heuristic success! */ | 1136 | pos = prev->next; /* heuristic success! */ |
@@ -1141,7 +1141,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, | |||
1141 | pos = sched->pending_timeout; | 1141 | pos = sched->pending_timeout; |
1142 | } | 1142 | } |
1143 | while ( (pos != NULL) && | 1143 | while ( (pos != NULL) && |
1144 | ( (pos->timeout.value <= t->timeout.value) || | 1144 | ( (pos->timeout.abs_value <= t->timeout.abs_value) || |
1145 | (pos->reason != 0) ) ) | 1145 | (pos->reason != 0) ) ) |
1146 | { | 1146 | { |
1147 | prev = pos; | 1147 | prev = pos; |
diff --git a/src/util/strings.c b/src/util/strings.c index 1f7f45d51..c8e5191bf 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -361,9 +361,9 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta) | |||
361 | { | 361 | { |
362 | const char *unit = _( /* time unit */ "ms"); | 362 | const char *unit = _( /* time unit */ "ms"); |
363 | char *ret; | 363 | char *ret; |
364 | uint64_t dval = delta.value; | 364 | uint64_t dval = delta.rel_value; |
365 | 365 | ||
366 | if (delta.value == GNUNET_TIME_UNIT_FOREVER_REL.value) | 366 | if (delta.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
367 | return GNUNET_strdup (_("eternity")); | 367 | return GNUNET_strdup (_("eternity")); |
368 | if (dval > 5 * 1000) | 368 | if (dval > 5 * 1000) |
369 | { | 369 | { |
@@ -403,9 +403,9 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t) | |||
403 | time_t tt; | 403 | time_t tt; |
404 | char *ret; | 404 | char *ret; |
405 | 405 | ||
406 | if (t.value == GNUNET_TIME_UNIT_FOREVER_ABS.value) | 406 | if (t.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) |
407 | return GNUNET_strdup (_("end of time")); | 407 | return GNUNET_strdup (_("end of time")); |
408 | tt = t.value / 1000; | 408 | tt = t.abs_value / 1000; |
409 | #ifdef ctime_r | 409 | #ifdef ctime_r |
410 | ret = ctime_r (&tt, GNUNET_malloc (32)); | 410 | ret = ctime_r (&tt, GNUNET_malloc (32)); |
411 | #else | 411 | #else |
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c index fd2b91bfb..429e03178 100644 --- a/src/util/test_configuration.c +++ b/src/util/test_configuration.c | |||
@@ -144,7 +144,7 @@ diffsCallBack (void *cls, | |||
144 | cbData->section = section; | 144 | cbData->section = section; |
145 | printf ("\nSection: %s\n", section); | 145 | printf ("\nSection: %s\n", section); |
146 | } | 146 | } |
147 | printf ("%s = %s\n", option, value); | 147 | printf ("%s = %s\n", option, abs_value); |
148 | #endif | 148 | #endif |
149 | default: | 149 | default: |
150 | break; | 150 | break; |
diff --git a/src/util/test_crypto_ksk.c b/src/util/test_crypto_ksk.c index 2a8d9c969..74f88d5bf 100644 --- a/src/util/test_crypto_ksk.c +++ b/src/util/test_crypto_ksk.c | |||
@@ -171,7 +171,7 @@ testEncryptDecrypt (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
171 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", | 171 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", |
172 | ITER, | 172 | ITER, |
173 | (unsigned long long) | 173 | (unsigned long long) |
174 | GNUNET_TIME_absolute_get_duration (start).value, ok); | 174 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); |
175 | if (ok == 0) | 175 | if (ok == 0) |
176 | return GNUNET_OK; | 176 | return GNUNET_OK; |
177 | else | 177 | else |
@@ -222,7 +222,7 @@ testSignVerify (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
222 | printf ("%d RSA sign/verify operations %llums\n", | 222 | printf ("%d RSA sign/verify operations %llums\n", |
223 | ITER, | 223 | ITER, |
224 | (unsigned long long) | 224 | (unsigned long long) |
225 | GNUNET_TIME_absolute_get_duration (start).value); | 225 | GNUNET_TIME_absolute_get_duration (start).rel_value); |
226 | return ok; | 226 | return ok; |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/src/util/test_crypto_rsa.c b/src/util/test_crypto_rsa.c index ca3f69c35..cacaa78e9 100644 --- a/src/util/test_crypto_rsa.c +++ b/src/util/test_crypto_rsa.c | |||
@@ -84,7 +84,7 @@ testEncryptDecrypt () | |||
84 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", | 84 | printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", |
85 | ITER, | 85 | ITER, |
86 | (unsigned long long) | 86 | (unsigned long long) |
87 | GNUNET_TIME_absolute_get_duration (start).value, ok); | 87 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); |
88 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 88 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
89 | if (ok == 0) | 89 | if (ok == 0) |
90 | return GNUNET_OK; | 90 | return GNUNET_OK; |
@@ -124,7 +124,7 @@ testEncryptPerformance () | |||
124 | printf ("%d RSA encrypt operations %llu ms (%d failures)\n", | 124 | printf ("%d RSA encrypt operations %llu ms (%d failures)\n", |
125 | ITER, | 125 | ITER, |
126 | (unsigned long long) | 126 | (unsigned long long) |
127 | GNUNET_TIME_absolute_get_duration (start).value, ok); | 127 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); |
128 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 128 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
129 | if (ok != 0) | 129 | if (ok != 0) |
130 | return GNUNET_SYSERR; | 130 | return GNUNET_SYSERR; |
@@ -183,7 +183,7 @@ testEncryptDecryptSK () | |||
183 | printf ("%d RSA encrypt/decrypt SK operations %llus (%d failures)\n", | 183 | printf ("%d RSA encrypt/decrypt SK operations %llus (%d failures)\n", |
184 | ITER, | 184 | ITER, |
185 | (unsigned long long) | 185 | (unsigned long long) |
186 | GNUNET_TIME_absolute_get_duration (start).value, ok); | 186 | GNUNET_TIME_absolute_get_duration (start).rel_value, ok); |
187 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 187 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
188 | if (ok != 0) | 188 | if (ok != 0) |
189 | return GNUNET_SYSERR; | 189 | return GNUNET_SYSERR; |
@@ -238,7 +238,7 @@ testSignVerify () | |||
238 | printf ("%d RSA sign/verify operations %llums\n", | 238 | printf ("%d RSA sign/verify operations %llums\n", |
239 | ITER, | 239 | ITER, |
240 | (unsigned long long) | 240 | (unsigned long long) |
241 | GNUNET_TIME_absolute_get_duration (start).value); | 241 | GNUNET_TIME_absolute_get_duration (start).rel_value); |
242 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 242 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
243 | return ok; | 243 | return ok; |
244 | } | 244 | } |
@@ -274,7 +274,7 @@ testSignPerformance () | |||
274 | } | 274 | } |
275 | printf ("%d RSA sign operations %llu ms\n", ITER, | 275 | printf ("%d RSA sign operations %llu ms\n", ITER, |
276 | (unsigned long long) | 276 | (unsigned long long) |
277 | GNUNET_TIME_absolute_get_duration (start).value); | 277 | GNUNET_TIME_absolute_get_duration (start).rel_value); |
278 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 278 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
279 | return ok; | 279 | return ok; |
280 | } | 280 | } |
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index 2f0ca4e80..24d30be99 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c | |||
@@ -52,10 +52,10 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
52 | struct GNUNET_TIME_Absolute now; | 52 | struct GNUNET_TIME_Absolute now; |
53 | 53 | ||
54 | now = GNUNET_TIME_absolute_get (); | 54 | now = GNUNET_TIME_absolute_get (); |
55 | if (now.value > target.value) | 55 | if (now.abs_value > target.abs_value) |
56 | cumDelta += (now.value - target.value); | 56 | cumDelta += (now.abs_value - target.abs_value); |
57 | else | 57 | else |
58 | cumDelta += (target.value - now.value); | 58 | cumDelta += (target.abs_value - now.abs_value); |
59 | target = | 59 | target = |
60 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply | 60 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply |
61 | (GNUNET_TIME_UNIT_MILLISECONDS, i)); | 61 | (GNUNET_TIME_UNIT_MILLISECONDS, i)); |
diff --git a/src/util/test_strings.c b/src/util/test_strings.c index c34c180fa..a1614b487 100644 --- a/src/util/test_strings.c +++ b/src/util/test_strings.c | |||
@@ -89,7 +89,7 @@ check () | |||
89 | WANT ("btx", b); | 89 | WANT ("btx", b); |
90 | if (0 != GNUNET_STRINGS_buffer_tokenize (buf, 2, 2, &r, &b)) | 90 | if (0 != GNUNET_STRINGS_buffer_tokenize (buf, 2, 2, &r, &b)) |
91 | return 1; | 91 | return 1; |
92 | at.value = 5000; | 92 | at.abs_value = 5000; |
93 | r = GNUNET_STRINGS_absolute_time_to_string (at); | 93 | r = GNUNET_STRINGS_absolute_time_to_string (at); |
94 | /* r should be something like "Wed Dec 31 17:00:05 1969" | 94 | /* r should be something like "Wed Dec 31 17:00:05 1969" |
95 | where the details of the day and hour depend on the timezone; | 95 | where the details of the day and hour depend on the timezone; |
diff --git a/src/util/test_time.c b/src/util/test_time.c index eecbbafae..13f5e58a0 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.c | |||
@@ -45,12 +45,12 @@ check () | |||
45 | forever = GNUNET_TIME_absolute_get_forever (); | 45 | forever = GNUNET_TIME_absolute_get_forever (); |
46 | relForever = GNUNET_TIME_relative_get_forever (); | 46 | relForever = GNUNET_TIME_relative_get_forever (); |
47 | relUnit = GNUNET_TIME_relative_get_unit (); | 47 | relUnit = GNUNET_TIME_relative_get_unit (); |
48 | zero.value = 0; | 48 | zero.abs_value = 0; |
49 | 49 | ||
50 | last = now = GNUNET_TIME_absolute_get (); | 50 | last = now = GNUNET_TIME_absolute_get (); |
51 | while (now.value == last.value) | 51 | while (now.abs_value == last.abs_value) |
52 | now = GNUNET_TIME_absolute_get (); | 52 | now = GNUNET_TIME_absolute_get (); |
53 | GNUNET_assert (now.value > last.value); | 53 | GNUNET_assert (now.abs_value > last.abs_value); |
54 | 54 | ||
55 | /* test overflow checking in multiply */ | 55 | /* test overflow checking in multiply */ |
56 | rel = GNUNET_TIME_UNIT_SECONDS; | 56 | rel = GNUNET_TIME_UNIT_SECONDS; |
@@ -58,169 +58,169 @@ check () | |||
58 | for (i = 0; i < 55; i++) | 58 | for (i = 0; i < 55; i++) |
59 | rel = GNUNET_TIME_relative_multiply (rel, 2); | 59 | rel = GNUNET_TIME_relative_multiply (rel, 2); |
60 | GNUNET_log_skip (0, GNUNET_NO); | 60 | GNUNET_log_skip (0, GNUNET_NO); |
61 | GNUNET_assert (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value); | 61 | GNUNET_assert (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value); |
62 | /*check zero*/ | 62 | /*check zero*/ |
63 | rel.value = (UINT64_MAX) - 1024; | 63 | rel.rel_value = (UINT64_MAX) - 1024; |
64 | GNUNET_assert (GNUNET_TIME_relative_get_zero ().value == GNUNET_TIME_relative_multiply (rel,0).value); | 64 | GNUNET_assert (GNUNET_TIME_relative_get_zero ().rel_value == GNUNET_TIME_relative_multiply (rel,0).rel_value); |
65 | 65 | ||
66 | /* test infinity-check for relative to absolute */ | 66 | /* test infinity-check for relative to absolute */ |
67 | GNUNET_log_skip (1, GNUNET_NO); | 67 | GNUNET_log_skip (1, GNUNET_NO); |
68 | last = GNUNET_TIME_relative_to_absolute (rel); | 68 | last = GNUNET_TIME_relative_to_absolute (rel); |
69 | GNUNET_assert (last.value == GNUNET_TIME_UNIT_FOREVER_ABS.value); | 69 | GNUNET_assert (last.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value); |
70 | GNUNET_log_skip (0, GNUNET_YES); | 70 | GNUNET_log_skip (0, GNUNET_YES); |
71 | 71 | ||
72 | /*check relative to absolute*/ | 72 | /*check relative to absolute*/ |
73 | rel.value = 0; | 73 | rel.rel_value = 0; |
74 | GNUNET_assert (GNUNET_TIME_absolute_get ().value == | 74 | GNUNET_assert (GNUNET_TIME_absolute_get ().abs_value == |
75 | GNUNET_TIME_relative_to_absolute(rel).value); | 75 | GNUNET_TIME_relative_to_absolute(rel).abs_value); |
76 | /*check forever*/ | 76 | /*check forever*/ |
77 | rel.value = UINT64_MAX; | 77 | rel.rel_value = UINT64_MAX; |
78 | GNUNET_assert (GNUNET_TIME_absolute_get_forever ().value == | 78 | GNUNET_assert (GNUNET_TIME_absolute_get_forever ().abs_value == |
79 | GNUNET_TIME_relative_to_absolute(rel).value); | 79 | GNUNET_TIME_relative_to_absolute(rel).abs_value); |
80 | /* check overflow for r2a */ | 80 | /* check overflow for r2a */ |
81 | rel.value = (UINT64_MAX) - 1024; | 81 | rel.rel_value = (UINT64_MAX) - 1024; |
82 | GNUNET_log_skip (1, GNUNET_NO); | 82 | GNUNET_log_skip (1, GNUNET_NO); |
83 | last = GNUNET_TIME_relative_to_absolute (rel); | 83 | last = GNUNET_TIME_relative_to_absolute (rel); |
84 | GNUNET_log_skip (0, GNUNET_NO); | 84 | GNUNET_log_skip (0, GNUNET_NO); |
85 | GNUNET_assert (last.value == GNUNET_TIME_UNIT_FOREVER_ABS.value); | 85 | GNUNET_assert (last.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value); |
86 | 86 | ||
87 | /* check overflow for relative add */ | 87 | /* check overflow for relative add */ |
88 | GNUNET_log_skip (1, GNUNET_NO); | 88 | GNUNET_log_skip (1, GNUNET_NO); |
89 | rel = GNUNET_TIME_relative_add (rel, rel); | 89 | rel = GNUNET_TIME_relative_add (rel, rel); |
90 | GNUNET_log_skip (0, GNUNET_NO); | 90 | GNUNET_log_skip (0, GNUNET_NO); |
91 | GNUNET_assert (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value); | 91 | GNUNET_assert (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value); |
92 | 92 | ||
93 | GNUNET_log_skip (1, GNUNET_NO); | 93 | GNUNET_log_skip (1, GNUNET_NO); |
94 | rel = GNUNET_TIME_relative_add (relForever, relForever); | 94 | rel = GNUNET_TIME_relative_add (relForever, relForever); |
95 | GNUNET_log_skip (0, GNUNET_NO); | 95 | GNUNET_log_skip (0, GNUNET_NO); |
96 | GNUNET_assert (rel.value == relForever.value); | 96 | GNUNET_assert (rel.rel_value == relForever.rel_value); |
97 | 97 | ||
98 | GNUNET_log_skip (1, GNUNET_NO); | 98 | GNUNET_log_skip (1, GNUNET_NO); |
99 | rel = GNUNET_TIME_relative_add (relUnit, relUnit); | 99 | rel = GNUNET_TIME_relative_add (relUnit, relUnit); |
100 | GNUNET_assert (rel.value == 2 * relUnit.value); | 100 | GNUNET_assert (rel.rel_value == 2 * relUnit.rel_value); |
101 | 101 | ||
102 | /* check relation check in get_duration */ | 102 | /* check relation check in get_duration */ |
103 | future.value = now.value + 1000000; | 103 | future.abs_value = now.abs_value + 1000000; |
104 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).value == | 104 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).rel_value == |
105 | 1000000); | 105 | 1000000); |
106 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).value == | 106 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value == |
107 | 0); | 107 | 0); |
108 | 108 | ||
109 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).value == | 109 | GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value == |
110 | forever.value); | 110 | forever.abs_value); |
111 | 111 | ||
112 | past.value = now.value - 1000000; | 112 | past.abs_value = now.abs_value - 1000000; |
113 | rel = GNUNET_TIME_absolute_get_duration (future); | 113 | rel = GNUNET_TIME_absolute_get_duration (future); |
114 | GNUNET_assert (rel.value == 0); | 114 | GNUNET_assert (rel.rel_value == 0); |
115 | rel = GNUNET_TIME_absolute_get_duration (past); | 115 | rel = GNUNET_TIME_absolute_get_duration (past); |
116 | GNUNET_assert (rel.value >= 1000000); | 116 | GNUNET_assert (rel.rel_value >= 1000000); |
117 | 117 | ||
118 | /* check get remaining */ | 118 | /* check get remaining */ |
119 | rel = GNUNET_TIME_absolute_get_remaining (now); | 119 | rel = GNUNET_TIME_absolute_get_remaining (now); |
120 | GNUNET_assert (rel.value == 0); | 120 | GNUNET_assert (rel.rel_value == 0); |
121 | rel = GNUNET_TIME_absolute_get_remaining (past); | 121 | rel = GNUNET_TIME_absolute_get_remaining (past); |
122 | GNUNET_assert (rel.value == 0); | 122 | GNUNET_assert (rel.rel_value == 0); |
123 | rel = GNUNET_TIME_absolute_get_remaining (future); | 123 | rel = GNUNET_TIME_absolute_get_remaining (future); |
124 | GNUNET_assert (rel.value > 0); | 124 | GNUNET_assert (rel.rel_value > 0); |
125 | GNUNET_assert (rel.value <= 1000000); | 125 | GNUNET_assert (rel.rel_value <= 1000000); |
126 | forever = GNUNET_TIME_absolute_get_forever (); | 126 | forever = GNUNET_TIME_absolute_get_forever (); |
127 | GNUNET_assert (GNUNET_TIME_relative_get_forever ().value == | 127 | GNUNET_assert (GNUNET_TIME_relative_get_forever ().rel_value == |
128 | GNUNET_TIME_absolute_get_remaining (forever).value); | 128 | GNUNET_TIME_absolute_get_remaining (forever).rel_value); |
129 | 129 | ||
130 | /* check endianess */ | 130 | /* check endianess */ |
131 | reln = GNUNET_TIME_relative_hton (rel); | 131 | reln = GNUNET_TIME_relative_hton (rel); |
132 | GNUNET_assert (rel.value == GNUNET_TIME_relative_ntoh (reln).value); | 132 | GNUNET_assert (rel.rel_value == GNUNET_TIME_relative_ntoh (reln).rel_value); |
133 | nown = GNUNET_TIME_absolute_hton (now); | 133 | nown = GNUNET_TIME_absolute_hton (now); |
134 | GNUNET_assert (now.value == GNUNET_TIME_absolute_ntoh (nown).value); | 134 | GNUNET_assert (now.abs_value == GNUNET_TIME_absolute_ntoh (nown).abs_value); |
135 | 135 | ||
136 | /* check absolute addition */ | 136 | /* check absolute addition */ |
137 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS); | 137 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS); |
138 | GNUNET_assert (future.value == now.value + 1000); | 138 | GNUNET_assert (future.abs_value == now.abs_value + 1000); |
139 | 139 | ||
140 | future = GNUNET_TIME_absolute_add (forever, GNUNET_TIME_UNIT_ZERO); | 140 | future = GNUNET_TIME_absolute_add (forever, GNUNET_TIME_UNIT_ZERO); |
141 | GNUNET_assert (future.value == forever.value); | 141 | GNUNET_assert (future.abs_value == forever.abs_value); |
142 | 142 | ||
143 | rel.value = (UINT64_MAX) - 1024; | 143 | rel.rel_value = (UINT64_MAX) - 1024; |
144 | now.value = rel.value; | 144 | now.abs_value = rel.rel_value; |
145 | future = GNUNET_TIME_absolute_add (now, rel); | 145 | future = GNUNET_TIME_absolute_add (now, rel); |
146 | GNUNET_assert (future.value == forever.value); | 146 | GNUNET_assert (future.abs_value == forever.abs_value); |
147 | 147 | ||
148 | /* check zero */ | 148 | /* check zero */ |
149 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO); | 149 | future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO); |
150 | GNUNET_assert (future.value == now.value); | 150 | GNUNET_assert (future.abs_value == now.abs_value); |
151 | 151 | ||
152 | GNUNET_assert (forever.value == | 152 | GNUNET_assert (forever.abs_value == |
153 | GNUNET_TIME_absolute_subtract (forever, | 153 | GNUNET_TIME_absolute_subtract (forever, |
154 | GNUNET_TIME_UNIT_MINUTES).value); | 154 | GNUNET_TIME_UNIT_MINUTES).abs_value); |
155 | /*check absolute subtract*/ | 155 | /*check absolute subtract*/ |
156 | now.value= 50000; | 156 | now.abs_value= 50000; |
157 | rel.value = 100000; | 157 | rel.rel_value = 100000; |
158 | GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.value == | 158 | GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value == |
159 | (GNUNET_TIME_absolute_subtract(now,rel)).value); | 159 | (GNUNET_TIME_absolute_subtract(now,rel)).abs_value); |
160 | rel.value = 10000; | 160 | rel.rel_value = 10000; |
161 | GNUNET_assert (40000 == | 161 | GNUNET_assert (40000 == |
162 | (GNUNET_TIME_absolute_subtract(now,rel)).value); | 162 | (GNUNET_TIME_absolute_subtract(now,rel)).abs_value); |
163 | 163 | ||
164 | /*check relative divide*/ | 164 | /*check relative divide*/ |
165 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.value == | 165 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value == |
166 | (GNUNET_TIME_relative_divide (rel,0)).value); | 166 | (GNUNET_TIME_relative_divide (rel,0)).rel_value); |
167 | 167 | ||
168 | rel = GNUNET_TIME_UNIT_FOREVER_REL; | 168 | rel = GNUNET_TIME_UNIT_FOREVER_REL; |
169 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.value == | 169 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value == |
170 | (GNUNET_TIME_relative_divide (rel,2)).value); | 170 | (GNUNET_TIME_relative_divide (rel,2)).rel_value); |
171 | 171 | ||
172 | rel = GNUNET_TIME_relative_divide (relUnit,2); | 172 | rel = GNUNET_TIME_relative_divide (relUnit,2); |
173 | GNUNET_assert(rel.value == relUnit.value / 2); | 173 | GNUNET_assert(rel.rel_value == relUnit.rel_value / 2); |
174 | 174 | ||
175 | 175 | ||
176 | /* check Return absolute time of 0ms*/ | 176 | /* check Return absolute time of 0ms*/ |
177 | zero = GNUNET_TIME_absolute_get_zero (); | 177 | zero = GNUNET_TIME_absolute_get_zero (); |
178 | 178 | ||
179 | /* check GNUNET_TIME_calculate_eta */ | 179 | /* check GNUNET_TIME_calculate_eta */ |
180 | last.value = GNUNET_TIME_absolute_get ().value - 1024; | 180 | last.abs_value = GNUNET_TIME_absolute_get ().abs_value - 1024; |
181 | forever = GNUNET_TIME_absolute_get_forever (); | 181 | forever = GNUNET_TIME_absolute_get_forever (); |
182 | forever.value = forever.value - 1024; | 182 | forever.abs_value = forever.abs_value - 1024; |
183 | GNUNET_assert(GNUNET_TIME_absolute_get_zero ().value == | 183 | GNUNET_assert(GNUNET_TIME_absolute_get_zero ().abs_value == |
184 | GNUNET_TIME_calculate_eta (forever, 50000, 100000).value); | 184 | GNUNET_TIME_calculate_eta (forever, 50000, 100000).rel_value); |
185 | /* check zero */ | 185 | /* check zero */ |
186 | GNUNET_log_skip (1, GNUNET_NO); | 186 | GNUNET_log_skip (1, GNUNET_NO); |
187 | GNUNET_assert(GNUNET_TIME_UNIT_ZERO.value == | 187 | GNUNET_assert(GNUNET_TIME_UNIT_ZERO.rel_value == |
188 | (GNUNET_TIME_calculate_eta (last, 60000, 50000)).value); | 188 | (GNUNET_TIME_calculate_eta (last, 60000, 50000)).rel_value); |
189 | GNUNET_log_skip (0, GNUNET_YES); | 189 | GNUNET_log_skip (0, GNUNET_YES); |
190 | /*check forever*/ | 190 | /*check forever*/ |
191 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.value == | 191 | GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.rel_value == |
192 | (GNUNET_TIME_calculate_eta (last, 0, 50000)).value); | 192 | (GNUNET_TIME_calculate_eta (last, 0, 50000)).rel_value); |
193 | 193 | ||
194 | /*check relative subtract*/ | 194 | /*check relative subtract*/ |
195 | now = GNUNET_TIME_absolute_get (); | 195 | now = GNUNET_TIME_absolute_get (); |
196 | rel.value = now.value; | 196 | rel.rel_value = now.abs_value; |
197 | relForever.value = rel.value + 1024; | 197 | relForever.rel_value = rel.rel_value + 1024; |
198 | GNUNET_assert(1024 == | 198 | GNUNET_assert(1024 == |
199 | GNUNET_TIME_relative_subtract(relForever,rel).value); | 199 | GNUNET_TIME_relative_subtract(relForever,rel).rel_value); |
200 | /*check zero*/ | 200 | /*check zero*/ |
201 | GNUNET_assert(GNUNET_TIME_relative_get_zero ().value == | 201 | GNUNET_assert(GNUNET_TIME_relative_get_zero ().rel_value == |
202 | GNUNET_TIME_relative_subtract(rel,relForever).value); | 202 | GNUNET_TIME_relative_subtract(rel,relForever).rel_value); |
203 | /*check forever*/ | 203 | /*check forever*/ |
204 | rel.value = UINT64_MAX; | 204 | rel.rel_value = UINT64_MAX; |
205 | GNUNET_assert(GNUNET_TIME_relative_get_forever ().value == | 205 | GNUNET_assert(GNUNET_TIME_relative_get_forever ().rel_value == |
206 | GNUNET_TIME_relative_subtract(rel,relForever).value); | 206 | GNUNET_TIME_relative_subtract(rel,relForever).rel_value); |
207 | 207 | ||
208 | /*check GNUNET_TIME_relative_min*/ | 208 | /*check GNUNET_TIME_relative_min*/ |
209 | now = GNUNET_TIME_absolute_get (); | 209 | now = GNUNET_TIME_absolute_get (); |
210 | rel.value = now.value; | 210 | rel.rel_value = now.abs_value; |
211 | relForever.value = rel.value - 1024; | 211 | relForever.rel_value = rel.rel_value - 1024; |
212 | GNUNET_assert(relForever.value == GNUNET_TIME_relative_min(rel,relForever).value); | 212 | GNUNET_assert(relForever.rel_value == GNUNET_TIME_relative_min(rel,relForever).rel_value); |
213 | 213 | ||
214 | /*check GNUNET_TIME_relative_max */ | 214 | /*check GNUNET_TIME_relative_max */ |
215 | GNUNET_assert(rel.value == GNUNET_TIME_relative_max(rel,relForever).value); | 215 | GNUNET_assert(rel.rel_value == GNUNET_TIME_relative_max(rel,relForever).rel_value); |
216 | 216 | ||
217 | /*check GNUNET_TIME_absolute_min*/ | 217 | /*check GNUNET_TIME_absolute_min*/ |
218 | now = GNUNET_TIME_absolute_get (); | 218 | now = GNUNET_TIME_absolute_get (); |
219 | last.value = now.value - 1024; | 219 | last.abs_value = now.abs_value - 1024; |
220 | GNUNET_assert(last.value == GNUNET_TIME_absolute_min(now,last).value); | 220 | GNUNET_assert(last.abs_value == GNUNET_TIME_absolute_min(now,last).abs_value); |
221 | 221 | ||
222 | /*check GNUNET_TIME_absolute_max*/ | 222 | /*check GNUNET_TIME_absolute_max*/ |
223 | GNUNET_assert(now.value == GNUNET_TIME_absolute_max(now,last).value); | 223 | GNUNET_assert(now.abs_value == GNUNET_TIME_absolute_max(now,last).abs_value); |
224 | 224 | ||
225 | return 0; | 225 | return 0; |
226 | } | 226 | } |
diff --git a/src/util/time.c b/src/util/time.c index 6a5a314da..d2e25d059 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -40,7 +40,7 @@ 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 = | 43 | ret.abs_value = |
44 | (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) + | 44 | (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) + |
45 | ((uint64_t) tv.tv_usec / 1000LL)); | 45 | ((uint64_t) tv.tv_usec / 1000LL)); |
46 | return ret; | 46 | return ret; |
@@ -108,15 +108,15 @@ struct GNUNET_TIME_Absolute | |||
108 | GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) | 108 | GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) |
109 | { | 109 | { |
110 | struct GNUNET_TIME_Absolute ret; | 110 | struct GNUNET_TIME_Absolute ret; |
111 | if (rel.value == UINT64_MAX) | 111 | if (rel.rel_value == UINT64_MAX) |
112 | return GNUNET_TIME_absolute_get_forever (); | 112 | return GNUNET_TIME_absolute_get_forever (); |
113 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 113 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
114 | if (rel.value + now.value < rel.value) | 114 | if (rel.rel_value + now.abs_value < rel.rel_value) |
115 | { | 115 | { |
116 | GNUNET_break (0); /* overflow... */ | 116 | GNUNET_break (0); /* overflow... */ |
117 | return GNUNET_TIME_absolute_get_forever (); | 117 | return GNUNET_TIME_absolute_get_forever (); |
118 | } | 118 | } |
119 | ret.value = rel.value + now.value; | 119 | ret.abs_value = rel.rel_value + now.abs_value; |
120 | return ret; | 120 | return ret; |
121 | } | 121 | } |
122 | 122 | ||
@@ -133,7 +133,7 @@ GNUNET_TIME_relative_min (struct | |||
133 | GNUNET_TIME_Relative | 133 | GNUNET_TIME_Relative |
134 | t1, struct GNUNET_TIME_Relative t2) | 134 | t1, struct GNUNET_TIME_Relative t2) |
135 | { | 135 | { |
136 | return (t1.value < t2.value) ? t1 : t2; | 136 | return (t1.rel_value < t2.rel_value) ? t1 : t2; |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
@@ -149,7 +149,7 @@ GNUNET_TIME_relative_max (struct | |||
149 | GNUNET_TIME_Relative | 149 | GNUNET_TIME_Relative |
150 | t1, struct GNUNET_TIME_Relative t2) | 150 | t1, struct GNUNET_TIME_Relative t2) |
151 | { | 151 | { |
152 | return (t1.value > t2.value) ? t1 : t2; | 152 | return (t1.rel_value > t2.rel_value) ? t1 : t2; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
@@ -166,7 +166,7 @@ GNUNET_TIME_absolute_min (struct | |||
166 | GNUNET_TIME_Absolute | 166 | GNUNET_TIME_Absolute |
167 | t1, struct GNUNET_TIME_Absolute t2) | 167 | t1, struct GNUNET_TIME_Absolute t2) |
168 | { | 168 | { |
169 | return (t1.value < t2.value) ? t1 : t2; | 169 | return (t1.abs_value < t2.abs_value) ? t1 : t2; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
@@ -182,7 +182,7 @@ GNUNET_TIME_absolute_max (struct | |||
182 | GNUNET_TIME_Absolute | 182 | GNUNET_TIME_Absolute |
183 | t1, struct GNUNET_TIME_Absolute t2) | 183 | t1, struct GNUNET_TIME_Absolute t2) |
184 | { | 184 | { |
185 | return (t1.value > t2.value) ? t1 : t2; | 185 | return (t1.abs_value > t2.abs_value) ? t1 : t2; |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
@@ -196,12 +196,12 @@ struct GNUNET_TIME_Relative | |||
196 | GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) | 196 | GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) |
197 | { | 197 | { |
198 | struct GNUNET_TIME_Relative ret; | 198 | struct GNUNET_TIME_Relative ret; |
199 | if (future.value == UINT64_MAX) | 199 | if (future.abs_value == UINT64_MAX) |
200 | return GNUNET_TIME_relative_get_forever (); | 200 | return GNUNET_TIME_relative_get_forever (); |
201 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 201 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
202 | if (now.value > future.value) | 202 | if (now.abs_value > future.abs_value) |
203 | return GNUNET_TIME_relative_get_zero (); | 203 | return GNUNET_TIME_relative_get_zero (); |
204 | ret.value = future.value - now.value; | 204 | ret.rel_value = future.abs_value - now.abs_value; |
205 | return ret; | 205 | return ret; |
206 | } | 206 | } |
207 | 207 | ||
@@ -217,11 +217,11 @@ GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, | |||
217 | struct GNUNET_TIME_Absolute end) | 217 | struct GNUNET_TIME_Absolute end) |
218 | { | 218 | { |
219 | struct GNUNET_TIME_Relative ret; | 219 | struct GNUNET_TIME_Relative ret; |
220 | if (end.value == UINT64_MAX) | 220 | if (end.abs_value == UINT64_MAX) |
221 | return GNUNET_TIME_relative_get_forever (); | 221 | return GNUNET_TIME_relative_get_forever (); |
222 | if (end.value < start.value) | 222 | if (end.abs_value < start.abs_value) |
223 | return GNUNET_TIME_relative_get_zero (); | 223 | return GNUNET_TIME_relative_get_zero (); |
224 | ret.value = end.value - start.value; | 224 | ret.rel_value = end.abs_value - start.abs_value; |
225 | return ret; | 225 | return ret; |
226 | } | 226 | } |
227 | 227 | ||
@@ -238,10 +238,10 @@ GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute hence) | |||
238 | struct GNUNET_TIME_Relative ret; | 238 | struct GNUNET_TIME_Relative ret; |
239 | 239 | ||
240 | now = GNUNET_TIME_absolute_get (); | 240 | now = GNUNET_TIME_absolute_get (); |
241 | GNUNET_assert (hence.value != UINT64_MAX); | 241 | GNUNET_assert (hence.abs_value != UINT64_MAX); |
242 | if (hence.value > now.value) | 242 | if (hence.abs_value > now.abs_value) |
243 | return GNUNET_TIME_relative_get_zero (); | 243 | return GNUNET_TIME_relative_get_zero (); |
244 | ret.value = now.value - hence.value; | 244 | ret.rel_value = now.abs_value - hence.abs_value; |
245 | return ret; | 245 | return ret; |
246 | } | 246 | } |
247 | 247 | ||
@@ -258,15 +258,15 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, | |||
258 | { | 258 | { |
259 | struct GNUNET_TIME_Absolute ret; | 259 | struct GNUNET_TIME_Absolute ret; |
260 | 260 | ||
261 | if ((start.value == UINT64_MAX) || | 261 | if ((start.abs_value == UINT64_MAX) || |
262 | (duration.value == UINT64_MAX)) | 262 | (duration.rel_value == UINT64_MAX)) |
263 | return GNUNET_TIME_absolute_get_forever (); | 263 | return GNUNET_TIME_absolute_get_forever (); |
264 | if (start.value + duration.value < start.value) | 264 | if (start.abs_value + duration.rel_value < start.abs_value) |
265 | { | 265 | { |
266 | GNUNET_break (0); | 266 | GNUNET_break (0); |
267 | return GNUNET_TIME_absolute_get_forever (); | 267 | return GNUNET_TIME_absolute_get_forever (); |
268 | } | 268 | } |
269 | ret.value = start.value + duration.value; | 269 | ret.abs_value = start.abs_value + duration.rel_value; |
270 | return ret; | 270 | return ret; |
271 | } | 271 | } |
272 | 272 | ||
@@ -288,11 +288,11 @@ GNUNET_TIME_absolute_subtract (struct | |||
288 | duration) | 288 | duration) |
289 | { | 289 | { |
290 | struct GNUNET_TIME_Absolute ret; | 290 | struct GNUNET_TIME_Absolute ret; |
291 | if (start.value <= duration.value) | 291 | if (start.abs_value <= duration.rel_value) |
292 | return GNUNET_TIME_UNIT_ZERO_ABS; | 292 | return GNUNET_TIME_UNIT_ZERO_ABS; |
293 | if (start.value == GNUNET_TIME_UNIT_FOREVER_ABS.value) | 293 | if (start.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) |
294 | return GNUNET_TIME_UNIT_FOREVER_ABS; | 294 | return GNUNET_TIME_UNIT_FOREVER_ABS; |
295 | ret.value = start.value - duration.value; | 295 | ret.abs_value = start.abs_value - duration.rel_value; |
296 | return ret; | 296 | return ret; |
297 | } | 297 | } |
298 | 298 | ||
@@ -309,8 +309,8 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, | |||
309 | struct GNUNET_TIME_Relative ret; | 309 | struct GNUNET_TIME_Relative ret; |
310 | if (factor == 0) | 310 | if (factor == 0) |
311 | return GNUNET_TIME_relative_get_zero (); | 311 | return GNUNET_TIME_relative_get_zero (); |
312 | ret.value = rel.value * (unsigned long long) factor; | 312 | ret.rel_value = rel.rel_value * (unsigned long long) factor; |
313 | if (ret.value / factor != rel.value) | 313 | if (ret.rel_value / factor != rel.rel_value) |
314 | { | 314 | { |
315 | GNUNET_break (0); | 315 | GNUNET_break (0); |
316 | return GNUNET_TIME_relative_get_forever (); | 316 | return GNUNET_TIME_relative_get_forever (); |
@@ -332,9 +332,9 @@ GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, | |||
332 | { | 332 | { |
333 | struct GNUNET_TIME_Relative ret; | 333 | struct GNUNET_TIME_Relative ret; |
334 | if ( (factor == 0) || | 334 | if ( (factor == 0) || |
335 | (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value) ) | 335 | (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) ) |
336 | return GNUNET_TIME_UNIT_FOREVER_REL; | 336 | return GNUNET_TIME_UNIT_FOREVER_REL; |
337 | ret.value = rel.value / (unsigned long long) factor; | 337 | ret.rel_value = rel.rel_value / (unsigned long long) factor; |
338 | return ret; | 338 | return ret; |
339 | } | 339 | } |
340 | 340 | ||
@@ -363,8 +363,8 @@ GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, | |||
363 | if (finished == 0) | 363 | if (finished == 0) |
364 | return GNUNET_TIME_UNIT_FOREVER_REL; | 364 | return GNUNET_TIME_UNIT_FOREVER_REL; |
365 | dur = GNUNET_TIME_absolute_get_duration (start); | 365 | dur = GNUNET_TIME_absolute_get_duration (start); |
366 | exp = ((double) dur.value) * ((double) total) / ((double) finished); | 366 | exp = ((double) dur.rel_value) * ((double) total) / ((double) finished); |
367 | ret.value = ((uint64_t) exp) - dur.value; | 367 | ret.rel_value = ((uint64_t) exp) - dur.rel_value; |
368 | return ret; | 368 | return ret; |
369 | } | 369 | } |
370 | 370 | ||
@@ -382,14 +382,14 @@ GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, | |||
382 | { | 382 | { |
383 | struct GNUNET_TIME_Relative ret; | 383 | struct GNUNET_TIME_Relative ret; |
384 | 384 | ||
385 | if ((a1.value == UINT64_MAX) || (a2.value == UINT64_MAX)) | 385 | if ((a1.rel_value == UINT64_MAX) || (a2.rel_value == UINT64_MAX)) |
386 | return GNUNET_TIME_relative_get_forever (); | 386 | return GNUNET_TIME_relative_get_forever (); |
387 | if (a1.value + a2.value < a1.value) | 387 | if (a1.rel_value + a2.rel_value < a1.rel_value) |
388 | { | 388 | { |
389 | GNUNET_break (0); | 389 | GNUNET_break (0); |
390 | return GNUNET_TIME_relative_get_forever (); | 390 | return GNUNET_TIME_relative_get_forever (); |
391 | } | 391 | } |
392 | ret.value = a1.value + a2.value; | 392 | ret.rel_value = a1.rel_value + a2.rel_value; |
393 | return ret; | 393 | return ret; |
394 | } | 394 | } |
395 | 395 | ||
@@ -407,11 +407,11 @@ GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, | |||
407 | { | 407 | { |
408 | struct GNUNET_TIME_Relative ret; | 408 | struct GNUNET_TIME_Relative ret; |
409 | 409 | ||
410 | if (a2.value >= a1.value) | 410 | if (a2.rel_value >= a1.rel_value) |
411 | return GNUNET_TIME_relative_get_zero (); | 411 | return GNUNET_TIME_relative_get_zero (); |
412 | if (a1.value == UINT64_MAX) | 412 | if (a1.rel_value == UINT64_MAX) |
413 | return GNUNET_TIME_relative_get_forever (); | 413 | return GNUNET_TIME_relative_get_forever (); |
414 | ret.value = a1.value - a2.value; | 414 | ret.rel_value = a1.rel_value - a2.rel_value; |
415 | return ret; | 415 | return ret; |
416 | } | 416 | } |
417 | 417 | ||
@@ -426,7 +426,7 @@ struct GNUNET_TIME_RelativeNBO | |||
426 | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) | 426 | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) |
427 | { | 427 | { |
428 | struct GNUNET_TIME_RelativeNBO ret; | 428 | struct GNUNET_TIME_RelativeNBO ret; |
429 | ret.value__ = GNUNET_htonll (a.value); | 429 | ret.value__ = GNUNET_htonll (a.rel_value); |
430 | return ret; | 430 | return ret; |
431 | } | 431 | } |
432 | 432 | ||
@@ -440,7 +440,7 @@ struct GNUNET_TIME_Relative | |||
440 | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) | 440 | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) |
441 | { | 441 | { |
442 | struct GNUNET_TIME_Relative ret; | 442 | struct GNUNET_TIME_Relative ret; |
443 | ret.value = GNUNET_ntohll (a.value__); | 443 | ret.rel_value = GNUNET_ntohll (a.value__); |
444 | return ret; | 444 | return ret; |
445 | 445 | ||
446 | } | 446 | } |
@@ -455,7 +455,7 @@ struct GNUNET_TIME_AbsoluteNBO | |||
455 | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) | 455 | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) |
456 | { | 456 | { |
457 | struct GNUNET_TIME_AbsoluteNBO ret; | 457 | struct GNUNET_TIME_AbsoluteNBO ret; |
458 | ret.value__ = GNUNET_htonll (a.value); | 458 | ret.value__ = GNUNET_htonll (a.abs_value); |
459 | return ret; | 459 | return ret; |
460 | } | 460 | } |
461 | 461 | ||
@@ -469,7 +469,7 @@ struct GNUNET_TIME_Absolute | |||
469 | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) | 469 | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) |
470 | { | 470 | { |
471 | struct GNUNET_TIME_Absolute ret; | 471 | struct GNUNET_TIME_Absolute ret; |
472 | ret.value = GNUNET_ntohll (a.value__); | 472 | ret.abs_value = GNUNET_ntohll (a.value__); |
473 | return ret; | 473 | return ret; |
474 | 474 | ||
475 | } | 475 | } |