L4Re - L4 Runtime Environment
mem_alloc.h
Go to the documentation of this file.
1 
5 /*
6  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
7  * economic rights: Technische Universit├Ąt Dresden (Germany)
8  *
9  * This file is part of TUD:OS and distributed under the terms of the
10  * GNU General Public License 2.
11  * Please see the COPYING-GPL-2 file for details.
12  *
13  * As a special exception, you may use this file as part of a free software
14  * library without restriction. Specifically, if other files instantiate
15  * templates or use macros or inline functions from this file, or you compile
16  * this file and link it with other files to produce an executable, this
17  * file does not by itself cause the resulting executable to be covered by
18  * the GNU General Public License. This exception does not however
19  * invalidate any other reasons why the executable file might be covered by
20  * the GNU General Public License.
21  */
22 #pragma once
23 
24 #include <l4/re/env.h>
25 #include <l4/sys/consts.h>
26 
27 #include <l4/re/c/dataspace.h>
28 
36 
43  L4RE_MA_CONTINUOUS = 0x01,
44  L4RE_MA_PINNED = 0x02,
45  L4RE_MA_SUPER_PAGES = 0x04,
46 };
47 
48 
66 L4_CV L4_INLINE long
67 l4re_ma_alloc(long size, l4re_ds_t const mem,
68  unsigned long flags) L4_NOTHROW;
69 
91 L4_CV L4_INLINE long
92 l4re_ma_alloc_align(long size, l4re_ds_t const mem,
93  unsigned long flags, unsigned long align) L4_NOTHROW;
94 
106 /* Deprecation message added Q4 2016.
107  * Remove together with L4Re::Mem_alloc::free() */
108 L4_CV L4_INLINE long
110 L4_DEPRECATED("This function is an empty stub and remains for backward compatibility only. See documentation for replacement options.");
111 
112 
113 
114 
133 L4_CV long
135  l4re_ds_t const mem, unsigned long flags,
136  unsigned long align) L4_NOTHROW;
137 
150 /* Deprecation message added Q4 2016.
151  * Remove together with L4Re::Mem_alloc::free() */
152 L4_CV long
154 L4_DEPRECATED("This function is an empty stub and remains for backward compatibility only. See documentation for replacement options.");
155 
156 
157 
158 
159 
160 /***************** Implementation *****************/
161 
162 /* Just warn actual users, but not for internal implementations */
163 #pragma GCC diagnostic push
164 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
165 
166 L4_CV L4_INLINE long
167 l4re_ma_alloc(long size, l4re_ds_t const mem,
168  unsigned long flags) L4_NOTHROW
169 {
170  return l4re_ma_alloc_align_srv(l4re_global_env->mem_alloc, size, mem,
171  flags, 0);
172 }
173 
174 L4_CV L4_INLINE long
175 l4re_ma_alloc_align(long size, l4re_ds_t const mem,
176  unsigned long flags, unsigned long align) L4_NOTHROW
177 {
178  return l4re_ma_alloc_align_srv(l4re_global_env->mem_alloc, size, mem,
179  flags, align);
180 }
181 
182 L4_CV L4_INLINE long
184 {
185  return l4re_ma_free_srv(l4re_global_env->mem_alloc, mem);
186 }
187 
188 #pragma GCC diagnostic pop
189 
long l4re_ma_alloc_align_srv(l4_cap_idx_t srv, long size, l4re_ds_t const mem, unsigned long flags, unsigned long align) L4_NOTHROW
Allocate memory.
#define EXTERN_C_END
End section with C types and functions.
Definition: compiler.h:187
l4re_ma_flags
Flags for requesting memory at the memory allocator.
Definition: mem_alloc.h:42
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
Environment interface.
long l4re_ma_alloc_align(long size, l4re_ds_t const mem, unsigned long flags, unsigned long align) L4_NOTHROW
Allocate memory.
Definition: mem_alloc.h:175
l4_cap_idx_t l4re_ds_t
Dataspace type.
Definition: dataspace.h:39
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition: compiler.h:186
long l4re_ma_free(l4re_ds_t const mem) L4_NOTHROW
Free memory.
Definition: mem_alloc.h:183
Data space C interface.
#define L4_CV
Define calling convention.
Definition: linkage.h:44
long l4re_ma_alloc(long size, l4re_ds_t const mem, unsigned long flags) L4_NOTHROW
Allocate memory.
Definition: mem_alloc.h:167
long l4re_ma_free_srv(l4_cap_idx_t srv, l4re_ds_t const mem) L4_NOTHROW
Free memory.
l4_cap_idx_t mem_alloc
Memory allocator object-capability.
Definition: env.h:112
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition: compiler.h:239
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185