GNUnet  0.20.0
Time library

Time and time calculations. More...

Collaboration diagram for Time library:

Data Structures

struct  GNUNET_TIME_Absolute
 Time for absolute times used by GNUnet, in microseconds. More...
 
struct  GNUNET_TIME_Timestamp
 Rounded time for timestamps used by GNUnet, in seconds. More...
 
struct  GNUNET_TIME_Relative
 Time for relative time used by GNUnet, in microseconds. More...
 
struct  GNUNET_TIME_RelativeNBO
 Time for relative time used by GNUnet, in microseconds and in network byte order. More...
 
struct  GNUNET_TIME_AbsoluteNBO
 Time for absolute time used by GNUnet, in microseconds and in network byte order. More...
 
struct  GNUNET_TIME_TimestampNBO
 Time for timestamps used by GNUnet, in seconds and in network byte order. More...
 

Macros

#define GNUNET_TIME_UNIT_ZERO   ((struct GNUNET_TIME_Relative){0})
 Relative time zero. More...
 
#define GNUNET_TIME_UNIT_ZERO_ABS   ((struct GNUNET_TIME_Absolute){0})
 Absolute time zero. More...
 
#define GNUNET_TIME_UNIT_ZERO_TS   ((struct GNUNET_TIME_Timestamp){{0}})
 Timestamp of zero. More...
 
#define GNUNET_TIME_UNIT_MICROSECONDS   GNUNET_TIME_relative_get_unit_ ()
 One microsecond, our basic time unit. More...
 
#define GNUNET_TIME_UNIT_MILLISECONDS   GNUNET_TIME_relative_get_millisecond_ ()
 One millisecond. More...
 
#define GNUNET_TIME_UNIT_SECONDS   GNUNET_TIME_relative_get_second_ ()
 One second. More...
 
#define GNUNET_TIME_UNIT_MINUTES   GNUNET_TIME_relative_get_minute_ ()
 One minute. More...
 
#define GNUNET_TIME_UNIT_HOURS   GNUNET_TIME_relative_get_hour_ ()
 One hour. More...
 
#define GNUNET_TIME_UNIT_DAYS
 One day. More...
 
#define GNUNET_TIME_UNIT_WEEKS
 One week. More...
 
#define GNUNET_TIME_UNIT_MONTHS
 One month (30 days). More...
 
#define GNUNET_TIME_UNIT_YEARS
 One year (365 days). More...
 
#define GNUNET_TIME_UNIT_FOREVER_REL    ((struct GNUNET_TIME_Relative){UINT64_MAX})
 Constant used to specify "forever". More...
 
#define GNUNET_TIME_UNIT_FOREVER_ABS    ((struct GNUNET_TIME_Absolute){UINT64_MAX})
 Constant used to specify "forever". More...
 
#define GNUNET_TIME_UNIT_FOREVER_TS    ((struct GNUNET_TIME_Timestamp){{UINT64_MAX}})
 Constant used to specify "forever". More...
 
#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
 Threshold after which exponential backoff should not increase (15 m). More...
 
#define GNUNET_TIME_STD_BACKOFF(r)
 Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of 2 up unto a maximum of 15 m. More...
 
#define GNUNET_TIME_absolute_cmp(t1, op, t2)    ((void) (1 op 2), (t1).abs_value_us op (t2).abs_value_us)
 Compare two absolute times. More...
 
#define GNUNET_TIME_timestamp_cmp(t1, op, t2)    GNUNET_TIME_absolute_cmp ((t1).abs_time,op,(t2).abs_time)
 Compare two timestamps. More...
 
#define GNUNET_TIME_relative_cmp(t1, op, t2)    ((void) (1 op 2), (t1).rel_value_us op (t2).rel_value_us)
 Compare two relative times. More...
 

Functions

enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
 Convert a given fancy human-readable time to our internal representation. More...
 
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_timestamp (const char *fancy_time, struct GNUNET_TIME_Timestamp *atime)
 Convert a given fancy human-readable time to our internal representation. More...
 
const char * GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
 Like asctime, except for GNUnet time. More...
 
const char * GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, int do_round)
 Give relative time in human-readable fancy format. More...
 
const char * GNUNET_TIME_timestamp2s (struct GNUNET_TIME_Timestamp ts)
 Convert ts to human-readable timestamp. More...
 
const char * GNUNET_TIME_absolute2s (struct GNUNET_TIME_Absolute ts)
 Like asctime, except for GNUnet time. More...
 
const char * GNUNET_TIME_relative2s (struct GNUNET_TIME_Relative delta, bool do_round)
 Give relative time in human-readable fancy format. More...
 
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. More...
 
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. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_ (void)
 Return relative time of 0ms. More...
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_ (void)
 Return absolute time of 0ms. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_unit_ (void)
 Return relative time of 1 microsecond. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_millisecond_ (void)
 Return relative time of 1ms. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_second_ (void)
 Return relative time of 1s. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_minute_ (void)
 Return relative time of 1 minute. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_hour_ (void)
 Return relative time of 1 hour. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_ (void)
 Return "forever". More...
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_ (void)
 Return "forever". More...
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get (void)
 Get the current time. More...
 
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
 Convert relative time to an absolute time in the future. More...
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_relative_to_timestamp (struct GNUNET_TIME_Relative rel)
 Convert relative time to a timestamp in the future. More...
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_absolute_to_timestamp (struct GNUNET_TIME_Absolute at)
 Round an absolute time to a timestamp. More...
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_get (void)
 Get timestamp representing the current time. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_max (struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2)
 Return the maximum of two timestamps. More...
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_min (struct GNUNET_TIME_Timestamp t1, struct GNUNET_TIME_Timestamp t2)
 Return the minimum of two timestamps. More...
 
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? More...
 
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. More...
 
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. More...
 
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. More...
 
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". More...
 
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. More...
 
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. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, unsigned long long factor)
 Multiply relative time by a given factor. More...
 
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. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, unsigned long long factor)
 Divide relative time by a given factor. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
 Add relative times together. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
 Subtract relative timestamp from the other. More...
 
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a)
 Convert relative time to network byte order. More...
 
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a)
 Convert relative time from network byte order. More...
 
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a)
 Convert absolute time to network byte order. More...
 
struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton (struct GNUNET_TIME_Timestamp t)
 Convert timestamp to network byte order. More...
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_ms (uint64_t ms_after_epoch)
 Convert milliseconds after the UNIX epoch to absolute time. More...
 
bool GNUNET_TIME_absolute_is_never (struct GNUNET_TIME_Absolute abs)
 Test if abs is never. More...
 
bool GNUNET_TIME_absolute_is_past (struct GNUNET_TIME_Absolute abs)
 Test if abs is truly in the past (excluding now). More...
 
bool GNUNET_TIME_absolute_is_zero (struct GNUNET_TIME_Absolute abs)
 Test if abs is truly zero. More...
 
bool GNUNET_TIME_absolute_is_future (struct GNUNET_TIME_Absolute abs)
 Test if abs is truly in the future (excluding now). More...
 
bool GNUNET_TIME_relative_is_forever (struct GNUNET_TIME_Relative rel)
 Test if rel is forever. More...
 
bool GNUNET_TIME_relative_is_zero (struct GNUNET_TIME_Relative rel)
 Test if rel is zero. More...
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s (uint64_t s_after_epoch)
 Convert seconds after the UNIX epoch to absolute time. More...
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_from_s (uint64_t s_after_epoch)
 Convert seconds after the UNIX epoch to timestamp. More...
 
uint64_t GNUNET_TIME_timestamp_to_s (struct GNUNET_TIME_Timestamp ts)
 Convert timestamp to number of seconds after the UNIX epoch. More...
 
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a)
 Convert absolute time from network byte order. More...
 
struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_ntoh (struct GNUNET_TIME_TimestampNBO tn)
 Convert timestamp from network byte order. More...
 
void GNUNET_TIME_set_offset (long long offset)
 Set the timestamp offset for this instance. More...
 
long long GNUNET_TIME_get_offset (void)
 Get the timestamp offset for this instance. More...
 
unsigned int GNUNET_TIME_get_current_year (void)
 Return the current year (e.g. More...
 
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. More...
 
unsigned int GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at)
 Convert an expiration time to the respective year (rounds) More...
 
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. More...
 

Detailed Description

Time and time calculations.

Macro Definition Documentation

◆ GNUNET_TIME_UNIT_ZERO

#define GNUNET_TIME_UNIT_ZERO   ((struct GNUNET_TIME_Relative){0})

Relative time zero.

Definition at line 125 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_ZERO_ABS

#define GNUNET_TIME_UNIT_ZERO_ABS   ((struct GNUNET_TIME_Absolute){0})

Absolute time zero.

Definition at line 130 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_ZERO_TS

#define GNUNET_TIME_UNIT_ZERO_TS   ((struct GNUNET_TIME_Timestamp){{0}})

Timestamp of zero.

Definition at line 135 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MICROSECONDS

#define GNUNET_TIME_UNIT_MICROSECONDS   GNUNET_TIME_relative_get_unit_ ()

One microsecond, our basic time unit.

Definition at line 140 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MILLISECONDS

#define GNUNET_TIME_UNIT_MILLISECONDS   GNUNET_TIME_relative_get_millisecond_ ()

One millisecond.

Definition at line 145 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_SECONDS

#define GNUNET_TIME_UNIT_SECONDS   GNUNET_TIME_relative_get_second_ ()

One second.

Definition at line 150 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MINUTES

#define GNUNET_TIME_UNIT_MINUTES   GNUNET_TIME_relative_get_minute_ ()

One minute.

Definition at line 155 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_HOURS

#define GNUNET_TIME_UNIT_HOURS   GNUNET_TIME_relative_get_hour_ ()

One hour.

Definition at line 160 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_DAYS

#define GNUNET_TIME_UNIT_DAYS
Value:
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:484

One day.

Definition at line 165 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_WEEKS

#define GNUNET_TIME_UNIT_WEEKS
Value:

One week.

Definition at line 171 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_MONTHS

#define GNUNET_TIME_UNIT_MONTHS
Value:

One month (30 days).

Definition at line 177 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_YEARS

#define GNUNET_TIME_UNIT_YEARS
Value:

One year (365 days).

Definition at line 183 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_FOREVER_REL

#define GNUNET_TIME_UNIT_FOREVER_REL    ((struct GNUNET_TIME_Relative){UINT64_MAX})

Constant used to specify "forever".

This constant will be treated specially in all time operations.

Definition at line 190 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_FOREVER_ABS

#define GNUNET_TIME_UNIT_FOREVER_ABS    ((struct GNUNET_TIME_Absolute){UINT64_MAX})

Constant used to specify "forever".

This constant will be treated specially in all time operations.

Definition at line 197 of file gnunet_time_lib.h.

◆ GNUNET_TIME_UNIT_FOREVER_TS

#define GNUNET_TIME_UNIT_FOREVER_TS    ((struct GNUNET_TIME_Timestamp){{UINT64_MAX}})

Constant used to specify "forever".

This constant will be treated specially in all time operations.

Definition at line 204 of file gnunet_time_lib.h.

◆ GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD

#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)

Threshold after which exponential backoff should not increase (15 m).

Definition at line 211 of file gnunet_time_lib.h.

◆ GNUNET_TIME_STD_BACKOFF

#define GNUNET_TIME_STD_BACKOFF (   r)
Value:
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.
Definition: time.c:343
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.
Definition: time.c:351
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD
Threshold after which exponential backoff should not increase (15 m).

Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of 2 up unto a maximum of 15 m.

Parameters
rcurrent backoff time, initially zero

Definition at line 221 of file gnunet_time_lib.h.

◆ GNUNET_TIME_absolute_cmp

#define GNUNET_TIME_absolute_cmp (   t1,
  op,
  t2 
)     ((void) (1 op 2), (t1).abs_value_us op (t2).abs_value_us)

Compare two absolute times.

Parameters
t1first time
opcompare operator
t2second time
Returns
true if t1 op t2

Definition at line 413 of file gnunet_time_lib.h.

◆ GNUNET_TIME_timestamp_cmp

#define GNUNET_TIME_timestamp_cmp (   t1,
  op,
  t2 
)     GNUNET_TIME_absolute_cmp ((t1).abs_time,op,(t2).abs_time)

Compare two timestamps.

Parameters
t1first timestamp
opcompare operator
t2second timestamp
Returns
true if t1 op t2

Definition at line 425 of file gnunet_time_lib.h.

◆ GNUNET_TIME_relative_cmp

#define GNUNET_TIME_relative_cmp (   t1,
  op,
  t2 
)     ((void) (1 op 2), (t1).rel_value_us op (t2).rel_value_us)

Compare two relative times.

Parameters
t1first time
opcompare operator
t2second time
Returns
true if t1 op t2

Definition at line 437 of file gnunet_time_lib.h.

Function Documentation

◆ GNUNET_STRINGS_fancy_time_to_absolute()

enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute ( const char *  fancy_time,
struct GNUNET_TIME_Absolute atime 
)

Convert a given fancy human-readable time to our internal representation.

The human-readable time is expected to be in local time, whereas the returned value will be in UTC.

Parameters
fancy_timehuman readable string (e.g. Y-m-d H:M:S)
atimeset to the absolute time
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 138 of file strings.c.

304 {
305  struct tm tv;
306  time_t t;
307  const char *eos;
308 
309  if (0 == strcasecmp ("end of time", fancy_time))
310  {
312  return GNUNET_OK;
313  }
314  eos = &fancy_time[strlen (fancy_time)];
315  memset (&tv, 0, sizeof(tv));
316  if ((eos != strptime (fancy_time, "%a %b %d %H:%M:%S %Y", &tv)) &&
317  (eos != strptime (fancy_time, "%c", &tv)) &&
318  (eos != strptime (fancy_time, "%Ec", &tv)) &&
319  (eos != strptime (fancy_time, "%Y-%m-%d %H:%M:%S", &tv)) &&
320  (eos != strptime (fancy_time, "%Y-%m-%d %H:%M", &tv)) &&
321  (eos != strptime (fancy_time, "%x", &tv)) &&
322  (eos != strptime (fancy_time, "%Ex", &tv)) &&
323  (eos != strptime (fancy_time, "%Y-%m-%d", &tv)) &&
324  (eos != strptime (fancy_time, "%Y-%m", &tv)) &&
325  (eos != strptime (fancy_time, "%Y", &tv)))
326  return GNUNET_SYSERR;
327  t = mktime (&tv);
328  atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL);
329  return GNUNET_OK;
330 }
static struct GNUNET_SCHEDULER_Task * t
Main task.
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
uint64_t abs_value_us
The actual value.

Referenced by database_setup(), parse_expiration(), and sign_cb().

Here is the caller graph for this function:

◆ GNUNET_STRINGS_fancy_time_to_timestamp()

enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_timestamp ( const char *  fancy_time,
struct GNUNET_TIME_Timestamp atime 
)

Convert a given fancy human-readable time to our internal representation.

The human-readable time is expected to be in local time, whereas the returned value will be in UTC.

Parameters
fancy_timehuman readable string (e.g. Y-m-d H:M:S)
atimeset to the absolute time
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 138 of file strings.c.

336 {
337  return GNUNET_STRINGS_fancy_time_to_absolute (fancy_time,
338  &atime->abs_time);
339 }
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:302
struct GNUNET_TIME_Absolute abs_time
The actual value.

◆ GNUNET_STRINGS_absolute_time_to_string()

const char* GNUNET_STRINGS_absolute_time_to_string ( struct GNUNET_TIME_Absolute  t)

Like asctime, except for GNUnet time.

Converts a GNUnet internal absolute time (which is in UTC) to a string in local time. Note that the returned value will be overwritten if this function is called again.

Parameters
tthe absolute time to convert
Returns
timestamp in human-readable form in local time

Definition at line 616 of file strings.c.

617 {
618  static GNUNET_THREAD_LOCAL char buf[255];
619  time_t tt;
620  struct tm *tp;
621 
623  return "end of time";
624  tt = t.abs_value_us / 1000LL / 1000LL;
625  tp = localtime (&tt);
626  /* This is hacky, but i don't know a way to detect libc character encoding.
627  * Just expect utf8 from glibc these days.
628  * As for msvcrt, use the wide variant, which always returns utf16
629  * (otherwise we'd have to detect current codepage or use W32API character
630  * set conversion routines to convert to UTF8).
631  */
632  strftime (buf, sizeof(buf), "%a %b %d %H:%M:%S %Y", tp);
633 
634  return buf;
635 }
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
Definition: gnunet-abd.c:76
static char buf[2048]
bool GNUNET_TIME_absolute_is_never(struct GNUNET_TIME_Absolute abs)
Test if abs is never.
Definition: time.c:648
#define GNUNET_THREAD_LOCAL
Definition: platform.h:247

References buf, GNUNET_THREAD_LOCAL, GNUNET_TIME_absolute_is_never(), t, and tt.

Referenced by dispatch_job(), display_record(), do_rekey(), dump_pc(), execute_get(), fragmented_message_done(), get_resp_callback(), GNUNET_FS_meta_data_add_publication_date(), got_hello(), handle_dht_response(), handle_namecache_block_response(), handle_p2p_estimate(), handle_validation_response(), inject_rekey(), learn_dv_path(), monitor_cb(), monitor_notify_connect(), monitor_notify_disconnect(), namecache_sqlite_cache_block(), neighbours_changed_notification(), ns_lookup_result_cb(), parse_expiration(), print_info(), print_plugin_event_info(), printer(), printer_watch(), process_queue(), process_record(), put_callback(), select_loop(), set_state_and_timeout(), sqlite_plugin_put(), store_and_free_entries(), store_pi(), timeout_cb(), transmit_item(), transmit_on_queue(), transmit_task_cb(), update_pm_next_attempt(), and warn_monitor_slow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_STRINGS_relative_time_to_string()

const char* GNUNET_STRINGS_relative_time_to_string ( struct GNUNET_TIME_Relative  delta,
int  do_round 
)

Give relative time in human-readable fancy format.

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
deltatime in milli seconds
do_roundare we allowed to round a bit?
Returns
string in human-readable form

Definition at line 569 of file strings.c.

571 {
572  static GNUNET_THREAD_LOCAL char buf[128];
573  const char *unit = /* time unit */ "µs";
574  uint64_t dval = delta.rel_value_us;
575 
576  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == delta.rel_value_us)
577  return "forever";
578  if (0 == delta.rel_value_us)
579  return "0 ms";
580  if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
581  {
582  dval = dval / 1000;
583  unit = /* time unit */ "ms";
584  if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
585  {
586  dval = dval / 1000;
587  unit = /* time unit */ "s";
588  if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
589  {
590  dval = dval / 60;
591  unit = /* time unit */ "m";
592  if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
593  {
594  dval = dval / 60;
595  unit = /* time unit */ "h";
596  if (((GNUNET_YES == do_round) && (dval > 5 * 24)) ||
597  (0 == (dval % 24)))
598  {
599  dval = dval / 24;
600  if (1 == dval)
601  unit = /* time unit */ "day";
602  else
603  unit = /* time unit */ "days";
604  }
605  }
606  }
607  }
608  }
609  GNUNET_snprintf (buf, sizeof(buf), "%llu %s",
610  (unsigned long long) dval, unit);
611  return buf;
612 }
static void do_round(void *cls)
Send out PUSHes and PULLs, possibly update #view, samplers.
@ GNUNET_YES
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36
uint64_t rel_value_us
The actual value.

References buf, delta, do_round(), GNUNET_snprintf(), GNUNET_THREAD_LOCAL, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, and GNUNET_TIME_Relative::rel_value_us.

Referenced by ack_proc(), ats_reserve_callback(), channel_open_sent_cb(), client_receive(), client_receive_mst_cb(), client_session_timeout(), connect_fail_continuation(), consider_sending_fc(), data_sent_cb(), delay_warning(), delayed_restart_task(), disconnect_and_schedule_reconnect(), display_record(), do_directory_scan(), do_disconnect(), do_shutdown(), do_speedup(), experiment_done_cb(), expired_processor(), find_proof(), flush_bulk(), fragmented_message_done(), GNUNET_ATS_solver_logging_start(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_solvers_experimentation_run(), GNUNET_BANDWIDTH_value_get_available_until(), GNUNET_DATASTORE_put(), GNUNET_HOSTLIST_client_start(), GNUNET_SCHEDULER_do_work(), GNUNET_SPEEDUP_start_(), GSC_CLIENTS_solicit_request(), GSF_block_peer_migration_(), GST_ats_block_address(), GST_ats_update_delay(), GST_manipulation_init(), GST_manipulation_send(), GST_neighbours_calculate_receive_delay(), GST_validation_start(), handle_announce(), handle_client_join(), handle_client_send(), handle_data(), handle_dv_learn(), handle_encrypted(), handle_p2p_migration_stop(), handle_p2p_put(), handle_send_transmit_continuation(), handle_tcp_data(), handler_advertisement(), http_client_plugin_update_inbound_delay(), http_server_plugin_update_inbound_delay(), interpreter_next(), list_callback(), load_episodes(), maint_child_death(), manage_first_hop_mq(), master_task(), monitor_cb(), netjail_exec_run(), odc_warn_delay_task(), parse_expiration(), plan(), print_plugin_event_info(), process_job_queue(), process_mst(), process_stat(), process_stdin(), prof_time(), progress_cb(), put_migration_continuation(), qc_message_sent(), queue_read(), queue_timeout(), quota_processor(), read_process_ack(), receive_ready(), RECLAIM_TICKETS_init(), reconnect(), regex_found_handler(), remove_timeout_messages_and_select(), reschedule_connect(), reservations_reserve(), revalidate_address(), run(), schedule_peer_transmission(), schedule_select_v4(), schedule_select_v6(), search_timed_out(), server_access_cb(), server_receive_mst_cb(), server_session_timeout(), session_timeout(), shutdown_task(), sqlite_plugin_put(), start_dv_learn(), store_completed_cb(), task_check(), task_hostlist_saving(), tcp_plugin_update_inbound_delay(), test_master(), timeout_cb(), timeout_episode(), transmit_item(), transmit_next(), transmit_on_queue(), try_reconnect(), try_transmission(), udp_plugin_send(), update_excess(), update_tracker(), update_velocity(), validation_start_cb(), warn_delay(), warn_delay_task(), warn_no_client_continue(), warn_no_receive_done(), and zone_iteration_finished().

Here is the call graph for this function:

◆ GNUNET_TIME_timestamp2s()

const char* GNUNET_TIME_timestamp2s ( struct GNUNET_TIME_Timestamp  ts)

Convert ts to human-readable timestamp.

Note that the returned value will be overwritten if this function is called again.

Parameters
tsthe timestamp to convert
Returns
statically allocated string, will change on the next call

Definition at line 214 of file time.c.

215 {
216  static GNUNET_THREAD_LOCAL char buf[255];
217  time_t tt;
218  struct tm *tp;
219 
221  return "end of time";
222  tt = ts.abs_time.abs_value_us / 1000LL / 1000LL;
223  tp = localtime (&tt);
224  /* This is hacky, but i don't know a way to detect libc character encoding.
225  * Just expect utf8 from glibc these days.
226  * As for msvcrt, use the wide variant, which always returns utf16
227  * (otherwise we'd have to detect current codepage or use W32API character
228  * set conversion routines to convert to UTF8).
229  */
230  strftime (buf,
231  sizeof(buf),
232  "%a %b %d %H:%M:%S %Y",
233  tp);
234  return buf;
235 }

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, buf, GNUNET_THREAD_LOCAL, GNUNET_TIME_absolute_is_never(), and tt.

Here is the call graph for this function:

◆ GNUNET_TIME_absolute2s()

const char* GNUNET_TIME_absolute2s ( struct GNUNET_TIME_Absolute  ts)

Like asctime, except for GNUnet time.

Converts a GNUnet internal absolute time (which is in UTC) to a string in local time. Note that the returned value will be overwritten if this function is called again.

Parameters
tsthe absolute time to convert
Returns
timestamp in human-readable form in local time

Definition at line 239 of file time.c.

240 {
241  static GNUNET_THREAD_LOCAL char buf[255];
242  time_t tt;
243  struct tm *tp;
244 
246  return "end of time";
247  tt = t.abs_value_us / 1000LL / 1000LL;
248  tp = localtime (&tt);
249  /* This is hacky, but i don't know a way to detect libc character encoding.
250  * Just expect utf8 from glibc these days.
251  * As for msvcrt, use the wide variant, which always returns utf16
252  * (otherwise we'd have to detect current codepage or use W32API character
253  * set conversion routines to convert to UTF8).
254  */
255  strftime (buf,
256  sizeof(buf),
257  "%a %b %d %H:%M:%S %Y",
258  tp);
259  return buf;
260 }

References buf, GNUNET_THREAD_LOCAL, GNUNET_TIME_absolute_is_never(), t, and tt.

Here is the call graph for this function:

◆ GNUNET_TIME_relative2s()

const char* GNUNET_TIME_relative2s ( struct GNUNET_TIME_Relative  delta,
bool  do_round 
)

Give relative time in human-readable fancy format.

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
deltatime in milli seconds
do_roundare we allowed to round a bit?
Returns
string in human-readable form

Definition at line 264 of file time.c.

266 {
267  static GNUNET_THREAD_LOCAL char buf[128];
268  const char *unit = /* time unit */ "µs";
269  uint64_t dval = delta.rel_value_us;
270 
272  return "forever";
273  if (0 == delta.rel_value_us)
274  return "0 ms";
275  if ( ((GNUNET_YES == do_round) &&
276  (dval > 5 * 1000)) ||
277  (0 == (dval % 1000)))
278  {
279  dval = dval / 1000;
280  unit = /* time unit */ "ms";
281  if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
282  {
283  dval = dval / 1000;
284  unit = /* time unit */ "s";
285  if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
286  {
287  dval = dval / 60;
288  unit = /* time unit */ "m";
289  if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
290  {
291  dval = dval / 60;
292  unit = /* time unit */ "h";
293  if (((GNUNET_YES == do_round) && (dval > 5 * 24)) ||
294  (0 == (dval % 24)))
295  {
296  dval = dval / 24;
297  if (1 == dval)
298  unit = /* time unit */ "day";
299  else
300  unit = /* time unit */ "days";
301  }
302  }
303  }
304  }
305  }
307  sizeof(buf),
308  "%llu %s",
309  (unsigned long long) dval,
310  unit);
311  return buf;
312 }
bool GNUNET_TIME_relative_is_forever(struct GNUNET_TIME_Relative rel)
Test if rel is forever.
Definition: time.c:655

Referenced by GNUNET_CURL_perform2().

Here is the caller graph for this function:

◆ GNUNET_TIME_randomized_backoff()

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.

Parameters
rtcurrent backoff time, initially zero
thresholdmaximum value for backoff
Returns
the next backoff time

Definition at line 779 of file time.c.

832 {
833  double r = (rand () % 500) / 1000.0;
834  struct GNUNET_TIME_Relative t;
835 
838  2 + r);
840 }
static unsigned int threshold
What should the threshold for then key be?
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_TIME_Relative relative_multiply_double(struct GNUNET_TIME_Relative rel, double factor)
Definition: time.c:504

Referenced by error_handler(), and validation_start_cb().

Here is the caller graph for this function:

◆ GNUNET_TIME_randomize()

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.

Parameters
rinput time for scaling
Returns
randomized time

Definition at line 844 of file time.c.

852 {
853  double d = ((rand () % 1001) + 500) / 1000.0;
854 
855  return relative_multiply_double (r, d);
856 }

Referenced by start_dv_learn().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_zero_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_ ( void  )

Return relative time of 0ms.

Definition at line 63 of file time.c.

134 {
135  static struct GNUNET_TIME_Relative zero;
136 
137  return zero;
138 }
static const struct GNUNET_IDENTITY_PrivateKey zero
Public key of all zeros.

Referenced by callback_verify_room_message(), create_handle(), delayed_disconnect_channel(), on_identity(), and solve_srv_room_member_collisions().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_zero_()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_ ( void  )

Return absolute time of 0ms.

Definition at line 63 of file time.c.

143 {
144  static struct GNUNET_TIME_Absolute zero;
145 
146  return zero;
147 }
Time for absolute times used by GNUnet, in microseconds.

Referenced by create_operation(), and stop_operation().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_unit_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_unit_ ( void  )

Return relative time of 1 microsecond.

Definition at line 63 of file time.c.

152 {
153  static struct GNUNET_TIME_Relative one = { 1 };
154 
155  return one;
156 }

◆ GNUNET_TIME_relative_get_millisecond_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_millisecond_ ( void  )

Return relative time of 1ms.

Definition at line 63 of file time.c.

161 {
162  static struct GNUNET_TIME_Relative one = { 1000 };
163 
164  return one;
165 }

◆ GNUNET_TIME_relative_get_second_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_second_ ( void  )

Return relative time of 1s.

Definition at line 63 of file time.c.

170 {
171  static struct GNUNET_TIME_Relative one = { 1000 * 1000LL };
172 
173  return one;
174 }

Referenced by login_cont().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_minute_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_minute_ ( void  )

Return relative time of 1 minute.

Definition at line 63 of file time.c.

179 {
180  static struct GNUNET_TIME_Relative one = { 60 * 1000 * 1000LL };
181 
182  return one;
183 }

Referenced by register_reciever().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_get_hour_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_hour_ ( void  )

Return relative time of 1 hour.

Definition at line 63 of file time.c.

188 {
189  static struct GNUNET_TIME_Relative one = { 60 * 60 * 1000 * 1000LL };
190 
191  return one;
192 }

◆ GNUNET_TIME_relative_get_forever_()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_ ( void  )

Return "forever".

Definition at line 63 of file time.c.

197 {
198  static struct GNUNET_TIME_Relative forever = { UINT64_MAX };
199 
200  return forever;
201 }

Referenced by delete_srv_room_message(), and main().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_forever_()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_ ( void  )

Return "forever".

Definition at line 63 of file time.c.

206 {
207  static struct GNUNET_TIME_Absolute forever = { UINT64_MAX };
208 
209  return forever;
210 }

◆ GNUNET_TIME_absolute_get()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get ( void  )

Get the current time.

Returns
the current time

Definition at line 63 of file time.c.

112 {
113  struct GNUNET_TIME_Absolute ret;
114  struct timeval tv;
115 
116  gettimeofday (&tv, NULL);
117  ret.abs_value_us = (uint64_t) (((uint64_t) tv.tv_sec * 1000LL * 1000LL)
118  + ((uint64_t) tv.tv_usec))
120  return ret;
121 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static long long timestamp_offset
Variable used to simulate clock skew.
Definition: time.c:46

Referenced by ack_proc(), add_valid_address(), add_without_sets(), announce_id(), batch_run(), cache_nick(), check_dht_local_get_result_seen(), check_iteration_start(), check_vl_transmission(), cleanup_expired_records(), client_receive(), client_receive_mst_cb(), code_redirect(), consider_for_advertising(), consider_path_cb(), continue_store_activity(), cookie_identity_interpretation(), core_init(), create_download_context(), create_member_session(), create_peers(), create_session(), cron_clean_data_hosts(), cummulative_ack(), data_sent_cb(), dht_connect_cb(), do_directory_scan(), do_transmit(), event_cb(), expire_blocks(), expired_processor(), find_proof(), flush_bulk(), GAS_addresses_add(), GAS_addresses_update(), GCC_handle_connection_create_ack(), GCC_handle_encrypted(), GCC_transmit(), GCT_add_inbound_connection(), GDS_ROUTING_add(), generate_id_token_body(), get_age(), get_any(), get_nick_record(), get_redirect_state(), get_typed(), GNUNET_ATS_solver_generate_preferences_start(), GNUNET_ATS_solver_generate_property_start(), GNUNET_ATS_solver_logging_now(), GNUNET_ATS_solvers_experimentation_run(), GNUNET_BANDWIDTH_tracker_init2(), GNUNET_CRYPTO_random_timeflake(), GNUNET_FS_meta_data_add_publication_date(), GNUNET_FS_publish_main_(), GNUNET_FS_queue_(), GNUNET_FS_search_probe_progress_(), GNUNET_FS_unindex_start(), GNUNET_LOAD_value_init(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_run(), GNUNET_SERVER_connect_socket(), GNUNET_SERVER_inject(), GNUNET_TESTING_cmd_batch_next_(), GNUNET_TIME_absolute_from_ms(), GNUNET_TIME_absolute_is_past(), GSC_KX_encrypt_and_transmit(), GSC_SESSIONS_set_typemap(), GSF_peer_transmit_(), GSF_pending_request_create_(), GSF_pending_request_get_message_(), GST_validation_start(), handle_client_send(), handle_client_send_request(), handle_connection_create(), handle_dht_p2p_put(), handle_dht_reply(), handle_dummy(), handle_dv_learn(), handle_ephemeral_key(), handle_fragment_box(), handle_icmp_back(), handle_message_delete(), handle_monitor_next(), handle_p2p_estimate(), handle_p2p_put(), handle_stop(), handle_tcp_back(), handle_tcp_data(), handle_tcp_nat_probe(), handle_tcp_welcome(), handle_udp_back(), handler_advertisement(), insert_sorted(), interpreter_next(), interpreter_run(), iterate_zones(), iteration_start(), lookup_authz_cb(), manage_first_hop_mq(), merge_with_nick_records(), monitor_cb(), monitor_notify_connect(), monitor_notify_disconnect(), monitor_unblock(), mylog(), namecache_postgres_expire_blocks(), namecache_sqlite_cache_block(), namecache_sqlite_expire_blocks(), notify_connect(), pack_srv_room_message(), peer_transmit(), postgres_plugin_del(), postgres_plugin_get_closest(), postgres_plugin_get_expiration(), prepare_pending_acknowledgement(), printer(), printer_watch(), process_incoming(), process_local_reply(), process_queue(), process_result(), process_rq_task(), process_stdin(), progress_cb(), read_host_file(), read_process_fragment(), read_start_time(), read_stdio(), RECLAIM_TICKETS_consume(), remove_expired(), route_message(), route_packet(), RPS_sampler_elem_reinit(), run(), sample_load_task(), sampler_mod_get_rand_peer(), scan(), schedule_peer_transmission(), search_start(), select_best_pending_from_link(), send_disconnect(), send_keepalive(), send_kx(), send_kx_auth(), send_simple_single(), send_syn(), send_utilization_data(), service_client_mst_cb(), session_disconnect_adapter(), set_feedback_task(), setup_estimate_message(), setup_job(), setup_neighbour(), setup_state_record(), shutdown_task(), sign_ephemeral_key(), solver_bandwidth_changed_cb(), sqlite_plugin_get_closest(), sqlite_plugin_get_expiration(), start_address_validation(), start_dht_request(), start_download(), start_dv_learn(), start_job(), start_local_query(), start_operation(), start_peers_task(), start_process(), start_publish(), stat_iterator(), store_completed_cb(), store_skipped_key(), switch_member_session(), t_ax_encrypt(), test_exist_cb(), tmt_rdy_ping(), transmit_next(), transmit_ping_if_allowed(), transmit_ready_callback_wrapper(), try_transmission(), udp_plugin_create_session(), udp_plugin_send(), udp_select_send(), unix_plugin_send(), update_active_address(), update_ax_by_kx(), update_excess(), update_hello(), update_hostlist(), update_tracker(), update_velocity(), updateAgedLoad(), and wait_op_completion().

◆ GNUNET_TIME_relative_to_absolute()

struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute ( struct GNUNET_TIME_Relative  rel)

Convert relative time to an absolute time in the future.

Parameters
relrelative time to convert
Returns
timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow)

Definition at line 264 of file time.c.

317 {
318  struct GNUNET_TIME_Absolute ret;
319 
323 
324  if (rel.rel_value_us + now.abs_value_us < rel.rel_value_us)
325  {
326  GNUNET_break (0); /* overflow... */
328  }
329  ret.abs_value_us = rel.rel_value_us + now.abs_value_us;
330  return ret;
331 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get()
Get the current time.
Definition: time.c:111

Referenced by add_setter_action(), add_without_sets(), boot_queue(), cadet_reply_proc(), check_for_glue(), client_receive_mst_cb(), client_reschedule_session_timeout(), create_macendpoint(), create_proto_queue(), create_session(), data_sent_cb(), do_dht_put(), download_hostlist(), forward_dv_box(), GNUNET_CONNECTION_notify_transmit_ready(), GNUNET_CONNECTION_receive(), GNUNET_DNSPARSER_parse_record(), GNUNET_OS_command_run(), GNUNET_RESOLVER_hostname_get(), GNUNET_RESOLVER_ip_get(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_add_select(), GSC_SESSIONS_transmit(), GSF_pending_request_create_(), GST_ats_block_address(), GST_manipulation_send(), GST_neighbours_calculate_receive_delay(), GST_neighbours_handle_session_ack(), GST_neighbours_handle_session_syn(), GST_neighbours_handle_session_syn_ack(), GST_neighbours_send(), GST_neighbours_session_terminated(), GST_validation_handle_ping(), GST_validation_handle_pong(), handle_client_call_message(), handle_dht_p2p_put(), handle_dht_reply(), handle_dv_box(), handle_dv_learn(), handle_find_my_hello(), handle_fragment_box(), handle_p2p_migration_stop(), handle_p2p_put(), handle_reliability_box(), handle_validation_response(), http_client_plugin_get_session(), http_client_plugin_update_inbound_delay(), http_server_plugin_update_inbound_delay(), learn_dv_path(), login_cont(), maint_child_death(), make_file(), master_task(), modify_address(), mq_init(), ns_lookup_result_cb(), plan(), print_record(), process_data(), process_record(), process_result(), publish_fs_connect_complete_cb(), put_migration_continuation(), refresh_hello_task(), regex_iterator(), reschedule_peer_timeout(), reschedule_queue_timeout(), reschedule_receiver_timeout(), reschedule_sender_timeout(), reschedule_session_timeout(), result_processor(), revalidate_address(), run(), schedule_next_hello(), send_create(), send_create_ack(), send_keepalive(), send_kx(), send_kx_auth(), send_session_syn_ack_cont(), send_session_syn_cont(), send_syn(), send_syn_ack_message(), send_with_fragmentation(), server_lookup_connection(), server_receive_mst_cb(), server_reschedule_session_timeout(), setup_filter(), setup_out_cipher(), setup_queue(), setup_sender(), sign_ephemeral_key(), start_address_validation(), store_pi(), switch_address_bl_check_cont(), tcp_plugin_send(), tcp_plugin_update_inbound_delay(), transmit_next(), transmit_on_queue(), transmit_ping_if_allowed(), transmit_request(), udp_plugin_create_session(), udp_plugin_send(), unix_plugin_get_session(), update_pm_next_attempt(), update_timeout(), validation_start_cb(), vpn_allocation_cb(), and wlan_plugin_update_session_timeout().

◆ GNUNET_TIME_relative_to_timestamp()

struct GNUNET_TIME_Timestamp GNUNET_TIME_relative_to_timestamp ( struct GNUNET_TIME_Relative  rel)

Convert relative time to a timestamp in the future.

Parameters
relrelative time to convert
Returns
timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow)

Definition at line 264 of file time.c.

336 {
339 }
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:316
struct GNUNET_TIME_Timestamp GNUNET_TIME_absolute_to_timestamp(struct GNUNET_TIME_Absolute at)
Round an absolute time to a timestamp.
Definition: time.c:79

Referenced by GNUNET_HELLO_builder_add_address().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_to_timestamp()

struct GNUNET_TIME_Timestamp GNUNET_TIME_absolute_to_timestamp ( struct GNUNET_TIME_Absolute  at)

Round an absolute time to a timestamp.

Parameters
attime to round
Returns
the result

Definition at line 63 of file time.c.

80 {
81  struct GNUNET_TIME_Timestamp ts;
82 
85  ts.abs_time.abs_value_us = at.abs_value_us - at.abs_value_us % 1000000;
86  return ts;
87 }
#define GNUNET_TIME_UNIT_FOREVER_TS
Constant used to specify "forever".
Rounded time for timestamps used by GNUnet, in seconds.

◆ GNUNET_TIME_timestamp_get()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_get ( void  )

Get timestamp representing the current time.

Returns
current time, rounded down to seconds

Definition at line 63 of file time.c.

126 {
129 }

◆ GNUNET_TIME_relative_min()

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.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 264 of file time.c.

345 {
346  return (t1.rel_value_us < t2.rel_value_us) ? t1 : t2;
347 }

Referenced by announce_id(), calculate_put_interval(), check_timeouts(), check_zone_namestore_next(), delayed_restart_task(), download_prepare(), find_advertisable_hello(), find_min_max_it(), GNUNET_FRAGMENT_process_ack(), GNUNET_TIME_absolute_approx_eq(), handle_validation_response(), master_task(), process_job_queue(), put_migration_continuation(), reconnect(), revalidate_address(), schedule_next_put(), schedule_next_task(), start_address_validation(), and try_connect_using_address().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_max()

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.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is larger

Definition at line 264 of file time.c.

353 {
354  return (t1.rel_value_us > t2.rel_value_us) ? t1 : t2;
355 }

Referenced by announce_id(), consider_gathering(), data_sent_cb(), do_scheduler_notify(), find_min_max_it(), put_migration_continuation(), reconnect(), schedule_next_task(), send_keep_alive(), and transmit_next().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_min()

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.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 264 of file time.c.

361 {
362  return (t1.abs_value_us < t2.abs_value_us) ? t1 : t2;
363 }

Referenced by cadet_reply_proc(), cummulative_ack(), find_other_matching(), handle_dht_reply(), handle_p2p_put(), handle_validation_response(), ns_lookup_result_cb(), process_result(), and try_transmission().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_max()

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.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 264 of file time.c.

369 {
370  return (t1.abs_value_us > t2.abs_value_us) ? t1 : t2;
371 }

Referenced by add_valid_address(), check_link_down(), find_max_expire(), handle_dht_result(), learn_dv_path(), neighbour_dv_monotime_cb(), timeout_hello_validation(), transmit_ping_if_allowed(), udp_select_send(), and update_iterator().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_round_down()

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.

Parameters
atabsolute time to round
rtmultiple to round to (non-zero)
Returns
rounded time

Definition at line 264 of file time.c.

393 {
394  struct GNUNET_TIME_Absolute ret;
395 
397  ret.abs_value_us
398  = at.abs_value_us
399  - at.abs_value_us % rt.rel_value_us;
400  return ret;
401 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
bool GNUNET_TIME_relative_is_zero(struct GNUNET_TIME_Relative rel)
Test if rel is zero.
Definition: time.c:662

◆ GNUNET_TIME_timestamp_max()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_max ( struct GNUNET_TIME_Timestamp  t1,
struct GNUNET_TIME_Timestamp  t2 
)

Return the maximum of two timestamps.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 264 of file time.c.

377 {
378  return (t1.abs_time.abs_value_us > t2.abs_time.abs_value_us) ? t1 : t2;
379 }

◆ GNUNET_TIME_timestamp_min()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_min ( struct GNUNET_TIME_Timestamp  t1,
struct GNUNET_TIME_Timestamp  t2 
)

Return the minimum of two timestamps.

Parameters
t1first timestamp
t2other timestamp
Returns
timestamp that is smaller

Definition at line 264 of file time.c.

385 {
386  return (t1.abs_time.abs_value_us < t2.abs_time.abs_value_us) ? t1 : t2;
387 }

◆ GNUNET_TIME_absolute_get_remaining()

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?

Parameters
futuresome absolute time, typically in the future
Returns
future - now, or 0 if now >= future, or FOREVER if future==FOREVER.

Definition at line 264 of file time.c.

406 {
407  struct GNUNET_TIME_Relative ret;
408 
409  if (GNUNET_TIME_absolute_is_never (future))
412 
413  if (now.abs_value_us > future.abs_value_us)
414  return GNUNET_TIME_UNIT_ZERO;
415  ret.rel_value_us = future.abs_value_us - now.abs_value_us;
416  return ret;
417 }
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.

Referenced by add_record(), add_valid_address(), announce_id(), backtalker_timeout_cb(), check_for_glue(), check_has_addr(), check_link_down(), check_proof_of_work(), check_timeouts(), client_session_timeout(), cmd_read(), connect_success_continuation(), connection_ready_cb(), consider_peer_destroy(), core_read_finished_cb(), count_address(), data_sent_cb(), delayed_restart_task(), display_record(), do_dht_put(), download_prepare(), find_advertisable_hello(), GNUNET_CONNECTION_notify_transmit_ready(), GNUNET_CONNECTION_receive(), GNUNET_DATASTORE_put(), GNUNET_GNSRECORD_is_expired(), GNUNET_SCHEDULER_add_at_with_priority(), GSF_block_peer_migration_(), GST_validation_handle_ping(), GST_validation_handle_pong(), handle_cadet_ring_message(), handle_dht_response(), handle_encrypted(), handle_namecache_block_response(), learn_dv_path(), list_callback(), load_operation(), macendpoint_timeout(), master_task(), monitor_cb(), path_cleanup_cb(), pick_random_dv_hops(), plan(), print_address(), print_plugin_event_info(), process_incoming(), process_job_queue(), process_migration_content(), process_pending_messages(), process_queue(), process_record(), proto_read_kx(), put_migration_continuation(), queue_read(), queue_read_kx(), queue_timeout(), queue_write(), quota_processor(), reassembly_cleanup_task(), remove_timeout_messages_and_select(), revalidate_address(), revive_migration(), schedule_next_hello(), schedule_peer_transmission(), schedule_select_v4(), schedule_select_v6(), select_best_pending_from_link(), select_loop(), send_keep_alive(), send_keepalive(), server_access_cb(), server_session_timeout(), session_timeout(), sqlite_plugin_put(), t_ax_encrypt(), task_download(), timeout_cb(), timeout_hello_validation(), transmit_item(), transmit_ready(), try_connect_using_address(), try_transmission(), try_transmission_to_peer(), udp_plugin_send(), unix_plugin_do_write(), validate_address_iterator(), and validation_start_cb().

◆ GNUNET_TIME_absolute_approx_eq()

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.

Parameters
a1time to compare
a2time to compare
ttolerance to apply
Returns
true if "|a1-a2|<=t" holds.

Definition at line 63 of file time.c.

66 {
68 
73  <=,
74  t);
75 }
#define GNUNET_TIME_relative_cmp(t1, op, t2)
Compare two relative times.
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.
Definition: time.c:421

References delta, GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_relative_cmp, GNUNET_TIME_relative_min(), and t.

Here is the call graph for this function:

◆ GNUNET_TIME_calculate_eta()

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.

Parameters
startwhen did the operation start?
finishedhow much has been done?
totalhow much must be done overall (same unit as for "finished")
Returns
remaining duration for the operation, assuming it continues at the same speed

Definition at line 264 of file time.c.

567 {
568  struct GNUNET_TIME_Relative due;
569  double exp;
570  struct GNUNET_TIME_Relative ret;
571 
572  GNUNET_break (finished <= total);
573  if (finished >= total)
574  return GNUNET_TIME_UNIT_ZERO;
575  if (0 == finished)
578  exp = ((double) due.rel_value_us) * ((double) total) / ((double) finished);
579  ret.rel_value_us = ((uint64_t) exp) - due.rel_value_us;
580  return ret;
581 }
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
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 "henc...
Definition: time.c:436

Referenced by GNUNET_FS_download_make_status_(), GNUNET_FS_publish_make_status_(), GNUNET_FS_unindex_make_status_(), and progress_proc().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_difference()

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.

Use this function instead of actual subtraction to ensure that "FOREVER" and overflows are handled correctly.

Parameters
startsome absolute time
endsome absolute time (typically larger or equal to start)
Returns
0 if start >= end; FOREVER if end==FOREVER; otherwise end - start

Definition at line 264 of file time.c.

423 {
424  struct GNUNET_TIME_Relative ret;
425 
428  if (end.abs_value_us < start.abs_value_us)
429  return GNUNET_TIME_UNIT_ZERO;
430  ret.rel_value_us = end.abs_value_us - start.abs_value_us;
431  return ret;
432 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34

Referenced by callback_verify_room_message(), client_receive(), expire_blocks(), expired_processor(), GNUNET_ATS_solver_logging_write_to_disk(), GNUNET_TIME_absolute_approx_eq(), handle_client_join(), handle_message_delete(), sampler_mod_get_rand_peer(), send_utilization_data(), solve_srv_room_member_collisions(), and update_timeout().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_get_duration()

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".

Parameters
whencesome absolute time, typically in the past
Returns
0 if hence > now, otherwise now-hence.

Definition at line 264 of file time.c.

437 {
438  struct GNUNET_TIME_Absolute now;
439  struct GNUNET_TIME_Relative ret;
440 
441  now = GNUNET_TIME_absolute_get ();
442  if (whence.abs_value_us > now.abs_value_us)
443  return GNUNET_TIME_UNIT_ZERO;
444  ret.rel_value_us = now.abs_value_us - whence.abs_value_us;
445  return ret;
446 }

Referenced by check_iteration_start(), consider_sending_fc(), do_directory_scan(), do_shutdown(), evaluate_connection(), find_best_address_it(), find_proof(), flush_bulk(), forward_dv_learn(), fragmented_message_done(), get_preference(), get_property(), GNUNET_ATS_solver_logging_now(), GNUNET_BANDWIDTH_tracker_get_available(), GNUNET_CURL_perform2(), GNUNET_FRAGMENT_process_ack(), GNUNET_FS_download_make_status_(), GNUNET_FS_publish_make_status_(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_probe_progress_(), GNUNET_FS_unindex_make_status_(), GNUNET_SCHEDULER_do_work(), GSC_CLIENTS_solicit_request(), GSF_peer_update_performance_(), GSF_update_datastore_delay_(), GST_neighbours_calculate_receive_delay(), GST_validation_handle_pong(), handle_acknowledged(), handle_client_send(), handle_data(), handle_dht_p2p_put(), handle_dv_learn(), handle_encrypted(), handle_fragment_box(), handle_matching_ack(), handle_result(), handle_send_transmit_continuation(), handle_validation_response(), internal_update(), interpreter_next(), iteration_done(), lookup_authz_cb(), maint_child_death(), mylog(), namecache_sqlite_cache_block(), notify_client_chk_update(), odc_warn_delay_task(), peer_transmit(), process_parallel_lookup_result(), process_queue(), process_result(), process_result_with_request(), process_stdin(), prof_time(), progress_cb(), put_migration_continuation(), qc_message_sent(), receive_ready(), regex_found_handler(), run(), schedule_next_task(), set_feedback_task(), shutdown_task(), signal_probe_result(), solver_bandwidth_changed_cb(), stop_job(), store_completed_cb(), test_master(), timeout_episode(), timeout_experiment(), transmit_cummulative_ack_cb(), update_pm_next_attempt(), update_tslots(), update_velocity(), updateAgedLoad(), warn_delay_task(), warn_no_client_continue(), warn_no_receive_done(), and write_start_time().

◆ GNUNET_TIME_absolute_add()

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.

Parameters
startsome absolute time
durationsome relative time to add
Returns
FOREVER if either argument is FOREVER or on overflow; start+duration otherwise

Definition at line 264 of file time.c.

452 {
453  struct GNUNET_TIME_Absolute ret;
454 
458  if (start.abs_value_us + duration.rel_value_us < start.abs_value_us)
459  {
460  GNUNET_break (0);
462  }
463  ret.abs_value_us = start.abs_value_us + duration.rel_value_us;
464  return ret;
465 }
static struct GNUNET_TIME_Relative duration
How long do we run the test?

Referenced by announce_id(), check_proof_of_work(), core_init(), enqueue_fragment(), generate_id_token_body(), handle_ephemeral_key(), handle_message_delete(), process_incoming(), process_job_queue(), process_queue(), run(), session_disconnect_adapter(), sign_ephemeral(), start_operation(), t_ax_encrypt(), timeout_cb(), udp_plugin_send(), unix_plugin_send(), update_ax_by_kx(), and update_next_challenge_time().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_subtract()

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.

Parameters
startsome absolute time
durationsome relative time to subtract
Returns
ZERO if start <= duration, or FOREVER if start time is FOREVER; start-duration otherwise

Definition at line 264 of file time.c.

471 {
472  struct GNUNET_TIME_Absolute ret;
473 
474  if (start.abs_value_us <= duration.rel_value_us)
478  ret.abs_value_us = start.abs_value_us - duration.rel_value_us;
479  return ret;
480 }
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.

Referenced by GSF_pending_request_create_(), handle_ephemeral_key(), handle_validation_response(), and read_start_time().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_multiply()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply ( struct GNUNET_TIME_Relative  rel,
unsigned long long  factor 
)

Multiply relative time by a given factor.

Parameters
relsome duration
factorinteger to multiply with
Returns
FOREVER if rel=FOREVER or on overflow; otherwise rel*factor

Definition at line 264 of file time.c.

486 {
487  struct GNUNET_TIME_Relative ret;
488 
489  if (0 == factor)
490  return GNUNET_TIME_UNIT_ZERO;
493  ret.rel_value_us = rel.rel_value_us * factor;
494  if (ret.rel_value_us / factor != rel.rel_value_us)
495  {
496  GNUNET_break (0);
498  }
499  return ret;
500 }

Referenced by announce_next_regex(), ats_perf_cb(), ats_perf_mon_cb(), attempt_connect_task(), barrier2_cb(), check_zone_namestore_next(), churn(), cleanup_expired_records(), client_schedule(), connection_create(), consider_gathering(), context_task(), create_macendpoint(), curl_download_prepare(), download_prepare(), expire_records_continuation(), GNUNET_DNSPARSER_parse_record(), GNUNET_REVOCATION_pow_start(), GNUNET_RPS_sub_start(), GNUNET_STATISTICS_destroy(), GNUNET_TESTBED_run(), GSF_pending_request_create_(), handle_connection_create(), handle_dht_p2p_put(), handle_dv_learn(), handle_fragment_box(), handle_p2p_put(), handle_validation_response(), helper_read(), helper_write(), init(), iter_finished(), libgnunet_plugin_transport_udp_init(), login_cont(), lookup_authz_cb(), main(), peer_id_cb(), plan(), process_job_queue(), profiler_cb(), reannounce_regex(), reconnect(), register_sender(), revalidate_address(), run(), run_httpd(), run_with_key(), schedule_missing_requests(), schedule_next_put(), send_find_peer_message(), send_hello(), send_hello_beacon(), start_dv_learn(), start_helper(), start_test(), task_check(), test_master(), timeout_cb(), transmit_on_queue(), udp_plugin_create_session(), and update_pm_next_attempt().

◆ GNUNET_TIME_relative_saturating_multiply()

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.

Parameters
relsome duration
factorinteger to multiply with
Returns
FOREVER if rel=FOREVER or on overflow; otherwise rel*factor

Definition at line 264 of file time.c.

533 {
534  struct GNUNET_TIME_Relative ret;
535 
536  if (0 == factor)
537  return GNUNET_TIME_UNIT_ZERO;
540  ret.rel_value_us = rel.rel_value_us * factor;
541  if (ret.rel_value_us / factor != rel.rel_value_us)
542  {
544  }
545  return ret;
546 }

Referenced by daemon_started(), GNUNET_FRAGMENT_context_destroy(), GNUNET_FRAGMENT_process_ack(), GNUNET_FS_search_start_probe_(), process_job_queue(), put_migration_continuation(), reconnect(), schedule_next_task(), transmit_next(), and update_excess().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_divide()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide ( struct GNUNET_TIME_Relative  rel,
unsigned long long  factor 
)

Divide relative time by a given factor.

Parameters
relsome duration
factorinteger to divide by
Returns
FOREVER if rel=FOREVER or factor==0; otherwise rel/factor

Definition at line 264 of file time.c.

552 {
553  struct GNUNET_TIME_Relative ret;
554 
555  if ((0 == factor) ||
558  ret.rel_value_us = rel.rel_value_us / factor;
559  return ret;
560 }

Referenced by adapt_parallelism(), add_valid_address(), calculate_put_interval(), check_iteration_start(), consider_gathering(), do_shutdown(), find_proof(), GST_neighbours_calculate_receive_delay(), GST_validation_handle_pong(), handle_dht_p2p_put(), handle_dv_learn(), handle_reliability_box(), peerstore_store_own_cb(), schedule_next_put(), send_keep_alive(), start_address_validation(), store_completed_cb(), udp_plugin_send(), update_pm_next_attempt(), and update_timeout().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_add()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_add ( struct GNUNET_TIME_Relative  a1,
struct GNUNET_TIME_Relative  a2 
)

Add relative times together.

Parameters
a1some relative time
a2some other relative time
Returns
FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise

Definition at line 264 of file time.c.

587 {
588  struct GNUNET_TIME_Relative ret;
589 
590  if ((a1.rel_value_us == UINT64_MAX) || (a2.rel_value_us == UINT64_MAX))
592  if (a1.rel_value_us + a2.rel_value_us < a1.rel_value_us)
593  {
594  GNUNET_break (0);
596  }
597  ret.rel_value_us = a1.rel_value_us + a2.rel_value_us;
598  return ret;
599 }

Referenced by adapt_parallelism(), forward_dv_learn(), handle_dht_p2p_put(), load_episodes(), process_queue(), process_result(), revalidate_address(), run(), sign_ephemeral_key(), stop_job(), store_completed_cb(), update_pm_next_attempt(), update_tslots(), and update_velocity().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_subtract()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract ( struct GNUNET_TIME_Relative  a1,
struct GNUNET_TIME_Relative  a2 
)

Subtract relative timestamp from the other.

Parameters
a1first timestamp
a2second timestamp
Returns
ZERO if a2>=a1 (including both FOREVER), FOREVER if a1 is FOREVER, a1-a2 otherwise

Definition at line 264 of file time.c.

605 {
606  struct GNUNET_TIME_Relative ret;
607 
608  if (a2.rel_value_us >= a1.rel_value_us)
609  return GNUNET_TIME_UNIT_ZERO;
610  if (a1.rel_value_us == UINT64_MAX)
612  ret.rel_value_us = a1.rel_value_us - a2.rel_value_us;
613  return ret;
614 }

Referenced by check_zone_namestore_next(), GNUNET_FS_search_probe_progress_(), handle_acknowledged(), handle_dv_learn(), learn_dv_path(), store_completed_cb(), and update_velocity().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_hton()

struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton ( struct GNUNET_TIME_Relative  a)

Convert relative time to network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 264 of file time.c.

619 {
621 
622  ret.rel_value_us__ = GNUNET_htonll (a.rel_value_us);
623  return ret;
624 }
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
Time for relative time used by GNUnet, in microseconds and in network byte order.

Referenced by announce_reconnect(), create_message_delete(), forward_dv_learn(), GAS_handle_reservation_request(), GNUNET_ATS_performance_give_feedback(), GNUNET_ATS_properties_hton(), GNUNET_REVOCATION_pow_start(), GNUNET_RPS_sub_start(), GNUNET_TRANSPORT_address_to_string(), GNUNET_TRANSPORT_communicator_receive(), GNUNET_TRANSPORT_manipulation_set(), GSF_block_peer_migration_(), mq_send_impl(), notify_monitor(), send_add_address(), start_dv_learn(), and transmit_cummulative_ack_cb().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_ntoh()

struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh ( struct GNUNET_TIME_RelativeNBO  a)

Convert relative time from network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 264 of file time.c.

629 {
630  struct GNUNET_TIME_Relative ret;
631 
632  ret.rel_value_us = GNUNET_ntohll (a.rel_value_us__);
633  return ret;
634 }
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
uint64_t rel_value_us__
The actual value (in network byte order).

Referenced by forward_dv_learn(), GNUNET_ATS_properties_ntoh(), GST_manipulation_set_metric(), handle_add_address(), handle_announce(), handle_client_address_to_string(), handle_client_send(), handle_client_start_sub(), handle_dv_learn(), handle_feedback(), handle_message_delete(), handle_monitor_data(), handle_p2p_migration_stop(), handle_reliability_ack(), handle_reservation_result(), and handle_validation_response().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_hton()

struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton ( struct GNUNET_TIME_Absolute  a)

Convert absolute time to network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 264 of file time.c.

639 {
641 
642  ret.abs_value_us__ = GNUNET_htonll (a.abs_value_us);
643  return ret;
644 }
Time for absolute time used by GNUnet, in microseconds and in network byte order.

Referenced by check_dht_p2p_put(), client_response_handler(), consider_sending_fc(), create_loc_uri(), do_dht_put(), extract_abs_time_nbo(), get_cb(), GNUNET_CONSENSUS_create(), GNUNET_DATASTORE_put(), GNUNET_DHT_put(), GNUNET_DHT_verify_path(), GNUNET_FS_uri_loc_create(), GNUNET_HELLO_add_address(), GNUNET_HELLO_extract_address(), GNUNET_HELLO_sign_address(), GNUNET_SECRETSHARING_create_session(), GNUNET_SECRETSHARING_decrypt(), GSC_KX_encrypt_and_transmit(), GST_clients_broadcast_peer_notification(), GST_validation_handle_ping(), handle_client_call_message(), handle_client_loc_sign(), handle_datastore_reply(), handle_list(), handle_lookup_block_it(), handle_p2p_reply(), inject_rekey(), monitor_notify_all(), notify_monitor(), pack_srv_room_message(), PEERSTORE_create_record_mq_envelope(), plugin_session_info_cb(), put_action(), regex_iterator(), response_action(), run_edkey(), run_pkey(), send_challenge(), send_create(), send_disconnect(), send_lookup_response_with_filter(), send_msg_with_kx(), send_peer_information(), send_request(), send_simple_single(), send_syn(), send_syn_ack_message(), setup_estimate_message(), setup_flood_message(), sign_ephemeral(), sign_ephemeral_key(), sign_hello(), sign_path(), start_dv_learn(), tmt_rdy_ping(), transmit_content(), transmit_item(), transmit_kx(), transmit_status(), update_backtalker_monotime(), uri_loc_parse(), and validation_transmit_on_queue().

◆ GNUNET_TIME_timestamp_hton()

struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton ( struct GNUNET_TIME_Timestamp  t)

Convert timestamp to network byte order.

Parameters
ttime to convert
Returns
converted time value

Definition at line 63 of file time.c.

92 {
93  struct GNUNET_TIME_TimestampNBO tn;
94 
96  return tn;
97 }
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
Time for timestamps used by GNUnet, in seconds and in network byte order.
struct GNUNET_TIME_AbsoluteNBO abs_time_nbo
The actual value.

◆ GNUNET_TIME_absolute_from_ms()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_ms ( uint64_t  ms_after_epoch)

Convert milliseconds after the UNIX epoch to absolute time.

Parameters
ms_after_epochmillisecond timestamp to convert
Returns
converted time value

Definition at line 679 of file time.c.

690 {
691  struct GNUNET_TIME_Absolute ret;
692 
693  ret.abs_value_us = GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us
694  * ms_after_epoch;
695  if (ret.abs_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us !=
696  ms_after_epoch)
698  return ret;
699 }

References GNUNET_TIME_Absolute::abs_value_us, and GNUNET_TIME_absolute_get().

Here is the call graph for this function:

◆ GNUNET_TIME_absolute_is_never()

bool GNUNET_TIME_absolute_is_never ( struct GNUNET_TIME_Absolute  abs)

Test if abs is never.

Returns
true if it is.

Definition at line 648 of file time.c.

649 {
650  return GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == abs.abs_value_us;
651 }

References GNUNET_TIME_Absolute::abs_value_us, and GNUNET_TIME_UNIT_FOREVER_ABS.

Referenced by GNUNET_JSON_from_timestamp(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute2s(), and GNUNET_TIME_timestamp2s().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_is_past()

bool GNUNET_TIME_absolute_is_past ( struct GNUNET_TIME_Absolute  abs)

Test if abs is truly in the past (excluding now).

Returns
true if it is.

Definition at line 669 of file time.c.

670 {
671  struct GNUNET_TIME_Absolute now;
672 
673  now = GNUNET_TIME_absolute_get ();
674  return abs.abs_value_us < now.abs_value_us;
675 }

References GNUNET_TIME_Absolute::abs_value_us, and GNUNET_TIME_absolute_get().

Referenced by check_dht_local_put(), check_dht_p2p_hello(), handle_dht_p2p_put(), and handle_find_local_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_is_zero()

bool GNUNET_TIME_absolute_is_zero ( struct GNUNET_TIME_Absolute  abs)

Test if abs is truly zero.

Returns
true if it is.

Definition at line 844 of file time.c.

845 {
846  return 0 == abs.abs_value_us;
847 }

◆ GNUNET_TIME_absolute_is_future()

bool GNUNET_TIME_absolute_is_future ( struct GNUNET_TIME_Absolute  abs)

Test if abs is truly in the future (excluding now).

Returns
true if it is.

Definition at line 679 of file time.c.

680 {
681  struct GNUNET_TIME_Absolute now;
682 
683  now = GNUNET_TIME_absolute_get ();
684  return abs.abs_value_us > now.abs_value_us;
685 }

◆ GNUNET_TIME_relative_is_forever()

bool GNUNET_TIME_relative_is_forever ( struct GNUNET_TIME_Relative  rel)

Test if rel is forever.

Returns
true if it is.

Definition at line 655 of file time.c.

656 {
657  return GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rel.rel_value_us;
658 }

References GNUNET_TIME_UNIT_FOREVER_REL, and GNUNET_TIME_Relative::rel_value_us.

Referenced by GNUNET_JSON_from_time_rel(), and relative_multiply_double().

Here is the caller graph for this function:

◆ GNUNET_TIME_relative_is_zero()

bool GNUNET_TIME_relative_is_zero ( struct GNUNET_TIME_Relative  rel)

Test if rel is zero.

Returns
true if it is.

Definition at line 662 of file time.c.

663 {
664  return 0 == rel.rel_value_us;
665 }

References GNUNET_TIME_Relative::rel_value_us.

◆ GNUNET_TIME_absolute_from_s()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s ( uint64_t  s_after_epoch)

Convert seconds after the UNIX epoch to absolute time.

Parameters
s_after_epochseconds after epoch to convert
Returns
converted time value

Definition at line 679 of file time.c.

704 {
705  struct GNUNET_TIME_Absolute ret;
706 
707  ret.abs_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * s_after_epoch;
708  if (ret.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us !=
709  s_after_epoch)
711  return ret;
712 }
#define GNUNET_TIME_UNIT_SECONDS
One second.

Referenced by GNUNET_HELLO_builder_from_url().

Here is the caller graph for this function:

◆ GNUNET_TIME_timestamp_from_s()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_from_s ( uint64_t  s_after_epoch)

Convert seconds after the UNIX epoch to timestamp.

Parameters
s_after_epochseconds after epoch to convert
Returns
converted time value

Definition at line 679 of file time.c.

717 {
718  struct GNUNET_TIME_Timestamp ret;
719 
720  ret.abs_time.abs_value_us
721  = GNUNET_TIME_UNIT_SECONDS.rel_value_us * s_after_epoch;
722  if (ret.abs_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us
723  != s_after_epoch)
725  return ret;
726 }

◆ GNUNET_TIME_timestamp_to_s()

uint64_t GNUNET_TIME_timestamp_to_s ( struct GNUNET_TIME_Timestamp  ts)

Convert timestamp to number of seconds after the UNIX epoch.

Parameters
tstimestamp to convert
Returns
converted time value

Definition at line 730 of file time.c.

731 {
732  return ts.abs_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
733 }

Referenced by GNUNET_HELLO_builder_add_address().

Here is the caller graph for this function:

◆ GNUNET_TIME_absolute_ntoh()

struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh ( struct GNUNET_TIME_AbsoluteNBO  a)

Convert absolute time from network byte order.

Parameters
atime to convert
Returns
converted time value

Definition at line 730 of file time.c.

738 {
739  struct GNUNET_TIME_Absolute ret;
740 
741  ret.abs_value_us = GNUNET_ntohll (a.abs_value_us__);
742  return ret;
743 }
uint64_t abs_value_us__
The actual value (in network byte order).

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, and GNUNET_TIME_UNIT_SECONDS.

Referenced by backtalker_monotime_cb(), bind_nbotime(), callback_verify_room_message(), check_client_result(), check_dht_p2p_hello(), check_monitor_put(), check_proof_of_work(), do_dht_put(), do_rekey(), GCP_check_and_update_monotime(), GNUNET_HELLO_builder_from_block(), GNUNET_HELLO_iterate_addresses(), GST_neighbours_handle_disconnect_message(), GST_neighbours_handle_session_syn(), GST_neighbours_handle_session_syn_ack(), GST_validation_handle_pong(), handle_arm_list_result(), handle_cadet_ring_message(), handle_client_decrypt(), handle_client_join(), handle_client_keygen(), handle_client_loc_sign(), handle_client_redirect_to_ip(), handle_client_redirect_to_service(), handle_client_send_request(), handle_data(), handle_dht_local_put(), handle_dht_p2p_put(), handle_dht_result(), handle_dv_box(), handle_dv_learn(), handle_encrypted(), handle_ephemeral_key(), handle_estimate(), handle_event(), handle_flow_control(), handle_lookup_block_response(), handle_message_delete(), handle_message_id(), handle_message_join(), handle_monitor_data(), handle_p2p_estimate(), handle_p2p_put(), handle_put(), handle_receive_info(), handle_record_result(), handle_reply(), handle_response(), handle_result(), handle_signature_response(), handle_status(), handle_validation_response(), handshake_ack_monotime_cb(), handshake_monotime_cb(), inject_rekey(), neighbour_dv_monotime_cb(), PEERSTORE_parse_record_message(), put_cb(), rekey_monotime_cb(), run(), and transmit_task_cb().

◆ GNUNET_TIME_timestamp_ntoh()

struct GNUNET_TIME_Timestamp GNUNET_TIME_timestamp_ntoh ( struct GNUNET_TIME_TimestampNBO  tn)

Convert timestamp from network byte order.

Parameters
tntime to convert
Returns
converted time value

Definition at line 63 of file time.c.

102 {
103  struct GNUNET_TIME_Timestamp t;
104 
105  t.abs_time = GNUNET_TIME_absolute_ntoh (tn.abs_time_nbo);
106  return t;
107 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737

Referenced by GNUNET_JSON_from_timestamp_nbo().

Here is the caller graph for this function:

◆ GNUNET_TIME_set_offset()

void GNUNET_TIME_set_offset ( long long  offset)

Set the timestamp offset for this instance.

Parameters
offsetthe offset to skew the locale time by

Definition at line 49 of file time.c.

50 {
51  timestamp_offset = offset;
52 }

References timestamp_offset.

Referenced by do_speedup(), GNUNET_SERVICE_run_(), and LEGACY_SERVICE_run().

Here is the caller graph for this function:

◆ GNUNET_TIME_get_offset()

long long GNUNET_TIME_get_offset ( void  )

Get the timestamp offset for this instance.

Returns
the offset we currently skew the locale time by

Definition at line 56 of file time.c.

57 {
58  return timestamp_offset;
59 }

References timestamp_offset.

Referenced by mylog().

Here is the caller graph for this function:

◆ GNUNET_TIME_get_current_year()

unsigned int GNUNET_TIME_get_current_year ( void  )

Return the current year (e.g.

'2011').

Definition at line 747 of file time.c.

748 {
749  time_t tp;
750  struct tm *t;
751 
752  tp = time (NULL);
753  t = gmtime (&tp);
754  if (t == NULL)
755  return 0;
756  return t->tm_year + 1900;
757 }

References t.

Referenced by main().

Here is the caller graph for this function:

◆ GNUNET_TIME_year_to_time()

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.

Parameters
yeara year (after 1970, please ;-)).
Returns
absolute time for January 1st of that year.

Definition at line 779 of file time.c.

802 {
803  struct GNUNET_TIME_Absolute ret;
804  time_t tp;
805  struct tm t;
806 
807  memset (&t, 0, sizeof(t));
808  if (year < 1900)
809  {
810  GNUNET_break (0);
811  return GNUNET_TIME_absolute_get (); /* now */
812  }
813  t.tm_year = year - 1900;
814  t.tm_mday = 1;
815  t.tm_mon = 0;
816  t.tm_wday = 1;
817  t.tm_yday = 1;
818 #ifndef HAVE_TIMEGM
819  tp = my_timegm (&t);
820 #else
821  tp = timegm (&t);
822 #endif
823  GNUNET_break (tp != (time_t) -1);
824  ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */
825  return ret;
826 }
static time_t my_timegm(struct tm *tm)
As suggested in the timegm() man page.
Definition: time.c:779

Referenced by main().

Here is the caller graph for this function:

◆ GNUNET_TIME_time_to_year()

unsigned int GNUNET_TIME_time_to_year ( struct GNUNET_TIME_Absolute  at)

Convert an expiration time to the respective year (rounds)

Parameters
atabsolute time
Returns
year a year (after 1970), 0 on error

Definition at line 761 of file time.c.

762 {
763  struct tm *t;
764  time_t tp;
765 
766  tp = at.abs_value_us / 1000LL / 1000LL; /* microseconds to seconds */
767  t = gmtime (&tp);
768  if (t == NULL)
769  return 0;
770  return t->tm_year + 1900;
771 }

References GNUNET_TIME_Absolute::abs_value_us, and t.

◆ GNUNET_TIME_absolute_get_monotonic()

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.

Guards against systems without an RTC or clocks running backwards and other nasty surprises. Does not guarantee that the returned time is near the current time returned by GNUNET_TIME_absolute_get(). Two subsequent calls (within a short time period) may return the same value. Persists the last returned time on disk to ensure that time never goes backwards. As a result, the resulting value can be used to check if a message is the "most recent" value and replays of older messages (from the same origin) would be discarded.

Parameters
cfgconfiguration, used to determine where to store the time; user can also insist RTC is working nicely and disable the feature
Returns
monotonically increasing time

Definition at line 844 of file time.c.

862 {
863  static const struct GNUNET_CONFIGURATION_Handle *last_cfg;
864  static struct GNUNET_TIME_Absolute last_time;
865  static struct GNUNET_DISK_MapHandle *map_handle;
866  static ATOMIC volatile uint64_t *map;
867  struct GNUNET_TIME_Absolute now;
868 
869  now = GNUNET_TIME_absolute_get ();
870  if (last_cfg != cfg)
871  {
872  char *filename;
873 
874  if (NULL != map_handle)
875  {
876  GNUNET_DISK_file_unmap (map_handle);
877  map_handle = NULL;
878  }
879  map = NULL;
880 
881  last_cfg = cfg;
882  if ((NULL != cfg) &&
883  (GNUNET_OK ==
885  "util",
886  "MONOTONIC_TIME_FILENAME",
887  &filename)))
888  {
889  struct GNUNET_DISK_FileHandle *fh;
890 
898  if (NULL == fh)
899  {
901  _ ("Failed to map `%s', cannot assure monotonic time!\n"),
902  filename);
903  }
904  else
905  {
906  off_t size;
907 
908  size = 0;
910  if (size < (off_t) sizeof(*map))
911  {
912  struct GNUNET_TIME_AbsoluteNBO o;
913 
914  o = GNUNET_TIME_absolute_hton (now);
915  if (sizeof(o) != GNUNET_DISK_file_write (fh, &o, sizeof(o)))
916  size = 0;
917  else
918  size = sizeof(o);
919  }
920  if (size == sizeof(*map))
921  {
923  &map_handle,
925  sizeof(*map));
926  if (NULL == map)
928  _ (
929  "Failed to map `%s', cannot assure monotonic time!\n"),
930  filename);
931  }
932  else
933  {
934  GNUNET_log (
936  _ (
937  "Failed to setup monotonic time file `%s', cannot assure monotonic time!\n"),
938  filename);
939  }
940  }
943  }
944  }
945  if (NULL != map)
946  {
947  struct GNUNET_TIME_AbsoluteNBO mt;
948 
949 #if __STDC_NO_ATOMICS__
950 #if __GNUC__
951  mt.abs_value_us__ = __sync_fetch_and_or (map, 0);
952 #else
953  mt.abs_value_us__ = *map; /* godspeed, pray this is atomic */
954 #endif
955 #else
956  mt.abs_value_us__ = atomic_load (map);
957 #endif
958  last_time =
960  }
961  if (now.abs_value_us <= last_time.abs_value_us)
962  now.abs_value_us = last_time.abs_value_us + 1;
963  last_time = now;
964  if (NULL != map)
965  {
966  uint64_t val = GNUNET_TIME_absolute_hton (now).abs_value_us__;
967 #if __STDC_NO_ATOMICS__
968 #if __GNUC__
969  (void) __sync_lock_test_and_set (map, val);
970 #else
971  *map = val; /* godspeed, pray this is atomic */
972 #endif
973 #else
974  atomic_store (map, val);
975 #endif
976  }
977  return now;
978 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
static char * filename
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1237
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:686
void * GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
Map a file into memory.
Definition: disk.c:1380
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1308
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, off_t *size)
Get the size of an open file.
Definition: disk.c:192
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h)
Unmap a file.
Definition: disk.c:1411
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_GROUP_WRITE
Group can write.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_MAP_TYPE_READWRITE
Read-write memory map.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_free(ptr)
Wrapper around free.
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.
Definition: time.c:367
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Handle used to access files (and pipes).
Handle for a memory-mapping operation.
Definition: disk.c:1361
#define ATOMIC
Definition: time.c:37

References GNUNET_TIME_Absolute::abs_value_us.

Referenced by __attribute__(), consider_sending_fc(), inject_rekey(), run(), send_challenge(), send_create(), send_msg_with_kx(), sign_ephemeral(), start_dv_learn(), transmit_kx(), and validation_transmit_on_queue().

Here is the caller graph for this function: