µ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-2023 Liviu Ionescu. All rights reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software
7 * for any purpose is hereby granted, under the terms of the MIT license.
8 *
9 * If a copy of the license was not distributed with this file, it can
10 * be obtained from https://opensource.org/licenses/mit/.
11 */
12
13#ifndef CMSIS_PLUS_MEMORY_NULL_H_
14#define CMSIS_PLUS_MEMORY_NULL_H_
15
16// ----------------------------------------------------------------------------
17
18#if defined(__cplusplus)
19
20// ----------------------------------------------------------------------------
21
22#include <cmsis-plus/rtos/os.h>
23
24// ----------------------------------------------------------------------------
25
26#pragma GCC diagnostic push
27#if defined(__clang__)
28#pragma clang diagnostic ignored "-Wc++98-compat"
29#endif
30
31// ----------------------------------------------------------------------------
32
33namespace os
34{
35 namespace memory
36 {
37
38#pragma GCC diagnostic push
39#if defined(__clang__)
40#pragma clang diagnostic ignored "-Wweak-vtables"
41#endif
42
43 // ========================================================================
44
57 {
58 public:
59
69
74 // The rule of five.
78 operator= (const null_memory_resource&) = delete;
80 operator= (null_memory_resource&&) = delete;
81
89 ~null_memory_resource () override = default;
90
95 protected:
96
108 virtual void*
109 do_allocate (std::size_t bytes, std::size_t alignment) override;
110
119 virtual void
120 do_deallocate (void* addr, std::size_t bytes, std::size_t alignment)
121 noexcept override;
122
126 };
127
128#pragma GCC diagnostic pop
129
130 // -------------------------------------------------------------------------
131 } /* namespace memory */
132} /* namespace os */
133
134// ===== Inline & template implementations ====================================
135
136namespace os
137{
138 namespace memory
139 {
140
141 // ========================================================================
142
143#pragma GCC diagnostic push
144#if defined(__clang__)
145#pragma clang diagnostic ignored "-Wunused-parameter"
146#elif defined(__GNUC__)
147// Needed because 'alignment' is used only in trace calls.
148#pragma GCC diagnostic ignored "-Wunused-parameter"
149#endif
150
151 inline void*
152 null_memory_resource::do_allocate (std::size_t bytes, std::size_t alignment)
153 {
155 }
156
157 inline void
158 null_memory_resource::do_deallocate (void* addr, std::size_t bytes,
159 std::size_t alignment) noexcept
160 {
161 }
162
163#pragma GCC diagnostic pop
164
165 // ==========================================================================
166 } /* namespace memory */
167} /* namespace os */
168
169#pragma GCC diagnostic pop
170
171// ----------------------------------------------------------------------------
172
173#endif /* __cplusplus */
174
175// ----------------------------------------------------------------------------
176
177#endif /* CMSIS_PLUS_MEMORY_NULL_H_ */
An internal memory manager that throws a bad_alloc() exception when trying to allocate.
Definition null.h:57
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:152
virtual void do_deallocate(void *addr, std::size_t bytes, std::size_t alignment) noexcept override
Implementation of the memory deallocator.
Definition null.h:158
~null_memory_resource() override=default
Destruct the memory manager object instance.
Memory resource manager (abstract class).
Definition os-memory.h:160
void __throw_bad_alloc(void)
System namespace.
Single file µOS++ RTOS definitions.