L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
shared_cap
Go to the documentation of this file.
1// vim:set ft=cpp: -*- Mode: C++ -*-
6/*
7 * (c) 2018 Alexander Warg <alexander.warg@kernkonzept.com>
8 *
9 * License: see LICENSE.spdx (in this directory or the directories above)
10 */
11
12#pragma once
13
14#include <l4/re/cap_alloc>
16#include <l4/sys/cxx/types>
17
18namespace L4Re {
19
33template< typename T >
35 = L4::Detail::Shared_cap_impl<T, L4Re::Smart_count_cap<L4_FP_ALL_SPACES>>;
37template< typename T >
38using shared_cap [[deprecated("Use L4Re::Shared_cap.")]]
39 = L4::Detail::Shared_cap_impl<T, L4Re::Smart_count_cap<L4_FP_ALL_SPACES>>;
40
50template< typename T >
53{ return Shared_cap<T>(ca->alloc<T>(), ca); }
54
67template<typename T, typename U>
69{
70 auto to = L4::cap_cast<T>(from.get());
71 return Shared_cap<T>(from, to);
72}
73
86template<typename T, typename U>
88{
89 auto to = L4::cap_cast<T>(from.get());
90 return Shared_cap<T>(L4::Types::move(from), to);
91}
92
103template<typename T, typename U>
105{
106 auto to = L4::cap_reinterpret_cast<T>(from.get());
107 return Shared_cap<T>(from, to);
108}
109
122template<typename T, typename U>
124{
125 auto to = L4::cap_reinterpret_cast<T>(from.get());
126 return Shared_cap<T>(L4::Types::move(from), to);
127}
128
139template<typename T, typename U>
141{
142 if (auto to = L4::cap_dynamic_cast<T>(from.get()))
143 return Shared_cap<T>(from, to);
144 else
145 return Shared_cap<T>();
146}
147
160template<typename T, typename U>
162{
163 if (auto to = L4::cap_dynamic_cast<T>(from.get()))
164 return Shared_cap<T>(L4::Types::move(from), to);
165 else
166 return Shared_cap<T>();
167}
168
185template< typename T >
186using Shared_del_cap
187 = L4::Detail::Shared_cap_impl<T, L4Re::Smart_count_cap<L4_FP_DELETE_OBJ>>;
189template<typename T>
190using shared_del_cap [[deprecated("Use L4Re::Shared_del_cap.")]]
191 = L4::Detail::Shared_cap_impl<T, L4Re::Smart_count_cap<L4_FP_DELETE_OBJ>>;
192
202template< typename T >
205{ return Shared_del_cap<T>(ca->alloc<T>(), ca); }
206
218 */
219template<typename T, typename U>
221{
222 auto to = L4::cap_cast<T>(from.get());
223 return Shared_del_cap<T>(from, to);
224}
225
237 */
238template<typename T, typename U>
240{
241 auto to = L4::cap_cast<T>(from.get());
242 return Shared_del_cap<T>(L4::Types::move(from), to);
243}
244
255template<typename T, typename U>
258{
259 auto to = L4::cap_reinterpret_cast<T>(from.get());
260 return Shared_del_cap<T>(from, to);
261}
262
275template<typename T, typename U>
278{
279 auto to = L4::cap_reinterpret_cast<T>(from.get());
280 return Shared_del_cap<T>(L4::Types::move(from), to);
281}
282
293template<typename T, typename U>
296{
297 if (auto to = L4::cap_dynamic_cast<T>(from.get()))
298 return Shared_del_cap<T>(from, to);
299 else
300 return Shared_del_cap<T>();
301}
302
315template<typename T, typename U>
318{
319 if (auto to = L4::cap_dynamic_cast<T>(from.get()))
320 return Shared_del_cap<T>(L4::Types::move(from), to);
321 else
322 return Shared_del_cap<T>();
323}
324
325} // namespace L4Re
Abstract capability-allocator interface.
Capability allocator interface.
Definition cap_alloc:31
virtual L4::Cap< void > alloc() noexcept=0
Allocate a capability.
L4Re C++ Interfaces.
Definition cmd_control:14
L4::Detail::Shared_cap_impl< T, L4Re::Smart_count_cap< L4_FP_ALL_SPACES > > Shared_cap
Shared capability that implements automatic free and unmap of the capability selector.
Definition shared_cap:34
Shared_del_cap< T > shared_del_cap_reinterpret_cast(Shared_del_cap< U > const &from) noexcept
Create a new shared capability by a reinterpret cast from another shared capability.
Definition shared_cap:255
Shared_cap< T > shared_cap_dynamic_cast(Shared_cap< U > const &from) noexcept
Create a new shared capability by a dynamic cast from another shared capability.
Definition shared_cap:139
Shared_cap< T > make_shared_cap(L4Re::Cap_alloc *ca)
Allocate a capability slot and wrap it in a Shared_cap.
Definition shared_cap:51
Shared_del_cap< T > make_shared_del_cap(L4Re::Cap_alloc *ca)
Allocate a capability slot and wrap it in a Shared_del_cap.
Definition shared_cap:202
Shared_cap< T > shared_cap_reinterpret_cast(Shared_cap< U > const &from) noexcept
Create a new shared capability by a reinterpret cast from another shared capability.
Definition shared_cap:103
Shared_cap< T > shared_cap_cast(Shared_cap< U > const &from) noexcept
Create a new shared capability by an explicit cast from another shared capability.
Definition shared_cap:67
Shared_del_cap< T > shared_del_cap_dynamic_cast(Shared_del_cap< U > const &from) noexcept
Create a new shared capability by a dynamic cast from another shared capability.
Definition shared_cap:293
L4::Detail::Shared_cap_impl< T, L4Re::Smart_count_cap< L4_FP_DELETE_OBJ > > Shared_del_cap
Shared capability that implements automatic free and unmap+delete of the capability selector.
Definition shared_cap:185
Shared_del_cap< T > shared_del_cap_cast(Shared_del_cap< U > const &from) noexcept
Create a new shared capability by an explicit cast from another shared capability.
Definition shared_cap:218
Cap< T > cap_reinterpret_cast(Cap< F > const &c) noexcept
reinterpret_cast for capabilities.
Definition capability.h:447
Cap< T > cap_cast(Cap< F > const &c) noexcept
static_cast for capabilities.
Definition capability.h:416
Cap< T > cap_dynamic_cast(Cap< F > const &c) noexcept
dynamic_cast for capabilities.
Definition capability:116