Skip to content

Commit

Permalink
Group memory doxygen into one module
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue committed Aug 22, 2024
1 parent 6557843 commit 76fd363
Show file tree
Hide file tree
Showing 31 changed files with 1,541 additions and 145 deletions.
1,391 changes: 1,391 additions & 0 deletions upstream_utils/memory_patches/0001-Group-doxygen-into-memory-module.patch

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace wpi
{
/// A \concept{concept_rawallocator,RawAllocator} adapter that ensures a minimum alignment.
/// It adjusts the alignment value so that it is always larger than the minimum and forwards to the specified allocator.
/// \ingroup adapter
/// \ingroup memory_adapter
template <class RawAllocator>
class aligned_allocator : WPI_EBO(allocator_traits<RawAllocator>::allocator_type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace wpi
/// A \concept{concept_rawallocator,RawAllocator} that stores another allocator.
/// The \concept{concept_storagepolicy,StoragePolicy} defines the allocator type being stored and how it is stored.
/// The \c Mutex controls synchronization of the access.
/// \ingroup storage
/// \ingroup memory_storage
template <class StoragePolicy, class Mutex>
class allocator_storage
: WPI_EBO(StoragePolicy,
Expand Down Expand Up @@ -317,14 +317,14 @@ namespace wpi

/// Tag type that enables type-erasure in \ref reference_storage.
/// It can be used everywhere a \ref allocator_reference is used internally.
/// \ingroup storage
/// \ingroup memory_storage
struct any_allocator
{
};

/// A \concept{concept_storagepolicy,StoragePolicy} that stores the allocator directly.
/// It embeds the allocator inside it, i.e. moving the storage policy will move the allocator.
/// \ingroup storage
/// \ingroup memory_storage
template <class RawAllocator>
class direct_storage : WPI_EBO(allocator_traits<RawAllocator>::allocator_type)
{
Expand Down Expand Up @@ -381,7 +381,7 @@ namespace wpi
/// An alias template for \ref allocator_storage using the \ref direct_storage policy without a mutex.
/// It has the effect of giving any \concept{concept_rawallocator,RawAllocator} the interface with all member functions,
/// avoiding the need to wrap it inside the \ref allocator_traits.
/// \ingroup storage
/// \ingroup memory_storage
template <class RawAllocator>
WPI_ALIAS_TEMPLATE(allocator_adapter,
allocator_storage<direct_storage<RawAllocator>, no_mutex>);
Expand All @@ -399,7 +399,7 @@ namespace wpi
/// It has a similar effect as \ref allocator_adapter but performs synchronization.
/// The \c Mutex will default to \c std::mutex if threading is supported,
/// otherwise there is no default.
/// \ingroup storage
/// \ingroup memory_storage
#if WPI_HOSTED_IMPLEMENTATION
template <class RawAllocator, class Mutex = std::mutex>
WPI_ALIAS_TEMPLATE(thread_safe_allocator,
Expand Down Expand Up @@ -528,7 +528,7 @@ namespace wpi
/// Specialize it for your own types, if they provide sharing semantics and can be copied.
/// They also must provide an `operator==` to check whether two allocators refer to the same shared one.
/// \note This makes no guarantees about the lifetime of the shared object, the sharing allocators can either own or refer to a shared object.
/// \ingroup storage
/// \ingroup memory_storage
template <class RawAllocator>
struct is_shared_allocator : std::false_type
{
Expand All @@ -540,7 +540,7 @@ namespace wpi
/// For allocators that are already shared (determined through \ref is_shared_allocator) it will store the allocator type directly.
/// \note It does not take ownership over the allocator in the stateful case, the user has to ensure that the allocator object stays valid.
/// In the other cases the lifetime does not matter.
/// \ingroup storage
/// \ingroup memory_storage
template <class RawAllocator>
class reference_storage
#ifndef DOXYGEN
Expand Down Expand Up @@ -611,7 +611,7 @@ namespace wpi
/// Specialization of the class template \ref reference_storage that is type-erased.
/// It is triggered by the tag type \ref any_allocator.
/// The specialization can store a reference to any allocator type.
/// \ingroup storage
/// \ingroup memory_storage
template <>
class reference_storage<any_allocator>
{
Expand Down Expand Up @@ -894,7 +894,7 @@ namespace wpi
/// An alias template for \ref allocator_storage using the \ref reference_storage policy.
/// It will store a reference to the given allocator type. The tag type \ref any_allocator enables type-erasure.
/// Wrap the allocator in a \ref thread_safe_allocator if you want thread safety.
/// \ingroup storage
/// \ingroup memory_storage
template <class RawAllocator>
WPI_ALIAS_TEMPLATE(allocator_reference,
allocator_storage<reference_storage<RawAllocator>, no_mutex>);
Expand All @@ -909,14 +909,14 @@ namespace wpi
}

/// An alias for the \ref reference_storage specialization using type-erasure.
/// \ingroup storage
/// \ingroup memory_storage
using any_reference_storage = reference_storage<any_allocator>;

/// An alias for \ref allocator_storage using the \ref any_reference_storage.
/// It will store a reference to any \concept{concept_rawallocator,RawAllocator}.
/// This is the same as passing the tag type \ref any_allocator to the alias \ref allocator_reference.
/// Wrap the allocator in a \ref thread_safe_allocator if you want thread safety.
/// \ingroup storage
/// \ingroup memory_storage
using any_allocator_reference = allocator_storage<any_reference_storage, no_mutex>;

/// \returns A new \ref any_allocator_reference object by forwarding the allocator to the constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ namespace wpi
/// It checks the existence of a custom \c construct(), \c destroy() function, if provided,
/// it cannot be used since it would not be called.<br>
/// Specialize it for custom \c Allocator types to override this check.
/// \ingroup core
/// \ingroup memory_core
template <class Allocator>
struct allocator_is_raw_allocator
: WPI_EBO(detail::check_standard_allocator<Allocator>::valid)
{
};

/// Specialization of \ref allocator_is_raw_allocator that allows \c std::allocator again.
/// \ingroup core
/// \ingroup memory_core
template <typename T>
struct allocator_is_raw_allocator<std::allocator<T>> : std::true_type
{
Expand Down Expand Up @@ -286,7 +286,7 @@ namespace wpi
/// The default specialization of the allocator_traits for a \concept{concept_rawallocator,RawAllocator}.
/// See the last link for the requirements on types that do not specialize this class and the interface documentation.
/// Any specialization must provide the same interface.
/// \ingroup core
/// \ingroup memory_core
template <class Allocator>
class allocator_traits
{
Expand Down Expand Up @@ -410,7 +410,7 @@ namespace wpi

/// Traits that check whether a type models concept \concept{concept_rawallocator,RawAllocator}.<br>
/// It must either provide the necessary functions for the default traits specialization or has specialized it.
/// \ingroup core
/// \ingroup memory_core
template <typename T>
struct is_raw_allocator
: detail::is_raw_allocator<T,
Expand Down Expand Up @@ -494,7 +494,7 @@ namespace wpi
/// The default specialization of the composable_allocator_traits for a \concept{concept_composableallocator,ComposableAllocator}.
/// See the last link for the requirements on types that do not specialize this class and the interface documentation.
/// Any specialization must provide the same interface.
/// \ingroup core
/// \ingroup memory_core
template <class Allocator>
class composable_allocator_traits
{
Expand Down Expand Up @@ -588,7 +588,7 @@ namespace wpi

/// Traits that check whether a type models concept \concept{concept_rawallocator,ComposableAllocator}.<br>
/// It must be a \concept{concept_rawallocator,RawAllocator} and either provide the necessary functions for the default traits specialization or has specialized it.
/// \ingroup core
/// \ingroup memory_core
template <typename T>
struct is_composable_allocator
: detail::is_composable_allocator<T, decltype(detail::composable_alloc_uses_default_traits(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,54 +83,54 @@
// dummy definitions of config macros for doxygen

/// The major version number.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_VERSION_MAJOR 1

/// The minor version number.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_VERSION_MINOR 1

/// The total version number of the form \c Mmm.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_VERSION \
(WPI_MEMORY_VERSION_MAJOR * 100 + WPI_MEMORY_VERSION_MINOR)

/// Whether or not the allocation size will be checked,
/// i.e. the \ref wpi::memory::bad_allocation_size thrown.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_CHECK_ALLOCATION_SIZE 1

/// Whether or not internal assertions in the library are enabled.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_DEBUG_ASSERT 1

/// Whether or not allocated memory will be filled with special values.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_DEBUG_FILL 1

/// The size of the fence memory, it has no effect if \ref WPI_MEMORY_DEBUG_FILL is \c false.
/// \note For most allocators, the actual value doesn't matter and they use appropriate defaults to ensure alignment etc.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_DEBUG_FENCE 1

/// Whether or not leak checking is enabled.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_DEBUG_LEAK_CHECK 1

/// Whether or not the deallocation functions will check for pointers that were never allocated by an allocator.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_DEBUG_POINTER_CHECK 1

/// Whether or not the deallocation functions will check for double free errors.
/// This option makes no sense if \ref WPI_MEMORY_DEBUG_POINTER_CHECK is \c false.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_DEBUG_DOUBLE_DEALLOC_CHECK 1

/// Whether or not everything is in namespace <tt>wpi::memory</tt>.
/// If \c false, a namespace alias <tt>namespace memory = wpi::memory</tt> is automatically inserted into each header,
/// allowing to qualify everything with <tt>wpi::</tt>.
/// \note This option breaks in combination with using <tt>using namespace wpi;</tt>.
/// \ingroup core
/// \ingroup memory_core
#define WPI_MEMORY_NAMESPACE_PREFIX 1

/// The mode of the automatic \ref wpi::memory::temporary_stack creation.
Expand All @@ -140,7 +140,7 @@
/// requires managing it through the \ref wpi::memory::temporary_stack_initializer.
/// Set to `0` to disable the per-thread stack completely.
/// \ref wpi::memory::get_temporary_stack() will abort the program upon call.
/// \ingroup allocator
/// \ingroup memory_allocator
#define WPI_MEMORY_TEMPORARY_STACK_MODE 2
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace wpi
{
namespace memory
{
/// \ingroup adapter
/// \ingroup memory_adapter
/// @{

/// Alias template for an STL container that uses a certain
Expand Down Expand Up @@ -213,7 +213,7 @@ namespace wpi
/// @{
/// Convenience function to create a container adapter using a certain
/// \concept{concept_rawallocator,RawAllocator}. \returns An empty adapter with an
/// implementation container using a reference to a given allocator. \ingroup adapter
/// implementation container using a reference to a given allocator. \ingroup memory_adapter
template <typename T, class RawAllocator, class Container = deque<T, RawAllocator>>
std::stack<T, Container> make_stack(RawAllocator& allocator)
{
Expand Down Expand Up @@ -271,7 +271,7 @@ namespace wpi
#endif

#else
/// \ingroup adapter
/// \ingroup memory_adapter
/// @{

/// Contains the node size of a node based STL container with a specific type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace wpi
/// The magic values that are used for debug filling.
/// If \ref WPI_MEMORY_DEBUG_FILL is \c true, memory will be filled to help detect use-after-free or missing initialization errors.
/// These are the constants for the different types.
/// \ingroup core
/// \ingroup memory_core
enum class debug_magic : unsigned char
{
/// Marks internal memory used by the allocator - "allocated block".
Expand Down Expand Up @@ -47,19 +47,19 @@ namespace wpi
/// It must not throw any exceptions since it is called in the cleanup process.
/// \defaultbe On a hosted implementation it logs the leak to \c stderr and returns, continuing execution.
/// On a freestanding implementation it does nothing.
/// \ingroup core
/// \ingroup memory_core
using leak_handler = void (*)(const allocator_info& info, std::ptrdiff_t amount);

/// Exchanges the \ref leak_handler.
/// \effects Sets \c h as the new \ref leak_handler in an atomic operation.
/// A \c nullptr sets the default \ref leak_handler.
/// \returns The previous \ref leak_handler. This is never \c nullptr.
/// \ingroup core
/// \ingroup memory_core
leak_handler set_leak_handler(leak_handler h);

/// Returns the \ref leak_handler.
/// \returns The current \ref leak_handler. This is never \c nullptr.
/// \ingroup core
/// \ingroup memory_core
leak_handler get_leak_handler();

/// The type of the handler called when an invalid pointer is passed to a deallocation function.
Expand All @@ -69,19 +69,19 @@ namespace wpi
/// It must not throw any exceptions since it might be called in the cleanup process.
/// \defaultbe On a hosted implementation it logs the information to \c stderr and calls \c std::abort().
/// On a freestanding implementation it only calls \c std::abort().
/// \ingroup core
/// \ingroup memory_core
using invalid_pointer_handler = void (*)(const allocator_info& info, const void* ptr);

/// Exchanges the \ref invalid_pointer_handler.
/// \effects Sets \c h as the new \ref invalid_pointer_handler in an atomic operation.
/// A \c nullptr sets the default \ref invalid_pointer_handler.
/// \returns The previous \ref invalid_pointer_handler. This is never \c nullptr.
/// \ingroup core
/// \ingroup memory_core
invalid_pointer_handler set_invalid_pointer_handler(invalid_pointer_handler h);

/// Returns the \ref invalid_pointer_handler.
/// \returns The current \ref invalid_pointer_handler. This is never \c nullptr.
/// \ingroup core
/// \ingroup memory_core
invalid_pointer_handler get_invalid_pointer_handler();

/// The type of the handler called when a buffer under/overflow is detected.
Expand All @@ -92,20 +92,20 @@ namespace wpi
/// It must not throw any exceptions since it me be called in the cleanup process.
/// \defaultbe On a hosted implementation it logs the information to \c stderr and calls \c std::abort().
/// On a freestanding implementation it only calls \c std::abort().
/// \ingroup core
/// \ingroup memory_core
using buffer_overflow_handler = void (*)(const void* memory, std::size_t size,
const void* write_ptr);

/// Exchanges the \ref buffer_overflow_handler.
/// \effects Sets \c h as the new \ref buffer_overflow_handler in an atomic operation.
/// A \c nullptr sets the default \ref buffer_overflow_handler.
/// \returns The previous \ref buffer_overflow_handler. This is never \c nullptr.
/// \ingroup core
/// \ingroup memory_core
buffer_overflow_handler set_buffer_overflow_handler(buffer_overflow_handler h);

/// Returns the \ref buffer_overflow_handler.
/// \returns The current \ref buffer_overflow_handler. This is never \c nullptr.
/// \ingroup core
/// \ingroup memory_core
buffer_overflow_handler get_buffer_overflow_handler();
} // namespace memory
} // namespace wpi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace wpi
/// \requiredbe Its type can be changed via the CMake option \c WPI_MEMORY_DEFAULT_ALLCOATOR,
/// but it must be one of the following: \ref heap_allocator, \ref new_allocator, \ref malloc_allocator, \ref static_allocator, \ref virtual_memory_allocator.
/// \defaultbe The default is \ref heap_allocator.
/// \ingroup allocator
/// \ingroup memory_allocator
using default_allocator = WPI_IMPL_DEFINED(WPI_MEMORY_IMPL_DEFAULT_ALLOCATOR);
} // namespace memory
} // namespace wpi
Expand Down
Loading

0 comments on commit 76fd363

Please sign in to comment.