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
1e14663a
Commit
1e14663a
authored
7 years ago
by
Kostyantyn Vorobyov
Browse files
Options
Downloads
Patches
Plain Diff
Minor refactoring in bittree model
parent
53a3dd0e
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/bittree_model/e_acsl_bittree_mmodel.c
+27
-20
27 additions, 20 deletions
...e-acsl/share/e-acsl/bittree_model/e_acsl_bittree_mmodel.c
with
27 additions
and
20 deletions
src/plugins/e-acsl/share/e-acsl/bittree_model/e_acsl_bittree_mmodel.c
+
27
−
20
View file @
1e14663a
...
@@ -212,35 +212,43 @@ static int initialized(void * ptr, size_t size) {
...
@@ -212,35 +212,43 @@ static int initialized(void * ptr, size_t size) {
/* return the length (in bytes) of the block containing ptr */
/* return the length (in bytes) of the block containing ptr */
static
size_t
block_length
(
void
*
ptr
)
{
static
size_t
block_length
(
void
*
ptr
)
{
bt_block
*
tmp
=
bt_find
(
ptr
);
bt_block
*
blk
=
bt_find
(
ptr
);
/* Hard failure when un-allocated memory is used */
/* Hard failure when un-allocated memory is used */
vassert
(
tmp
!=
NULL
,
"
\\
block_length of unallocated memory"
,
NULL
);
vassert
(
blk
!=
NULL
,
"
\\
block_length of unallocated memory"
,
NULL
);
return
tmp
->
size
;
return
blk
->
size
;
}
}
static
int
allocated
(
void
*
ptr
,
size_t
size
,
void
*
ptr_base
)
{
static
bt_block
*
allocated
(
void
*
ptr
,
size_t
size
,
void
*
ptr_base
)
{
bt_block
*
blk
=
bt_find
(
ptr
);
bt_block
*
blk
=
bt_find
(
ptr
);
if
(
blk
==
NULL
)
return
NULL
;
#ifndef E_ACSL_WEAK_VALIDITY
bt_block
*
blk_base
=
bt_find
(
ptr_base
);
bt_block
*
blk_base
=
bt_find
(
ptr_base
);
if
(
blk
==
NULL
||
blk_base
==
NULL
||
blk
->
ptr
!=
blk_base
->
ptr
)
if
(
blk_base
==
NULL
||
blk
->
ptr
!=
blk_base
->
ptr
)
return
false
;
return
NULL
;
return
(
blk
->
size
-
((
size_t
)
ptr
-
blk
->
ptr
)
>=
size
);
#endif
return
(
blk
->
size
-
((
size_t
)
ptr
-
blk
->
ptr
)
>=
size
)
?
blk
:
NULL
;
}
}
/* return whether the size bytes of ptr are readable/writable */
/** \brief Return 1 if a given memory location is read-only and 0 otherwise */
static
int
valid
(
void
*
ptr
,
size_t
size
,
void
*
ptr_base
,
void
*
addr_of_base
)
{
static
int
readonly
(
void
*
ptr
)
{
/* Many similarities with allocated (so far at least), but it is better
* to use this tandalone definition, otherwise the block needs to be looked
* up twice */
bt_block
*
blk
=
bt_find
(
ptr
);
bt_block
*
blk
=
bt_find
(
ptr
);
bt_block
*
blk_base
=
bt_find
(
ptr_base
);
vassert
(
blk
!=
NULL
,
"Readonly on unallocated memory"
,
NULL
);
if
(
blk
==
NULL
||
blk_base
==
NULL
||
blk
->
ptr
!=
blk_base
->
ptr
)
return
blk
->
is_readonly
;
return
false
;
}
return
(
blk
->
size
-
((
size_t
)
ptr
-
blk
->
ptr
)
>=
size
&&
!
blk
->
is_readonly
);
/* return whether the size bytes of ptr are readable/writable */
static
int
valid
(
void
*
ptr
,
size_t
size
,
void
*
ptr_base
,
void
*
addrof_base
)
{
bt_block
*
blk
=
allocated
(
ptr
,
size
,
ptr_base
);
if
(
blk
!=
NULL
)
return
!
blk
->
is_readonly
;
return
0
;
}
}
/* return whether the size bytes of ptr are readable */
/* return whether the size bytes of ptr are readable */
static
int
valid_read
(
void
*
ptr
,
size_t
size
,
void
*
ptr_base
,
void
*
addr_of_base
)
{
static
int
valid_read
(
void
*
ptr
,
size_t
size
,
void
*
ptr_base
,
void
*
addrof_base
)
{
return
allocated
(
ptr
,
size
,
ptr_base
);
bt_block
*
blk
=
allocated
(
ptr
,
size
,
ptr_base
);
return
blk
!=
NULL
;
}
}
/* return the base address of the block containing ptr */
/* return the base address of the block containing ptr */
...
@@ -407,8 +415,7 @@ static int bittree_posix_memalign(void **memptr, size_t alignment, size_t size)
...
@@ -407,8 +415,7 @@ static int bittree_posix_memalign(void **memptr, size_t alignment, size_t size)
return
-
1
;
return
-
1
;
/* Make sure that the first argument to posix memalign is indeed allocated */
/* Make sure that the first argument to posix memalign is indeed allocated */
vassert
(
allocated
((
void
*
)
memptr
,
sizeof
(
void
*
),
(
void
*
)
memptr
),
DVALIDATE_RW_ACCESS
((
void
*
)
memptr
,
sizeof
(
void
*
));
"
\\
invalid memptr in posix_memalign"
,
NULL
);
int
res
=
native_posix_memalign
(
memptr
,
alignment
,
size
);
int
res
=
native_posix_memalign
(
memptr
,
alignment
,
size
);
if
(
!
res
)
{
if
(
!
res
)
{
...
...
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