Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
8d14b16e
Commit
8d14b16e
authored
9 years ago
by
Kostyantyn Vorobyov
Browse files
Options
Downloads
Patches
Plain Diff
[RTL] Refactoring functions dealing with initialization using bit-level
macros in e_acsl_bits.h
parent
bbbf8228
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/share/e-acsl/adt_models/e_acsl_adt_mmodel.h
+8
-16
8 additions, 16 deletions
...lugins/e-acsl/share/e-acsl/adt_models/e_acsl_adt_mmodel.h
with
8 additions
and
16 deletions
src/plugins/e-acsl/share/e-acsl/adt_models/e_acsl_adt_mmodel.h
+
8
−
16
View file @
8d14b16e
...
@@ -264,26 +264,18 @@ void __initialize (void * ptr, size_t size) {
...
@@ -264,26 +264,18 @@ void __initialize (void * ptr, size_t size) {
* initialization of `size' bytes starting from `ptr'. */
* initialization of `size' bytes starting from `ptr'. */
unsigned
i
;
unsigned
i
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
for
(
i
=
0
;
i
<
size
;
i
++
)
{
/
/ B
yte-offset within the block, i.e., mark `offset' byte as initialized
/
* b
yte-offset within the block, i.e., mark `offset' byte as initialized
*/
size_t
offset
=
(
uintptr_t
)
ptr
-
tmp
->
ptr
+
i
;
size_t
offset
=
(
uintptr_t
)
ptr
-
tmp
->
ptr
+
i
;
/
/ B
yte offset within tmp->init_ptr, i.e., a byte containing the bit to
/
* b
yte offset within tmp->init_ptr, i.e., a byte containing the bit to
//
be toggled
be toggled
*/
int
byte
=
offset
/
8
;
int
byte
=
offset
/
8
;
/
/ B
it-offset within the above byte, i.e., bit to be toggled
/
* b
it-offset within the above byte, i.e., bit to be toggled
*/
int
bit
=
offset
%
8
;
int
bit
=
offset
%
8
;
if
(((
tmp
->
init_ptr
[
byte
]
>>
bit
)
&
1
)
==
0
)
{
// if the bit is not set ...
if
(
!
bitcheck
(
bit
,
tmp
->
init_ptr
[
byte
]))
{
/* if bit is unset ... */
tmp
->
init_ptr
[
byte
]
|=
1
<<
bit
;
// ... set the bit and ...
bitset
(
bit
,
tmp
->
init_ptr
[
byte
]);
/* ... set the bit ... */
tmp
->
init_cpt
++
;
// ... increment the counter tracking the number
tmp
->
init_cpt
++
;
/* ... and increment initialized bytes count */
// of initialized bits.
}
}
/* NOTE:
* ((tmp->init_ptr[byte] >> bit) & 1)
* - shift's the bit of interest to position [0] and applies bitwise
* AND using mask '1000 0000', then if the result is 0 the bit is unset
* 1 << bit
* - bit-mask that has 1 shifted to the bit offset and the remaining
* bits are all zeroes */
}
}
/* now fully initialized */
/* now fully initialized */
...
@@ -341,7 +333,7 @@ int __initialized (void * ptr, size_t size) {
...
@@ -341,7 +333,7 @@ int __initialized (void * ptr, size_t size) {
size_t
offset
=
(
uintptr_t
)
ptr
-
tmp
->
ptr
+
i
;
size_t
offset
=
(
uintptr_t
)
ptr
-
tmp
->
ptr
+
i
;
int
byte
=
offset
/
8
;
int
byte
=
offset
/
8
;
int
bit
=
offset
%
8
;
int
bit
=
offset
%
8
;
if
(
((
tmp
->
init_ptr
[
byte
]
>>
bit
)
&
1
)
==
0
)
if
(
!
bitcheck
(
bit
,
tmp
->
init_ptr
[
byte
]
)
)
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment