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 
79 L4_CV L4_INLINE long
80 l4re_ma_alloc(long size, l4re_ds_t const mem,
81  unsigned long flags) L4_NOTHROW;
82 
116 L4_CV L4_INLINE long
117 l4re_ma_alloc_align(long size, l4re_ds_t const mem,
118  unsigned long flags, unsigned long align) L4_NOTHROW;
119 
131 /* Deprecation message added Q4 2016.
132  * Remove together with L4Re::Mem_alloc::free() */
133 L4_CV L4_INLINE long
135 L4_DEPRECATED("This function is an empty stub and remains for backward compatibility only. See documentation for replacement options.");
136 
137 
138 
139 
158 L4_CV long
160  l4re_ds_t const mem, unsigned long flags,
161  unsigned long align) L4_NOTHROW;
162 
175 /* Deprecation message added Q4 2016.
176  * Remove together with L4Re::Mem_alloc::free() */
177 L4_CV long
179 L4_DEPRECATED("This function is an empty stub and remains for backward compatibility only. See documentation for replacement options.");
180 
181 
182 
183 
184 
185 /***************** Implementation *****************/
186 
187 /* Just warn actual users, but not for internal implementations */
188 #pragma GCC diagnostic push
189 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
190 
191 L4_CV L4_INLINE long
192 l4re_ma_alloc(long size, l4re_ds_t const mem,
193  unsigned long flags) L4_NOTHROW
194 {
195  return l4re_ma_alloc_align_srv(l4re_global_env->mem_alloc, size, mem,
196  flags, 0);
197 }
198 
199 L4_CV L4_INLINE long
200 l4re_ma_alloc_align(long size, l4re_ds_t const mem,
201  unsigned long flags, unsigned long align) L4_NOTHROW
202 {
203  return l4re_ma_alloc_align_srv(l4re_global_env->mem_alloc, size, mem,
204  flags, align);
205 }
206 
207 L4_CV L4_INLINE long
209 {
210  return l4re_ma_free_srv(l4re_global_env->mem_alloc, mem);
211 }
212 
213 #pragma GCC diagnostic pop
214 
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:186
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition: compiler.h:190
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition: compiler.h:243
#define EXTERN_C_END
End section with C types and functions.
Definition: compiler.h:191
Data space C interface.
Environment interface.
l4_cap_idx_t l4re_ds_t
Dataspace type.
Definition: dataspace.h:39
long l4re_ma_free(l4re_ds_t const mem) L4_NOTHROW
Free memory.
Definition: mem_alloc.h:208
long l4re_ma_free_srv(l4_cap_idx_t srv, l4re_ds_t const mem) L4_NOTHROW
Free memory.
l4re_ma_flags
Flags for requesting memory at the memory allocator.
Definition: mem_alloc.h:42
long l4re_ma_alloc(long size, l4re_ds_t const mem, unsigned long flags) L4_NOTHROW
Allocate memory.
Definition: mem_alloc.h:192
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:200
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.
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
#define L4_CV
Define calling convention.
Definition: linkage.h:44
l4_cap_idx_t mem_alloc
Memory allocator object-capability.
Definition: env.h:113