ROHC compression/decompression library
rohc_time_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013,2014 Didier Barvaux
3  * Copyright 2010,2013 Viveris Technologies
4  * Copyright 2009,2010 Thales Communications
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file rohc_time_internal.h
23  * @brief ROHC internal functions related to time
24  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
25  * @author Thales Communications
26  * @author Didier Barvaux <didier@barvaux.org>
27  */
28 
29 #ifndef ROHC_TIME_INTERNAL_H
30 #define ROHC_TIME_INTERNAL_H
31 
32 #include "rohc_time.h" /* for public definition of struct rohc_ts */
33 
34 #ifndef __KERNEL__
35 # include <sys/time.h>
36 #endif
37 
38 
39 static inline uint64_t rohc_time_interval(const struct rohc_ts begin,
40  const struct rohc_ts end)
41  __attribute__((warn_unused_result, const));
42 
43 
44 /**
45  * @brief Compute the interval of time between 2 timestamps
46  *
47  * @param begin The begin timestamp (in seconds and nanoseconds)
48  * @param end The end timestamp (in seconds and nanoseconds)
49  * @return The interval of time in microseconds
50  */
51 static inline uint64_t rohc_time_interval(const struct rohc_ts begin,
52  const struct rohc_ts end)
53 {
54  uint64_t interval;
55 
56  interval = end.sec - begin.sec; /* difference btw seconds */
57  interval *= 1000000000UL; /* convert in nanoseconds */
58  interval += end.nsec; /* additional end nanoseconds */
59  interval -= begin.nsec; /* superfluous begin nanoseconds */
60  interval /= 1000UL; /* convert in microseconds */
61 
62  return interval;
63 }
64 
65 
66 #endif /* ROHC_TIME_INTERNAL_H */
67 
static uint64_t rohc_time_interval(const struct rohc_ts begin, const struct rohc_ts end)
Compute the interval of time between 2 timestamps.
Definition: rohc_time_internal.h:51
A timestamp for the ROHC library.
Definition: rohc_time.h:51
uint64_t sec
Definition: rohc_time.h:53
uint64_t nsec
Definition: rohc_time.h:54
ROHC public definitions related to time.