µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
null.h
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ distribution.
3 * (https://github.com/micro-os-plus)
4 * Copyright (c) 2016 Liviu Ionescu.
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#ifndef CMSIS_PLUS_MEMORY_NULL_H_
29#define CMSIS_PLUS_MEMORY_NULL_H_
30
31// ----------------------------------------------------------------------------
32
33#if defined(__cplusplus)
34
35// ----------------------------------------------------------------------------
36
37#include <cmsis-plus/rtos/os.h>
38
39// ----------------------------------------------------------------------------
40
41#pragma GCC diagnostic push
42
43#if defined(__clang__)
44#pragma clang diagnostic ignored "-Wc++98-compat"
45#endif
46
47// ----------------------------------------------------------------------------
48
49namespace os
50{
51 namespace memory
52 {
53
54#pragma GCC diagnostic push
55#if defined(__clang__)
56#pragma clang diagnostic ignored "-Wweak-vtables"
57#endif
58
59 // ========================================================================
60
73 {
74 public:
75
85
90 // The rule of five.
94 operator= (const null_memory_resource&) = delete;
96 operator= (null_memory_resource&&) = delete;
97
105 ~null_memory_resource () override = default;
106
111 protected:
112
124 virtual void*
125 do_allocate (std::size_t bytes, std::size_t alignment) override;
126
135 virtual void
136 do_deallocate (void* addr, std::size_t bytes, std::size_t alignment)
137 noexcept override;
138
142 };
143
144#pragma GCC diagnostic pop
145
146 // -------------------------------------------------------------------------
147 } /* namespace memory */
148} /* namespace os */
149
150// ===== Inline & template implementations ====================================
151
152namespace os
153{
154 namespace memory
155 {
156
157 // ========================================================================
158
159#pragma GCC diagnostic push
160// Needed because 'alignment' is used only in trace calls.
161#pragma GCC diagnostic ignored "-Wunused-parameter"
162
163 inline void*
164 null_memory_resource::do_allocate (std::size_t bytes, std::size_t alignment)
165 {
167 }
168
169 inline void
170 null_memory_resource::do_deallocate (void* addr, std::size_t bytes,
171 std::size_t alignment) noexcept
172 {
173 ;
174 }
175
176#pragma GCC diagnostic pop
177
178 // ==========================================================================
179 } /* namespace memory */
180} /* namespace os */
181
182#pragma GCC diagnostic pop
183
184// ----------------------------------------------------------------------------
185
186#endif /* __cplusplus */
187
188// ----------------------------------------------------------------------------
189
190#endif /* CMSIS_PLUS_MEMORY_NULL_H_ */
An internal memory manager that throws a bad_alloc() exception when trying to allocate.
Definition null.h:73
null_memory_resource()=default
Default constructor. Construct a memory manager object instance.
virtual void * do_allocate(std::size_t bytes, std::size_t alignment) override
Implementation of the memory allocator.
Definition null.h:164
virtual void do_deallocate(void *addr, std::size_t bytes, std::size_t alignment) noexcept override
Implementation of the memory deallocator.
Definition null.h:170
~null_memory_resource() override=default
Destruct the memory manager object instance.
Memory resource manager (abstract class).
Definition os-memory.h:165
void __throw_bad_alloc(void)
System namespace.
Single file µOS++ RTOS definitions.