diff --git a/repos/base/include/base/error.h b/repos/base/include/base/error.h new file mode 100644 index 0000000000..4c42cc3ee4 --- /dev/null +++ b/repos/base/include/base/error.h @@ -0,0 +1,36 @@ +/* + * \brief Error types + * \author Norman Feske + * \date 2025-03-05 + */ + +/* + * Copyright (C) 2025 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _INCLUDE__BASE__ERROR_H_ +#define _INCLUDE__BASE__ERROR_H_ + +namespace Genode { + + /** + * Common error returned by constrained allocators + * + * OUT_OF_RAM and OUT_OF_CAPS can in principle be resolved by upgrading + * the resource budget of the allocator. + * + * DENIED expresses a situation where the allocator cannot satisfy the + * allocation for unresolvable reasons. For example, the allocator may + * have a hard limit of the number of allocations, or the allocation of + * a large contiguous range is prevented by internal fragmentation, or + * a requested alignment constraint cannot be met. In these cases, the + * allocator reflects the condition to the caller to stay healthy and let + * the caller fail gracefully or consciously panic at the caller side. + */ + enum class Alloc_error { OUT_OF_RAM, OUT_OF_CAPS, DENIED }; +} + +#endif /* _INCLUDE__BASE__ERROR_H_ */ diff --git a/repos/base/include/base/ram.h b/repos/base/include/base/ram.h index 8904e78445..9d6c0f3eb9 100644 --- a/repos/base/include/base/ram.h +++ b/repos/base/include/base/ram.h @@ -15,6 +15,7 @@ #define _INCLUDE__BASE__RAM_H_ #include +#include #include #include #include @@ -25,8 +26,7 @@ namespace Genode::Ram { struct Dataspace : Genode::Dataspace { }; using Capability = Genode::Capability; - - enum class Error { OUT_OF_RAM, OUT_OF_CAPS, DENIED }; + using Error = Alloc_error; struct Unmapped_allocator;