Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/i-ring.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | void | - | ||||||
5 | i_ring_init (I_ring *ir, int default_val) | - | ||||||
6 | { | - | ||||||
7 | int i; | - | ||||||
8 | ir->ir_empty = | - | ||||||
9 | 1 | - | ||||||
10 | ; | - | ||||||
11 | ir->ir_front = 0; | - | ||||||
12 | ir->ir_back = 0; | - | ||||||
13 | for (i = 0; i < I_RING_SIZE
| 6820-27280 | ||||||
14 | ir->ir_data[i] = default_val; executed 27280 times by 6 tests: ir->ir_data[i] = default_val; Executed by:
| 27280 | ||||||
15 | ir->ir_default_val = default_val; | - | ||||||
16 | } executed 6820 times by 6 tests: end of block Executed by:
| 6820 | ||||||
17 | - | |||||||
18 | - | |||||||
19 | _Bool | - | ||||||
20 | - | |||||||
21 | i_ring_empty (I_ring const *ir) | - | ||||||
22 | { | - | ||||||
23 | return executed 152919 times by 6 tests: ir->ir_empty;return ir->ir_empty; Executed by:
executed 152919 times by 6 tests: return ir->ir_empty; Executed by:
| 152919 | ||||||
24 | } | - | ||||||
25 | - | |||||||
26 | int | - | ||||||
27 | i_ring_push (I_ring *ir, int val) | - | ||||||
28 | { | - | ||||||
29 | unsigned int dest_idx = (ir->ir_front + !ir->ir_empty) % I_RING_SIZE; | - | ||||||
30 | int old_val = ir->ir_data[dest_idx]; | - | ||||||
31 | ir->ir_data[dest_idx] = val; | - | ||||||
32 | ir->ir_front = dest_idx; | - | ||||||
33 | if (dest_idx == ir->ir_back
| 27174-46604 | ||||||
34 | ir->ir_back = (ir->ir_back + !ir->ir_empty) % I_RING_SIZE; executed 27174 times by 6 tests: ir->ir_back = (ir->ir_back + !ir->ir_empty) % I_RING_SIZE; Executed by:
| 27174 | ||||||
35 | ir->ir_empty = | - | ||||||
36 | 0 | - | ||||||
37 | ; | - | ||||||
38 | return executed 73778 times by 6 tests: old_val;return old_val; Executed by:
executed 73778 times by 6 tests: return old_val; Executed by:
| 73778 | ||||||
39 | } | - | ||||||
40 | - | |||||||
41 | int | - | ||||||
42 | i_ring_pop (I_ring *ir) | - | ||||||
43 | { | - | ||||||
44 | int top_val; | - | ||||||
45 | if (i_ring_empty (ir)
| 0-59567 | ||||||
46 | abort (); never executed: abort (); | 0 | ||||||
47 | top_val = ir->ir_data[ir->ir_front]; | - | ||||||
48 | ir->ir_data[ir->ir_front] = ir->ir_default_val; | - | ||||||
49 | if (ir->ir_front == ir->ir_back
| 12963-46604 | ||||||
50 | ir->ir_empty = executed 12963 times by 6 tests: ir->ir_empty = 1 ; Executed by:
| 12963 | ||||||
51 | 1 executed 12963 times by 6 tests: ir->ir_empty = 1 ; Executed by:
| 12963 | ||||||
52 | ; executed 12963 times by 6 tests: ir->ir_empty = 1 ; Executed by:
| 12963 | ||||||
53 | else | - | ||||||
54 | ir->ir_front = ((ir->ir_front + I_RING_SIZE - 1) % I_RING_SIZE); executed 46604 times by 6 tests: ir->ir_front = ((ir->ir_front + I_RING_SIZE - 1) % I_RING_SIZE); Executed by:
| 46604 | ||||||
55 | return executed 59567 times by 6 tests: top_val;return top_val; Executed by:
executed 59567 times by 6 tests: return top_val; Executed by:
| 59567 | ||||||
56 | } | - | ||||||
Switch to Source code | Preprocessed file |