/src/rtpproxy/libelperiodic/src/prdic_time.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2019 Sippy Software, Inc., http://www.sippysoft.com |
3 | | * Copyright (c) 2016-2018, Maksym Sobolyev <sobomax@sippysoft.com> |
4 | | * All rights reserved. |
5 | | * |
6 | | * Redistribution and use in source and binary forms, with or without |
7 | | * modification, are permitted provided that the following conditions are met: |
8 | | * |
9 | | * * Redistributions of source code must retain the above copyright notice, this |
10 | | * list of conditions and the following disclaimer. |
11 | | * |
12 | | * * Redistributions in binary form must reproduce the above copyright notice, |
13 | | * this list of conditions and the following disclaimer in the documentation |
14 | | * and/or other materials provided with the distribution. |
15 | | * |
16 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
17 | | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
18 | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
20 | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
21 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
22 | | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
23 | | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 | | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | | */ |
27 | | |
28 | | #ifndef _PRDIC_TIME_H_ |
29 | | #define _PRDIC_TIME_H_ |
30 | | |
31 | | static inline int |
32 | | getttime(struct timespec *ttp, int abort_on_fail) |
33 | 142 | { |
34 | | |
35 | 142 | if (clock_gettime(CLOCK_MONOTONIC, ttp) == -1) { |
36 | 0 | if (abort_on_fail) |
37 | 0 | abort(); |
38 | 0 | return (-1); |
39 | 0 | } |
40 | 142 | return (0); |
41 | 142 | } Line | Count | Source | 33 | 4 | { | 34 | | | 35 | 4 | if (clock_gettime(CLOCK_MONOTONIC, ttp) == -1) { | 36 | 0 | if (abort_on_fail) | 37 | 0 | abort(); | 38 | 0 | return (-1); | 39 | 0 | } | 40 | 4 | return (0); | 41 | 4 | } |
Unexecuted instantiation: prdic_main_fd.c:getttime Unexecuted instantiation: prdic_main_pfd.c:getttime Line | Count | Source | 33 | 138 | { | 34 | | | 35 | 138 | if (clock_gettime(CLOCK_MONOTONIC, ttp) == -1) { | 36 | 0 | if (abort_on_fail) | 37 | 0 | abort(); | 38 | 0 | return (-1); | 39 | 0 | } | 40 | 138 | return (0); | 41 | 138 | } |
|
42 | | |
43 | | #if 0 |
44 | | static void |
45 | | dtime2timespec(double dtime, struct timespec *ttp) |
46 | | { |
47 | | |
48 | | SEC(ttp) = trunc(dtime); |
49 | | dtime -= (double)SEC(ttp); |
50 | | NSEC(ttp) = round((double)NSEC_IN_SEC * dtime); |
51 | | } |
52 | | #endif |
53 | | |
54 | | static inline void |
55 | | tplusdtime(struct timespec *ttp, double offset) |
56 | 4 | { |
57 | 4 | struct timespec tp; |
58 | | |
59 | 4 | dtime2timespec(offset, &tp); |
60 | 4 | timespecadd(ttp, &tp); |
61 | 4 | } Line | Count | Source | 56 | 4 | { | 57 | 4 | struct timespec tp; | 58 | | | 59 | 4 | dtime2timespec(offset, &tp); | 60 | 4 | timespecadd(ttp, &tp); | 61 | 4 | } |
Unexecuted instantiation: prdic_main_fd.c:tplusdtime Unexecuted instantiation: prdic_main_pfd.c:tplusdtime Unexecuted instantiation: prdic_main.c:tplusdtime |
62 | | |
63 | | #endif /* _PRDIC_TIME_H_ */ |