summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/malloc.c
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2006-11-18 05:32:29 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2006-11-18 05:32:29 +0000
commit2751cbe005af59c99af13464f17679e880b51dcf (patch)
tree5f60c5a095e05f9c0a6f7f38aa1f67eca017fb3c /cpukit/libcsupport/src/malloc.c
parentAdd check for uintmax_t. (diff)
downloadrtems-2751cbe005af59c99af13464f17679e880b51dcf.tar.bz2
Use uintmax_t instead of uint64_t for MALLOC_STATS statistics.
Use inttypes.h PRIxXXX macros for printing.
Diffstat (limited to 'cpukit/libcsupport/src/malloc.c')
-rw-r--r--cpukit/libcsupport/src/malloc.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c
index 9220eea1a3..c261e1e070 100644
--- a/cpukit/libcsupport/src/malloc.c
+++ b/cpukit/libcsupport/src/malloc.c
@@ -32,9 +32,19 @@
#include <string.h>
#include <unistd.h> /* sbrk(2) */
+#include <inttypes.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
#define SENTINELSIZE 12
#define SENTINEL "\xD1\xAC\xB2\xF1" "BITE ME"
@@ -95,8 +105,8 @@ struct {
uint32_t realloc_calls;
uint32_t calloc_calls;
uint32_t max_depth; /* most ever malloc'd at 1 time */
- uint64_t lifetime_allocated;
- uint64_t lifetime_freed;
+ uintmax_t lifetime_allocated;
+ uintmax_t lifetime_freed;
} rtems_malloc_stats;
#else /* No rtems_malloc_stats */
@@ -533,17 +543,19 @@ void malloc_dump(void)
rtems_malloc_stats.lifetime_freed;
printf("Malloc stats\n");
- printf(" avail:%uk allocated:%uk (%d%%) "
- "max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
- (unsigned int) rtems_malloc_stats.space_available / 1024,
- (unsigned int) allocated / 1024,
+ printf(" avail:%"PRIu32"k allocated:%"PRIu32"k (%"PRId32"%%) "
+ "max:%"PRIu32"k (%"PRIu32"%%)"
+ " lifetime:%"PRIuMAX"k freed:%"PRIuMAX"k\n",
+ rtems_malloc_stats.space_available / 1024,
+ allocated / 1024,
/* avoid float! */
(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,
- (uint64_t ) rtems_malloc_stats.lifetime_allocated / 1024,
- (uint64_t ) rtems_malloc_stats.lifetime_freed / 1024);
- printf(" Call counts: malloc:%d free:%d realloc:%d calloc:%d\n",
+ rtems_malloc_stats.lifetime_allocated / 1024,
+ rtems_malloc_stats.lifetime_freed / 1024
+ );
+ printf(" Call counts: malloc:%"PRIu32" free:%"PRIu32" realloc:%"PRIu32" calloc:%"PRIu32"\n",
rtems_malloc_stats.malloc_calls,
rtems_malloc_stats.free_calls,
rtems_malloc_stats.realloc_calls,