1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup rtems_bsd_rtems |
---|
5 | * |
---|
6 | * @brief TODO. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2009, 2010 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Obere Lagerstr. 30 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.com/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <freebsd/machine/rtems-bsd-config.h> |
---|
24 | |
---|
25 | #include <freebsd/sys/param.h> |
---|
26 | #include <freebsd/sys/types.h> |
---|
27 | #include <freebsd/sys/systm.h> |
---|
28 | #include <freebsd/sys/malloc.h> |
---|
29 | #include <freebsd/sys/kernel.h> |
---|
30 | |
---|
31 | MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory"); |
---|
32 | |
---|
33 | MALLOC_DEFINE(M_TEMP, "temp", "misc temporary data buffers"); |
---|
34 | |
---|
35 | MALLOC_DEFINE(M_IP6OPT, "ip6opt", "IPv6 options"); |
---|
36 | MALLOC_DEFINE(M_IP6NDP, "ip6ndp", "IPv6 Neighbor Discovery"); |
---|
37 | |
---|
38 | MALLOC_DEFINE(M_IOV, "iov", "large iov's"); |
---|
39 | |
---|
40 | void |
---|
41 | malloc_init(void *data) |
---|
42 | { |
---|
43 | struct malloc_type *mtp = data; |
---|
44 | } |
---|
45 | |
---|
46 | void |
---|
47 | malloc_uninit(void *data) |
---|
48 | { |
---|
49 | struct malloc_type *mtp = data; |
---|
50 | |
---|
51 | BSD_PRINTF( "desc = %s\n", mtp->ks_shortdesc); |
---|
52 | } |
---|
53 | |
---|
54 | #undef malloc |
---|
55 | |
---|
56 | void * |
---|
57 | _bsd_malloc(unsigned long size, struct malloc_type *mtp, int flags) |
---|
58 | { |
---|
59 | void *p = malloc(size); |
---|
60 | |
---|
61 | if ((flags & M_ZERO) != 0 && p != NULL) { |
---|
62 | memset(p, 0, size); |
---|
63 | } |
---|
64 | |
---|
65 | return p; |
---|
66 | } |
---|
67 | |
---|
68 | #undef realloc |
---|
69 | void * |
---|
70 | _bsd_realloc( void *addr, unsigned long size, |
---|
71 | struct malloc_type *type, int flags) |
---|
72 | { |
---|
73 | void *p = realloc(addr, size); |
---|
74 | |
---|
75 | if ((flags & M_ZERO) != 0 && p != NULL) { |
---|
76 | memset(p, 0, size); |
---|
77 | } |
---|
78 | |
---|
79 | return p; |
---|
80 | } |
---|
81 | |
---|
82 | #undef free |
---|
83 | |
---|
84 | void |
---|
85 | _bsd_free(void *addr, struct malloc_type *mtp) |
---|
86 | { |
---|
87 | free(addr); |
---|
88 | } |
---|
89 | |
---|
90 | #undef strdup |
---|
91 | |
---|
92 | char * |
---|
93 | _bsd_strdup(const char *__restrict s, struct malloc_type *type) |
---|
94 | { |
---|
95 | return strdup(s); |
---|
96 | } |
---|