blob: 7c9f1b71b08abe990adad6b1ab631a47f795949a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
}
|