summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-10-18 15:02:06 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-10-18 15:02:06 +0000
commit3815a2b73c951c77f7e06f30837e95bcfe709ec8 (patch)
tree44233e93d730cd9b56507347947f557533ff2b21 /cpukit
parent2000-10-18 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-3815a2b73c951c77f7e06f30837e95bcfe709ec8.tar.bz2
2000-10-18 Joel Sherrill <joel@OARcorp.com>
* libc/Makefile.am: Added mallocfreespace.c. * libc/mallocfreespace.c: New file based on work by Nick Simon <Nick.SIMON@syntegra.bt.co.uk> which he included in malloc.c. * libc/libcsupport.h: Added prototype for malloc_free_space().
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libcsupport/include/rtems/libcsupport.h1
-rw-r--r--cpukit/libcsupport/src/mallocfreespace.c40
2 files changed, 41 insertions, 0 deletions
diff --git a/cpukit/libcsupport/include/rtems/libcsupport.h b/cpukit/libcsupport/include/rtems/libcsupport.h
index 4c6764c1d4..4def1e82c5 100644
--- a/cpukit/libcsupport/include/rtems/libcsupport.h
+++ b/cpukit/libcsupport/include/rtems/libcsupport.h
@@ -33,6 +33,7 @@ extern void malloc_walk(size_t source, size_t printf_enabled);
extern void libc_init(int reentrant);
extern int host_errno(void);
extern void fix_syscall_errno(void);
+extern size_t malloc_free_space();
#ifdef __cplusplus
}
diff --git a/cpukit/libcsupport/src/mallocfreespace.c b/cpukit/libcsupport/src/mallocfreespace.c
new file mode 100644
index 0000000000..28ef83278e
--- /dev/null
+++ b/cpukit/libcsupport/src/mallocfreespace.c
@@ -0,0 +1,40 @@
+/*
+ * RTEMS Malloc Get Status Information
+ *
+ *
+ * COPYRIGHT (c) 1989-2000.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
+#include <rtems.h>
+#include "libcsupport.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+extern rtems_id RTEMS_Malloc_Heap;
+
+/*
+ * Find amount of free heap remaining
+ */
+
+size_t malloc_free_space( void )
+{
+ region_information_block heap_info;
+
+ if ( region_get_information( RTEMS_Malloc_Heap, &heap_info ) ) {
+ return (size_t) heap_info.free_size;
+ }
+ return (size_t) -1;
+}