1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28/*=============================================================================
29Create the vcos_malloc API from the regular system malloc/free
30=============================================================================*/
31
32/**
33 * \file
34 *
35 * Create the vcos malloc API from a regular system malloc/free library.
36 *
37 * The API lets callers specify an alignment.
38 *
39 * Under VideoCore this is not needed, as we can simply use the rtos_malloc routines.
40 * But on host platforms that won't be the case.
41 *
42 */
43
44VCOSPRE_ void * VCOSPOST_ vcos_generic_mem_alloc(VCOS_UNSIGNED sz, const char *desc);
45VCOSPRE_ void * VCOSPOST_ vcos_generic_mem_calloc(VCOS_UNSIGNED count, VCOS_UNSIGNED sz, const char *descr);
46VCOSPRE_ void VCOSPOST_ vcos_generic_mem_free(void *ptr);
47VCOSPRE_ void * VCOSPOST_ vcos_generic_mem_alloc_aligned(VCOS_UNSIGNED sz, VCOS_UNSIGNED align, const char *desc);
48
49#ifdef VCOS_INLINE_BODIES
50
51VCOS_INLINE_IMPL
52void *vcos_malloc(VCOS_UNSIGNED size, const char *description) {
53 return vcos_generic_mem_alloc(size, description);
54}
55
56VCOS_INLINE_IMPL
57void *vcos_calloc(VCOS_UNSIGNED num, VCOS_UNSIGNED size, const char *description) {
58 return vcos_generic_mem_calloc(num, size, description);
59}
60
61VCOS_INLINE_IMPL
62void vcos_free(void *ptr) {
63 vcos_generic_mem_free(ptr);
64}
65
66VCOS_INLINE_IMPL
67void * vcos_malloc_aligned(VCOS_UNSIGNED size, VCOS_UNSIGNED align, const char *description) {
68 return vcos_generic_mem_alloc_aligned(size, align, description);
69}
70
71/* Returns invalid result, do not use */
72
73VCOS_INLINE_IMPL
74unsigned long VCOS_DEPRECATED("returns invalid result") vcos_get_free_mem(void) {
75 return 0;
76}
77
78#endif /* VCOS_INLINE_BODIES */
79
80
81