From 46a63dc665f31fa7d42639ab6adabbdb1af239c8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 27 May 2012 21:46:41 +0000 Subject: [PATCH] renaming GNUNET_TIME_relative_get_forever and GNUNET_TIME_absolute_get_forever methods, adding underscore, to make it clear that the respective #defines should be used instead; replacing use of direct function calls with respective macros where applicable; adding additional GNUNET_TIME_relative_get_xxx-functions to avoid calls to GNUNET_TIME_relative_multiply, which turn out to have gotten performance-relevant --- src/ats/gnunet-service-ats_addresses.c | 9 +-- src/ats/gnunet-service-ats_addresses_mlp.c | 6 +- src/ats/test_ats_api_update_address.c | 2 +- src/core/core_api_is_connected.c | 2 +- src/core/core_api_iterate_peers.c | 4 +- src/dns/plugin_block_dns.c | 2 +- src/dv/gnunet-service-dv.c | 12 +-- src/gns/gnunet-service-gns_resolver.c | 2 +- src/gns/plugin_block_gns.c | 2 +- src/gns/test_gns_dht_delegated_lookup.c | 6 +- src/gns/test_gns_max_queries.c | 2 +- src/gns/test_gns_pseu_shorten.c | 14 ++-- src/gns/test_gns_simple_delegated_lookup.c | 4 +- src/gns/test_gns_simple_get_authority.c | 14 ++-- src/gns/test_gns_simple_lookup.c | 2 +- src/gns/test_gns_simple_mx_lookup.c | 6 +- src/gns/test_gns_simple_shorten.c | 10 +-- src/gns/test_gns_simple_zkey_lookup.c | 4 +- src/hostlist/hostlist-client.c | 1 - src/include/gnunet_time_lib.h | 70 +++++++++++++---- src/integration-tests/connection_watchdog.c | 12 +-- src/mesh/gnunet-service-mesh.c | 2 +- src/mesh/test_mesh_2dtorus.c | 2 +- src/mesh/test_mesh_small.c | 2 +- src/namestore/gnunet-namestore.c | 2 +- src/namestore/gnunet-service-namestore.c | 16 ++-- src/namestore/namestore_api.c | 8 +- src/namestore/test_namestore_api.c | 2 +- src/namestore/test_namestore_api_create.c | 2 +- .../test_namestore_api_create_update.c | 12 +-- src/namestore/test_namestore_api_lookup.c | 2 +- .../test_namestore_api_lookup_specific_type.c | 12 +-- src/namestore/test_namestore_api_put.c | 2 +- src/namestore/test_namestore_api_remove.c | 12 +-- ...namestore_api_remove_not_existing_record.c | 2 +- .../test_namestore_api_zone_iteration.c | 2 +- ...mestore_api_zone_iteration_specific_zone.c | 2 +- .../test_namestore_api_zone_iteration_stop.c | 2 +- .../test_namestore_record_serialization.c | 2 +- src/nse/gnunet-nse-profiler.c | 2 +- src/nse/nse_profiler_test.conf | 30 ++++---- src/testing/test_testing_2dtorus.c | 2 +- src/testing/testing_group.c | 2 +- src/transport/plugin_transport_http.c | 2 - src/transport/plugin_transport_http_server.c | 2 +- src/transport/plugin_transport_udp.c | 11 +-- src/util/test_time.c | 24 +++--- src/util/time.c | 75 ++++++++++++++----- 48 files changed, 241 insertions(+), 181 deletions(-) diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 7f96edcac..7412cee19 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -170,11 +170,6 @@ create_address (const struct GNUNET_PeerIdentity *peer, memcpy (&aa[1], plugin_addr, plugin_addr_len); aa->plugin = GNUNET_strdup (plugin_name); aa->session_id = session_id; - aa->mlp_information = NULL; - aa->blocked_until = GNUNET_TIME_absolute_get_zero(); - aa->block_interval = GNUNET_TIME_relative_get_zero(); - aa->next = NULL; - aa->prev = NULL; return aa; } @@ -751,8 +746,8 @@ reset_address_it (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resetting interval for peer `%s' address %p from %llu to 0\n", GNUNET_i2s (&aa->peer), aa, aa->block_interval); - aa->blocked_until = GNUNET_TIME_absolute_get_zero(); - aa->block_interval = GNUNET_TIME_relative_get_zero(); + aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS; + aa->block_interval = GNUNET_TIME_UNIT_ZERO; return GNUNET_OK; } diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 196ebaba8..8bfa010ca 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -1021,8 +1021,8 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContex ctx->lp_result = GNUNET_SYSERR; ctx->mlp_result = GNUNET_SYSERR; - ctx->lp_duration = GNUNET_TIME_relative_get_forever(); - ctx->mlp_duration = GNUNET_TIME_relative_get_forever(); + ctx->lp_duration = GNUNET_TIME_UNIT_FOREVER_REL; + ctx->mlp_duration = GNUNET_TIME_UNIT_FOREVER_REL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n"); #if WRITE_MLP @@ -1369,7 +1369,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, #endif mlp->control_param_mlp.tm_lim = max_duration.rel_value; - mlp->last_execution = GNUNET_TIME_absolute_get_forever(); + mlp->last_execution = GNUNET_TIME_UNIT_FOREVER_ABS; mlp->co_D = D; mlp->co_R = R; diff --git a/src/ats/test_ats_api_update_address.c b/src/ats/test_ats_api_update_address.c index 19585903f..12d283aac 100644 --- a/src/ats/test_ats_api_update_address.c +++ b/src/ats/test_ats_api_update_address.c @@ -38,7 +38,7 @@ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) -#define VALID GNUNET_TIME_absolute_get_forever () +#define VALID GNUNET_TIME_UNIT_FOREVER_ABS static struct GNUNET_ATS_SchedulingHandle *ats; diff --git a/src/core/core_api_is_connected.c b/src/core/core_api_is_connected.c index 2e56dffc8..2e01b3691 100644 --- a/src/core/core_api_is_connected.c +++ b/src/core/core_api_is_connected.c @@ -204,7 +204,7 @@ GNUNET_CORE_is_peer_connected (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CLIENT_notify_transmit_ready (client, sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_PeerIdentity), - GNUNET_TIME_relative_get_forever (), + GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &transmit_is_connected_request, cth); GNUNET_assert (NULL != cth->th); return cth; diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c index 8e6904480..7db948618 100644 --- a/src/core/core_api_iterate_peers.c +++ b/src/core/core_api_iterate_peers.c @@ -192,11 +192,11 @@ GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, request_context->th = GNUNET_CLIENT_notify_transmit_ready (client, sizeof (struct GNUNET_MessageHeader), - GNUNET_TIME_relative_get_forever (), + GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &transmit_request, NULL); GNUNET_CLIENT_receive (client, &receive_info, request_context, - GNUNET_TIME_relative_get_forever ()); + GNUNET_TIME_UNIT_FOREVER_REL); return GNUNET_OK; } diff --git a/src/dns/plugin_block_dns.c b/src/dns/plugin_block_dns.c index 96a4dc04e..da8add50c 100644 --- a/src/dns/plugin_block_dns.c +++ b/src/dns/plugin_block_dns.c @@ -85,7 +85,7 @@ block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; } - if (GNUNET_TIME_relative_get_zero ().rel_value == + if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (rec->expiration_time)).rel_value) { diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 651b92ac0..ecf574e20 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -1334,7 +1334,7 @@ send_message_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { send_message (&msg_ctx->dest, &msg_ctx->sender, NULL, msg_ctx->message, msg_ctx->message_size, default_dv_priority, msg_ctx->uid, - GNUNET_TIME_relative_get_forever ()); + GNUNET_TIME_UNIT_FOREVER_REL); GNUNET_free (msg_ctx->message); GNUNET_free (msg_ctx); } @@ -1629,7 +1629,7 @@ handle_dv_data_message (void *cls, const struct GNUNET_PeerIdentity *peer, send_message (destination, original_sender, NULL, packed_message, packed_message_size, default_dv_priority, ntohl (incoming->uid), - GNUNET_TIME_relative_get_forever ()); + GNUNET_TIME_UNIT_FOREVER_REL); } if (ret != GNUNET_SYSERR) return GNUNET_OK; @@ -1764,7 +1764,7 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) sizeof (p2p_dv_MESSAGE_NeighborInfo)); pending_message->msg = (struct GNUNET_MessageHeader *) &pending_message[1]; pending_message->importance = default_dv_priority; - pending_message->timeout = GNUNET_TIME_relative_get_forever (); + pending_message->timeout = GNUNET_TIME_UNIT_FOREVER_REL; memcpy (&pending_message->recipient, &to->identity, sizeof (struct GNUNET_PeerIdentity)); pending_message->msg_size = sizeof (p2p_dv_MESSAGE_NeighborInfo); @@ -1784,7 +1784,7 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_now (try_core_send, NULL); /*if (core_transmit_handle == NULL) - * core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, GNUNET_YES, default_dv_priority, GNUNET_TIME_relative_get_forever(), &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL); */ + * core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, GNUNET_YES, default_dv_priority, GNUNET_TIME_UNIT_FOREVER_REL, &to->identity, sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL); */ } @@ -2193,7 +2193,7 @@ schedule_disconnect_messages (void *cls, const GNUNET_HashCode * key, sizeof (p2p_dv_MESSAGE_Disconnect)); pending_message->msg = (struct GNUNET_MessageHeader *) &pending_message[1]; pending_message->importance = default_dv_priority; - pending_message->timeout = GNUNET_TIME_relative_get_forever (); + pending_message->timeout = GNUNET_TIME_UNIT_FOREVER_REL; memcpy (&pending_message->recipient, ¬ify->identity, sizeof (struct GNUNET_PeerIdentity)); pending_message->msg_size = sizeof (p2p_dv_MESSAGE_Disconnect); @@ -2207,7 +2207,7 @@ schedule_disconnect_messages (void *cls, const GNUNET_HashCode * key, GNUNET_SCHEDULER_add_now (try_core_send, NULL); /*if (core_transmit_handle == NULL) - * core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, GNUNET_YES, default_dv_priority, GNUNET_TIME_relative_get_forever(), ¬ify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL); */ + * core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, GNUNET_YES, default_dv_priority, GNUNET_TIME_UNIT_FOREVER_REL, ¬ify->identity, sizeof(p2p_dv_MESSAGE_Disconnect), &core_transmit_notify, NULL); */ return GNUNET_YES; } diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 0f65390ee..cf12e4bac 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -132,7 +132,7 @@ process_pseu_lookup_ns(void* cls, GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "GNS_AUTO_PSEU: Name %s not taken in NS! Adding\n", gph->new_name); - new_pkey.expiration = GNUNET_TIME_absolute_get_forever (); + new_pkey.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; new_pkey.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); new_pkey.data = &gph->new_zone; new_pkey.record_type = GNUNET_GNS_RECORD_PKEY; diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index dc92f6aec..5d986ce98 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c @@ -135,7 +135,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, { struct GNUNET_NAMESTORE_RecordData rd[rd_count]; unsigned int i; - struct GNUNET_TIME_Absolute exp = GNUNET_TIME_absolute_get_forever(); + struct GNUNET_TIME_Absolute exp = GNUNET_TIME_UNIT_FOREVER_ABS; if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_len, rd_data, diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c index b27c5ec33..882bb7e5e 100644 --- a/src/gns/test_gns_dht_delegated_lookup.c +++ b/src/gns/test_gns_dht_delegated_lookup.c @@ -211,13 +211,13 @@ put_dht(void *cls, int32_t success, const char *emsg) char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); rd.data_size = sizeof(struct in_addr); rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; - sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_RECORD_NAME, + sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd); nrb = GNUNET_malloc(rd_payload_length + strlen(TEST_RECORD_NAME) + 1 @@ -315,7 +315,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); struct GNUNET_NAMESTORE_RecordData rd; - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); rd.data = &bob_hash; rd.record_type = GNUNET_GNS_RECORD_PKEY; diff --git a/src/gns/test_gns_max_queries.c b/src/gns/test_gns_max_queries.c index 8bc0bf54e..ad1743c67 100644 --- a/src/gns/test_gns_max_queries.c +++ b/src/gns/test_gns_max_queries.c @@ -269,7 +269,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); rd.data_size = sizeof(struct in_addr); rd.data = web; diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c index 69301a8eb..3c2d20420 100644 --- a/src/gns/test_gns_pseu_shorten.c +++ b/src/gns/test_gns_pseu_shorten.c @@ -272,13 +272,13 @@ put_pseu_dht(void *cls, int success) struct GNUNET_CRYPTO_RsaSignature *sig; struct GNUNET_NAMESTORE_RecordData rd; - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; rd.data_size = strlen(TEST_PSEU_ALICE)+1; rd.data = TEST_PSEU_ALICE; rd.record_type = GNUNET_GNS_RECORD_PSEU; sig = GNUNET_NAMESTORE_create_signature(alice_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, "+", &rd, 1); rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd); @@ -352,14 +352,14 @@ put_www_dht(void *cls, int success) char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); rd.data_size = sizeof(struct in_addr); rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(alice_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd); @@ -430,13 +430,13 @@ put_pkey_dht(void *cls, int32_t success, const char *emsg) struct GNUNET_CRYPTO_RsaSignature *sig; struct GNUNET_NAMESTORE_RecordData rd; - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); rd.data = &alice_hash; rd.record_type = GNUNET_GNS_RECORD_PKEY; sig = GNUNET_NAMESTORE_create_signature(bob_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, TEST_AUTHORITY_ALICE, &rd, 1); @@ -547,7 +547,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); struct GNUNET_NAMESTORE_RecordData rd; - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); rd.data = &bob_hash; rd.record_type = GNUNET_GNS_RECORD_PKEY; diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c index a91870681..36fb96915 100644 --- a/src/gns/test_gns_simple_delegated_lookup.c +++ b/src/gns/test_gns_simple_delegated_lookup.c @@ -238,7 +238,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); @@ -258,7 +258,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(bob_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); diff --git a/src/gns/test_gns_simple_get_authority.c b/src/gns/test_gns_simple_get_authority.c index f274d2cd4..dbecb7dfd 100644 --- a/src/gns/test_gns_simple_get_authority.c +++ b/src/gns/test_gns_simple_get_authority.c @@ -236,7 +236,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); @@ -256,13 +256,13 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id, /* put alice into bobs zone */ GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); rd.data = &alice_hash; - sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_AUTHORITY_ALICE, + sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_UNIT_FOREVER_ABS, TEST_AUTHORITY_ALICE, &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &bob_pkey, TEST_AUTHORITY_ALICE, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, @@ -274,13 +274,13 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id, rd.data_size = sizeof(struct in_addr); rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; - sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_absolute_get_forever(), TEST_RECORD_NAME, + sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &alice_pkey, TEST_RECORD_NAME, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, @@ -292,13 +292,13 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id, rd.record_type = GNUNET_GNS_RECORD_PSEU; GNUNET_free(sig); - sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_absolute_get_forever(), "", + sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_UNIT_FOREVER_ABS, "", &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &alice_pkey, "", - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, diff --git a/src/gns/test_gns_simple_lookup.c b/src/gns/test_gns_simple_lookup.c index 12d7a68ac..89a9aefee 100644 --- a/src/gns/test_gns_simple_lookup.c +++ b/src/gns/test_gns_simple_lookup.c @@ -220,7 +220,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); rd.data_size = sizeof(struct in_addr); rd.data = web; diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c index ffd97f07b..fdc639a72 100644 --- a/src/gns/test_gns_simple_mx_lookup.c +++ b/src/gns/test_gns_simple_mx_lookup.c @@ -257,7 +257,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, struct in_addr *mail = GNUNET_malloc(sizeof(struct in_addr)); char *mx_record; uint16_t mx_preference = 1; - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, mail)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); @@ -277,7 +277,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, rd.data = mail; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(bob_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); @@ -298,7 +298,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, rd.data = mx_record; rd.record_type = GNUNET_GNS_RECORD_MX; sig = GNUNET_NAMESTORE_create_signature(bob_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, "+", &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c index be6fc27b0..53717932f 100644 --- a/src/gns/test_gns_simple_shorten.c +++ b/src/gns/test_gns_simple_shorten.c @@ -236,7 +236,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); @@ -257,14 +257,14 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); rd.data = &alice_hash; sig = GNUNET_NAMESTORE_create_signature(bob_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, TEST_AUTHORITY_ALICE, &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &bob_pkey, TEST_AUTHORITY_ALICE, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, @@ -277,14 +277,14 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id, rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(alice_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); GNUNET_NAMESTORE_record_put (namestore_handle, &alice_pkey, TEST_RECORD_NAME, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, sig, diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c index 32298cba5..8b9b78bef 100644 --- a/src/gns/test_gns_simple_zkey_lookup.c +++ b/src/gns/test_gns_simple_zkey_lookup.c @@ -241,7 +241,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_NAMESTORE_RecordData rd; char* ip = TEST_IP; struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); - rd.expiration = GNUNET_TIME_absolute_get_forever (); + rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); @@ -261,7 +261,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, rd.data = web; rd.record_type = GNUNET_DNSPARSER_TYPE_A; sig = GNUNET_NAMESTORE_create_signature(bob_key, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME, &rd, 1); diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 9e320e51c..6be37fc78 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -1194,7 +1194,6 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, hostlist->hostlist_uri = (const char *) &hostlist[1]; memcpy (&hostlist[1], uri, uri_size); hostlist->time_creation = GNUNET_TIME_absolute_get (); - hostlist->time_last_usage = GNUNET_TIME_absolute_get_zero (); hostlist->quality = HOSTLIST_INITIAL; hostlist_to_test = hostlist; diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index 7090c33a1..35d180ce2 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h @@ -90,32 +90,32 @@ GNUNET_NETWORK_STRUCT_END /** * Relative time zero. */ -#define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero() +#define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero_() /** * Absolute time zero. */ -#define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero() +#define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero_() /** * One millisecond, our basic time unit. */ -#define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit() +#define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit_() /** * One second. */ -#define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) +#define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_get_second_() /** * One minute. */ -#define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) +#define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_get_minute_() /** * One hour. */ -#define GNUNET_TIME_UNIT_HOURS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 60) +#define GNUNET_TIME_UNIT_HOURS GNUNET_TIME_relative_get_hour_() /** * One day. @@ -141,43 +141,70 @@ GNUNET_NETWORK_STRUCT_END * Constant used to specify "forever". This constant * will be treated specially in all time operations. */ -#define GNUNET_TIME_UNIT_FOREVER_REL GNUNET_TIME_relative_get_forever () +#define GNUNET_TIME_UNIT_FOREVER_REL GNUNET_TIME_relative_get_forever_ () /** * Constant used to specify "forever". This constant * will be treated specially in all time operations. */ -#define GNUNET_TIME_UNIT_FOREVER_ABS GNUNET_TIME_absolute_get_forever () +#define GNUNET_TIME_UNIT_FOREVER_ABS GNUNET_TIME_absolute_get_forever_ () + /** * Return relative time of 0ms. */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_zero (void); +GNUNET_TIME_relative_get_zero_ (void); + /** * Return absolute time of 0ms. */ struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get_zero (void); +GNUNET_TIME_absolute_get_zero_ (void); + /** * Return relative time of 1ms. */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_unit (void); +GNUNET_TIME_relative_get_unit_ (void); + + +/** + * Return relative time of 1s. + */ +struct GNUNET_TIME_Relative +GNUNET_TIME_relative_get_second_ (void); + + +/** + * Return relative time of 1 minute. + */ +struct GNUNET_TIME_Relative +GNUNET_TIME_relative_get_minute_ (void); + + +/** + * Return relative time of 1 hour. + */ +struct GNUNET_TIME_Relative +GNUNET_TIME_relative_get_hour_ (void); + /** * Return "forever". */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_forever (void); +GNUNET_TIME_relative_get_forever_ (void); + /** * Return "forever". */ struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get_forever (void); +GNUNET_TIME_absolute_get_forever_ (void); + /** * Get the current time. @@ -187,6 +214,7 @@ GNUNET_TIME_absolute_get_forever (void); struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get (void); + /** * Convert relative time to an absolute time in the * future. @@ -197,6 +225,7 @@ GNUNET_TIME_absolute_get (void); struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel); + /** * Return the minimum of two relative time values. * @@ -209,6 +238,7 @@ GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2); + /** * Return the maximum of two relative time values. * @@ -220,6 +250,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2); + /** * Return the minimum of two absolute time values. * @@ -231,6 +262,7 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2); + /** * Return the maximum of two absolute time values. * @@ -242,6 +274,7 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2); + /** * Given a timestamp in the future, how much time * remains until then? @@ -281,6 +314,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end); + /** * Get the duration of an operation as the * difference of the current time and the given start time "hence". @@ -317,6 +351,7 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration); + /** * Multiply relative time by a given factor. * @@ -328,6 +363,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, unsigned int factor); + /** * Divide relative time by a given factor. * @@ -339,6 +375,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, unsigned int factor); + /** * Add relative times together. * @@ -350,6 +387,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2); + /** * Subtract relative timestamp from the other. * @@ -371,6 +409,7 @@ GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a); + /** * Convert relative time from network byte order. * @@ -380,6 +419,7 @@ GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a); struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a); + /** * Convert relative time to network byte order. * @@ -389,6 +429,7 @@ GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a); struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a); + /** * Convert relative time from network byte order. * @@ -398,6 +439,7 @@ GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a); struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a); + /** * Convert a relative time to a string. * NOT reentrant! @@ -409,6 +451,7 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a); const char * GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time); + /** * Set the timestamp offset for this instance. * @@ -417,6 +460,7 @@ GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time); void GNUNET_TIME_set_offset (long long offset); + #if 0 /* keep Emacsens' auto-indent happy */ { #endif diff --git a/src/integration-tests/connection_watchdog.c b/src/integration-tests/connection_watchdog.c index 592947694..ac19338cf 100644 --- a/src/integration-tests/connection_watchdog.c +++ b/src/integration-tests/connection_watchdog.c @@ -461,14 +461,14 @@ int map_ping_it (void *cls, if ((GNUNET_YES == pc->transport_connected) && (NULL == pc->th_ping)) pc->th_ping = GNUNET_TRANSPORT_notify_transmit_ready(th, &pc->id, sizeof (struct PING), UINT_MAX, - GNUNET_TIME_relative_get_forever(), &send_transport_ping_cb, pc); + GNUNET_TIME_UNIT_FOREVER_REL, &send_transport_ping_cb, pc); else GNUNET_break(0); if ((GNUNET_YES == pc->core_connected) && (NULL == pc->ch_ping)) pc->ch_ping = GNUNET_CORE_notify_transmit_ready(ch, GNUNET_NO, UINT_MAX, - GNUNET_TIME_relative_get_forever(), + GNUNET_TIME_UNIT_FOREVER_REL, &pc->id, sizeof (struct PING), send_core_ping_cb, pc); @@ -580,7 +580,7 @@ map_connect (const struct GNUNET_PeerIdentity *peer, void * source) if (GNUNET_YES == ping) { if (NULL == pc->th_ping) - pc->th_ping = GNUNET_TRANSPORT_notify_transmit_ready(th, peer, sizeof (struct PING), UINT_MAX, GNUNET_TIME_relative_get_forever(), &send_transport_ping_cb, pc); + pc->th_ping = GNUNET_TRANSPORT_notify_transmit_ready(th, peer, sizeof (struct PING), UINT_MAX, GNUNET_TIME_UNIT_FOREVER_REL, &send_transport_ping_cb, pc); else GNUNET_break(0); } @@ -605,7 +605,7 @@ map_connect (const struct GNUNET_PeerIdentity *peer, void * source) if (NULL == pc->ch_ping) pc->ch_ping = GNUNET_CORE_notify_transmit_ready(ch, GNUNET_NO, UINT_MAX, - GNUNET_TIME_relative_get_forever(), + GNUNET_TIME_UNIT_FOREVER_REL, peer, sizeof (struct PING), send_core_ping_cb, pc); @@ -842,7 +842,7 @@ transport_notify_receive_cb (void *cls, if (NULL == pc->th_pong) pc->th_pong = GNUNET_TRANSPORT_notify_transmit_ready(th, peer, sizeof (struct PONG), - UINT_MAX, GNUNET_TIME_relative_get_forever(), + UINT_MAX, GNUNET_TIME_UNIT_FOREVER_REL, &send_transport_pong_cb, pc); else GNUNET_break (0); @@ -893,7 +893,7 @@ core_notify_receive_cb (void *cls, if (NULL == pc->ch_pong) pc->ch_pong = GNUNET_CORE_notify_transmit_ready(ch, GNUNET_NO, UINT_MAX, - GNUNET_TIME_relative_get_forever(), + GNUNET_TIME_UNIT_FOREVER_REL, peer, sizeof (struct PONG), send_core_pong_cb, pc); diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index d278c2039..36c6115a1 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -694,7 +694,7 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_BLOCK_TYPE_TEST, /* Block type */ sizeof (my_full_id), /* Size of the data */ (char *) &my_full_id, /* Data itself */ - GNUNET_TIME_absolute_get_forever (), /* Data expiration */ + GNUNET_TIME_UNIT_FOREVER_ABS, /* Data expiration */ GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ NULL, /* Continuation */ NULL); /* Continuation closure */ diff --git a/src/mesh/test_mesh_2dtorus.c b/src/mesh/test_mesh_2dtorus.c index e447e11c2..c708e8f44 100644 --- a/src/mesh/test_mesh_2dtorus.c +++ b/src/mesh/test_mesh_2dtorus.c @@ -316,7 +316,7 @@ run (void *cls, char *const *args, const char *cfgfile, hosts); GNUNET_assert (pg != NULL); shutdown_handle = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c index b06e324f7..974b63590 100644 --- a/src/mesh/test_mesh_small.c +++ b/src/mesh/test_mesh_small.c @@ -901,7 +901,7 @@ run (void *cls, char *const *args, const char *cfgfile, hosts); GNUNET_assert (pg != NULL); shutdown_handle = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 6bde4d90e..a0d1de10a 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c @@ -356,7 +356,7 @@ run (void *cls, char *const *args, const char *cfgfile, { if (0 == strcmp (expirationstring, "never")) { - etime = GNUNET_TIME_relative_get_forever(); + etime = GNUNET_TIME_UNIT_FOREVER_REL; } else if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (expirationstring, diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index e9475c9f1..d6c299882 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -226,15 +226,13 @@ int zone_to_disk_it (void *cls, struct GNUNET_TIME_Absolute get_block_expiration_time (unsigned int rd_count, const struct GNUNET_NAMESTORE_RecordData *rd) { - int c; - struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get_forever(); + unsigned int c; + struct GNUNET_TIME_Absolute expire = GNUNET_TIME_UNIT_FOREVER_ABS; + if (NULL == rd) - return GNUNET_TIME_absolute_get_zero(); - for (c = 0; c < rd_count; c++) - { - if (rd[c].expiration.abs_value < expire.abs_value) - expire = rd[c].expiration; - } + return GNUNET_TIME_UNIT_ZERO_ABS; + for (c = 0; c < rd_count; c++) + expire = GNUNET_TIME_absolute_min (rd[c].expiration, expire); return expire; } @@ -1611,7 +1609,7 @@ void send_zone_iteration_result (struct ZoneIterationProcResult *proc) zir_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE); zir_msg.gns_header.header.size = htons (sizeof (struct ZoneIterationResponseMessage)); zir_msg.gns_header.r_id = htonl(zi->request_id); - zir_msg.expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_zero()); + zir_msg.expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_UNIT_ZERO_ABS); zir_msg.name_len = htons (0); zir_msg.reserved = htons (0); zir_msg.rd_count = htons (0); diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index eadbeb55f..151fb9752 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c @@ -463,13 +463,13 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "An error occured during zone to name operation\n"); if (qe->proc != NULL) - qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL); + qe->proc (qe->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL); } else if (res == GNUNET_NO) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore has no result for zone to name mapping \n"); if (qe->proc != NULL) - qe->proc (qe->proc_cls, NULL, GNUNET_TIME_absolute_get_zero(), NULL, 0, NULL, NULL); + qe->proc (qe->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL); } else if (res == GNUNET_YES) { @@ -606,7 +606,7 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze); if (ze->proc != NULL) - ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL); + ze->proc(ze->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL , 0, NULL, NULL); GNUNET_free (ze); return; @@ -1197,7 +1197,7 @@ GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, msg->rd_count = htons (1); msg->rd_len = htons (rd_ser_len); msg->pkey_len = htons (key_len); - msg->expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_forever()); + msg->expire = GNUNET_TIME_absolute_hton(GNUNET_TIME_UNIT_FOREVER_ABS); memcpy (pkey_tmp, pkey_enc, key_len); memcpy (name_tmp, name, name_len); memcpy (rd_tmp, rd_ser, rd_ser_len); diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c index c28220fb7..039f1b9d7 100644 --- a/src/namestore/test_namestore_api.c +++ b/src/namestore/test_namestore_api.c @@ -197,7 +197,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_break (NULL != nsh); GNUNET_NAMESTORE_record_put (nsh, &pubkey, name, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, 1, &rd, &signature, put_cont, name); GNUNET_free ((void *)rd.data); diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c index 8a2c8a903..131c934cb 100644 --- a/src/namestore/test_namestore_api_create.c +++ b/src/namestore/test_namestore_api_create.c @@ -301,7 +301,7 @@ void name_lookup_initial_proc (void *cls, /* create a second record */ s_second_record = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_RecordData) + TEST_CREATE_RECORD_DATALEN); - s_second_record->expiration = GNUNET_TIME_absolute_get_forever(); + s_second_record->expiration = GNUNET_TIME_UNIT_FOREVER_ABS; s_second_record->record_type = TEST_CREATE_RECORD_TYPE; s_second_record->flags = GNUNET_NAMESTORE_RF_AUTHORITY; s_second_record->data = &s_second_record[1]; diff --git a/src/namestore/test_namestore_api_create_update.c b/src/namestore/test_namestore_api_create_update.c index d11c894cc..93570e458 100644 --- a/src/namestore/test_namestore_api_create_update.c +++ b/src/namestore/test_namestore_api_create_update.c @@ -294,7 +294,7 @@ void name_lookup_initial_proc (void *cls, /* create a second record */ s_second_record = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_RecordData) + TEST_CREATE_RECORD_DATALEN); - s_second_record->expiration = GNUNET_TIME_absolute_get_forever(); + s_second_record->expiration = GNUNET_TIME_UNIT_FOREVER_ABS; s_second_record->record_type = TEST_CREATE_RECORD_TYPE; s_second_record->flags = GNUNET_NAMESTORE_RF_AUTHORITY; s_second_record->data = &s_second_record[1]; @@ -406,11 +406,11 @@ create_record (int count) for (c = 0; c < count; c++) { - rd[c].expiration = GNUNET_TIME_absolute_get_zero(); - rd[c].record_type = TEST_RECORD_TYPE; - rd[c].data_size = TEST_RECORD_DATALEN; - rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); - memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); + rd[c].expiration = GNUNET_TIME_UNIT_ZERO_ABS; + rd[c].record_type = TEST_RECORD_TYPE; + rd[c].data_size = TEST_RECORD_DATALEN; + rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); + memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); } return rd; diff --git a/src/namestore/test_namestore_api_lookup.c b/src/namestore/test_namestore_api_lookup.c index 3857ca141..734e5b8fb 100644 --- a/src/namestore/test_namestore_api_lookup.c +++ b/src/namestore/test_namestore_api_lookup.c @@ -284,7 +284,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_break (s_name != NULL); GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS RECORDS, s_rd, s_signature, put_cont, s_name); diff --git a/src/namestore/test_namestore_api_lookup_specific_type.c b/src/namestore/test_namestore_api_lookup_specific_type.c index 03a6887c6..981e252de 100644 --- a/src/namestore/test_namestore_api_lookup_specific_type.c +++ b/src/namestore/test_namestore_api_lookup_specific_type.c @@ -279,11 +279,11 @@ create_record (int count) for (c = 0; c < RECORDS-1; c++) { - rd[c].expiration = GNUNET_TIME_absolute_get_zero(); - rd[c].record_type = 1; - rd[c].data_size = TEST_RECORD_DATALEN; - rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); - memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); + rd[c].expiration = GNUNET_TIME_UNIT_ZERO_ABS; + rd[c].record_type = 1; + rd[c].data_size = TEST_RECORD_DATALEN; + rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); + memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); } rd[c].expiration = GNUNET_TIME_absolute_get(); @@ -358,7 +358,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_break (s_name != NULL); GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, RECORDS, s_rd, s_signature, put_cont, s_name); diff --git a/src/namestore/test_namestore_api_put.c b/src/namestore/test_namestore_api_put.c index cdec716da..9315fd3b5 100644 --- a/src/namestore/test_namestore_api_put.c +++ b/src/namestore/test_namestore_api_put.c @@ -203,7 +203,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_break (s_name != NULL); GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, RECORDS, s_rd, signature, put_cont, s_name); GNUNET_free (signature); diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c index d1b566659..57bb4a822 100644 --- a/src/namestore/test_namestore_api_remove.c +++ b/src/namestore/test_namestore_api_remove.c @@ -251,11 +251,11 @@ create_record (int count) for (c = 1; c < RECORDS; c++) { - rd[c].expiration = GNUNET_TIME_absolute_get_zero(); - rd[c].record_type = TEST_RECORD_TYPE; - rd[c].data_size = TEST_RECORD_DATALEN; - rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); - memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); + rd[c].expiration = GNUNET_TIME_UNIT_ZERO_ABS; + rd[c].record_type = TEST_RECORD_TYPE; + rd[c].data_size = TEST_RECORD_DATALEN; + rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); + memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); } return rd; @@ -325,7 +325,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_break (s_name != NULL); GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, RECORDS, s_rd, s_signature, put_cont, s_name); diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c index 68920cb96..8c3227874 100644 --- a/src/namestore/test_namestore_api_remove_not_existing_record.c +++ b/src/namestore/test_namestore_api_remove_not_existing_record.c @@ -259,7 +259,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_break (s_name != NULL); GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, - GNUNET_TIME_absolute_get_forever(), + GNUNET_TIME_UNIT_FOREVER_ABS, RECORDS, s_rd, s_signature, put_cont, s_name); diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c index 6743146e0..066554187 100644 --- a/src/namestore/test_namestore_api_zone_iteration.c +++ b/src/namestore/test_namestore_api_zone_iteration.c @@ -452,7 +452,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_asprintf(&s_name_3, "dummy3"); s_rd_3 = create_record(1); sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, s_rd_3->expiration, s_name_3, s_rd_3, 1); - GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_absolute_get_forever(), 1, s_rd_3, sig_3, &put_cont, NULL); + GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); } static int diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c index 192853e5a..b21c860c8 100644 --- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c +++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c @@ -414,7 +414,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_asprintf(&s_name_3, "dummy3"); s_rd_3 = create_record(1); sig_3 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_3[0].expiration, s_name_3, s_rd_3, 1); - GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_absolute_get_forever(), 1, s_rd_3, sig_3, &put_cont, NULL); + GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); } static int diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c index f5f2e3a34..9f62c73b6 100644 --- a/src/namestore/test_namestore_api_zone_iteration_stop.c +++ b/src/namestore/test_namestore_api_zone_iteration_stop.c @@ -464,7 +464,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_asprintf(&s_name_3, "dummy3"); s_rd_3 = create_record(1); sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, s_rd_3[0].expiration, s_name_3, s_rd_3, 1); - GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_absolute_get_forever(), 1, s_rd_3, sig_3, &put_cont, NULL); + GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); } static int diff --git a/src/namestore/test_namestore_record_serialization.c b/src/namestore/test_namestore_record_serialization.c index a045e59a5..5e952539b 100644 --- a/src/namestore/test_namestore_record_serialization.c +++ b/src/namestore/test_namestore_record_serialization.c @@ -78,7 +78,7 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_break (0); res = 1; } - if (GNUNET_TIME_absolute_get_difference(src[c].expiration, dst[c].expiration).rel_value != GNUNET_TIME_relative_get_zero().rel_value) + if (0 != GNUNET_TIME_absolute_get_difference(src[c].expiration, dst[c].expiration).rel_value) { GNUNET_break (0); res = 1; diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 4748ed370..4a4bea5ed 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c @@ -896,7 +896,7 @@ run (void *cls, char *const *args, const char *cfgfile, &connect_cb, &my_cb, NULL, hosts); GNUNET_assert (pg != NULL); shutdown_handle = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/nse/nse_profiler_test.conf b/src/nse/nse_profiler_test.conf index 0185ed217..3a3217dbc 100644 --- a/src/nse/nse_profiler_test.conf +++ b/src/nse/nse_profiler_test.conf @@ -104,7 +104,7 @@ AUTOSTART = NO AUTOSTART = NO [testing] -NUM_PEERS = 4000 +NUM_PEERS = 2000 WEAKRANDOM = YES TOPOLOGY = NONE #CONNECT_TOPOLOGY = SMALL_WORLD_RING @@ -122,7 +122,7 @@ HOSTKEYSFILE = hostkeys.dat MAX_CONCURRENT_SSH = 20 USE_PROGRESSBARS = YES PEERGROUP_TIMEOUT = 1000 s -TOPOLOGY_OUTPUT_FILE = nse_topo_4000_peers_initial +TOPOLOGY_OUTPUT_FILE = nse_topo_2000_peers_initial MAX_OUTSTANDING_CONNECTIONS = 100 #SINGLE_PEERINFO_PER_HOST = YES #NUM_PEERINFO_PER_HOST = 10 @@ -132,20 +132,20 @@ DELETE_FILES = NO #SKEW_VARIANCE = 30000 [nse-profiler] -OUTPUT_FILE = nse_output_4000_peers.dat -TOPOLOGY_OUTPUT_FILE = nse_topo_4000_peers -DATA_OUTPUT_FILE = nse_stats_4000_peers +OUTPUT_FILE = nse_output_2000_peers.dat +TOPOLOGY_OUTPUT_FILE = nse_topo_2000_peers +DATA_OUTPUT_FILE = nse_stats_2000_peers ROUND0 = 1000 -#ROUND1 = 4000 -ROUND2 = 4000 -ROUND3 = 4000 -ROUND4 = 4000 -ROUND5 = 4000 -ROUND6 = 4000 -ROUND7 = 4000 -ROUND8 = 4000 -ROUND9 = 4000 -ROUND10 = 4000 +#ROUND1 = 2000 +ROUND2 = 2000 +ROUND3 = 2000 +ROUND4 = 2000 +ROUND5 = 2000 +ROUND6 = 2000 +ROUND7 = 2000 +ROUND8 = 2000 +ROUND9 = 2000 +ROUND10 = 2000 ROUND11 = 1000 ROUND12 = 1000 ROUND13 = 1000 diff --git a/src/testing/test_testing_2dtorus.c b/src/testing/test_testing_2dtorus.c index 7b109bca4..00a66d65c 100644 --- a/src/testing/test_testing_2dtorus.c +++ b/src/testing/test_testing_2dtorus.c @@ -317,7 +317,7 @@ run (void *cls, char *const *args, const char *cfgfile, hosts); GNUNET_assert (pg != NULL); shutdown_handle = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 8c83f988f..245ebd3d9 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -4968,7 +4968,7 @@ schedule_get_statistics (void *cls, core_context->stats_get_handle = GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL, - GNUNET_TIME_relative_get_forever (), + GNUNET_TIME_UNIT_FOREVER_REL, &internal_stats_cont, &internal_stats_callback, core_context); if (core_context->stats_get_handle == NULL) diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 37f7f798d..d55cdb76b 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -620,8 +620,6 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, s->addr = GNUNET_malloc (addrlen); memcpy (s->addr, addr, addrlen); s->addrlen = addrlen; - s->next = NULL; - s->next_receive = GNUNET_TIME_absolute_get_zero (); s->ats_address_network_type = htonl (GNUNET_ATS_NET_UNSPECIFIED); start_session_timeout(s); return s; diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index bee885453..fce6bd1a3 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -542,7 +542,7 @@ create: s->ats_address_network_type = ats.value; s->inbound = GNUNET_YES; - s->next_receive = GNUNET_TIME_absolute_get_zero (); + s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS; s->tag = tag; if (0 == strcmp (MHD_HTTP_METHOD_PUT, method)) s->server_recv = s; diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 45387cfc8..474180db5 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -846,16 +846,11 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, GNUNET_break_op (0); return NULL; } - s->addrlen = len; s->target = *target; s->sock_addr = (const struct sockaddr *) &s[1]; - s->flow_delay_for_other_peer = GNUNET_TIME_relative_get_zero(); - s->flow_delay_from_other_peer = GNUNET_TIME_absolute_get_zero(); s->last_expected_delay = GNUNET_TIME_UNIT_SECONDS; - start_session_timeout(s); - return s; } @@ -1521,14 +1516,10 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) sockaddr_in6)), delay); udpw = GNUNET_malloc (sizeof (struct UDPMessageWrapper) + msize); - udpw->cont = NULL; - udpw->cont_cls = NULL; - udpw->frag_ctx = NULL; udpw->msg_size = msize; udpw->session = s; - udpw->timeout = GNUNET_TIME_absolute_get_forever(); + udpw->timeout = GNUNET_TIME_UNIT_FOREVER_ABS; udpw->udp = (char *)&udpw[1]; - udp_ack = (struct UDP_ACK_Message *) udpw->udp; udp_ack->header.size = htons ((uint16_t) msize); udp_ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK); diff --git a/src/util/test_time.c b/src/util/test_time.c index 788884fcc..b4c723344 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.c @@ -43,9 +43,9 @@ check () struct GNUNET_TIME_RelativeNBO reln; unsigned int i; - forever = GNUNET_TIME_absolute_get_forever (); - relForever = GNUNET_TIME_relative_get_forever (); - relUnit = GNUNET_TIME_relative_get_unit (); + forever = GNUNET_TIME_UNIT_FOREVER_ABS; + relForever = GNUNET_TIME_UNIT_FOREVER_REL; + relUnit = GNUNET_TIME_UNIT_MILLISECONDS; zero.abs_value = 0; last = now = GNUNET_TIME_absolute_get (); @@ -62,7 +62,7 @@ check () GNUNET_assert (rel.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value); /*check zero */ rel.rel_value = (UINT64_MAX) - 1024; - GNUNET_assert (GNUNET_TIME_relative_get_zero ().rel_value == + GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value == GNUNET_TIME_relative_multiply (rel, 0).rel_value); /* test infinity-check for relative to absolute */ @@ -77,7 +77,7 @@ check () GNUNET_TIME_relative_to_absolute (rel).abs_value); /*check forever */ rel.rel_value = UINT64_MAX; - GNUNET_assert (GNUNET_TIME_absolute_get_forever ().abs_value == + GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value == GNUNET_TIME_relative_to_absolute (rel).abs_value); /* check overflow for r2a */ rel.rel_value = (UINT64_MAX) - 1024; @@ -125,8 +125,8 @@ check () rel = GNUNET_TIME_absolute_get_remaining (future); GNUNET_assert (rel.rel_value > 0); GNUNET_assert (rel.rel_value <= 1000000); - forever = GNUNET_TIME_absolute_get_forever (); - GNUNET_assert (GNUNET_TIME_relative_get_forever ().rel_value == + forever = GNUNET_TIME_UNIT_FOREVER_ABS; + GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == GNUNET_TIME_absolute_get_remaining (forever).rel_value); /* check endianess */ @@ -175,13 +175,13 @@ check () /* check Return absolute time of 0ms */ - zero = GNUNET_TIME_absolute_get_zero (); + zero = GNUNET_TIME_UNIT_ZERO_ABS; /* check GNUNET_TIME_calculate_eta */ last.abs_value = GNUNET_TIME_absolute_get ().abs_value - 1024; - forever = GNUNET_TIME_absolute_get_forever (); + forever = GNUNET_TIME_UNIT_FOREVER_ABS; forever.abs_value = forever.abs_value - 1024; - GNUNET_assert (GNUNET_TIME_absolute_get_zero ().abs_value == + GNUNET_assert (GNUNET_TIME_UNIT_ZERO_ABS.abs_value == GNUNET_TIME_calculate_eta (forever, 50000, 100000).rel_value); /* check zero */ GNUNET_log_skip (1, GNUNET_NO); @@ -199,11 +199,11 @@ check () GNUNET_assert (1024 == GNUNET_TIME_relative_subtract (relForever, rel).rel_value); /*check zero */ - GNUNET_assert (GNUNET_TIME_relative_get_zero ().rel_value == + GNUNET_assert (GNUNET_TIME_UNIT_ZERO.rel_value == GNUNET_TIME_relative_subtract (rel, relForever).rel_value); /*check forever */ rel.rel_value = UINT64_MAX; - GNUNET_assert (GNUNET_TIME_relative_get_forever ().rel_value == + GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == GNUNET_TIME_relative_subtract (rel, relForever).rel_value); /*check GNUNET_TIME_relative_min */ diff --git a/src/util/time.c b/src/util/time.c index 3a6f38041..7467b4497 100644 --- a/src/util/time.c +++ b/src/util/time.c @@ -68,7 +68,7 @@ GNUNET_TIME_absolute_get () * Return relative time of 0ms. */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_zero () +GNUNET_TIME_relative_get_zero_ () { static struct GNUNET_TIME_Relative zero; @@ -80,28 +80,63 @@ GNUNET_TIME_relative_get_zero () * Return absolute time of 0ms. */ struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get_zero () +GNUNET_TIME_absolute_get_zero_ () { static struct GNUNET_TIME_Absolute zero; return zero; } + /** * Return relative time of 1ms. */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_unit () +GNUNET_TIME_relative_get_unit_ () { static struct GNUNET_TIME_Relative one = { 1 }; return one; } + +/** + * Return relative time of 1s. + */ +struct GNUNET_TIME_Relative +GNUNET_TIME_relative_get_second_ () +{ + static struct GNUNET_TIME_Relative one = { 1000 }; + return one; +} + + +/** + * Return relative time of 1 minute. + */ +struct GNUNET_TIME_Relative +GNUNET_TIME_relative_get_minute_ () +{ + static struct GNUNET_TIME_Relative one = { 60 * 1000 }; + return one; +} + + +/** + * Return relative time of 1 hour. + */ +struct GNUNET_TIME_Relative +GNUNET_TIME_relative_get_hour_ () +{ + static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 }; + return one; +} + + /** * Return "forever". */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_get_forever () +GNUNET_TIME_relative_get_forever_ () { static struct GNUNET_TIME_Relative forever = { UINT64_MAX }; return forever; @@ -111,7 +146,7 @@ GNUNET_TIME_relative_get_forever () * Return "forever". */ struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_get_forever () +GNUNET_TIME_absolute_get_forever_ () { static struct GNUNET_TIME_Absolute forever = { UINT64_MAX }; return forever; @@ -129,13 +164,13 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) struct GNUNET_TIME_Absolute ret; if (rel.rel_value == UINT64_MAX) - return GNUNET_TIME_absolute_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_ABS; struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); if (rel.rel_value + now.abs_value < rel.rel_value) { GNUNET_break (0); /* overflow... */ - return GNUNET_TIME_absolute_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_ABS; } ret.abs_value = rel.rel_value + now.abs_value; return ret; @@ -215,11 +250,11 @@ GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) struct GNUNET_TIME_Relative ret; if (future.abs_value == UINT64_MAX) - return GNUNET_TIME_relative_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_REL; struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); if (now.abs_value > future.abs_value) - return GNUNET_TIME_relative_get_zero (); + return GNUNET_TIME_UNIT_ZERO; ret.rel_value = future.abs_value - now.abs_value; return ret; } @@ -238,9 +273,9 @@ GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative ret; if (end.abs_value == UINT64_MAX) - return GNUNET_TIME_relative_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_REL; if (end.abs_value < start.abs_value) - return GNUNET_TIME_relative_get_zero (); + return GNUNET_TIME_UNIT_ZERO; ret.rel_value = end.abs_value - start.abs_value; return ret; } @@ -260,7 +295,7 @@ GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute whence) now = GNUNET_TIME_absolute_get (); GNUNET_assert (whence.abs_value != UINT64_MAX); if (whence.abs_value > now.abs_value) - return GNUNET_TIME_relative_get_zero (); + return GNUNET_TIME_UNIT_ZERO; ret.rel_value = now.abs_value - whence.abs_value; return ret; } @@ -279,11 +314,11 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute ret; if ((start.abs_value == UINT64_MAX) || (duration.rel_value == UINT64_MAX)) - return GNUNET_TIME_absolute_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_ABS; if (start.abs_value + duration.rel_value < start.abs_value) { GNUNET_break (0); - return GNUNET_TIME_absolute_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_ABS; } ret.abs_value = start.abs_value + duration.rel_value; return ret; @@ -325,12 +360,12 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, struct GNUNET_TIME_Relative ret; if (factor == 0) - return GNUNET_TIME_relative_get_zero (); + return GNUNET_TIME_UNIT_ZERO; ret.rel_value = rel.rel_value * (unsigned long long) factor; if (ret.rel_value / factor != rel.rel_value) { GNUNET_break (0); - return GNUNET_TIME_relative_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_REL; } return ret; } @@ -401,11 +436,11 @@ GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative ret; if ((a1.rel_value == UINT64_MAX) || (a2.rel_value == UINT64_MAX)) - return GNUNET_TIME_relative_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_REL; if (a1.rel_value + a2.rel_value < a1.rel_value) { GNUNET_break (0); - return GNUNET_TIME_relative_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_REL; } ret.rel_value = a1.rel_value + a2.rel_value; return ret; @@ -426,9 +461,9 @@ GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative ret; if (a2.rel_value >= a1.rel_value) - return GNUNET_TIME_relative_get_zero (); + return GNUNET_TIME_UNIT_ZERO; if (a1.rel_value == UINT64_MAX) - return GNUNET_TIME_relative_get_forever (); + return GNUNET_TIME_UNIT_FOREVER_REL; ret.rel_value = a1.rel_value - a2.rel_value; return ret; } -- 2.25.1