functions for handling time and time arithmetic More...
Go to the source code of this file.
Macros | |
| #define | __STDC_NO_ATOMICS__ 1 |
| #define | ATOMIC |
| #define | LOG(kind, ...) GNUNET_log_from (kind, "util-time", __VA_ARGS__) |
Functions | |
| void | GNUNET_TIME_set_offset (long long offset) |
| Set the timestamp offset for this instance. | |
| long long | GNUNET_TIME_get_offset () |
| Get the timestamp offset for this instance. | |
| bool | GNUNET_TIME_absolute_approx_eq (struct GNUNET_TIME_Absolute a1, struct GNUNET_TIME_Absolute a2, struct GNUNET_TIME_Relative t) |
| Test if a1 and a2 are equal within a margin of error of t. | |
| struct GNUNET_TIME_Timestamp | GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at) |
| Round an absolute time to a timestamp. | |
| struct GNUNET_TIME_TimestampNBO | GNUNET_TIME_timestamp_hton (struct GNUNET_TIME_Timestamp t) |
| Convert timestamp to network byte order. | |
| struct GNUNET_TIME_Timestamp | GNUNET_TIME_timestamp_ntoh (struct GNUNET_TIME_TimestampNBO tn) |
| Convert timestamp from network byte order. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_get () |
| Get the current time. | |
| struct GNUNET_TIME_Timestamp | GNUNET_TIME_timestamp_get () |
| Get timestamp representing the current time. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_get_zero_ () |
| Return relative time of 0ms. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_get_zero_ () |
| Return absolute time of 0ms. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_get_unit_ () |
| Return relative time of 1 microsecond. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_get_millisecond_ () |
| Return relative time of 1ms. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_get_second_ () |
| Return relative time of 1s. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_get_minute_ () |
| Return relative time of 1 minute. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_get_hour_ () |
| Return relative time of 1 hour. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_get_forever_ () |
| Return "forever". | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_get_forever_ () |
| Return "forever". | |
| const char * | GNUNET_TIME_timestamp2s (struct GNUNET_TIME_Timestamp ts) |
| Convert ts to human-readable timestamp. | |
| const char * | GNUNET_TIME_absolute2s (struct GNUNET_TIME_Absolute t) |
Like asctime, except for GNUnet time. | |
| const char * | GNUNET_TIME_relative2s (struct GNUNET_TIME_Relative delta, bool do_round) |
| Give relative time in human-readable fancy format. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) |
| Convert relative time to an absolute time in the future. | |
| struct GNUNET_TIME_Timestamp | GNUNET_TIME_relative_to_timestamp (struct GNUNET_TIME_Relative rel) |
| Convert relative time to a timestamp in the future. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2) |
| Return the minimum of two relative time values. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2) |
| Return the maximum of two relative time values. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2) |
| Return the minimum of two absolute time values. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2) |
| Return the maximum of two absolute time values. | |
| struct GNUNET_TIME_Timestamp | GNUNET_TIME_timestamp_max (struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2) |
| Return the maximum of two timestamps. | |
| struct GNUNET_TIME_Timestamp | GNUNET_TIME_timestamp_min (struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2) |
| Return the minimum of two timestamps. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_round_down (struct GNUNET_TIME_Absolute at, struct GNUNET_TIME_Relative rt) |
| Round down absolute time at to multiple of rt. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) |
| Given a timestamp in the future, how much time remains until then? | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end) |
| Compute the time difference between the given start and end times. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute whence) |
| Get the duration of an operation as the difference of the current time and the given start time "hence". | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration) |
| Add a given relative duration to the given start time. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration) |
| Subtract a given relative duration from the given start time. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, unsigned long long factor) |
| Multiply relative time by a given factor. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_multiply_double (struct GNUNET_TIME_Relative rel, double factor) |
| Multiply relative time by a given factor. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_saturating_multiply (struct GNUNET_TIME_Relative rel, unsigned long long factor) |
| Saturating multiply relative time by a given factor. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, unsigned long long factor) |
| Divide relative time by a given factor. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished, uint64_t total) |
| Calculate the estimate time of arrival/completion for an operation. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2) |
| Add relative times together. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2) |
| Subtract relative timestamp from the other. | |
| struct GNUNET_TIME_RelativeNBO | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) |
| Convert relative time to network byte order. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) |
| Convert relative time from network byte order. | |
| struct GNUNET_TIME_AbsoluteNBO | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) |
| Convert absolute time to network byte order. | |
| bool | GNUNET_TIME_absolute_is_never (struct GNUNET_TIME_Absolute abs) |
| Test if abs is never. | |
| bool | GNUNET_TIME_relative_is_forever (struct GNUNET_TIME_Relative rel) |
| Test if rel is forever. | |
| bool | GNUNET_TIME_relative_is_zero (struct GNUNET_TIME_Relative rel) |
| Test if rel is zero. | |
| bool | GNUNET_TIME_absolute_is_past (struct GNUNET_TIME_Absolute abs) |
| Test if abs is truly in the past (excluding now). | |
| bool | GNUNET_TIME_absolute_is_future (struct GNUNET_TIME_Absolute abs) |
| Test if abs is truly in the future (excluding now). | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch) |
| Convert milliseconds after the UNIX epoch to absolute time. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_from_s (uint64_t s_after_epoch) |
| Convert seconds after the UNIX epoch to absolute time. | |
| struct GNUNET_TIME_Timestamp | GNUNET_TIME_timestamp_from_s (uint64_t s_after_epoch) |
| Convert seconds after the UNIX epoch to timestamp. | |
| uint64_t | GNUNET_TIME_timestamp_to_s (struct GNUNET_TIME_Timestamp ts) |
| Convert timestamp to number of seconds after the UNIX epoch. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) |
| Convert absolute time from network byte order. | |
| unsigned int | GNUNET_TIME_get_current_year () |
| Return the current year (e.g. | |
| unsigned int | GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at) |
| Convert an expiration time to the respective year (rounds) | |
| static time_t | my_timegm (struct tm *tm) |
| As suggested in the timegm() man page. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_year_to_time (unsigned int year) |
| Convert a year to an expiration time of January 1st of that year. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_randomized_backoff (struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold) |
| Randomized exponential back-off, starting at 1 ms and going up by a factor of 2+r, where 0 <= r <= 0.5, up to a maximum of the given threshold. | |
| bool | GNUNET_TIME_absolute_is_zero (struct GNUNET_TIME_Absolute abs) |
| Test if abs is truly zero. | |
| struct GNUNET_TIME_Relative | GNUNET_TIME_randomize (struct GNUNET_TIME_Relative r) |
| Return a random time value between 0.5*r and 1.5*r. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cfg) |
| Obtain the current time and make sure it is monotonically increasing. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_round_up (struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri) |
| Round up the given at to the interval ri. | |
| struct GNUNET_TIME_Absolute | GNUNET_TIME_round_down (struct GNUNET_TIME_Absolute at, enum GNUNET_TIME_RounderInterval ri) |
| Round @at down to the start of the next interval ri. | |
| enum GNUNET_TIME_RounderInterval | GNUNET_TIME_relative_to_round_interval (struct GNUNET_TIME_Relative rel) |
| Convert a relative time to the corresponding rounding interval. | |
| enum GNUNET_GenericReturnValue | GNUNET_TIME_string_to_round_interval (const char *ri_str, enum GNUNET_TIME_RounderInterval *ri) |
| Convert rounding interval given as a string to the enum value. | |
| const char * | GNUNET_TIME_round_interval2s (enum GNUNET_TIME_RounderInterval ri) |
| Convert rounding interval to string. | |
| void | GNUNET_util_time_fini (void) |
| void | __attribute__ ((destructor)) |
| Destructor. | |
Variables | ||
| static long long | timestamp_offset | |
| Variable used to simulate clock skew. | ||
| struct { | ||
| enum GNUNET_TIME_RounderInterval ri | ||
| const char * str | ||
| } | ri_lookup_table [] | |
| Lookup table mapping rounding interval enum values to their string representations. | ||
functions for handling time and time arithmetic
Definition in file time.c.
| #define LOG | ( | kind, | |
| ... | |||
| ) | GNUNET_log_from (kind, "util-time", __VA_ARGS__) |
|
static |
As suggested in the timegm() man page.
Definition at line 779 of file time.c.
Referenced by GNUNET_TIME_year_to_time().
| void GNUNET_util_time_fini | ( | void | ) |
| void __attribute__ | ( | (destructor) | ) |
Destructor.
Definition at line 1313 of file time.c.
References GNUNET_TIME_absolute_get_monotonic().
|
static |
Variable used to simulate clock skew.
Used for testing, never in production.
Definition at line 46 of file time.c.
Referenced by GNUNET_TIME_absolute_get(), GNUNET_TIME_get_offset(), and GNUNET_TIME_set_offset().
| enum GNUNET_TIME_RounderInterval ri |
Definition at line 1251 of file time.c.
Referenced by get_redirect_state(), GNUNET_JSON_pack_time_rounder_interval(), GNUNET_JSON_spec_time_rounder_interval(), GNUNET_NAMESTORE_record_set_store(), GNUNET_TIME_round_down(), GNUNET_TIME_round_interval2s(), GNUNET_TIME_round_up(), GNUNET_TIME_string_to_round_interval(), hash_redirect_info(), rfn_majority(), rfn_vote(), task_start_apply_round(), task_start_eval_echo(), and task_start_grade().
| const char* str |
Definition at line 1252 of file time.c.
Referenced by check_create_message(), check_identity_update(), check_identity_update(), check_identity_update(), clean_string(), compare_member_public_keys(), dfa_move(), evaluate_nfa(), extract_string(), find_and_terminate(), find_fragment(), find_path(), find_query(), fix_base64(), get_identity_for_string(), get_store_contact(), glob_match(), GNUNET_buffer_write_path(), GNUNET_buffer_write_str(), GNUNET_CRYPTO_blindable_private_key_from_string(), GNUNET_CRYPTO_blindable_public_key_from_string(), GNUNET_GETOPT_option_filename(), GNUNET_GETOPT_option_string(), GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_JSON_pack_time_rounder_interval(), GNUNET_TIME_string_to_round_interval(), GNUNET_xstrdup_(), GNUNET_xstrndup_(), handle_create_message(), handle_identity_update(), handle_identity_update(), handle_identity_update(), has_epsilon(), issue_ticket(), my_index(), natoi(), needs_parentheses(), output_vectors(), parse_rsa_signature(), parse_scheme(), parse_string(), parse_string_copy(), parse_tri(), parse_variable_data(), pool_write(), qconv_array(), REGEX_TEST_generate_random_string(), remove_epsilon(), remove_parentheses(), replace_char(), run(), gdb-iterate-dll::search_dll(), and string_to_auth_key().
| const struct { ... } ri_lookup_table[] |
Lookup table mapping rounding interval enum values to their string representations.
Referenced by GNUNET_TIME_round_interval2s(), and GNUNET_TIME_string_to_round_interval().