13#if defined(OS_USE_OS_APP_CONFIG_H)
14#include <cmsis-plus/os-app-config.h>
30#pragma clang diagnostic ignored "-Wc++98-compat"
45 std::size_t file_descriptors_manager::size__;
47 io** file_descriptors_manager::descriptors_array__;
61 size__ =
size + reserved__;
62 descriptors_array__ =
new class io*[size__];
66 descriptors_array__[i] =
nullptr;
72 trace::printf (
"file_descriptors_manager::%s(%) @%p\n", __func__,
this);
74 delete[] descriptors_array__;
84 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__)
85 || (descriptors_array__ ==
nullptr))
89 return descriptors_array__[fildes];
95 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__))
105#if defined(OS_TRACE_POSIX_IO_FILE_DESCRIPTORS_MANAGER)
116 for (std::size_t i = reserved__; i < size__; ++i)
118 if (descriptors_array__[i] ==
nullptr)
120 descriptors_array__[i] =
io;
122#if defined(OS_TRACE_POSIX_IO_FILE_DESCRIPTORS_MANAGER)
126 return static_cast<int> (i);
138 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__))
151 descriptors_array__[fildes] =
io;
159#if defined(OS_TRACE_POSIX_IO_FILE_DESCRIPTORS_MANAGER)
160 trace::printf (
"file_descriptors_manager::%s(%d)\n", __func__, fildes);
163 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__))
169 descriptors_array__[fildes]->clear_file_descriptor ();
170 descriptors_array__[fildes] =
nullptr;
177 assert((fildes >= 0) && (
static_cast<std::size_t
> (fildes) < size__));
178 auto*
const io = descriptors_array__[fildes];
183 return reinterpret_cast<class
socket*
> (
io);
189 std::size_t count = reserved__;
193 if (descriptors_array__[i] !=
nullptr)
static class socket * socket(int fildes)
~file_descriptors_manager()
static bool valid(int fildes)
static int deallocate(file_descriptor_t fildes)
file_descriptors_manager(std::size_t size)
static int assign(file_descriptor_t fildes, class io *io)
static int allocate(class io *io)
static class io * io(int fildes)
file_descriptor_t file_descriptor(void) const
type_t get_type(void) const
int printf(const char *format,...)
Write a formatted string to the trace device.