mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-06 07:33:17 +00:00
Use uintmax_t instead of uint64_t for MALLOC_STATS statistics.
Use inttypes.h PRIxXXX macros for printing.
This commit is contained in:
@@ -32,9 +32,19 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <unistd.h> /* sbrk(2) */
|
#include <unistd.h> /* sbrk(2) */
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include <rtems/chain.h>
|
#include <rtems/chain.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_UINTMAX_T
|
||||||
|
/* Fall back to unsigned long if uintmax_t is not available */
|
||||||
|
#define unsigned long uintmax_t
|
||||||
|
|
||||||
|
#ifndef PRIuMAX
|
||||||
|
#define PRIuMAX "%lu"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MALLOC_ARENA_CHECK
|
#ifdef MALLOC_ARENA_CHECK
|
||||||
#define SENTINELSIZE 12
|
#define SENTINELSIZE 12
|
||||||
#define SENTINEL "\xD1\xAC\xB2\xF1" "BITE ME"
|
#define SENTINEL "\xD1\xAC\xB2\xF1" "BITE ME"
|
||||||
@@ -95,8 +105,8 @@ struct {
|
|||||||
uint32_t realloc_calls;
|
uint32_t realloc_calls;
|
||||||
uint32_t calloc_calls;
|
uint32_t calloc_calls;
|
||||||
uint32_t max_depth; /* most ever malloc'd at 1 time */
|
uint32_t max_depth; /* most ever malloc'd at 1 time */
|
||||||
uint64_t lifetime_allocated;
|
uintmax_t lifetime_allocated;
|
||||||
uint64_t lifetime_freed;
|
uintmax_t lifetime_freed;
|
||||||
} rtems_malloc_stats;
|
} rtems_malloc_stats;
|
||||||
|
|
||||||
#else /* No rtems_malloc_stats */
|
#else /* No rtems_malloc_stats */
|
||||||
@@ -533,17 +543,19 @@ void malloc_dump(void)
|
|||||||
rtems_malloc_stats.lifetime_freed;
|
rtems_malloc_stats.lifetime_freed;
|
||||||
|
|
||||||
printf("Malloc stats\n");
|
printf("Malloc stats\n");
|
||||||
printf(" avail:%uk allocated:%uk (%d%%) "
|
printf(" avail:%"PRIu32"k allocated:%"PRIu32"k (%"PRId32"%%) "
|
||||||
"max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
|
"max:%"PRIu32"k (%"PRIu32"%%)"
|
||||||
(unsigned int) rtems_malloc_stats.space_available / 1024,
|
" lifetime:%"PRIuMAX"k freed:%"PRIuMAX"k\n",
|
||||||
(unsigned int) allocated / 1024,
|
rtems_malloc_stats.space_available / 1024,
|
||||||
|
allocated / 1024,
|
||||||
/* avoid float! */
|
/* avoid float! */
|
||||||
(allocated * 100) / rtems_malloc_stats.space_available,
|
(allocated * 100) / rtems_malloc_stats.space_available,
|
||||||
(unsigned int) rtems_malloc_stats.max_depth / 1024,
|
rtems_malloc_stats.max_depth / 1024,
|
||||||
(rtems_malloc_stats.max_depth * 100) / rtems_malloc_stats.space_available,
|
(rtems_malloc_stats.max_depth * 100) / rtems_malloc_stats.space_available,
|
||||||
(uint64_t ) rtems_malloc_stats.lifetime_allocated / 1024,
|
rtems_malloc_stats.lifetime_allocated / 1024,
|
||||||
(uint64_t ) rtems_malloc_stats.lifetime_freed / 1024);
|
rtems_malloc_stats.lifetime_freed / 1024
|
||||||
printf(" Call counts: malloc:%d free:%d realloc:%d calloc:%d\n",
|
);
|
||||||
|
printf(" Call counts: malloc:%"PRIu32" free:%"PRIu32" realloc:%"PRIu32" calloc:%"PRIu32"\n",
|
||||||
rtems_malloc_stats.malloc_calls,
|
rtems_malloc_stats.malloc_calls,
|
||||||
rtems_malloc_stats.free_calls,
|
rtems_malloc_stats.free_calls,
|
||||||
rtems_malloc_stats.realloc_calls,
|
rtems_malloc_stats.realloc_calls,
|
||||||
|
|||||||
Reference in New Issue
Block a user