summaryrefslogtreecommitdiffstats
path: root/bsd_eth_drivers/libbsdport/contigmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsd_eth_drivers/libbsdport/contigmalloc.c')
-rw-r--r--bsd_eth_drivers/libbsdport/contigmalloc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/bsd_eth_drivers/libbsdport/contigmalloc.c b/bsd_eth_drivers/libbsdport/contigmalloc.c
new file mode 100644
index 0000000..7c9f1b7
--- /dev/null
+++ b/bsd_eth_drivers/libbsdport/contigmalloc.c
@@ -0,0 +1,33 @@
+#include <rtems.h>
+
+#define _KERNEL
+#include <rtems/rtems_bsdnet_internal.h>
+#include <sys/malloc.h>
+
+void *
+contigmalloc(
+ unsigned long size,
+ int type,
+ int flags,
+ unsigned long lo,
+ unsigned long hi,
+ unsigned long align,
+ unsigned long bound)
+{
+void *ptr = rtems_bsdnet_malloc(size + sizeof(ptr) + align-1, type, flags);
+char *rval = 0;
+ if ( ptr ) {
+ unsigned tmp = (unsigned)ptr + align - 1;
+ tmp -= tmp % align;
+ rval = (char*)tmp;
+ /* save backlink */
+ *(void**)(rval+size) = ptr;
+ }
+ return rval;
+}
+
+void
+contigfree(void *ptr, size_t size, int type)
+{
+ rtems_bsdnet_free( *(void**)((unsigned)ptr + size), type);
+}