Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
cm-projects
RIOT
Commits
00092130
Commit
00092130
authored
6 years ago
by
Cenk Gündoğan
Browse files
Options
Downloads
Patches
Plain Diff
tlsf: add custom walker to get total free / used sizes
parent
ec5ca98b
Branches
Branches containing commit
No related tags found
Loading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/tlsf/contrib/include/tlsf-malloc.h
+22
-0
22 additions, 0 deletions
pkg/tlsf/contrib/include/tlsf-malloc.h
pkg/tlsf/contrib/tlsf-malloc.c
+12
-0
12 additions, 0 deletions
pkg/tlsf/contrib/tlsf-malloc.c
sys/ps/ps.c
+4
-1
4 additions, 1 deletion
sys/ps/ps.c
with
38 additions
and
1 deletion
pkg/tlsf/contrib/include/tlsf-malloc.h
+
22
−
0
View file @
00092130
...
@@ -43,6 +43,28 @@
...
@@ -43,6 +43,28 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
/**
* @brief Struct to hold the total sizes of free and used blocks
* Used for @ref tlsf_size_walker()
*/
typedef
struct
{
unsigned
free
;
/**< total free size */
unsigned
used
;
/**< total used size */
}
tlsf_size_container_t
;
/**
* Walk the memory pool to print all block sizes and to calculate
* the total amount of free and used block sizes.
*
* @note This function is passed to tlsf_walk_pool()
*
* @param ptr Pointer to the current block.
* @param size Size of the current block at @p ptr.
* @param used Shows whether the current block is used or free.
* @param user Custom data expected to be of type ``pointer to tlsf_size_container_t``
*/
void
tlsf_size_walker
(
void
*
ptr
,
size_t
size
,
int
used
,
void
*
user
);
/**
/**
* Add an area of memory to the global allocator pool.
* Add an area of memory to the global allocator pool.
*
*
...
...
This diff is collapsed.
Click to expand it.
pkg/tlsf/contrib/tlsf-malloc.c
+
12
−
0
View file @
00092130
...
@@ -63,6 +63,18 @@ tlsf_t *_tlsf_get_global_control(void)
...
@@ -63,6 +63,18 @@ tlsf_t *_tlsf_get_global_control(void)
return
gheap
;
return
gheap
;
}
}
void
tlsf_size_walker
(
void
*
ptr
,
size_t
size
,
int
used
,
void
*
user
)
{
printf
(
"
\t
%p %s size: %u (%p)
\n
"
,
ptr
,
used
?
"used"
:
"free"
,
(
unsigned
int
)
size
,
ptr
);
if
(
used
)
{
((
tlsf_size_container_t
*
)
user
)
->
used
+=
(
unsigned
int
)
size
;
}
else
{
((
tlsf_size_container_t
*
)
user
)
->
free
+=
(
unsigned
int
)
size
;
}
}
/**
/**
* Allocate a block of size "bytes"
* Allocate a block of size "bytes"
*/
*/
...
...
This diff is collapsed.
Click to expand it.
sys/ps/ps.c
+
4
−
1
View file @
00092130
...
@@ -147,7 +147,10 @@ void ps(void)
...
@@ -147,7 +147,10 @@ void ps(void)
overall_stacksz
,
overall_used
);
overall_stacksz
,
overall_used
);
# ifdef MODULE_TLSF_MALLOC
# ifdef MODULE_TLSF_MALLOC
puts
(
"
\n
Heap usage:"
);
puts
(
"
\n
Heap usage:"
);
tlsf_walk_pool
(
tlsf_get_pool
(
_tlsf_get_global_control
()),
NULL
,
NULL
);
tlsf_size_container_t
sizes
=
{
.
free
=
0
,
.
used
=
0
};
tlsf_walk_pool
(
tlsf_get_pool
(
_tlsf_get_global_control
()),
tlsf_size_walker
,
&
sizes
);
printf
(
"
\t
Total free size: %u
\n
"
,
sizes
.
free
);
printf
(
"
\t
Total used size: %u
\n
"
,
sizes
.
used
);
# endif
# endif
#endif
#endif
}
}
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