aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/bandwidth.c48
-rw-r--r--src/util/client.c12
-rw-r--r--src/util/common_logging.c21
-rw-r--r--src/util/connection.c25
-rw-r--r--src/util/gnunet-service-resolver.c12
-rw-r--r--src/util/load.c16
-rw-r--r--src/util/network.c42
-rw-r--r--src/util/perf_crypto_hash.c6
-rw-r--r--src/util/perf_malloc.c10
-rw-r--r--src/util/resolver_api.c14
-rw-r--r--src/util/scheduler.c26
-rw-r--r--src/util/server.c10
-rw-r--r--src/util/speedup.c24
-rw-r--r--src/util/strings.c97
-rw-r--r--src/util/test_common_logging_dummy.c6
-rw-r--r--src/util/test_crypto_ecc.c6
-rw-r--r--src/util/test_scheduler_delay.c35
-rw-r--r--src/util/test_speedup.c27
-rw-r--r--src/util/test_strings.c6
-rw-r--r--src/util/test_time.c169
-rw-r--r--src/util/time.c111
21 files changed, 376 insertions, 347 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 60cb50529..5caaec03c 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -83,9 +83,9 @@ GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO
83 b = ntohl (bps.value__); 83 b = ntohl (bps.value__);
84 LOG (GNUNET_ERROR_TYPE_DEBUG, 84 LOG (GNUNET_ERROR_TYPE_DEBUG,
85 "Bandwidth has %llu bytes available until deadline in %s\n", 85 "Bandwidth has %llu bytes available until deadline in %s\n",
86 (unsigned long long) ((b * deadline.rel_value + 500LL) / 1000LL), 86 (unsigned long long) ((b * deadline.rel_value_us + 500000LL) / 1000000LL),
87 GNUNET_STRINGS_relative_time_to_string (deadline, GNUNET_YES)); 87 GNUNET_STRINGS_relative_time_to_string (deadline, GNUNET_YES));
88 return (b * deadline.rel_value + 500LL) / 1000LL; 88 return (b * deadline.rel_value_us + 500000LL) / 1000000LL;
89} 89}
90 90
91 91
@@ -105,16 +105,17 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps,
105 struct GNUNET_TIME_Relative ret; 105 struct GNUNET_TIME_Relative ret;
106 106
107 b = ntohl (bps.value__); 107 b = ntohl (bps.value__);
108 if (b == 0) 108 if (0 == b)
109 { 109 {
110 LOG (GNUNET_ERROR_TYPE_DEBUG, 110 LOG (GNUNET_ERROR_TYPE_DEBUG,
111 "Bandwidth suggests delay of infinity (zero bandwidth)\n"); 111 "Bandwidth suggests delay of infinity (zero bandwidth)\n");
112 return GNUNET_TIME_UNIT_FOREVER_REL; 112 return GNUNET_TIME_UNIT_FOREVER_REL;
113 } 113 }
114 ret.rel_value = size * 1000LL / b; 114 ret.rel_value_us = size * 1000LL * 1000LL / b;
115 LOG (GNUNET_ERROR_TYPE_DEBUG, 115 LOG (GNUNET_ERROR_TYPE_DEBUG,
116 "Bandwidth suggests delay of %llu ms for %llu bytes of traffic\n", 116 "Bandwidth suggests delay of %s for %llu bytes of traffic\n",
117 (unsigned long long) ret.rel_value, (unsigned long long) size); 117 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES),
118 (unsigned long long) size);
118 return ret; 119 return ret;
119} 120}
120 121
@@ -158,16 +159,17 @@ static void
158update_tracker (struct GNUNET_BANDWIDTH_Tracker *av) 159update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
159{ 160{
160 struct GNUNET_TIME_Absolute now; 161 struct GNUNET_TIME_Absolute now;
162 struct GNUNET_TIME_Relative delta;
161 uint64_t delta_time; 163 uint64_t delta_time;
162 uint64_t delta_avail; 164 uint64_t delta_avail;
163 uint64_t left_bytes; 165 uint64_t left_bytes;
164 uint64_t max_carry; 166 uint64_t max_carry;
165 167
166 now = GNUNET_TIME_absolute_get (); 168 now = GNUNET_TIME_absolute_get ();
167 delta_time = now.abs_value - av->last_update__.abs_value; 169 delta_time = now.abs_value_us - av->last_update__.abs_value_us;
168 delta_avail = 170 delta_avail =
169 (delta_time * ((unsigned long long) av->available_bytes_per_s__) + 171 (delta_time * ((unsigned long long) av->available_bytes_per_s__) +
170 500LL) / 1000LL; 172 500000LL) / 1000000LL;
171 av->consumption_since_last_update__ -= delta_avail; 173 av->consumption_since_last_update__ -= delta_avail;
172 av->last_update__ = now; 174 av->last_update__ = now;
173 if (av->consumption_since_last_update__ < 0) 175 if (av->consumption_since_last_update__ < 0)
@@ -181,10 +183,11 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av)
181 else 183 else
182 av->consumption_since_last_update__ = -max_carry; 184 av->consumption_since_last_update__ = -max_carry;
183 } 185 }
186 delta.rel_value_us = delta_time;
184 LOG (GNUNET_ERROR_TYPE_DEBUG, 187 LOG (GNUNET_ERROR_TYPE_DEBUG,
185 "Tracker %p updated, have %u Bps, last update was %llu ms ago\n", av, 188 "Tracker %p updated, have %u Bps, last update was %s ago\n", av,
186 (unsigned int) av->available_bytes_per_s__, 189 (unsigned int) av->available_bytes_per_s__,
187 (unsigned long long) delta_time); 190 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
188} 191}
189 192
190 193
@@ -251,22 +254,26 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av,
251 254
252 if (av->available_bytes_per_s__ == 0) 255 if (av->available_bytes_per_s__ == 0)
253 { 256 {
254 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay is infinity\n", av); 257 LOG (GNUNET_ERROR_TYPE_DEBUG,
258 "Tracker %p delay is infinity\n", av);
255 return GNUNET_TIME_UNIT_FOREVER_REL; 259 return GNUNET_TIME_UNIT_FOREVER_REL;
256 } 260 }
257 update_tracker (av); 261 update_tracker (av);
258 bytes_needed = size + av->consumption_since_last_update__; 262 bytes_needed = size + av->consumption_since_last_update__;
259 if (bytes_needed <= 0) 263 if (bytes_needed <= 0)
260 { 264 {
261 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is zero\n", av, 265 LOG (GNUNET_ERROR_TYPE_DEBUG,
266 "Tracker %p delay for %u bytes is zero\n", av,
262 (unsigned int) size); 267 (unsigned int) size);
263 return GNUNET_TIME_UNIT_ZERO; 268 return GNUNET_TIME_UNIT_ZERO;
264 } 269 }
265 ret.rel_value = 270 ret.rel_value_us =
266 (1000LL * bytes_needed) / 271 (1000LL * 1000LL * bytes_needed) /
267 (unsigned long long) av->available_bytes_per_s__; 272 (unsigned long long) av->available_bytes_per_s__;
268 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay for %u bytes is %llu ms\n", 273 LOG (GNUNET_ERROR_TYPE_DEBUG,
269 av, (unsigned int) size, (unsigned long long) ret.rel_value); 274 "Tracker %p delay for %u bytes is %s\n",
275 av, (unsigned int) size,
276 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES));
270 return ret; 277 return ret;
271} 278}
272 279
@@ -293,7 +300,7 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker * av)
293 (av->last_update__)); 300 (av->last_update__));
294 used = av->consumption_since_last_update__; 301 used = av->consumption_since_last_update__;
295 LOG (GNUNET_ERROR_TYPE_DEBUG, 302 LOG (GNUNET_ERROR_TYPE_DEBUG,
296 "Tracker %p available bandwidth is %lld bytes\n", av, 303 "Tracker %p available bandwidth is %lld bytes\n", av,
297 (long long) (int64_t) (avail - used)); 304 (long long) (int64_t) (avail - used));
298 return (int64_t) (avail - used); 305 return (int64_t) (avail - used);
299} 306}
@@ -314,7 +321,8 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av,
314 uint32_t new_limit; 321 uint32_t new_limit;
315 322
316 new_limit = ntohl (bytes_per_second_limit.value__); 323 new_limit = ntohl (bytes_per_second_limit.value__);
317 LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p bandwidth changed to %u Bps\n", av, 324 LOG (GNUNET_ERROR_TYPE_DEBUG,
325 "Tracker %p bandwidth changed to %u Bps\n", av,
318 (unsigned int) new_limit); 326 (unsigned int) new_limit);
319 update_tracker (av); 327 update_tracker (av);
320 old_limit = av->available_bytes_per_s__; 328 old_limit = av->available_bytes_per_s__;
diff --git a/src/util/client.c b/src/util/client.c
index 811bb8e12..6c5e93ce4 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2006, 2008, 2009, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -409,7 +409,7 @@ GNUNET_CLIENT_connect (const char *service_name,
409 cfg)) 409 cfg))
410 return NULL; 410 return NULL;
411 connection = do_connect (service_name, cfg, 0); 411 connection = do_connect (service_name, cfg, 0);
412 client = GNUNET_malloc (sizeof (struct GNUNET_CLIENT_Connection)); 412 client = GNUNET_new (struct GNUNET_CLIENT_Connection);
413 client->first_message = GNUNET_YES; 413 client->first_message = GNUNET_YES;
414 client->attempts = 1; 414 client->attempts = 1;
415 client->connection = connection; 415 client->connection = connection;
@@ -536,7 +536,7 @@ receive_helper (void *cls, const void *buf, size_t available,
536 check_complete (client); 536 check_complete (client);
537 /* check for timeout */ 537 /* check for timeout */
538 remaining = GNUNET_TIME_absolute_get_remaining (client->receive_timeout); 538 remaining = GNUNET_TIME_absolute_get_remaining (client->receive_timeout);
539 if (0 == remaining.rel_value) 539 if (0 == remaining.rel_value_us)
540 { 540 {
541 /* signal timeout! */ 541 /* signal timeout! */
542 if (NULL != client->receiver_handler) 542 if (NULL != client->receiver_handler)
@@ -1094,9 +1094,9 @@ client_notify (void *cls, size_t size, void *buf)
1094 if (NULL == buf) 1094 if (NULL == buf)
1095 { 1095 {
1096 delay = GNUNET_TIME_absolute_get_remaining (th->timeout); 1096 delay = GNUNET_TIME_absolute_get_remaining (th->timeout);
1097 delay.rel_value /= 2; 1097 delay.rel_value_us /= 2;
1098 if ((GNUNET_YES != th->auto_retry) || (0 == --th->attempts_left) || 1098 if ((GNUNET_YES != th->auto_retry) || (0 == --th->attempts_left) ||
1099 (delay.rel_value < 1)|| 1099 (delay.rel_value_us < 1)||
1100 (0 != (GNUNET_SCHEDULER_get_reason() & GNUNET_SCHEDULER_REASON_SHUTDOWN))) 1100 (0 != (GNUNET_SCHEDULER_get_reason() & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
1101 { 1101 {
1102 LOG (GNUNET_ERROR_TYPE_DEBUG, 1102 LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 5b355b2e1..8f1c8e876 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2006, 2008, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2006-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -26,17 +26,15 @@
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_common.h" 28#include "gnunet_common.h"
29#include "gnunet_crypto_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_strings_lib.h"
31#include "gnunet_time_lib.h"
32
33#include <regex.h> 30#include <regex.h>
34 31
32
35/** 33/**
36 * After how many milliseconds do we always print 34 * After how many milliseconds do we always print
37 * that "message X was repeated N times"? Use 12h. 35 * that "message X was repeated N times"? Use 12h.
38 */ 36 */
39#define BULK_DELAY_THRESHOLD (12 * 60 * 60 * 1000) 37#define BULK_DELAY_THRESHOLD (12 * 60 * 60 * 1000LL * 1000LL)
40 38
41/** 39/**
42 * After how many repetitions do we always print 40 * After how many repetitions do we always print
@@ -800,7 +798,7 @@ flush_bulk (const char *datestr)
800 char *last; 798 char *last;
801 const char *ft; 799 const char *ft;
802 800
803 if ((last_bulk_time.abs_value == 0) || (last_bulk_repeat == 0)) 801 if ((0 == last_bulk_time.abs_value_us) || (0 == last_bulk_repeat))
804 return; 802 return;
805 rev = 0; 803 rev = 0;
806 last = memchr (last_bulk, '\0', BULK_TRACK_SIZE); 804 last = memchr (last_bulk, '\0', BULK_TRACK_SIZE);
@@ -951,12 +949,13 @@ mylog (enum GNUNET_ErrorType kind, const char *comp, const char *message,
951 if (NULL != tmptr) 949 if (NULL != tmptr)
952 (void) setup_log_file (tmptr); 950 (void) setup_log_file (tmptr);
953 if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && 951 if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
954 (last_bulk_time.abs_value != 0) && 952 (0 != last_bulk_time.abs_value_us) &&
955 (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) 953 (0 == strncmp (buf, last_bulk, sizeof (last_bulk))))
956 { 954 {
957 last_bulk_repeat++; 955 last_bulk_repeat++;
958 if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value > 956 if ( (GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value_us >
959 BULK_DELAY_THRESHOLD) || (last_bulk_repeat > BULK_REPEAT_THRESHOLD)) 957 BULK_DELAY_THRESHOLD) ||
958 (last_bulk_repeat > BULK_REPEAT_THRESHOLD) )
960 flush_bulk (date); 959 flush_bulk (date);
961 return; 960 return;
962 } 961 }
diff --git a/src/util/connection.c b/src/util/connection.c
index ea35b04e1..bdfcd1add 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -33,11 +33,8 @@
33 33
34#include "platform.h" 34#include "platform.h"
35#include "gnunet_common.h" 35#include "gnunet_common.h"
36#include "gnunet_connection_lib.h" 36#include "gnunet_util_lib.h"
37#include "gnunet_container_lib.h"
38#include "gnunet_resolver_service.h" 37#include "gnunet_resolver_service.h"
39#include "gnunet_scheduler_lib.h"
40#include "gnunet_server_lib.h"
41 38
42 39
43#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) 40#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -304,7 +301,7 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket)
304{ 301{
305 struct GNUNET_CONNECTION_Handle *connection; 302 struct GNUNET_CONNECTION_Handle *connection;
306 303
307 connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); 304 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
308 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 305 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
309 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 306 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
310 connection->sock = osSocket; 307 connection->sock = osSocket;
@@ -362,7 +359,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access,
362 if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr))) 359 if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr)))
363 { 360 {
364 /* convert to V4 address */ 361 /* convert to V4 address */
365 v4 = GNUNET_malloc (sizeof (struct sockaddr_in)); 362 v4 = GNUNET_new (struct sockaddr_in);
366 memset (v4, 0, sizeof (struct sockaddr_in)); 363 memset (v4, 0, sizeof (struct sockaddr_in));
367 v4->sin_family = AF_INET; 364 v4->sin_family = AF_INET;
368#if HAVE_SOCKADDR_IN_SIN_LEN 365#if HAVE_SOCKADDR_IN_SIN_LEN
@@ -432,7 +429,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access,
432 GNUNET_free (uaddr); 429 GNUNET_free (uaddr);
433 return NULL; 430 return NULL;
434 } 431 }
435 connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); 432 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
436 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 433 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
437 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 434 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
438 connection->addr = uaddr; 435 connection->addr = uaddr;
@@ -800,7 +797,7 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle
800 struct GNUNET_CONNECTION_Handle *connection; 797 struct GNUNET_CONNECTION_Handle *connection;
801 798
802 GNUNET_assert (0 < strlen (hostname)); /* sanity check */ 799 GNUNET_assert (0 < strlen (hostname)); /* sanity check */
803 connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); 800 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
804 connection->cfg = cfg; 801 connection->cfg = cfg;
805 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 802 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
806 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 803 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
@@ -834,7 +831,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
834 size_t slen; 831 size_t slen;
835 832
836 GNUNET_assert (0 < strlen (unixpath)); /* sanity check */ 833 GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
837 un = GNUNET_malloc (sizeof (struct sockaddr_un)); 834 un = GNUNET_new (struct sockaddr_un);
838 un->sun_family = AF_UNIX; 835 un->sun_family = AF_UNIX;
839 slen = strlen (unixpath); 836 slen = strlen (unixpath);
840 if (slen >= sizeof (un->sun_path)) 837 if (slen >= sizeof (un->sun_path))
@@ -848,7 +845,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct
848#if LINUX 845#if LINUX
849 un->sun_path[0] = '\0'; 846 un->sun_path[0] = '\0';
850#endif 847#endif
851 connection = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); 848 connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
852 connection->cfg = cfg; 849 connection->cfg = cfg;
853 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; 850 connection->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE;
854 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size); 851 connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
@@ -1042,9 +1039,9 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1042 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) 1039 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
1043 { 1040 {
1044 LOG (GNUNET_ERROR_TYPE_DEBUG, 1041 LOG (GNUNET_ERROR_TYPE_DEBUG,
1045 "Receive from `%s' encounters error: timeout (%p)\n", 1042 "Receive from `%s' encounters error: timeout (%s, %p)\n",
1046 GNUNET_a2s (connection->addr, connection->addrlen), 1043 GNUNET_a2s (connection->addr, connection->addrlen),
1047 GNUNET_TIME_absolute_get_duration (connection->receive_timeout).rel_value, 1044 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (connection->receive_timeout), GNUNET_YES),
1048 connection); 1045 connection);
1049 signal_receive_timeout (connection); 1046 signal_receive_timeout (connection);
1050 return; 1047 return;
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index 507ecf661..cab13ae57 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2007, 2008, 2009, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2007-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -217,8 +217,8 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client,
217 (0 != memcmp (pos->ip, ip, ip_len))) ) 217 (0 != memcmp (pos->ip, ip, ip_len))) )
218 { 218 {
219 next = pos->next; 219 next = pos->next;
220 if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value < 220 if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value_us <
221 60 * 60 * 1000) 221 60 * 60 * 1000 * 1000LL)
222 { 222 {
223 GNUNET_CONTAINER_DLL_remove (cache_head, 223 GNUNET_CONTAINER_DLL_remove (cache_head,
224 cache_tail, 224 cache_tail,
@@ -231,8 +231,8 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client,
231 if (pos != NULL) 231 if (pos != NULL)
232 { 232 {
233 pos->last_request = now; 233 pos->last_request = now;
234 if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value < 234 if (GNUNET_TIME_absolute_get_duration (pos->last_request).rel_value_us <
235 60 * 60 * 1000) 235 60 * 60 * 1000 * 1000LL)
236 { 236 {
237 GNUNET_free_non_null (pos->addr); 237 GNUNET_free_non_null (pos->addr);
238 pos->addr = NULL; 238 pos->addr = NULL;
diff --git a/src/util/load.c b/src/util/load.c
index 146e85095..06e284c4c 100644
--- a/src/util/load.c
+++ b/src/util/load.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -24,7 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_load_lib.h" 27#include "gnunet_util_lib.h"
28 28
29 29
30#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) 30#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -87,18 +87,18 @@ internal_update (struct GNUNET_LOAD_Value *load)
87 struct GNUNET_TIME_Relative delta; 87 struct GNUNET_TIME_Relative delta;
88 unsigned int n; 88 unsigned int n;
89 89
90 if (load->autodecline.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 90 if (load->autodecline.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
91 return; 91 return;
92 delta = GNUNET_TIME_absolute_get_duration (load->last_update); 92 delta = GNUNET_TIME_absolute_get_duration (load->last_update);
93 if (delta.rel_value < load->autodecline.rel_value) 93 if (delta.rel_value_us < load->autodecline.rel_value_us)
94 return; 94 return;
95 if (load->autodecline.rel_value == 0) 95 if (0 == load->autodecline.rel_value_us)
96 { 96 {
97 load->runavg_delay = 0.0; 97 load->runavg_delay = 0.0;
98 load->load = 0; 98 load->load = 0;
99 return; 99 return;
100 } 100 }
101 n = delta.rel_value / load->autodecline.rel_value; 101 n = delta.rel_value_us / load->autodecline.rel_value_us;
102 if (n > 16) 102 if (n > 16)
103 { 103 {
104 load->runavg_delay = 0.0; 104 load->runavg_delay = 0.0;
@@ -126,7 +126,7 @@ GNUNET_LOAD_value_init (struct GNUNET_TIME_Relative autodecline)
126{ 126{
127 struct GNUNET_LOAD_Value *ret; 127 struct GNUNET_LOAD_Value *ret;
128 128
129 ret = GNUNET_malloc (sizeof (struct GNUNET_LOAD_Value)); 129 ret = GNUNET_new (struct GNUNET_LOAD_Value);
130 ret->autodecline = autodecline; 130 ret->autodecline = autodecline;
131 ret->last_update = GNUNET_TIME_absolute_get (); 131 ret->last_update = GNUNET_TIME_absolute_get ();
132 return ret; 132 return ret;
diff --git a/src/util/network.c b/src/util/network.c
index 7a51a8b67..8398b9fab 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -1332,7 +1332,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1332 } 1332 }
1333 1333
1334 if ((nfds == 0) && 1334 if ((nfds == 0) &&
1335 (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 1335 (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
1336#ifdef MINGW 1336#ifdef MINGW
1337 && handles == 0 1337 && handles == 0
1338#endif 1338#endif
@@ -1345,25 +1345,26 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1345 "select"); 1345 "select");
1346 } 1346 }
1347#ifndef MINGW 1347#ifndef MINGW
1348 tv.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value; 1348 tv.tv_sec = timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
1349 tv.tv_usec = 1349 tv.tv_usec =
1350 1000 * (timeout.rel_value - 1350 (timeout.rel_value_us -
1351 (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value)); 1351 (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us));
1352 return select (nfds, (rfds != NULL) ? &rfds->sds : NULL, 1352 return select (nfds,
1353 (wfds != NULL) ? &wfds->sds : NULL, 1353 (NULL != rfds) ? &rfds->sds : NULL,
1354 (efds != NULL) ? &efds->sds : NULL, 1354 (NULL != wfds) ? &wfds->sds : NULL,
1355 (timeout.rel_value == 1355 (NULL != efds) ? &efds->sds : NULL,
1356 GNUNET_TIME_UNIT_FOREVER_REL.rel_value) ? NULL : &tv); 1356 (timeout.rel_value_us ==
1357 GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) ? NULL : &tv);
1357 1358
1358#else 1359#else
1359#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set)) 1360#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
1360 /* calculate how long we need to wait in milliseconds */ 1361 /* calculate how long we need to wait in milliseconds */
1361 if (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 1362 if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
1362 ms_total = INFINITE; 1363 ms_total = INFINITE;
1363 else 1364 else
1364 { 1365 {
1365 ms_total = timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value; 1366 ms_total = timeout.rel_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
1366 if (timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value > 0xFFFFFFFFLL - 1) 1367 if (timeout.rel_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us > 0xFFFFFFFFLL - 1)
1367 { 1368 {
1368 GNUNET_break (0); 1369 GNUNET_break (0);
1369 ms_total = 0xFFFFFFFF - 1; 1370 ms_total = 0xFFFFFFFF - 1;
@@ -1376,7 +1377,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1376 return 0; 1377 return 0;
1377 } 1378 }
1378 1379
1379 if (select_thread == NULL) 1380 if (NULL == select_thread)
1380 { 1381 {
1381 SOCKET select_listening_socket = -1; 1382 SOCKET select_listening_socket = -1;
1382 struct sockaddr_in s_in; 1383 struct sockaddr_in s_in;
@@ -1742,15 +1743,16 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1742 if (nfds > 0) 1743 if (nfds > 0)
1743 { 1744 {
1744 LOG (GNUNET_ERROR_TYPE_DEBUG, 1745 LOG (GNUNET_ERROR_TYPE_DEBUG,
1745 "Adding the socket event to the array as %d\n", nhandles); 1746 "Adding the socket event to the array as %d\n",
1747 nhandles);
1746 handle_array[nhandles++] = select_finished_event; 1748 handle_array[nhandles++] = select_finished_event;
1747 if (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 1749 if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
1748 sp.tv = NULL; 1750 sp.tv = NULL;
1749 else 1751 else
1750 { 1752 {
1751 select_timeout.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value; 1753 select_timeout.tv_sec = timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
1752 select_timeout.tv_usec = 1000 * (timeout.rel_value - 1754 select_timeout.tv_usec =(timeout.rel_value_us -
1753 (select_timeout.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value)); 1755 (select_timeout.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us));
1754 sp.tv = &select_timeout; 1756 sp.tv = &select_timeout;
1755 } 1757 }
1756 FD_SET (select_wakeup_socket, &aread); 1758 FD_SET (select_wakeup_socket, &aread);
diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c
index 930e99844..affd4a2d5 100644
--- a/src/util/perf_crypto_hash.c
+++ b/src/util/perf_crypto_hash.c
@@ -53,9 +53,9 @@ main (int argc, char *argv[])
53 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), 53 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
54 GNUNET_YES)); 54 GNUNET_YES));
55 GAUGER ("UTIL", "Cryptographic hashing", 55 GAUGER ("UTIL", "Cryptographic hashing",
56 1024 * 64 * 1024 / (1 + 56 64 * 1024 / (1 +
57 GNUNET_TIME_absolute_get_duration 57 GNUNET_TIME_absolute_get_duration
58 (start).rel_value), "kb/s"); 58 (start).rel_value_us / 1000LL), "kb/ms");
59 return 0; 59 return 0;
60} 60}
61 61
diff --git a/src/util/perf_malloc.c b/src/util/perf_malloc.c
index 31f08dff0..f25529269 100644
--- a/src/util/perf_malloc.c
+++ b/src/util/perf_malloc.c
@@ -53,13 +53,13 @@ main (int argc, char *argv[])
53 53
54 start = GNUNET_TIME_absolute_get (); 54 start = GNUNET_TIME_absolute_get ();
55 kb = perfMalloc (); 55 kb = perfMalloc ();
56 printf ("Malloc perf took %llu ms\n", 56 printf ("Malloc perf took %s\n",
57 (unsigned long long) 57 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
58 GNUNET_TIME_absolute_get_duration (start).rel_value); 58 GNUNET_YES));
59 GAUGER ("UTIL", "Allocation", 59 GAUGER ("UTIL", "Allocation",
60 kb / 1024 / (1 + 60 kb / 1024 / (1 +
61 GNUNET_TIME_absolute_get_duration 61 GNUNET_TIME_absolute_get_duration
62 (start).rel_value), "kb/s"); 62 (start).rel_value_us / 1000LL), "kb/ms");
63 return 0; 63 return 0;
64} 64}
65 65
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 7acc0f87f..9a2228da0 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009, 2011 Christian Grothoff (and other contributing authors) 3 (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -24,13 +24,9 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_getopt_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_os_lib.h"
29#include "gnunet_client_lib.h"
30#include "gnunet_container_lib.h"
31#include "gnunet_protocols.h" 28#include "gnunet_protocols.h"
32#include "gnunet_resolver_service.h" 29#include "gnunet_resolver_service.h"
33#include "gnunet_server_lib.h"
34#include "resolver.h" 30#include "resolver.h"
35 31
36#define LOG(kind,...) GNUNET_log_from (kind, "resolver-api", __VA_ARGS__) 32#define LOG(kind,...) GNUNET_log_from (kind, "resolver-api", __VA_ARGS__)
@@ -703,8 +699,8 @@ reconnect ()
703 } 699 }
704 } 700 }
705 LOG (GNUNET_ERROR_TYPE_DEBUG, 701 LOG (GNUNET_ERROR_TYPE_DEBUG,
706 "Will try to connect to DNS service in %llu ms\n", 702 "Will try to connect to DNS service in %s\n",
707 (unsigned long long) backoff.rel_value); 703 GNUNET_STRINGS_relative_time_to_string (backoff, GNUNET_YES));
708 GNUNET_assert (NULL != resolver_cfg); 704 GNUNET_assert (NULL != resolver_cfg);
709 r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL); 705 r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL);
710 backoff = GNUNET_TIME_STD_BACKOFF (backoff); 706 backoff = GNUNET_TIME_STD_BACKOFF (backoff);
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 23f683808..5b90d7e4f 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2009, 2011 Christian Grothoff (and other contributing authors) 3 (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -300,7 +300,7 @@ update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws,
300 if (pos != NULL) 300 if (pos != NULL)
301 { 301 {
302 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); 302 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout);
303 if (timeout->rel_value > to.rel_value) 303 if (timeout->rel_value_us > to.rel_value_us)
304 *timeout = to; 304 *timeout = to;
305 if (pos->reason != 0) 305 if (pos->reason != 0)
306 *timeout = GNUNET_TIME_UNIT_ZERO; 306 *timeout = GNUNET_TIME_UNIT_ZERO;
@@ -308,10 +308,10 @@ update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws,
308 pos = pending; 308 pos = pending;
309 while (pos != NULL) 309 while (pos != NULL)
310 { 310 {
311 if (pos->timeout.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) 311 if (pos->timeout.abs_value_us != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
312 { 312 {
313 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); 313 to = GNUNET_TIME_absolute_get_difference (now, pos->timeout);
314 if (timeout->rel_value > to.rel_value) 314 if (timeout->rel_value_us > to.rel_value_us)
315 *timeout = to; 315 *timeout = to;
316 } 316 }
317 if (pos->read_fd != -1) 317 if (pos->read_fd != -1)
@@ -373,7 +373,7 @@ is_ready (struct Task *task, struct GNUNET_TIME_Absolute now,
373 enum GNUNET_SCHEDULER_Reason reason; 373 enum GNUNET_SCHEDULER_Reason reason;
374 374
375 reason = task->reason; 375 reason = task->reason;
376 if (now.abs_value >= task->timeout.abs_value) 376 if (now.abs_value_us >= task->timeout.abs_value_us)
377 reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; 377 reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
378 if ((0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) && 378 if ((0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
379 (((task->read_fd != -1) && 379 (((task->read_fd != -1) &&
@@ -433,7 +433,7 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs,
433 while (pos != NULL) 433 while (pos != NULL)
434 { 434 {
435 next = pos->next; 435 next = pos->next;
436 if (now.abs_value >= pos->timeout.abs_value) 436 if (now.abs_value_us >= pos->timeout.abs_value_us)
437 pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; 437 pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
438 if (0 == pos->reason) 438 if (0 == pos->reason)
439 break; 439 break;
@@ -569,8 +569,8 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws)
569 current_lifeness = pos->lifeness; 569 current_lifeness = pos->lifeness;
570 active_task = pos; 570 active_task = pos;
571#if PROFILE_DELAYS 571#if PROFILE_DELAYS
572 if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value > 572 if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value_us >
573 DELAY_THRESHOLD.rel_value) 573 DELAY_THRESHOLD.rel_value_us)
574 { 574 {
575 LOG (GNUNET_ERROR_TYPE_DEBUG, 575 LOG (GNUNET_ERROR_TYPE_DEBUG,
576 "Task %llu took %s to be scheduled\n", 576 "Task %llu took %s to be scheduled\n",
@@ -777,7 +777,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
777 GNUNET_abort (); 777 GNUNET_abort ();
778 break; 778 break;
779 } 779 }
780 if ((ret == 0) && (timeout.rel_value == 0) && (busy_wait_warning > 16)) 780 if ((0 == ret) && (0 == timeout.rel_value_us) && (busy_wait_warning > 16))
781 { 781 {
782 LOG (GNUNET_ERROR_TYPE_WARNING, _("Looks like we're busy waiting...\n")); 782 LOG (GNUNET_ERROR_TYPE_WARNING, _("Looks like we're busy waiting...\n"));
783 sleep (1); /* mitigate */ 783 sleep (1); /* mitigate */
@@ -1091,7 +1091,7 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
1091 prev = pending_timeout_last; 1091 prev = pending_timeout_last;
1092 if (prev != NULL) 1092 if (prev != NULL)
1093 { 1093 {
1094 if (prev->timeout.abs_value > t->timeout.abs_value) 1094 if (prev->timeout.abs_value_us > t->timeout.abs_value_us)
1095 prev = NULL; 1095 prev = NULL;
1096 else 1096 else
1097 pos = prev->next; /* heuristic success! */ 1097 pos = prev->next; /* heuristic success! */
@@ -1102,8 +1102,8 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay,
1102 pos = pending_timeout; 1102 pos = pending_timeout;
1103 } 1103 }
1104 while ((pos != NULL) && 1104 while ((pos != NULL) &&
1105 ((pos->timeout.abs_value <= t->timeout.abs_value) || 1105 ((pos->timeout.abs_value_us <= t->timeout.abs_value_us) ||
1106 (pos->reason != 0))) 1106 (0 != pos->reason)))
1107 { 1107 {
1108 prev = pos; 1108 prev = pos;
1109 pos = pos->next; 1109 pos = pos->next;
diff --git a/src/util/server.c b/src/util/server.c
index b2264479a..05463e1cb 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -1032,8 +1032,8 @@ process_mst (struct GNUNET_SERVER_Client *client, int ret)
1032 if (GNUNET_OK == ret) 1032 if (GNUNET_OK == ret)
1033 { 1033 {
1034 LOG (GNUNET_ERROR_TYPE_DEBUG, 1034 LOG (GNUNET_ERROR_TYPE_DEBUG,
1035 "Server re-enters receive loop, timeout: %llu.\n", 1035 "Server re-enters receive loop, timeout: %s.\n",
1036 client->idle_timeout.rel_value); 1036 GNUNET_STRINGS_relative_time_to_string (client->idle_timeout, GNUNET_YES));
1037 client->receive_pending = GNUNET_YES; 1037 client->receive_pending = GNUNET_YES;
1038 GNUNET_CONNECTION_receive (client->connection, 1038 GNUNET_CONNECTION_receive (client->connection,
1039 GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, 1039 GNUNET_SERVER_MAX_MESSAGE_SIZE - 1,
@@ -1094,7 +1094,7 @@ process_incoming (void *cls, const void *buf, size_t available,
1094 if ((NULL == buf) && (0 == available) && (NULL == addr) && (0 == errCode) && 1094 if ((NULL == buf) && (0 == available) && (NULL == addr) && (0 == errCode) &&
1095 (GNUNET_YES != client->shutdown_now) && (NULL != server) && 1095 (GNUNET_YES != client->shutdown_now) && (NULL != server) &&
1096 (GNUNET_YES == GNUNET_CONNECTION_check (client->connection)) && 1096 (GNUNET_YES == GNUNET_CONNECTION_check (client->connection)) &&
1097 (end.abs_value > now.abs_value)) 1097 (end.abs_value_us > now.abs_value_us))
1098 { 1098 {
1099 /* wait longer, timeout changed (i.e. due to us sending) */ 1099 /* wait longer, timeout changed (i.e. due to us sending) */
1100 LOG (GNUNET_ERROR_TYPE_DEBUG, 1100 LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/util/speedup.c b/src/util/speedup.c
index 6cb8a4e05..2482decea 100644
--- a/src/util/speedup.c
+++ b/src/util/speedup.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2006, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2011-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -24,8 +24,7 @@
24 * @brief functions to speedup peer execution by manipulation system time 24 * @brief functions to speedup peer execution by manipulation system time
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_time_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_scheduler_lib.h"
29 28
30#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) 29#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
31 30
@@ -45,10 +44,11 @@ do_speedup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
45 speedup_task = GNUNET_SCHEDULER_NO_TASK; 44 speedup_task = GNUNET_SCHEDULER_NO_TASK;
46 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 45 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
47 return; 46 return;
48 current_offset += delta.rel_value; 47 current_offset += delta.rel_value_us;
49 GNUNET_TIME_set_offset (current_offset); 48 GNUNET_TIME_set_offset (current_offset);
50 LOG (GNUNET_ERROR_TYPE_DEBUG, 49 LOG (GNUNET_ERROR_TYPE_DEBUG,
51 "Speeding up execution time by %llu ms\n", delta.rel_value); 50 "Speeding up execution time by %s\n",
51 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO));
52 speedup_task = GNUNET_SCHEDULER_add_delayed (interval, &do_speedup, NULL); 52 speedup_task = GNUNET_SCHEDULER_add_delayed (interval, &do_speedup, NULL);
53} 53}
54 54
@@ -67,15 +67,18 @@ GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg)
67 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "testing", "SPEEDUP_DELTA", &delta)) 67 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "testing", "SPEEDUP_DELTA", &delta))
68 return GNUNET_SYSERR; 68 return GNUNET_SYSERR;
69 69
70 if ((0 == interval.rel_value) || (0 == delta.rel_value)) 70 if ((0 == interval.rel_value_us) || (0 == delta.rel_value_us))
71 { 71 {
72 LOG (GNUNET_ERROR_TYPE_DEBUG, 72 LOG (GNUNET_ERROR_TYPE_DEBUG,
73 "Speed up disabled\n"); 73 "Speed up disabled\n");
74 return GNUNET_OK; 74 return GNUNET_OK;
75 } 75 }
76 LOG (GNUNET_ERROR_TYPE_DEBUG, 76 LOG (GNUNET_ERROR_TYPE_DEBUG,
77 "Speed up execution time %llu ms every %llu ms\n", 77 "Speed up execution by %s\n",
78 delta.rel_value, interval.rel_value); 78 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO));
79 LOG (GNUNET_ERROR_TYPE_DEBUG,
80 "Speed up executed every %s\n",
81 GNUNET_STRINGS_relative_time_to_string (interval, GNUNET_NO));
79 speedup_task = GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, &do_speedup, NULL); 82 speedup_task = GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, &do_speedup, NULL);
80 return GNUNET_OK; 83 return GNUNET_OK;
81} 84}
@@ -92,7 +95,8 @@ GNUNET_SPEEDUP_stop_ ( )
92 GNUNET_SCHEDULER_cancel (speedup_task); 95 GNUNET_SCHEDULER_cancel (speedup_task);
93 speedup_task = GNUNET_SCHEDULER_NO_TASK; 96 speedup_task = GNUNET_SCHEDULER_NO_TASK;
94 } 97 }
95 if ((0 != interval.rel_value) && (0 != delta.rel_value)) 98 if ( (0 != interval.rel_value_us) &&
99 (0 != delta.rel_value_us) )
96 LOG (GNUNET_ERROR_TYPE_DEBUG, 100 LOG (GNUNET_ERROR_TYPE_DEBUG,
97 "Stopped execution speed up\n"); 101 "Stopped execution speed up\n");
98} 102}
diff --git a/src/util/strings.c b/src/util/strings.c
index 8bbc904bc..da02a9c4f 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2005, 2006 Christian Grothoff (and other contributing authors) 3 (C) 2005-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -300,18 +300,19 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
300{ 300{
301 static const struct ConversionTable table[] = 301 static const struct ConversionTable table[] =
302 { 302 {
303 { "ms", 1}, 303 { "us", 1},
304 { "s", 1000}, 304 { "ms", 1000 },
305 { "\"", 1000}, 305 { "s", 1000 * 1000LL },
306 { "m", 60 * 1000}, 306 { "\"", 1000 * 1000LL },
307 { "min", 60 * 1000}, 307 { "m", 60 * 1000 * 1000LL},
308 { "minutes", 60 * 1000}, 308 { "min", 60 * 1000 * 1000LL},
309 { "'", 60 * 1000}, 309 { "minutes", 60 * 1000 * 1000LL},
310 { "h", 60 * 60 * 1000}, 310 { "'", 60 * 1000 * 1000LL},
311 { "d", 24 * 60 * 60 * 1000}, 311 { "h", 60 * 60 * 1000 * 1000LL},
312 { "day", 24 * 60 * 60 * 1000}, 312 { "d", 24 * 60 * 60 * 1000LL * 1000LL},
313 { "days", 24 * 60 * 60 * 1000}, 313 { "day", 24 * 60 * 60 * 1000LL * 1000LL},
314 { "a", 31536000000LL /* year */ }, 314 { "days", 24 * 60 * 60 * 1000LL * 1000LL},
315 { "a", 31536000000000LL /* year */ },
315 { NULL, 0} 316 { NULL, 0}
316 }; 317 };
317 int ret; 318 int ret;
@@ -325,7 +326,7 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
325 ret = convert_with_table (fancy_time, 326 ret = convert_with_table (fancy_time,
326 table, 327 table,
327 &val); 328 &val);
328 rtime->rel_value = (uint64_t) val; 329 rtime->rel_value_us = (uint64_t) val;
329 return ret; 330 return ret;
330} 331}
331 332
@@ -363,9 +364,9 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
363 (NULL == strptime (fancy_time, "%Y", &tv)) ) 364 (NULL == strptime (fancy_time, "%Y", &tv)) )
364 return GNUNET_SYSERR; 365 return GNUNET_SYSERR;
365 t = mktime (&tv); 366 t = mktime (&tv);
366 atime->abs_value = (uint64_t) ((uint64_t) t * 1000LL); 367 atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL);
367#if LINUX 368#if LINUX
368 atime->abs_value -= 1000LL * timezone; 369 atime->abs_value_us -= 1000LL * 1000LL * timezone;
369#endif 370#endif
370 return GNUNET_OK; 371 return GNUNET_OK;
371} 372}
@@ -380,7 +381,10 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
380 * string is returned. 381 * string is returned.
381 */ 382 */
382char * 383char *
383GNUNET_STRINGS_conv (const char *input, size_t len, const char *input_charset, const char *output_charset) 384GNUNET_STRINGS_conv (const char *input,
385 size_t len,
386 const char *input_charset,
387 const char *output_charset)
384{ 388{
385 char *ret; 389 char *ret;
386 uint8_t *u8_string; 390 uint8_t *u8_string;
@@ -634,41 +638,48 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta,
634 int do_round) 638 int do_round)
635{ 639{
636 static char buf[128]; 640 static char buf[128];
637 const char *unit = _( /* time unit */ "ms"); 641 const char *unit = _( /* time unit */ "µs");
638 uint64_t dval = delta.rel_value; 642 uint64_t dval = delta.rel_value_us;
639 643
640 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == delta.rel_value) 644 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == delta.rel_value_us)
641 return _("forever"); 645 return _("forever");
642 if (0 == delta.rel_value) 646 if (0 == delta.rel_value_us)
643 return _("0 ms"); 647 return _("0 ms");
644 if ( ( (GNUNET_YES == do_round) && 648 if ( ( (GNUNET_YES == do_round) &&
645 (dval > 5 * 1000) ) || 649 (dval > 5 * 1000) ) ||
646 (0 == (dval % 1000) )) 650 (0 == (dval % 1000) ))
647 { 651 {
648 dval = dval / 1000; 652 dval = dval / 1000;
649 unit = _( /* time unit */ "s"); 653 unit = _( /* time unit */ "ms");
650 if ( ( (GNUNET_YES == do_round) && 654 if ( ( (GNUNET_YES == do_round) &&
651 (dval > 5 * 60) ) || 655 (dval > 5 * 1000) ) ||
652 (0 == (dval % 60) ) ) 656 (0 == (dval % 1000) ))
653 { 657 {
654 dval = dval / 60; 658 dval = dval / 1000;
655 unit = _( /* time unit */ "m"); 659 unit = _( /* time unit */ "s");
656 if ( ( (GNUNET_YES == do_round) && 660 if ( ( (GNUNET_YES == do_round) &&
657 (dval > 5 * 60) ) || 661 (dval > 5 * 60) ) ||
658 (0 == (dval % 60) )) 662 (0 == (dval % 60) ) )
659 { 663 {
660 dval = dval / 60; 664 dval = dval / 60;
661 unit = _( /* time unit */ "h"); 665 unit = _( /* time unit */ "m");
662 if ( ( (GNUNET_YES == do_round) && 666 if ( ( (GNUNET_YES == do_round) &&
663 (dval > 5 * 24) ) || 667 (dval > 5 * 60) ) ||
664 (0 == (dval % 24)) ) 668 (0 == (dval % 60) ))
665 { 669 {
666 dval = dval / 24; 670 dval = dval / 60;
667 if (1 == dval) 671 unit = _( /* time unit */ "h");
668 unit = _( /* time unit */ "day"); 672 if ( ( (GNUNET_YES == do_round) &&
669 else 673 (dval > 5 * 24) ) ||
670 unit = _( /* time unit */ "days"); 674 (0 == (dval % 24)) )
671 } 675 {
676 dval = dval / 24;
677 if (1 == dval)
678 unit = _( /* time unit */ "day");
679 else
680 unit = _( /* time unit */ "days");
681 }
682 }
672 } 683 }
673 } 684 }
674 } 685 }
@@ -693,9 +704,9 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
693 time_t tt; 704 time_t tt;
694 struct tm *tp; 705 struct tm *tp;
695 706
696 if (t.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) 707 if (t.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
697 return _("end of time"); 708 return _("end of time");
698 tt = t.abs_value / 1000; 709 tt = t.abs_value_us / 1000LL / 1000LL;
699 tp = gmtime (&tt); 710 tp = gmtime (&tt);
700 strftime (buf, sizeof (buf), "%a %b %d %H:%M:%S %Y", tp); 711 strftime (buf, sizeof (buf), "%a %b %d %H:%M:%S %Y", tp);
701 return buf; 712 return buf;
diff --git a/src/util/test_common_logging_dummy.c b/src/util/test_common_logging_dummy.c
index a1f479976..a360d5dee 100644
--- a/src/util/test_common_logging_dummy.c
+++ b/src/util/test_common_logging_dummy.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2008 Christian Grothoff (and other contributing authors) 3 (C) 2008-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -59,7 +59,7 @@ expensive_func ()
59 GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\ 59 GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\
60 t2 = GNUNET_TIME_absolute_get ();\ 60 t2 = GNUNET_TIME_absolute_get ();\
61 printf ("1%s %llu\n", lvl,\ 61 printf ("1%s %llu\n", lvl,\
62 (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value); \ 62 (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value_us); \
63} 63}
64 64
65#define pr2(kind,lvl) {\ 65#define pr2(kind,lvl) {\
@@ -68,7 +68,7 @@ expensive_func ()
68 GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\ 68 GNUNET_log (kind, "L%s %d\n", lvl, expensive_func());\
69 t2 = GNUNET_TIME_absolute_get ();\ 69 t2 = GNUNET_TIME_absolute_get ();\
70 printf ("2%s %llu\n", lvl,\ 70 printf ("2%s %llu\n", lvl,\
71 (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value); \ 71 (unsigned long long) GNUNET_TIME_absolute_get_difference (t1, t2).rel_value_us); \
72} 72}
73 73
74int 74int
diff --git a/src/util/test_crypto_ecc.c b/src/util/test_crypto_ecc.c
index 00d264e0f..bb5fb002f 100644
--- a/src/util/test_crypto_ecc.c
+++ b/src/util/test_crypto_ecc.c
@@ -166,9 +166,9 @@ testSignPerformance ()
166 continue; 166 continue;
167 } 167 }
168 } 168 }
169 printf ("%d ECC sign operations %llu ms\n", ITER, 169 printf ("%d ECC sign operations %s\n", ITER,
170 (unsigned long long) 170 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
171 GNUNET_TIME_absolute_get_duration (start).rel_value); 171 GNUNET_YES));
172 return ok; 172 return ok;
173} 173}
174#endif 174#endif
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c
index 132066979..ce96213c7 100644
--- a/src/util/test_scheduler_delay.c
+++ b/src/util/test_scheduler_delay.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other contributing authors) 3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -20,13 +20,11 @@
20/** 20/**
21 * @file util/test_scheduler_delay.c 21 * @file util/test_scheduler_delay.c
22 * @brief testcase for delay of scheduler, measures how 22 * @brief testcase for delay of scheduler, measures how
23 * precise the timers are. Expect values between 10 and 20 ms on 23 * precise the timers are. Expect values between 0.2 and 2 ms on
24 * modern machines. 24 * modern machines.
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_common.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_scheduler_lib.h"
29#include "gnunet_time_lib.h"
30 28
31static struct GNUNET_TIME_Absolute target; 29static struct GNUNET_TIME_Absolute target;
32 30
@@ -36,7 +34,8 @@ static unsigned long long cumDelta;
36 34
37#define INCR 47 35#define INCR 47
38 36
39#define MAXV 1500 37#define MAXV 5000
38
40 39
41/** 40/**
42 * Signature of the main function of a task. 41 * Signature of the main function of a task.
@@ -45,18 +44,19 @@ static unsigned long long cumDelta;
45 * @param tc context 44 * @param tc context
46 */ 45 */
47static void 46static void
48test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 47test_task (void *cls,
48 const struct GNUNET_SCHEDULER_TaskContext *tc)
49{ 49{
50 struct GNUNET_TIME_Absolute now; 50 struct GNUNET_TIME_Absolute now;
51 51
52 now = GNUNET_TIME_absolute_get (); 52 now = GNUNET_TIME_absolute_get ();
53 if (now.abs_value > target.abs_value) 53 if (now.abs_value_us > target.abs_value_us)
54 cumDelta += (now.abs_value - target.abs_value); 54 cumDelta += (now.abs_value_us - target.abs_value_us);
55 else 55 else
56 cumDelta += (target.abs_value - now.abs_value); 56 cumDelta += (target.abs_value_us - now.abs_value_us);
57 target = 57 target =
58 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply 58 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
59 (GNUNET_TIME_UNIT_MILLISECONDS, i)); 59 (GNUNET_TIME_UNIT_MICROSECONDS, i));
60 FPRINTF (stderr, "%s", "."); 60 FPRINTF (stderr, "%s", ".");
61 if (i > MAXV) 61 if (i > MAXV)
62 { 62 {
@@ -64,7 +64,7 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
64 return; 64 return;
65 } 65 }
66 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 66 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
67 (GNUNET_TIME_UNIT_MILLISECONDS, i), &test_task, 67 (GNUNET_TIME_UNIT_MICROSECONDS, i), &test_task,
68 NULL); 68 NULL);
69 i += INCR; 69 i += INCR;
70} 70}
@@ -76,13 +76,14 @@ main (int argc, char *argv[])
76 GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL); 76 GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL);
77 target = GNUNET_TIME_absolute_get (); 77 target = GNUNET_TIME_absolute_get ();
78 GNUNET_SCHEDULER_run (&test_task, NULL); 78 GNUNET_SCHEDULER_run (&test_task, NULL);
79 FPRINTF (stdout, "Sleep precision: %llu ms. ", 79 FPRINTF (stdout,
80 cumDelta / 1000 / (MAXV / INCR)); 80 "Sleep precision: %llu microseconds (average delta). ",
81 if (cumDelta <= 10 * MAXV / INCR) 81 cumDelta / (MAXV / INCR));
82 if (cumDelta <= 500 * MAXV / INCR)
82 FPRINTF (stdout, "%s", "Timer precision is excellent.\n"); 83 FPRINTF (stdout, "%s", "Timer precision is excellent.\n");
83 else if (cumDelta <= 50 * MAXV / INCR) /* 50 ms average deviation */ 84 else if (cumDelta <= 5000 * MAXV / INCR) /* 5 ms average deviation */
84 FPRINTF (stdout, "%s", "Timer precision is good.\n"); 85 FPRINTF (stdout, "%s", "Timer precision is good.\n");
85 else if (cumDelta > 250 * MAXV / INCR) 86 else if (cumDelta > 25000 * MAXV / INCR)
86 FPRINTF (stdout, "%s", "Timer precision is awful.\n"); 87 FPRINTF (stdout, "%s", "Timer precision is awful.\n");
87 else 88 else
88 FPRINTF (stdout, "%s", "Timer precision is acceptable.\n"); 89 FPRINTF (stdout, "%s", "Timer precision is acceptable.\n");
diff --git a/src/util/test_speedup.c b/src/util/test_speedup.c
index 03cffbd54..a2e6bb29c 100644
--- a/src/util/test_speedup.c
+++ b/src/util/test_speedup.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2011-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -22,10 +22,7 @@
22 * @brief testcase for speedup.c 22 * @brief testcase for speedup.c
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_common.h" 25#include "gnunet_util_lib.h"
26#include "gnunet_program_lib.h"
27#include "gnunet_time_lib.h"
28#include "gnunet_strings_lib.h"
29 26
30/** 27/**
31 * Start time of the testcase 28 * Start time of the testcase
@@ -100,19 +97,23 @@ main (int argc, char *argv[])
100 "nohelp", options, &check, NULL); 97 "nohelp", options, &check, NULL);
101 98
102 end_real = time (NULL); 99 end_real = time (NULL);
103 delta = GNUNET_TIME_absolute_get_difference(start, end); 100 delta = GNUNET_TIME_absolute_get_difference (start, end);
104 101
105 if (delta.rel_value > ((end_real - start_real) * 1500LL)) 102 if (delta.rel_value_us > ((end_real - start_real) * 1500LL * 1000LL))
106 { 103 {
107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution time in GNUnet time: %llu ms\n", 104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
108 (unsigned long long) delta.rel_value); 105 "Execution time in GNUnet time: %s\n",
109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution time in system time: %llu ms\n", 106 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
108 "Execution time in system time: %llu ms\n",
110 (unsigned long long) ((end_real - start_real) * 1000LL)); 109 (unsigned long long) ((end_real - start_real) * 1000LL));
111 return 0; 110 return 0;
112 } 111 }
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Execution time in GNUnet time: %llu ms\n", 112 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
114 (unsigned long long) delta.rel_value); 113 "Execution time in GNUnet time: %s\n",
115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Execution time in system time: %llu ms\n", 114 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
116 "Execution time in system time: %llu ms\n",
116 (unsigned long long) ((end_real - start_real) * 1000LL)); 117 (unsigned long long) ((end_real - start_real) * 1000LL));
117 return 1; 118 return 1;
118} 119}
diff --git a/src/util/test_strings.c b/src/util/test_strings.c
index e5247ad91..e0c3cfebf 100644
--- a/src/util/test_strings.c
+++ b/src/util/test_strings.c
@@ -87,7 +87,7 @@ main (int argc, char *argv[])
87 WANT ("btx", b); 87 WANT ("btx", b);
88 if (0 != GNUNET_STRINGS_buffer_tokenize (buf, 2, 2, &r, &b)) 88 if (0 != GNUNET_STRINGS_buffer_tokenize (buf, 2, 2, &r, &b))
89 return 1; 89 return 1;
90 at.abs_value = 5000; 90 at.abs_value_us = 5000000;
91 bc = GNUNET_STRINGS_absolute_time_to_string (at); 91 bc = GNUNET_STRINGS_absolute_time_to_string (at);
92 /* bc should be something like "Wed Dec 31 17:00:05 1969" 92 /* bc should be something like "Wed Dec 31 17:00:05 1969"
93 * where the details of the day and hour depend on the timezone; 93 * where the details of the day and hour depend on the timezone;
@@ -105,7 +105,7 @@ main (int argc, char *argv[])
105 bc = GNUNET_STRINGS_absolute_time_to_string (at); 105 bc = GNUNET_STRINGS_absolute_time_to_string (at);
106 GNUNET_assert (GNUNET_OK == 106 GNUNET_assert (GNUNET_OK ==
107 GNUNET_STRINGS_fancy_time_to_absolute (bc, &atx)); 107 GNUNET_STRINGS_fancy_time_to_absolute (bc, &atx));
108 GNUNET_assert (atx.abs_value == at.abs_value); 108 GNUNET_assert (atx.abs_value_us == at.abs_value_us);
109 109
110 GNUNET_log_skip (2, GNUNET_NO); 110 GNUNET_log_skip (2, GNUNET_NO);
111 b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "unknown"); 111 b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "unknown");
@@ -116,7 +116,7 @@ main (int argc, char *argv[])
116 GNUNET_STRINGS_fancy_time_to_relative ("15m", &rt)); 116 GNUNET_STRINGS_fancy_time_to_relative ("15m", &rt));
117 GNUNET_assert (GNUNET_OK == 117 GNUNET_assert (GNUNET_OK ==
118 GNUNET_STRINGS_fancy_time_to_relative ("15 m", &rtx)); 118 GNUNET_STRINGS_fancy_time_to_relative ("15 m", &rtx));
119 GNUNET_assert (rt.rel_value == rtx.rel_value); 119 GNUNET_assert (rt.rel_value_us == rtx.rel_value_us);
120 120
121 return 0; 121 return 0;
122} 122}
diff --git a/src/util/test_time.c b/src/util/test_time.c
index cd1175416..467336e0a 100644
--- a/src/util/test_time.c
+++ b/src/util/test_time.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -22,8 +22,7 @@
22 * @brief testcase for time.c 22 * @brief testcase for time.c
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_common.h" 25#include "gnunet_util_lib.h"
26#include "gnunet_time_lib.h"
27 26
28 27
29int 28int
@@ -46,186 +45,186 @@ main (int argc, char *argv[])
46 forever = GNUNET_TIME_UNIT_FOREVER_ABS; 45 forever = GNUNET_TIME_UNIT_FOREVER_ABS;
47 relForever = GNUNET_TIME_UNIT_FOREVER_REL; 46 relForever = GNUNET_TIME_UNIT_FOREVER_REL;
48 relUnit = GNUNET_TIME_UNIT_MILLISECONDS; 47 relUnit = GNUNET_TIME_UNIT_MILLISECONDS;
49 zero.abs_value = 0; 48 zero.abs_value_us = 0;
50 49
51 last = now = GNUNET_TIME_absolute_get (); 50 last = now = GNUNET_TIME_absolute_get ();
52 while (now.abs_value == last.abs_value) 51 while (now.abs_value_us == last.abs_value_us)
53 now = GNUNET_TIME_absolute_get (); 52 now = GNUNET_TIME_absolute_get ();
54 GNUNET_assert (now.abs_value > last.abs_value); 53 GNUNET_assert (now.abs_value_us > last.abs_value_us);
55 54
56 /* test overflow checking in multiply */ 55 /* test overflow checking in multiply */
57 rel = GNUNET_TIME_UNIT_SECONDS; 56 rel = GNUNET_TIME_UNIT_MILLISECONDS;
58 GNUNET_log_skip (1, GNUNET_NO); 57 GNUNET_log_skip (1, GNUNET_NO);
59 for (i = 0; i < 55; i++) 58 for (i = 0; i < 55; i++)
60 rel = GNUNET_TIME_relative_multiply (rel, 2); 59 rel = GNUNET_TIME_relative_multiply (rel, 2);
61 GNUNET_log_skip (0, GNUNET_NO); 60 GNUNET_log_skip (0, GNUNET_NO);
62 GNUNET_assert (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value); 61 GNUNET_assert (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us);
63 /*check zero */ 62 /*check zero */
64 rel.rel_value = (UINT64_MAX) - 1024; 63 rel.rel_value_us = (UINT64_MAX) - 1024;
65 GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value == 64 GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us ==
66 GNUNET_TIME_relative_multiply (rel, 0).rel_value); 65 GNUNET_TIME_relative_multiply (rel, 0).rel_value_us);
67 66
68 /* test infinity-check for relative to absolute */ 67 /* test infinity-check for relative to absolute */
69 GNUNET_log_skip (1, GNUNET_NO); 68 GNUNET_log_skip (1, GNUNET_NO);
70 last = GNUNET_TIME_relative_to_absolute (rel); 69 last = GNUNET_TIME_relative_to_absolute (rel);
71 GNUNET_assert (last.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value); 70 GNUNET_assert (last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us);
72 GNUNET_log_skip (0, GNUNET_YES); 71 GNUNET_log_skip (0, GNUNET_YES);
73 72
74 /*check relative to absolute */ 73 /*check relative to absolute */
75 rel.rel_value = 0; 74 rel.rel_value_us = 0;
76 GNUNET_assert (GNUNET_TIME_absolute_get ().abs_value == 75 GNUNET_assert (GNUNET_TIME_absolute_get ().abs_value_us ==
77 GNUNET_TIME_relative_to_absolute (rel).abs_value); 76 GNUNET_TIME_relative_to_absolute (rel).abs_value_us);
78 /*check forever */ 77 /*check forever */
79 rel.rel_value = UINT64_MAX; 78 rel.rel_value_us = UINT64_MAX;
80 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value == 79 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us ==
81 GNUNET_TIME_relative_to_absolute (rel).abs_value); 80 GNUNET_TIME_relative_to_absolute (rel).abs_value_us);
82 /* check overflow for r2a */ 81 /* check overflow for r2a */
83 rel.rel_value = (UINT64_MAX) - 1024; 82 rel.rel_value_us = (UINT64_MAX) - 1024;
84 GNUNET_log_skip (1, GNUNET_NO); 83 GNUNET_log_skip (1, GNUNET_NO);
85 last = GNUNET_TIME_relative_to_absolute (rel); 84 last = GNUNET_TIME_relative_to_absolute (rel);
86 GNUNET_log_skip (0, GNUNET_NO); 85 GNUNET_log_skip (0, GNUNET_NO);
87 GNUNET_assert (last.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value); 86 GNUNET_assert (last.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us);
88 87
89 /* check overflow for relative add */ 88 /* check overflow for relative add */
90 GNUNET_log_skip (1, GNUNET_NO); 89 GNUNET_log_skip (1, GNUNET_NO);
91 rel = GNUNET_TIME_relative_add (rel, rel); 90 rel = GNUNET_TIME_relative_add (rel, rel);
92 GNUNET_log_skip (0, GNUNET_NO); 91 GNUNET_log_skip (0, GNUNET_NO);
93 GNUNET_assert (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value); 92 GNUNET_assert (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us);
94 93
95 GNUNET_log_skip (1, GNUNET_NO); 94 GNUNET_log_skip (1, GNUNET_NO);
96 rel = GNUNET_TIME_relative_add (relForever, relForever); 95 rel = GNUNET_TIME_relative_add (relForever, relForever);
97 GNUNET_log_skip (0, GNUNET_NO); 96 GNUNET_log_skip (0, GNUNET_NO);
98 GNUNET_assert (rel.rel_value == relForever.rel_value); 97 GNUNET_assert (rel.rel_value_us == relForever.rel_value_us);
99 98
100 GNUNET_log_skip (1, GNUNET_NO); 99 GNUNET_log_skip (1, GNUNET_NO);
101 rel = GNUNET_TIME_relative_add (relUnit, relUnit); 100 rel = GNUNET_TIME_relative_add (relUnit, relUnit);
102 GNUNET_assert (rel.rel_value == 2 * relUnit.rel_value); 101 GNUNET_assert (rel.rel_value_us == 2 * relUnit.rel_value_us);
103 102
104 /* check relation check in get_duration */ 103 /* check relation check in get_duration */
105 future.abs_value = now.abs_value + 1000000; 104 future.abs_value_us = now.abs_value_us + 1000000;
106 GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).rel_value == 105 GNUNET_assert (GNUNET_TIME_absolute_get_difference (now, future).rel_value_us ==
107 1000000); 106 1000000);
108 GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value == 107 GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value_us ==
109 0); 108 0);
110 109
111 GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value 110 GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value_us
112 == forever.abs_value); 111 == forever.abs_value_us);
113 112
114 past.abs_value = now.abs_value - 1000000; 113 past.abs_value_us = now.abs_value_us - 1000000;
115 rel = GNUNET_TIME_absolute_get_duration (future); 114 rel = GNUNET_TIME_absolute_get_duration (future);
116 GNUNET_assert (rel.rel_value == 0); 115 GNUNET_assert (rel.rel_value_us == 0);
117 rel = GNUNET_TIME_absolute_get_duration (past); 116 rel = GNUNET_TIME_absolute_get_duration (past);
118 GNUNET_assert (rel.rel_value >= 1000000); 117 GNUNET_assert (rel.rel_value_us >= 1000000);
119 118
120 /* check get remaining */ 119 /* check get remaining */
121 rel = GNUNET_TIME_absolute_get_remaining (now); 120 rel = GNUNET_TIME_absolute_get_remaining (now);
122 GNUNET_assert (rel.rel_value == 0); 121 GNUNET_assert (rel.rel_value_us == 0);
123 rel = GNUNET_TIME_absolute_get_remaining (past); 122 rel = GNUNET_TIME_absolute_get_remaining (past);
124 GNUNET_assert (rel.rel_value == 0); 123 GNUNET_assert (rel.rel_value_us == 0);
125 rel = GNUNET_TIME_absolute_get_remaining (future); 124 rel = GNUNET_TIME_absolute_get_remaining (future);
126 GNUNET_assert (rel.rel_value > 0); 125 GNUNET_assert (rel.rel_value_us > 0);
127 GNUNET_assert (rel.rel_value <= 1000000); 126 GNUNET_assert (rel.rel_value_us <= 1000000);
128 forever = GNUNET_TIME_UNIT_FOREVER_ABS; 127 forever = GNUNET_TIME_UNIT_FOREVER_ABS;
129 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == 128 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
130 GNUNET_TIME_absolute_get_remaining (forever).rel_value); 129 GNUNET_TIME_absolute_get_remaining (forever).rel_value_us);
131 130
132 /* check endianess */ 131 /* check endianess */
133 reln = GNUNET_TIME_relative_hton (rel); 132 reln = GNUNET_TIME_relative_hton (rel);
134 GNUNET_assert (rel.rel_value == GNUNET_TIME_relative_ntoh (reln).rel_value); 133 GNUNET_assert (rel.rel_value_us == GNUNET_TIME_relative_ntoh (reln).rel_value_us);
135 nown = GNUNET_TIME_absolute_hton (now); 134 nown = GNUNET_TIME_absolute_hton (now);
136 GNUNET_assert (now.abs_value == GNUNET_TIME_absolute_ntoh (nown).abs_value); 135 GNUNET_assert (now.abs_value_us == GNUNET_TIME_absolute_ntoh (nown).abs_value_us);
137 136
138 /* check absolute addition */ 137 /* check absolute addition */
139 future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS); 138 future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_SECONDS);
140 GNUNET_assert (future.abs_value == now.abs_value + 1000); 139 GNUNET_assert (future.abs_value_us == now.abs_value_us + 1000 * 1000LL);
141 140
142 future = GNUNET_TIME_absolute_add (forever, GNUNET_TIME_UNIT_ZERO); 141 future = GNUNET_TIME_absolute_add (forever, GNUNET_TIME_UNIT_ZERO);
143 GNUNET_assert (future.abs_value == forever.abs_value); 142 GNUNET_assert (future.abs_value_us == forever.abs_value_us);
144 143
145 rel.rel_value = (UINT64_MAX) - 1024; 144 rel.rel_value_us = (UINT64_MAX) - 1024;
146 now.abs_value = rel.rel_value; 145 now.abs_value_us = rel.rel_value_us;
147 future = GNUNET_TIME_absolute_add (now, rel); 146 future = GNUNET_TIME_absolute_add (now, rel);
148 GNUNET_assert (future.abs_value == forever.abs_value); 147 GNUNET_assert (future.abs_value_us == forever.abs_value_us);
149 148
150 /* check zero */ 149 /* check zero */
151 future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO); 150 future = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_ZERO);
152 GNUNET_assert (future.abs_value == now.abs_value); 151 GNUNET_assert (future.abs_value_us == now.abs_value_us);
153 152
154 GNUNET_assert (forever.abs_value == 153 GNUNET_assert (forever.abs_value_us ==
155 GNUNET_TIME_absolute_subtract (forever, 154 GNUNET_TIME_absolute_subtract (forever,
156 GNUNET_TIME_UNIT_MINUTES).abs_value); 155 GNUNET_TIME_UNIT_MINUTES).abs_value_us);
157 /*check absolute subtract */ 156 /*check absolute subtract */
158 now.abs_value = 50000; 157 now.abs_value_us = 50000;
159 rel.rel_value = 100000; 158 rel.rel_value_us = 100000;
160 GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value == 159 GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us ==
161 (GNUNET_TIME_absolute_subtract (now, rel)).abs_value); 160 (GNUNET_TIME_absolute_subtract (now, rel)).abs_value_us);
162 rel.rel_value = 10000; 161 rel.rel_value_us = 10000;
163 GNUNET_assert (40000 == (GNUNET_TIME_absolute_subtract (now, rel)).abs_value); 162 GNUNET_assert (40000 == (GNUNET_TIME_absolute_subtract (now, rel)).abs_value_us);
164 163
165 /*check relative divide */ 164 /*check relative divide */
166 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == 165 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
167 (GNUNET_TIME_relative_divide (rel, 0)).rel_value); 166 (GNUNET_TIME_relative_divide (rel, 0)).rel_value_us);
168 167
169 rel = GNUNET_TIME_UNIT_FOREVER_REL; 168 rel = GNUNET_TIME_UNIT_FOREVER_REL;
170 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == 169 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
171 (GNUNET_TIME_relative_divide (rel, 2)).rel_value); 170 (GNUNET_TIME_relative_divide (rel, 2)).rel_value_us);
172 171
173 rel = GNUNET_TIME_relative_divide (relUnit, 2); 172 rel = GNUNET_TIME_relative_divide (relUnit, 2);
174 GNUNET_assert (rel.rel_value == relUnit.rel_value / 2); 173 GNUNET_assert (rel.rel_value_us == relUnit.rel_value_us / 2);
175 174
176 175
177 /* check Return absolute time of 0ms */ 176 /* check Return absolute time of 0ms */
178 zero = GNUNET_TIME_UNIT_ZERO_ABS; 177 zero = GNUNET_TIME_UNIT_ZERO_ABS;
179 178
180 /* check GNUNET_TIME_calculate_eta */ 179 /* check GNUNET_TIME_calculate_eta */
181 last.abs_value = GNUNET_TIME_absolute_get ().abs_value - 1024; 180 last.abs_value_us = GNUNET_TIME_absolute_get ().abs_value_us - 1024;
182 forever = GNUNET_TIME_UNIT_FOREVER_ABS; 181 forever = GNUNET_TIME_UNIT_FOREVER_ABS;
183 forever.abs_value = forever.abs_value - 1024; 182 forever.abs_value_us = forever.abs_value_us - 1024;
184 GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value == 183 GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us ==
185 GNUNET_TIME_calculate_eta (forever, 50000, 100000).rel_value); 184 GNUNET_TIME_calculate_eta (forever, 50000, 100000).rel_value_us);
186 /* check zero */ 185 /* check zero */
187 GNUNET_log_skip (1, GNUNET_NO); 186 GNUNET_log_skip (1, GNUNET_NO);
188 GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value == 187 GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us ==
189 (GNUNET_TIME_calculate_eta (last, 60000, 50000)).rel_value); 188 (GNUNET_TIME_calculate_eta (last, 60000, 50000)).rel_value_us);
190 GNUNET_log_skip (0, GNUNET_YES); 189 GNUNET_log_skip (0, GNUNET_YES);
191 /*check forever */ 190 /*check forever */
192 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == 191 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
193 (GNUNET_TIME_calculate_eta (last, 0, 50000)).rel_value); 192 (GNUNET_TIME_calculate_eta (last, 0, 50000)).rel_value_us);
194 193
195 /*check relative subtract */ 194 /*check relative subtract */
196 now = GNUNET_TIME_absolute_get (); 195 now = GNUNET_TIME_absolute_get ();
197 rel.rel_value = now.abs_value; 196 rel.rel_value_us = now.abs_value_us;
198 relForever.rel_value = rel.rel_value + 1024; 197 relForever.rel_value_us = rel.rel_value_us + 1024;
199 GNUNET_assert (1024 == 198 GNUNET_assert (1024 ==
200 GNUNET_TIME_relative_subtract (relForever, rel).rel_value); 199 GNUNET_TIME_relative_subtract (relForever, rel).rel_value_us);
201 /*check zero */ 200 /*check zero */
202 GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value == 201 GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value_us ==
203 GNUNET_TIME_relative_subtract (rel, relForever).rel_value); 202 GNUNET_TIME_relative_subtract (rel, relForever).rel_value_us);
204 /*check forever */ 203 /*check forever */
205 rel.rel_value = UINT64_MAX; 204 rel.rel_value_us = UINT64_MAX;
206 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == 205 GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us ==
207 GNUNET_TIME_relative_subtract (rel, relForever).rel_value); 206 GNUNET_TIME_relative_subtract (rel, relForever).rel_value_us);
208 207
209 /*check GNUNET_TIME_relative_min */ 208 /*check GNUNET_TIME_relative_min */
210 now = GNUNET_TIME_absolute_get (); 209 now = GNUNET_TIME_absolute_get ();
211 rel.rel_value = now.abs_value; 210 rel.rel_value_us = now.abs_value_us;
212 relForever.rel_value = rel.rel_value - 1024; 211 relForever.rel_value_us = rel.rel_value_us - 1024;
213 GNUNET_assert (relForever.rel_value == 212 GNUNET_assert (relForever.rel_value_us ==
214 GNUNET_TIME_relative_min (rel, relForever).rel_value); 213 GNUNET_TIME_relative_min (rel, relForever).rel_value_us);
215 214
216 /*check GNUNET_TIME_relative_max */ 215 /*check GNUNET_TIME_relative_max */
217 GNUNET_assert (rel.rel_value == 216 GNUNET_assert (rel.rel_value_us ==
218 GNUNET_TIME_relative_max (rel, relForever).rel_value); 217 GNUNET_TIME_relative_max (rel, relForever).rel_value_us);
219 218
220 /*check GNUNET_TIME_absolute_min */ 219 /*check GNUNET_TIME_absolute_min */
221 now = GNUNET_TIME_absolute_get (); 220 now = GNUNET_TIME_absolute_get ();
222 last.abs_value = now.abs_value - 1024; 221 last.abs_value_us = now.abs_value_us - 1024;
223 GNUNET_assert (last.abs_value == 222 GNUNET_assert (last.abs_value_us ==
224 GNUNET_TIME_absolute_min (now, last).abs_value); 223 GNUNET_TIME_absolute_min (now, last).abs_value_us);
225 224
226 /*check GNUNET_TIME_absolute_max */ 225 /*check GNUNET_TIME_absolute_max */
227 GNUNET_assert (now.abs_value == 226 GNUNET_assert (now.abs_value_us ==
228 GNUNET_TIME_absolute_max (now, last).abs_value); 227 GNUNET_TIME_absolute_max (now, last).abs_value_us);
229 228
230 return 0; 229 return 0;
231} 230}
diff --git a/src/util/time.c b/src/util/time.c
index 825b7f8ca..5e9a01b09 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -1,10 +1,10 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2006, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -70,9 +70,9 @@ GNUNET_TIME_absolute_get ()
70 struct timeval tv; 70 struct timeval tv;
71 71
72 GETTIMEOFDAY (&tv, NULL); 72 GETTIMEOFDAY (&tv, NULL);
73 ret.abs_value = 73 ret.abs_value_us =
74 (uint64_t) (((uint64_t) tv.tv_sec * 1000LL) + 74 (uint64_t) (((uint64_t) tv.tv_sec * 1000LL * 1000LL) +
75 ((uint64_t) tv.tv_usec / 1000LL)) + timestamp_offset; 75 ((uint64_t) tv.tv_usec)) + timestamp_offset;
76 return ret; 76 return ret;
77} 77}
78 78
@@ -102,7 +102,7 @@ GNUNET_TIME_absolute_get_zero_ ()
102 102
103 103
104/** 104/**
105 * Return relative time of 1ms. 105 * Return relative time of 1us.
106 */ 106 */
107struct GNUNET_TIME_Relative 107struct GNUNET_TIME_Relative
108GNUNET_TIME_relative_get_unit_ () 108GNUNET_TIME_relative_get_unit_ ()
@@ -113,12 +113,23 @@ GNUNET_TIME_relative_get_unit_ ()
113 113
114 114
115/** 115/**
116 * Return relative time of 1ms.
117 */
118struct GNUNET_TIME_Relative
119GNUNET_TIME_relative_get_millisecond_ ()
120{
121 static struct GNUNET_TIME_Relative one = { 1000 };
122 return one;
123}
124
125
126/**
116 * Return relative time of 1s. 127 * Return relative time of 1s.
117 */ 128 */
118struct GNUNET_TIME_Relative 129struct GNUNET_TIME_Relative
119GNUNET_TIME_relative_get_second_ () 130GNUNET_TIME_relative_get_second_ ()
120{ 131{
121 static struct GNUNET_TIME_Relative one = { 1000 }; 132 static struct GNUNET_TIME_Relative one = { 1000 * 1000LL };
122 return one; 133 return one;
123} 134}
124 135
@@ -129,7 +140,7 @@ GNUNET_TIME_relative_get_second_ ()
129struct GNUNET_TIME_Relative 140struct GNUNET_TIME_Relative
130GNUNET_TIME_relative_get_minute_ () 141GNUNET_TIME_relative_get_minute_ ()
131{ 142{
132 static struct GNUNET_TIME_Relative one = { 60 * 1000 }; 143 static struct GNUNET_TIME_Relative one = { 60 * 1000 * 1000LL };
133 return one; 144 return one;
134} 145}
135 146
@@ -140,7 +151,7 @@ GNUNET_TIME_relative_get_minute_ ()
140struct GNUNET_TIME_Relative 151struct GNUNET_TIME_Relative
141GNUNET_TIME_relative_get_hour_ () 152GNUNET_TIME_relative_get_hour_ ()
142{ 153{
143 static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 }; 154 static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 * 1000LL };
144 return one; 155 return one;
145} 156}
146 157
@@ -176,16 +187,16 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
176{ 187{
177 struct GNUNET_TIME_Absolute ret; 188 struct GNUNET_TIME_Absolute ret;
178 189
179 if (rel.rel_value == UINT64_MAX) 190 if (rel.rel_value_us == UINT64_MAX)
180 return GNUNET_TIME_UNIT_FOREVER_ABS; 191 return GNUNET_TIME_UNIT_FOREVER_ABS;
181 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 192 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
182 193
183 if (rel.rel_value + now.abs_value < rel.rel_value) 194 if (rel.rel_value_us + now.abs_value_us < rel.rel_value_us)
184 { 195 {
185 GNUNET_break (0); /* overflow... */ 196 GNUNET_break (0); /* overflow... */
186 return GNUNET_TIME_UNIT_FOREVER_ABS; 197 return GNUNET_TIME_UNIT_FOREVER_ABS;
187 } 198 }
188 ret.abs_value = rel.rel_value + now.abs_value; 199 ret.abs_value_us = rel.rel_value_us + now.abs_value_us;
189 return ret; 200 return ret;
190} 201}
191 202
@@ -201,7 +212,7 @@ struct GNUNET_TIME_Relative
201GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, 212GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1,
202 struct GNUNET_TIME_Relative t2) 213 struct GNUNET_TIME_Relative t2)
203{ 214{
204 return (t1.rel_value < t2.rel_value) ? t1 : t2; 215 return (t1.rel_value_us < t2.rel_value_us) ? t1 : t2;
205} 216}
206 217
207 218
@@ -216,7 +227,7 @@ struct GNUNET_TIME_Relative
216GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, 227GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1,
217 struct GNUNET_TIME_Relative t2) 228 struct GNUNET_TIME_Relative t2)
218{ 229{
219 return (t1.rel_value > t2.rel_value) ? t1 : t2; 230 return (t1.rel_value_us > t2.rel_value_us) ? t1 : t2;
220} 231}
221 232
222 233
@@ -232,7 +243,7 @@ struct GNUNET_TIME_Absolute
232GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, 243GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1,
233 struct GNUNET_TIME_Absolute t2) 244 struct GNUNET_TIME_Absolute t2)
234{ 245{
235 return (t1.abs_value < t2.abs_value) ? t1 : t2; 246 return (t1.abs_value_us < t2.abs_value_us) ? t1 : t2;
236} 247}
237 248
238 249
@@ -247,7 +258,7 @@ struct GNUNET_TIME_Absolute
247GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, 258GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1,
248 struct GNUNET_TIME_Absolute t2) 259 struct GNUNET_TIME_Absolute t2)
249{ 260{
250 return (t1.abs_value > t2.abs_value) ? t1 : t2; 261 return (t1.abs_value_us > t2.abs_value_us) ? t1 : t2;
251} 262}
252 263
253 264
@@ -262,13 +273,13 @@ GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future)
262{ 273{
263 struct GNUNET_TIME_Relative ret; 274 struct GNUNET_TIME_Relative ret;
264 275
265 if (future.abs_value == UINT64_MAX) 276 if (future.abs_value_us == UINT64_MAX)
266 return GNUNET_TIME_UNIT_FOREVER_REL; 277 return GNUNET_TIME_UNIT_FOREVER_REL;
267 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 278 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
268 279
269 if (now.abs_value > future.abs_value) 280 if (now.abs_value_us > future.abs_value_us)
270 return GNUNET_TIME_UNIT_ZERO; 281 return GNUNET_TIME_UNIT_ZERO;
271 ret.rel_value = future.abs_value - now.abs_value; 282 ret.rel_value_us = future.abs_value_us - now.abs_value_us;
272 return ret; 283 return ret;
273} 284}
274 285
@@ -285,11 +296,11 @@ GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start,
285{ 296{
286 struct GNUNET_TIME_Relative ret; 297 struct GNUNET_TIME_Relative ret;
287 298
288 if (end.abs_value == UINT64_MAX) 299 if (end.abs_value_us == UINT64_MAX)
289 return GNUNET_TIME_UNIT_FOREVER_REL; 300 return GNUNET_TIME_UNIT_FOREVER_REL;
290 if (end.abs_value < start.abs_value) 301 if (end.abs_value_us < start.abs_value_us)
291 return GNUNET_TIME_UNIT_ZERO; 302 return GNUNET_TIME_UNIT_ZERO;
292 ret.rel_value = end.abs_value - start.abs_value; 303 ret.rel_value_us = end.abs_value_us - start.abs_value_us;
293 return ret; 304 return ret;
294} 305}
295 306
@@ -306,10 +317,10 @@ GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute whence)
306 struct GNUNET_TIME_Relative ret; 317 struct GNUNET_TIME_Relative ret;
307 318
308 now = GNUNET_TIME_absolute_get (); 319 now = GNUNET_TIME_absolute_get ();
309 GNUNET_assert (whence.abs_value != UINT64_MAX); 320 GNUNET_assert (whence.abs_value_us != UINT64_MAX);
310 if (whence.abs_value > now.abs_value) 321 if (whence.abs_value_us > now.abs_value_us)
311 return GNUNET_TIME_UNIT_ZERO; 322 return GNUNET_TIME_UNIT_ZERO;
312 ret.rel_value = now.abs_value - whence.abs_value; 323 ret.rel_value_us = now.abs_value_us - whence.abs_value_us;
313 return ret; 324 return ret;
314} 325}
315 326
@@ -326,14 +337,14 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start,
326{ 337{
327 struct GNUNET_TIME_Absolute ret; 338 struct GNUNET_TIME_Absolute ret;
328 339
329 if ((start.abs_value == UINT64_MAX) || (duration.rel_value == UINT64_MAX)) 340 if ((start.abs_value_us == UINT64_MAX) || (duration.rel_value_us == UINT64_MAX))
330 return GNUNET_TIME_UNIT_FOREVER_ABS; 341 return GNUNET_TIME_UNIT_FOREVER_ABS;
331 if (start.abs_value + duration.rel_value < start.abs_value) 342 if (start.abs_value_us + duration.rel_value_us < start.abs_value_us)
332 { 343 {
333 GNUNET_break (0); 344 GNUNET_break (0);
334 return GNUNET_TIME_UNIT_FOREVER_ABS; 345 return GNUNET_TIME_UNIT_FOREVER_ABS;
335 } 346 }
336 ret.abs_value = start.abs_value + duration.rel_value; 347 ret.abs_value_us = start.abs_value_us + duration.rel_value_us;
337 return ret; 348 return ret;
338} 349}
339 350
@@ -352,11 +363,11 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start,
352{ 363{
353 struct GNUNET_TIME_Absolute ret; 364 struct GNUNET_TIME_Absolute ret;
354 365
355 if (start.abs_value <= duration.rel_value) 366 if (start.abs_value_us <= duration.rel_value_us)
356 return GNUNET_TIME_UNIT_ZERO_ABS; 367 return GNUNET_TIME_UNIT_ZERO_ABS;
357 if (start.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) 368 if (start.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
358 return GNUNET_TIME_UNIT_FOREVER_ABS; 369 return GNUNET_TIME_UNIT_FOREVER_ABS;
359 ret.abs_value = start.abs_value - duration.rel_value; 370 ret.abs_value_us = start.abs_value_us - duration.rel_value_us;
360 return ret; 371 return ret;
361} 372}
362 373
@@ -372,10 +383,10 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
372{ 383{
373 struct GNUNET_TIME_Relative ret; 384 struct GNUNET_TIME_Relative ret;
374 385
375 if (factor == 0) 386 if (0 == factor)
376 return GNUNET_TIME_UNIT_ZERO; 387 return GNUNET_TIME_UNIT_ZERO;
377 ret.rel_value = rel.rel_value * (unsigned long long) factor; 388 ret.rel_value_us = rel.rel_value_us * (unsigned long long) factor;
378 if (ret.rel_value / factor != rel.rel_value) 389 if (ret.rel_value_us / factor != rel.rel_value_us)
379 { 390 {
380 GNUNET_break (0); 391 GNUNET_break (0);
381 return GNUNET_TIME_UNIT_FOREVER_REL; 392 return GNUNET_TIME_UNIT_FOREVER_REL;
@@ -397,10 +408,10 @@ GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel,
397{ 408{
398 struct GNUNET_TIME_Relative ret; 409 struct GNUNET_TIME_Relative ret;
399 410
400 if ((factor == 0) || 411 if ((0 == factor) ||
401 (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)) 412 (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us))
402 return GNUNET_TIME_UNIT_FOREVER_REL; 413 return GNUNET_TIME_UNIT_FOREVER_REL;
403 ret.rel_value = rel.rel_value / (unsigned long long) factor; 414 ret.rel_value_us = rel.rel_value_us / (unsigned long long) factor;
404 return ret; 415 return ret;
405} 416}
406 417
@@ -426,11 +437,11 @@ GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished,
426 GNUNET_break (finished <= total); 437 GNUNET_break (finished <= total);
427 if (finished >= total) 438 if (finished >= total)
428 return GNUNET_TIME_UNIT_ZERO; 439 return GNUNET_TIME_UNIT_ZERO;
429 if (finished == 0) 440 if (0 == finished)
430 return GNUNET_TIME_UNIT_FOREVER_REL; 441 return GNUNET_TIME_UNIT_FOREVER_REL;
431 dur = GNUNET_TIME_absolute_get_duration (start); 442 dur = GNUNET_TIME_absolute_get_duration (start);
432 exp = ((double) dur.rel_value) * ((double) total) / ((double) finished); 443 exp = ((double) dur.rel_value_us) * ((double) total) / ((double) finished);
433 ret.rel_value = ((uint64_t) exp) - dur.rel_value; 444 ret.rel_value_us = ((uint64_t) exp) - dur.rel_value_us;
434 return ret; 445 return ret;
435} 446}
436 447
@@ -448,14 +459,14 @@ GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1,
448{ 459{
449 struct GNUNET_TIME_Relative ret; 460 struct GNUNET_TIME_Relative ret;
450 461
451 if ((a1.rel_value == UINT64_MAX) || (a2.rel_value == UINT64_MAX)) 462 if ((a1.rel_value_us == UINT64_MAX) || (a2.rel_value_us == UINT64_MAX))
452 return GNUNET_TIME_UNIT_FOREVER_REL; 463 return GNUNET_TIME_UNIT_FOREVER_REL;
453 if (a1.rel_value + a2.rel_value < a1.rel_value) 464 if (a1.rel_value_us + a2.rel_value_us < a1.rel_value_us)
454 { 465 {
455 GNUNET_break (0); 466 GNUNET_break (0);
456 return GNUNET_TIME_UNIT_FOREVER_REL; 467 return GNUNET_TIME_UNIT_FOREVER_REL;
457 } 468 }
458 ret.rel_value = a1.rel_value + a2.rel_value; 469 ret.rel_value_us = a1.rel_value_us + a2.rel_value_us;
459 return ret; 470 return ret;
460} 471}
461 472
@@ -473,11 +484,11 @@ GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1,
473{ 484{
474 struct GNUNET_TIME_Relative ret; 485 struct GNUNET_TIME_Relative ret;
475 486
476 if (a2.rel_value >= a1.rel_value) 487 if (a2.rel_value_us >= a1.rel_value_us)
477 return GNUNET_TIME_UNIT_ZERO; 488 return GNUNET_TIME_UNIT_ZERO;
478 if (a1.rel_value == UINT64_MAX) 489 if (a1.rel_value_us == UINT64_MAX)
479 return GNUNET_TIME_UNIT_FOREVER_REL; 490 return GNUNET_TIME_UNIT_FOREVER_REL;
480 ret.rel_value = a1.rel_value - a2.rel_value; 491 ret.rel_value_us = a1.rel_value_us - a2.rel_value_us;
481 return ret; 492 return ret;
482} 493}
483 494
@@ -493,7 +504,7 @@ GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a)
493{ 504{
494 struct GNUNET_TIME_RelativeNBO ret; 505 struct GNUNET_TIME_RelativeNBO ret;
495 506
496 ret.rel_value__ = GNUNET_htonll (a.rel_value); 507 ret.rel_value_us__ = GNUNET_htonll (a.rel_value_us);
497 return ret; 508 return ret;
498} 509}
499 510
@@ -509,7 +520,7 @@ GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a)
509{ 520{
510 struct GNUNET_TIME_Relative ret; 521 struct GNUNET_TIME_Relative ret;
511 522
512 ret.rel_value = GNUNET_ntohll (a.rel_value__); 523 ret.rel_value_us = GNUNET_ntohll (a.rel_value_us__);
513 return ret; 524 return ret;
514 525
515} 526}
@@ -526,7 +537,7 @@ GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a)
526{ 537{
527 struct GNUNET_TIME_AbsoluteNBO ret; 538 struct GNUNET_TIME_AbsoluteNBO ret;
528 539
529 ret.abs_value__ = GNUNET_htonll (a.abs_value); 540 ret.abs_value_us__ = GNUNET_htonll (a.abs_value_us);
530 return ret; 541 return ret;
531} 542}
532 543
@@ -542,7 +553,7 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a)
542{ 553{
543 struct GNUNET_TIME_Absolute ret; 554 struct GNUNET_TIME_Absolute ret;
544 555
545 ret.abs_value = GNUNET_ntohll (a.abs_value__); 556 ret.abs_value_us = GNUNET_ntohll (a.abs_value_us__);
546 return ret; 557 return ret;
547 558
548} 559}