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
a22838dd
Commit
a22838dd
authored
1 year ago
by
Andre Maroneze
Browse files
Options
Downloads
Patches
Plain Diff
[Libc] add prototype and spec for non-POSIX function memmem
parent
3531a9c0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
share/libc/string.h
+15
-0
15 additions, 0 deletions
share/libc/string.h
tests/libc/string_h.c
+10
-0
10 additions, 0 deletions
tests/libc/string_h.c
with
25 additions
and
0 deletions
share/libc/string.h
+
15
−
0
View file @
a22838dd
...
@@ -499,6 +499,21 @@ extern size_t strlcat(char *restrict dest, const char *restrict src, size_t n);
...
@@ -499,6 +499,21 @@ extern size_t strlcat(char *restrict dest, const char *restrict src, size_t n);
extern
size_t
strxfrm
(
char
*
restrict
dest
,
extern
size_t
strxfrm
(
char
*
restrict
dest
,
const
char
*
restrict
src
,
size_t
n
);
const
char
*
restrict
src
,
size_t
n
);
// Non-POSIX; GNU extension
/*@
requires valid_haystack: \valid_read((char*)haystack + (0 .. haystacklen-1));
requires valid_needle: \valid_read((char*)needle + (0 .. needlelen-1));
assigns \result \from haystack,
indirect:((char*)haystack)[0 .. haystacklen-1],
indirect:((char*)needle)[0 .. needlelen-1];
ensures result_null_or_valid:
\result == \null || \valid_read((char*)\result);
ensures result_null_or_same_base:
\result == \null || \base_addr(\result) == \base_addr(haystack);
*/
extern
void
*
memmem
(
const
void
*
haystack
,
size_t
haystacklen
,
const
void
*
needle
,
size_t
needlelen
);
// Allocate strings
// Allocate strings
/*@ requires valid_string_s: valid_read_string(s);
/*@ requires valid_string_s: valid_read_string(s);
...
...
This diff is collapsed.
Click to expand it.
tests/libc/string_h.c
+
10
−
0
View file @
a22838dd
...
@@ -174,5 +174,15 @@ int main(int argc, char **argv)
...
@@ -174,5 +174,15 @@ int main(int argc, char **argv)
rchr
=
memrchr
(
c
,
'n'
,
strlen
(
c
));
rchr
=
memrchr
(
c
,
'n'
,
strlen
(
c
));
//@ check imprecise: rchr == \null;
//@ check imprecise: rchr == \null;
char
mm_haystack
[]
=
{
'I'
,
'h'
,
'a'
,
'v'
,
'e'
,
'\0'
,
'z'
,
'e'
,
'r'
,
'o'
};
char
mm_needle
[]
=
{
'z'
,
'e'
,
'r'
,
'o'
};
char
*
memm
=
memmem
(
mm_haystack
,
sizeof
(
mm_haystack
),
mm_needle
,
sizeof
(
mm_needle
));
//@ check imprecise: memm == mm_haystack + 6;
char
mm_needle2
[]
=
{
'0'
};
memm
=
memmem
(
mm_haystack
,
sizeof
(
mm_haystack
),
mm_needle2
,
sizeof
(
mm_needle2
));
//@ check imprecise: memm == \null;
return
0
;
return
0
;
}
}
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