OpenCoverage

memchr2.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/memchr2.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8void *-
9memchr2 (void const *s, int c1_in, int c2_in, size_t n)-
10{-
11-
12-
13-
14-
15-
16 typedef unsigned long int longword;-
17-
18 const unsigned char *char_ptr;-
19 void const *void_ptr;-
20 const longword *longword_ptr;-
21 longword repeated_one;-
22 longword repeated_c1;-
23 longword repeated_c2;-
24 unsigned char c1;-
25 unsigned char c2;-
26-
27 c1 = (unsigned char) c1_in;-
28 c2 = (unsigned char) c2_in;-
29-
30 if (c1 == c2
c1 == c2Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 95 times by 1 test
Evaluated by:
  • cut
)
15-95
31 return
executed 15 times by 1 test: return memchr (s, c1, n);
Executed by:
  • cut
memchr (s, c1, n);
executed 15 times by 1 test: return memchr (s, c1, n);
Executed by:
  • cut
15
32-
33-
34-
35 for (void_ptr = s;-
36 n > 0
n > 0Description
TRUEevaluated 119 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 3 times by 1 test
Evaluated by:
  • cut
&& (
(uintptr_t) vo...longword) != 0Description
TRUEevaluated 51 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cut
uintptr_t) void_ptr % sizeof (longword) != 0
(uintptr_t) vo...longword) != 0Description
TRUEevaluated 51 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cut
;
3-119
37 --n)-
38 {-
39 char_ptr = void_ptr;-
40 if (*
*char_ptr == c1Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 27 times by 1 test
Evaluated by:
  • cut
char_ptr == c1
*char_ptr == c1Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 27 times by 1 test
Evaluated by:
  • cut
|| *
*char_ptr == c2Description
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • cut
char_ptr == c2
*char_ptr == c2Description
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • cut
)
0-27
41 return
executed 24 times by 1 test: return (void *) void_ptr;
Executed by:
  • cut
(void *) void_ptr;
executed 24 times by 1 test: return (void *) void_ptr;
Executed by:
  • cut
24
42 void_ptr = char_ptr + 1;-
43 }
executed 27 times by 1 test: end of block
Executed by:
  • cut
27
44-
45 longword_ptr = void_ptr;-
46 repeated_one = 0x01010101;-
47 repeated_c1 = c1 | (c1 << 8);-
48 repeated_c2 = c2 | (c2 << 8);-
49 repeated_c1 |= repeated_c1 << 16;-
50 repeated_c2 |= repeated_c2 << 16;-
51 if (0xffffffffU < (longword) -1
0xffffffffU < (longword) -1Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • cut
FALSEnever evaluated
)
0-71
52 {-
53 repeated_one |= repeated_one << 31 << 1;-
54 repeated_c1 |= repeated_c1 << 31 << 1;-
55 repeated_c2 |= repeated_c2 << 31 << 1;-
56 if (8 < sizeof (longword)
8 < sizeof (longword)Description
TRUEnever evaluated
FALSEevaluated 71 times by 1 test
Evaluated by:
  • cut
)
0-71
57 {-
58 size_t i;-
59-
60 for (i = 64; i < sizeof (longword) * 8
i < sizeof (longword) * 8Description
TRUEnever evaluated
FALSEnever evaluated
; i *= 2)
0
61 {-
62 repeated_one |= repeated_one << i;-
63 repeated_c1 |= repeated_c1 << i;-
64 repeated_c2 |= repeated_c2 << i;-
65 }
never executed: end of block
0
66 }
never executed: end of block
0
67 }
executed 71 times by 1 test: end of block
Executed by:
  • cut
71
68 while (n >= sizeof (longword)
n >= sizeof (longword)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 62 times by 1 test
Evaluated by:
  • cut
)
9-62
69 {-
70 longword longword1 = *longword_ptr ^ repeated_c1;-
71 longword longword2 = *longword_ptr ^ repeated_c2;-
72-
73 if (((((
((((longword1 ...ne << 7)) != 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • cut
FALSEnever evaluated
longword1 - repeated_one) & ~longword1)
((((longword1 ...ne << 7)) != 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • cut
FALSEnever evaluated
0-9
74 | ((longword2 - repeated_one) & ~longword2))
((((longword1 ...ne << 7)) != 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • cut
FALSEnever evaluated
0-9
75 & (repeated_one << 7)) != 0
((((longword1 ...ne << 7)) != 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • cut
FALSEnever evaluated
)
0-9
76 break;
executed 9 times by 1 test: break;
Executed by:
  • cut
9
77 longword_ptr++;-
78 n -= sizeof (longword);-
79 }
never executed: end of block
0
80-
81 char_ptr = (const unsigned char *) longword_ptr;-
82 for (; n > 0
n > 0Description
TRUEevaluated 122 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 5 times by 1 test
Evaluated by:
  • cut
; --n, ++char_ptr)
5-122
83 {-
84 if (*
*char_ptr == c1Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 59 times by 1 test
Evaluated by:
  • cut
char_ptr == c1
*char_ptr == c1Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 59 times by 1 test
Evaluated by:
  • cut
|| *
*char_ptr == c2Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 56 times by 1 test
Evaluated by:
  • cut
char_ptr == c2
*char_ptr == c2Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • cut
FALSEevaluated 56 times by 1 test
Evaluated by:
  • cut
)
3-63
85 return
executed 66 times by 1 test: return (void *) char_ptr;
Executed by:
  • cut
(void *) char_ptr;
executed 66 times by 1 test: return (void *) char_ptr;
Executed by:
  • cut
66
86 }
executed 56 times by 1 test: end of block
Executed by:
  • cut
56
87-
88 return
executed 5 times by 1 test: return ((void *)0) ;
Executed by:
  • cut
executed 5 times by 1 test: return ((void *)0) ;
Executed by:
  • cut
5
89 ((void *)0)
executed 5 times by 1 test: return ((void *)0) ;
Executed by:
  • cut
5
90 ;
executed 5 times by 1 test: return ((void *)0) ;
Executed by:
  • cut
5
91}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2