µ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++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2016-2025 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 */
11
12#ifndef CMSIS_PLUS_MEMORY_NULL_H_
13#define CMSIS_PLUS_MEMORY_NULL_H_
14
15// ----------------------------------------------------------------------------
16
17#if defined(__cplusplus)
18
19// ----------------------------------------------------------------------------
20
21#include <cmsis-plus/rtos/os.h>
22
23// ----------------------------------------------------------------------------
24
25#pragma GCC diagnostic push
26#if defined(__clang__)
27#pragma clang diagnostic ignored "-Wc++98-compat"
28#endif
29
30// ----------------------------------------------------------------------------
31
32namespace os
33{
34 namespace memory
35 {
36
37#pragma GCC diagnostic push
38#if defined(__clang__)
39#pragma clang diagnostic ignored "-Wweak-vtables"
40#endif
41
42 // ========================================================================
43
56 {
57 public:
68
73 // The rule of five.
77 operator= (const null_memory_resource&)
78 = delete;
80 operator= (null_memory_resource&&)
81 = delete;
82
90 ~null_memory_resource () override = default;
91
96 protected:
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,
121 std::size_t alignment) 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*
153 std::size_t alignment)
154 {
156 }
157
158 inline void
159 null_memory_resource::do_deallocate (void* addr, std::size_t bytes,
160 std::size_t alignment) noexcept
161 {
162 }
163
164#pragma GCC diagnostic pop
165
166 // ========================================================================
167 } /* namespace memory */
168} /* namespace os */
169
170#pragma GCC diagnostic pop
171
172// ----------------------------------------------------------------------------
173
174#endif /* __cplusplus */
175
176// ----------------------------------------------------------------------------
177
178#endif /* CMSIS_PLUS_MEMORY_NULL_H_ */
An internal memory manager that throws a bad_alloc() exception when trying to allocate.
Definition null.h:56
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:159
~null_memory_resource() override=default
Destruct the memory manager object instance.
Memory resource manager (abstract class).
Definition os-memory.h:159
void __throw_bad_alloc(void)
System namespace.
Single file µOS++ RTOS definitions.