Coverage Report

Created: 2026-03-15 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/radvd/timer.c
Line
Count
Source
1
/*
2
 *
3
 *   Authors:
4
 *    Pedro Roque   <roque@di.fc.ul.pt>
5
 *    Lars Fenneberg    <lf@elemental.net>
6
 *
7
 *   This software is Copyright 1996-2000 by the above mentioned author(s),
8
 *   All Rights Reserved.
9
 *
10
 *   The license which is distributed with this software in the file COPYRIGHT
11
 *   applies to this software. If your distribution is missing this file, you
12
 *   may request it from <reubenhwk@gmail.com>.
13
 *
14
 */
15
16
#include "config.h"
17
#include "radvd.h"
18
19
struct timespec next_timespec(double next)
20
0
{
21
0
  struct timespec ts;
22
23
0
  clock_gettime(CLOCK_MONOTONIC, &ts);
24
0
  ts.tv_sec += (int)next;
25
0
  ts.tv_nsec += 1000000000ULL * (next - (int)next);
26
0
  return ts;
27
0
}
28
29
int64_t timespecdiff(struct timespec const *a, struct timespec const *b)
30
0
{
31
0
  int64_t msec;
32
0
  msec = ((int64_t)a->tv_sec - b->tv_sec) * 1000;
33
0
  msec += ((int64_t)a->tv_nsec - b->tv_nsec) / (1000 * 1000);
34
0
  return msec;
35
0
}
36
37
/* Returns when the next time should expire in milliseconds. */
38
uint64_t next_time_msec(struct Interface const *iface)
39
0
{
40
0
  struct timespec ts;
41
0
  int64_t diff_ms;
42
0
  clock_gettime(CLOCK_MONOTONIC, &ts);
43
0
  diff_ms = timespecdiff(&iface->times.next_multicast, &ts);
44
0
  if (diff_ms <= 0)
45
0
    return 0;
46
0
  return (uint64_t)diff_ms;
47
0
}