Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/lib/sh/timeval.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | struct timeval * | - | ||||||||||||||||||||||||
8 | difftimeval (d, t1, t2) | - | ||||||||||||||||||||||||
9 | struct timeval *d, *t1, *t2; | - | ||||||||||||||||||||||||
10 | { | - | ||||||||||||||||||||||||
11 | d->tv_sec = t2->tv_sec - t1->tv_sec; | - | ||||||||||||||||||||||||
12 | d->tv_usec = t2->tv_usec - t1->tv_usec; | - | ||||||||||||||||||||||||
13 | if (d->tv_usec < 0
| 0-30 | ||||||||||||||||||||||||
14 | { | - | ||||||||||||||||||||||||
15 | d->tv_usec += 1000000; | - | ||||||||||||||||||||||||
16 | d->tv_sec -= 1; | - | ||||||||||||||||||||||||
17 | if (d->tv_sec < 0
| 0 | ||||||||||||||||||||||||
18 | { | - | ||||||||||||||||||||||||
19 | d->tv_sec = 0; | - | ||||||||||||||||||||||||
20 | d->tv_usec = 0; | - | ||||||||||||||||||||||||
21 | } never executed: end of block | 0 | ||||||||||||||||||||||||
22 | } never executed: end of block | 0 | ||||||||||||||||||||||||
23 | return executed 30 times by 1 test: d;return d; Executed by:
executed 30 times by 1 test: return d; Executed by:
| 30 | ||||||||||||||||||||||||
24 | } | - | ||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | struct timeval * | - | ||||||||||||||||||||||||
27 | addtimeval (d, t1, t2) | - | ||||||||||||||||||||||||
28 | struct timeval *d, *t1, *t2; | - | ||||||||||||||||||||||||
29 | { | - | ||||||||||||||||||||||||
30 | d->tv_sec = t1->tv_sec + t2->tv_sec; | - | ||||||||||||||||||||||||
31 | d->tv_usec = t1->tv_usec + t2->tv_usec; | - | ||||||||||||||||||||||||
32 | if (d->tv_usec >= 1000000
| 0-18 | ||||||||||||||||||||||||
33 | { | - | ||||||||||||||||||||||||
34 | d->tv_usec -= 1000000; | - | ||||||||||||||||||||||||
35 | d->tv_sec += 1; | - | ||||||||||||||||||||||||
36 | } never executed: end of block | 0 | ||||||||||||||||||||||||
37 | return executed 18 times by 1 test: d;return d; Executed by:
executed 18 times by 1 test: return d; Executed by:
| 18 | ||||||||||||||||||||||||
38 | } | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | int | - | ||||||||||||||||||||||||
43 | timeval_to_cpu (rt, ut, st) | - | ||||||||||||||||||||||||
44 | struct timeval *rt, *ut, *st; | - | ||||||||||||||||||||||||
45 | { | - | ||||||||||||||||||||||||
46 | struct timeval t1, t2; | - | ||||||||||||||||||||||||
47 | register int i; | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | addtimeval (&t1, ut, st); | - | ||||||||||||||||||||||||
50 | t2.tv_sec = rt->tv_sec; | - | ||||||||||||||||||||||||
51 | t2.tv_usec = rt->tv_usec; | - | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | for (i = 0; i < 6
| 6-36 | ||||||||||||||||||||||||
54 | { | - | ||||||||||||||||||||||||
55 | if ((
| 0-36 | ||||||||||||||||||||||||
56 | break; never executed: break; | 0 | ||||||||||||||||||||||||
57 | t1.tv_sec *= 10; | - | ||||||||||||||||||||||||
58 | t1.tv_sec += t1.tv_usec / 100000; | - | ||||||||||||||||||||||||
59 | t1.tv_usec *= 10; | - | ||||||||||||||||||||||||
60 | t1.tv_usec %= 1000000; | - | ||||||||||||||||||||||||
61 | t2.tv_sec *= 10; | - | ||||||||||||||||||||||||
62 | t2.tv_sec += t2.tv_usec / 100000; | - | ||||||||||||||||||||||||
63 | t2.tv_usec *= 10; | - | ||||||||||||||||||||||||
64 | t2.tv_usec %= 1000000; | - | ||||||||||||||||||||||||
65 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||||||||
66 | for (i = 0; i < 4
| 6-24 | ||||||||||||||||||||||||
67 | { | - | ||||||||||||||||||||||||
68 | if (t1.tv_sec < 100000000
| 0-24 | ||||||||||||||||||||||||
69 | t1.tv_sec *= 10; executed 24 times by 1 test: t1.tv_sec *= 10; Executed by:
| 24 | ||||||||||||||||||||||||
70 | else | - | ||||||||||||||||||||||||
71 | t2.tv_sec /= 10; never executed: t2.tv_sec /= 10; | 0 | ||||||||||||||||||||||||
72 | } | - | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | return executed 6 times by 1 test: ((t2.tv_sec == 0) ? 0 : t1.tv_sec / t2.tv_sec);return ((t2.tv_sec == 0) ? 0 : t1.tv_sec / t2.tv_sec); Executed by:
executed 6 times by 1 test: return ((t2.tv_sec == 0) ? 0 : t1.tv_sec / t2.tv_sec); Executed by:
| 6 | ||||||||||||||||||||||||
75 | } | - | ||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | void | - | ||||||||||||||||||||||||
81 | timeval_to_secs (tvp, sp, sfp) | - | ||||||||||||||||||||||||
82 | struct timeval *tvp; | - | ||||||||||||||||||||||||
83 | time_t *sp; | - | ||||||||||||||||||||||||
84 | int *sfp; | - | ||||||||||||||||||||||||
85 | { | - | ||||||||||||||||||||||||
86 | int rest; | - | ||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | *sp = tvp->tv_sec; | - | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | *sfp = tvp->tv_usec % 1000000; | - | ||||||||||||||||||||||||
91 | rest = *sfp % 1000; | - | ||||||||||||||||||||||||
92 | *sfp = (*sfp * 1000) / 1000000; | - | ||||||||||||||||||||||||
93 | if (rest >= 500
| 0-18 | ||||||||||||||||||||||||
94 | * never executed: sfp += 1;*sfp += 1; never executed: *sfp += 1; | 0 | ||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | if (*
| 0-18 | ||||||||||||||||||||||||
98 | { | - | ||||||||||||||||||||||||
99 | *sp += 1; | - | ||||||||||||||||||||||||
100 | *sfp -= 1000; | - | ||||||||||||||||||||||||
101 | } never executed: end of block | 0 | ||||||||||||||||||||||||
102 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | void | - | ||||||||||||||||||||||||
107 | print_timeval (fp, tvp) | - | ||||||||||||||||||||||||
108 | FILE *fp; | - | ||||||||||||||||||||||||
109 | struct timeval *tvp; | - | ||||||||||||||||||||||||
110 | { | - | ||||||||||||||||||||||||
111 | time_t timestamp; | - | ||||||||||||||||||||||||
112 | long minutes; | - | ||||||||||||||||||||||||
113 | int seconds, seconds_fraction; | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | timeval_to_secs (tvp, ×tamp, &seconds_fraction); | - | ||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||
117 | minutes = timestamp / 60; | - | ||||||||||||||||||||||||
118 | seconds = timestamp % 60; | - | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | fprintf (fp, "%ldm%d.%03ds", minutes, seconds, seconds_fraction); | - | ||||||||||||||||||||||||
121 | } never executed: end of block | 0 | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |