source: rtems-libbsd/rtemsbsd/rtems/rtems-kernel-malloc.c @ dd35ec5

55-freebsd-126-freebsd-12
Last change on this file since dd35ec5 was 0237319, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/17 at 11:18:31

Update due to Newlib 2017-06-07 changes

The following files are now provided by Newlib:

  • arpa/inet.h
  • net/if.h
  • netinet/in.h
  • netinet/tcp.h
  • sys/socket.h
  • sys/uio.h
  • sys/un.h

The <sys/param.h> and <sys/cpuset.h> are now compatible enough to be
used directly.

Update #2833.

  • Property mode set to 100644
File size: 2.9 KB
Line 
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 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 *    notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 *    notice, this list of conditions and the following disclaimer in the
25 *    documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#include <machine/rtems-bsd-kernel-space.h>
41#include <machine/rtems-bsd-support.h>
42
43#include <sys/param.h>
44#include <sys/types.h>
45#include <sys/systm.h>
46#include <sys/malloc.h>
47#include <sys/kernel.h>
48
49MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
50
51MALLOC_DEFINE(M_TEMP, "temp", "misc temporary data buffers");
52
53MALLOC_DEFINE(M_IOV, "iov", "large iov's");
54
55void
56malloc_init(void *data)
57{
58        struct malloc_type *mtp = data;
59}
60
61void
62malloc_uninit(void *data)
63{
64        struct malloc_type *mtp = data;
65
66        BSD_PRINTF( "desc = %s\n", mtp->ks_shortdesc);
67}
68
69#undef malloc
70
71void *
72_bsd_malloc(unsigned long size, struct malloc_type *mtp, int flags)
73{
74        void *p = malloc(size > 0 ? size : 1);
75
76        if ((flags & M_ZERO) != 0 && p != NULL) {
77                memset(p, 0, size);
78        }
79
80        return p;
81}
82
83#undef realloc
84void *
85_bsd_realloc( void *addr, unsigned long size,
86  struct malloc_type *type, int flags)
87{
88        void *p = realloc(addr, size > 0 ? size : 1);
89
90        if ((flags & M_ZERO) != 0 && p != NULL) {
91                memset(p, 0, size);
92        }
93
94        return p;
95}
96
97#undef reallocf
98void *
99_bsd_reallocf( void *addr, unsigned long size,
100  struct malloc_type *type, int flags)
101{
102        void *p = realloc(addr, size > 0 ? size : 1);
103
104        if (p == NULL) {
105                free(addr,NULL);
106        }
107
108        return p;
109}
110
111#undef free
112void
113_bsd_free(void *addr, struct malloc_type *mtp)
114{
115        free(addr);
116}
117
118#undef strdup
119
120char *
121_bsd_strdup(const char *__restrict s, struct malloc_type *type)
122{
123        return strdup(s);
124}
Note: See TracBrowser for help on using the repository browser.