Overview / Common headers

Common headers

Types, status codes and macros that every module uses: the platform layer, the status codes of the C layer and the attributes.

Include #include <ethereal/assert_macros.h>C layer

assert_macros.h

#include <ethereal/assert_macros.h>

File: assert_macros.h Language: C, C++ (11, 14, 17, 20)

Public assert macros for the Ethereal framework.

'cpp/assert/assert.hpp' declares the dispatch model (call site, site state, listeners, policy) and states that it does not define the macros themselves. This is that file. It is language neutral: it is reached through 'cpp/assert/assert_inc.h' in a C++ translation unit and through 'c/assert/assert_inc.h' in a C one, and expands to the matching reporting primitive in each.

Public runtime macros:

  • ETL_ASSERT fatal check, full diagnostics in Debug
  • ETL_SDK_ASSERT fatal check marked as SDK originated
  • ETL_SILENT_ASSERT non fatal check, reports and continues
  • ETL_VERIFY non fatal check, expression always evaluated
  • ETL_ENSURE non fatal check that yields the condition

Public compile time macros:

  • ETL_STATIC_ASSERT_ARITHMETIC
  • ETL_STATIC_ASSERT_FLOAT

Defining ETL_DISABLE_ASSERTS compiles out the runtime checks for shipping builds. Compile time checks remain active because they carry no runtime cost. ETL_VERIFY still evaluates its expression when checks are disabled, because callers rely on its side effects.

Copyright (C) Typename Studios LLC. All Rights Reserved.

macro

ETL_FILE_NAME

#
#define ETL_FILE_NAME \

Resolves to the file name only, with the leading path removed.

@def ETL_FILE_NAME

Scans __FILE__ for the last path separator and returns the segment after it. Both forward slash and backslash are handled, so the result is correct on Windows and on Unix like systems.

When no separator is present the full __FILE__ value is used.

macro

ETL_BASE_ASSERT

#
#define ETL_BASE_ASSERT( _Expression, _File, _Line, _Func, _Msg, _Flags ) \

Internal base macro used to implement all assert variants.

@macro ETL_BASE_ASSERT Evaluates the expression and, on failure, describes the call site and forwards it to the dispatcher. When the dispatcher resolves the failure with a debugger trap, the break is issued here so the debugger lands on the failing line instead of inside the assertion machinery.

The site descriptor is built on the failing branch rather than being a constant initialized static. assert.hpp describes the ideal as read only storage, and that holds for the expression, file and function strings, but the substitute identifier accepted by @ETL_ASSERT may be an obfuscated string produced by @ETL_XORSTR, which decrypts at run time and is therefore not a constant expression. Building the descriptor inside the failure branch costs nothing on the success path and keeps both spellings working.

Nothing here has static storage, so the macro remains usable inside a constexpr function.

_Expression
Expression to evaluate.
_File
File identifier (full or symbolic).
_Line
Source line number.
_Func
Function name, or null.
_Msg
Optional message string, or null.
_Flags
Combination of EAssertFlag values.
Internal use only. Use the public assert macros instead.
macro

ETL_SDK_ASSERT

#
#define ETL_SDK_ASSERT( _Expression ) \

Performs a full assert originating from the Ethereal SDK. If the expression fails: - Generates a detailed log entry marked as SDK-originated. - Forces application termination/crash.

@macro ETL_SDK_ASSERT Always captures full diagnostic information, including file name, line number, and function name. The SDK flag is set, allowing the assertion system to route SDK defects to a different sink than integrator defects.

_Expression
Logical expression that must evaluate to true.
Intended for internal SDK validation and invariants. Should not be used for user-level assertions.
macro

ETL_VERIFY

#
#define ETL_VERIFY( _Expression ) \

Evaluates an expression and reports failure without terminating execution.

@macro ETL_VERIFY Unlike @ETL_ASSERT, the expression is evaluated in every build configuration, including when assertions are compiled out, because callers rely on its side effects. Failure is reported and execution continues.

_Expression
Logical expression to evaluate.
macro

ETL_VERIFY

#
#define ETL_VERIFY( _Expression ) ( (void)( _Expression ) )
The expression is still evaluated: @ETL_VERIFY exists precisely for checks whose side effects the caller depends on.

align.h

#include <ethereal/resource/align.h>
const

ETL_DEFAULT_ALIGNMENT

Ethereal#
constexpr std::size_t ETL_DEFAULT_ALIGNMENT = 32;
const

alignof

Ethereal#
constexpr std::size_t ETL_DEFAULT_ALIGNMENT = alignof( std::max_align_t );
const

ETL_Alignment

Ethereal#
constexpr std::size_t ETL_Alignment = ETL_DEFAULT_ALIGNMENT;

Global definition of class/struct or object alignment.

union

ETL_MaxAlign_t

#
C++
typedef union ETL_MaxAlign_t
{
    long long           etl_ll;
    long double         etl_ld;
    void *              etl_ptr;
    void ( *etl_fnptr )( void );
} ETL_MaxAlign_t;
macro

ETL_ALIGNMENT

#
#define ETL_ALIGNMENT ETL_DEFAULT_ALIGNMENT

Global definition of class/struct or object alignment.

function

_Static_assert

#
_Static_assert((ETL_ALIGNMENT & (ETL_ALIGNMENT - 1)) == 0, "ETL_ALIGNMENT must be a power of two");
macro

ETL_CLASS_ALIGN

#
#define ETL_ALIGN

Compatibility aliases of @ETL_ALIGN for class and struct declarations.

@macro ETL_CLASS_ALIGN @macro ETL_STRUCT_ALIGN Before the resource layer was unified, class and struct alignment came from two separate headers ('structures/class-inc.hpp' and 'structures/struct-inc.hpp'), each carrying its own constant. Both collapsed into the single @ETL_Alignment defined above, but the declaration sites across the framework still spell the old names.

They are kept as exact aliases so existing declarations keep compiling, and so the intent at the declaration site (this is a class / this is a struct) stays readable.

New code should prefer @ETL_ALIGN directly.

api.h

#include <ethereal/resource/api.h>

attributes.h

#include <ethereal/resource/attributes.h>
macro

ETL_INLINE

#
#define inline

Defines the default inline specifier.

@macro ETL_INLINE Expands to the standard @inline keyword, used to suggest function inlining to the compiler.

macro

ETL_S_INLINE

#
#define ETL_S_INLINE static inline

Defines the default inline specifier.

@macro ETL_S_INLINE Expands to the standard @inline keyword, used to suggest function inlining to the compiler.

macro

ETL_UNUSED

#
#define ETL_UNUSED( x ) (void)(x)

Marks a variable as intentionally unused.

@macro ETL_UNUSED Suppresses compiler warnings for unused variables by explicitly casting them to @void. Commonly used in function parameters, debug code paths, or platform-specific implementations.

It is the portable replacement of UNREFERENCED_PARAMETER, a Win32 macro that only exists with <windows.h> included.

x
Variable to mark as unused.
macro

ETL_ARRAY_COUNT

#
#define ETL_ARRAY_COUNT( arr ) (sizeof(arr) / sizeof((arr)[0]))

Returns the number of elements in a static array.

@macro ETL_ARRAY_COUNT Computes the element count of a compile-time array by dividing its total size by the size of a single element. This macro only works with static arrays and must not be used with pointers.

arr
Static array.
Number of elements in the array.
Using this macro with pointers will produce incorrect results.
macro

ETL_DEPRECATED_SOON

#
#define ETL_DEPRECATED_SOON( msg ) [[deprecated( msg )

Marks a function, type, or variable as scheduled for future deprecation.

@macro ETL_DEPRECATED_SOON Indicates that the symbol is not yet deprecated, but will be in a future version of the SDK. Does not trigger compiler warnings, but documents intent for migration and API evolution.

msg
Message describing future deprecation.
function

_mm_pause

#
extern "C" void _mm_pause( void );
function

_mm_pause

#
void _mm_pause( void );
function

__yield

#
extern "C" void __yield( void );
function

__yield

#
void __yield( void );

cpu_features.h

#include <ethereal/resource/cpu_features.h>

Vector capability of the processor.

This is core, not a module. Section 2 of the conventions forbids a module from including another module's header to get functionality, but explicitly allows the shared target of core headers (types, macros, attributes). Capability detection falls there: Encoding and Compression need the same answer, and duplicating it would create two sources of truth about the same processor.

enum

ESimdLevel

Ethereal::Cpu#
C++
enum class   ESimdLevel : ETL_UINT8
{
    /// @brief    None. Only the scalar path, which is the reference for all the others.
    Scalar = 0,

    /// @brief    SSE2. Baseline of any 64 bit x86.
    Sse2 = 1,

    /// @brief    SSSE3. Brings the byte shuffle, which is what makes the vector path pay off.
    Ssse3 = 2,

    /// @brief    SSE4.1.
    Sse41 = 3,

    /// @brief    SSE4.2.
    ///
    /// @details    Has its own value: the x86 @c CRC32 instruction requires 4.2, and
    ///                 there are processors with 4.1 and without 4.2 (the Penryn
    ///                 family). Treating both as one would produce illegal instructions
    ///                 on those machines.
    Sse42 = 4,

    /// @brief    AVX2. 32 byte vector.
    Avx2 = 5,

    /// @brief    NEON, on ARM. It sits above AVX2 in the order only to fit in the same
    ///             number. The two families never coexist on the same machine.
    Neon = 6,

    /// @brief    AVX-512 (F), 64 byte vector, with the system saving the ZMM registers.
    ///
    /// @details    Never returned by @ref DetectedSimdLevel or @ref ActiveSimdLevel:
    ///                 the ladder stops at AVX2. The existing modules ask "is it AVX2?"
    ///                 (the C layer of Encoding publishes the value), and on a machine
    ///                 with AVX-512 they would no longer find their path. The value
    ///                 exists for batch Math to declare the path it ran
    ///                 ('Math::BatchPath') and for the test suite to request it. The
    ///                 one that offers it is 'Platform::CpuFacts' (bit 'ETL_CPU_AVX512F').
    Avx512 = 7
};

The largest vector instruction set available.

The values grow on purpose: a path written for one level runs on any higher level, so the choice is a simple comparison and not a compatibility table.

function

SimdLevelName

Ethereal::Cpu#
const ETL_CHAR * SimdLevelName( ESimdLevel eLevel ) noexcept;

Name of the level, for logging and for the test suite to report what it measured.

eLevel
The level.
Static string, null terminated.
Thread safety: full.
function

DetectedSimdLevel

Ethereal::Cpu#
ESimdLevel DetectedSimdLevel() noexcept;

What this machine really offers.

Asked of the processor once, on the first call, and stored. There is no lock: the value is a small integer, and two threads that arrive together compute the same result and write the same value.

On x86 it reads CPUID, and for AVX2 it also checks XGETBV: having the instruction is not enough, the operating system must have enabled saving the wide registers on context switch. Without that second check the program breaks on old machines, with an illegal instruction.

The largest supported level.
Does not allocate. Thread safety: full.
function

ActiveSimdLevel

Ethereal::Cpu#
ESimdLevel ActiveSimdLevel() noexcept;

The level the modules must use.

The smaller of DetectedSimdLevel and the ceiling set by SetSimdCeiling. In normal operation there is no ceiling and the two are equal.

The level to use.
Does not allocate. Thread safety: full.
function

AesClmulActive

Ethereal::Cpu#
bool AesClmulActive() noexcept;

Whether the AES-NI and PCLMULQDQ path of AES-GCM may run (2026-10-11).

true when the processor has AES-NI, PCLMULQDQ and SSSE3 (CPUID leaf 1, ECX bits 25, 1 and 9) and ActiveSimdLevel is at least ESimdLevel::Ssse3. The second condition lets the suite force the constant time scalar AES with SetSimdCeiling. Always false outside x86.

true when the hardware AES path is available and allowed.
Does not allocate. Thread safety: full.
function

SetSimdCeiling

Ethereal::Cpu#
void SetSimdCeiling( ESimdLevel eCeiling ) noexcept;

Limits the level that ActiveSimdLevel returns.

This function exists so that the slow paths get measured.

Without it, on a machine with AVX2 the SSSE3 code and the scalar code would never run: they would be compiled, shipped to the client and never executed by anyone. This project hit exactly that twice (the 'poll' path of the event loop and 'MulShiftPortable' of the Time module), and both times the fix was the same: a way to turn the path on by hand.

The test suite uses it to check each level against the scalar one. Production code must not call it.

eCeiling
The ceiling. ESimdLevel::Neon in practice removes the ceiling.
Thread safety: none. Callers serialize, and only the test suite calls it.
function

ClearSimdCeiling

Ethereal::Cpu#
void ClearSimdCeiling() noexcept;

Resets the ceiling to the value that limits nothing.

Thread safety: none.

etl.h

#include <ethereal/resource/etl.h>
macro

ETL_RESOURCE_INC

#
#define ETL_RESOURCE_INC

Indicates that Ethereal resource headers are being included through the unified entry point.

@macro ETL_RESOURCE_INC This macro is defined internally when Ethereal headers are included via the main aggregated header (etl.h). When present, internal headers skip redundant includes and avoid re-declaring dependencies, ensuring a controlled and consistent inclusion order.

This mechanism prevents improper direct inclusion, redundant parsing, and potential circular dependency chains across Ethereal modules.

This macro is for internal build coordination only and must not be defined manually by user code. It is defined before the first resource include below, because every resource header refuses to compile without it.
macro

ETL_C_DEF

#
#define ETL_S_INLINE

Defines the function qualifier for the C functions defined inside a header. Always expands to ETL_S_INLINE (inlined, zero overhead), in the static and in the shared build.

It used to expand to ETL_C_API in the shared build (ETHEREAL_DLL_BUILD). A function with a body in a header and external linkage is defined again by every translation unit that includes it, so the four sources of 'src/c/math/geometry/' left the link with a duplicate of each 'ETL_SqrtF32', 'Vec3_Make' and the like, and no shared build ever linked. What a header exports is declared with ETL_C_API and defined once in a '.c' (see 'c/math/geometry/vector2.h' and 'src/c/math/geometry/vector2.c').

lang.h

#include <ethereal/resource/lang.h>

sanity.h

#include <ethereal/resource/sanity.h>
function

ETL_STATIC_CHECK

#
ETL_STATIC_CHECK( sizeof(ETL_UINT32) == 4, "ETL_UINT32 must be 32-bit" );

Compile-time validation that ETL_UINT32 occupies exactly 4 bytes.

function

ETL_STATIC_CHECK

#
ETL_STATIC_CHECK( sizeof(ETL_UINT64) == 8, "ETL_UINT64 must be 64-bit" );

Compile-time validation that ETL_UINT64 occupies exactly 8 bytes.

types.h

#include <ethereal/resource/types.h>
alias

ETL_INT8

#
typedef signed char ETL_INT8;

8-bit signed integer.

alias

ETL_INT16

#
typedef signed short ETL_INT16;

16-bit signed integer.

alias

ETL_INT32

#
typedef signed int ETL_INT32;

32-bit signed integer.

alias

ETL_INT64

#
typedef signed long long ETL_INT64;

64-bit signed integer.

alias

ETL_UINT8

#
typedef unsigned char ETL_UINT8;

8-bit unsigned integer.

alias

ETL_UINT16

#
typedef unsigned short ETL_UINT16;

16-bit unsigned integer.

alias

ETL_UINT32

#
typedef unsigned int ETL_UINT32;

32-bit unsigned integer.

alias

ETL_DWORD

#
typedef unsigned long ETL_DWORD;
alias

ETL_DWORD

#
typedef ETL_UINT32 ETL_DWORD;
alias

ETL_UINT64

#
typedef unsigned long long ETL_UINT64;

64-bit unsigned integer.

alias

ETL_CHAR

#
typedef char ETL_CHAR;

8-bit character type. Typically used for ASCII or UTF-8 encoded text.

The signedness of @char is implementation-defined. Prefer explicit types when strict behavior is required.
alias

ETL_UCHAR

#
typedef unsigned char ETL_UCHAR;

8-bit unsigned character type.

Unlike @ETL_CHAR, this type is explicitly unsigned.
alias

ETL_WCHAR

#
typedef wchar_t ETL_WCHAR;

Wide character type.

Represents a wide character, typically used for UTF-16 or UTF-32 depending on the platform: - Windows: UTF-16 (16 bits) - Linux/macOS: UTF-32 (32 bits)
Size and encoding are platform-dependent. Use with caution in cross-platform code.
alias

ETL_BOOL

#
typedef bool ETL_BOOL;
alias

ETL_BOOL

#
typedef _Bool ETL_BOOL;
alias

ETL_FLOAT

#
typedef float ETL_FLOAT;

32-bit floating-point value.

alias

ETL_DOUBLE

#
typedef double ETL_DOUBLE;

64-bit floating-point value. Provides higher precision and range than @ETL_FLOAT.

alias

ETL_PTR

#
typedef void * ETL_PTR;

Generic pointer type.

alias

ETL_CPTR

#
typedef const void * ETL_CPTR;

Generic constant pointer type.

alias

ETL_HANDLE

#
typedef void * ETL_HANDLE;
alias

ETL_HMODULE

#
typedef void * ETL_HMODULE;
alias

ETL_HANDLE

#
typedef int ETL_HANDLE;
alias

ETL_HMODULE

#
typedef void * ETL_HMODULE;
macro

ETL_INVALID_HANDLE

#
#define ETL_INVALID_HANDLE ((ETL_HANDLE)-1)

Defines the default invalid value for a system handle.

@macro ETL_INVALID_HANDLE Represents an invalid or uninitialized handle value. On most platforms, this maps to -1, which is commonly used to indicate failure (e.g., invalid file descriptor).

Always validate handles against this value before use.
alias

ETL_FILE

#
typedef struct ETL_FILE_TAG * ETL_FILE;

Opaque file handle type.

Represents a pointer to an internal file structure (ETL_FILE_TAG) whose definition is hidden from the user. This abstraction enforces encapsulation, preventing direct access to the underlying file implementation and allowing the library to change internal details without breaking the public API.

Typically used as a handle for file operations within the Ethereal framework.

The actual structure is defined internally and must not be accessed or manipulated directly by user code.
const

TArithmetic

#
template< typename T > concept TArithmetic = std::is_arithmetic_v< T >;

Constrains a type to arithmetic types.

@concept TArithmetic Matches any type that satisfies @std::is_arithmetic_v<T>, including both integral and floating-point types.

T
Type to evaluate.
const

TIntegral

#
template< typename T > concept TIntegral = std::is_integral_v< T >;

Constrains a type to integral types.

@concept TIntegral Matches any type that satisfies @std::is_integral_v<T>, including signed and unsigned integers.

T
Type to evaluate.
const

TFloat

#
template< typename T > concept TFloat = std::is_floating_point_v< T >;

Constrains a type to floating-point types.

@concept TFloat Matches any type that satisfies @std::is_floating_point_v<T>, such as float, double, and long double.

T
Type to evaluate.

ecs_concurrency.hpp

#include <ethereal/glue/ecs_concurrency.hpp>

ECS executor on top of the Concurrency job manager.

Why this is a separate target: section 2 of the conventions says a module never includes the header of another one to get its functionality, and that what links two modules lives in a glue target of its own, 'ethereal-<a>-<b>-glue'. The ECS spec says the same: "Depends on: nothing at link time. Optional glue with Concurrency for the parallel scheduler."

The Ecs module does not know that Concurrency exists. It declares 'IExecutor' and nothing else. Whoever wants both links this target. Whoever only wants the ECS does not, and does not get a thread pool along with it.

What this is worth in this tree: today all the modules live in a single library, so linking this target adds no bytes that were not there already. What the split keeps is the direction of the dependency (the ECS still builds and passes its tests without Concurrency), and the day the library is split, this is already in the right place.

What the job manager lacks, and this had to build: 'IExecutor::RunAll' promises to run N tasks and return only when all of them are done. 'CJobManager::CreateJob' is fire and forget: it returns no handle, does not signal completion and has no wait. The barrier is built here, in the '.cpp', and its design is explained there.

One job per group of systems would be a design error, and this was measured. The first version submitted one job per system on every round. Measured on this machine (i7-6700, Windows 10, Release, four workers):

  • each 'CreateJob' costs about 28 us to the caller, and there are N per group.
  • the last job submitted only starts 2.7 to 5.4 ms later.

A group of ECS systems runs in tens of microseconds. Submitting cost more than the whole work, and the latency was a hundred times the work: the caller always finished everything alone before a worker even woke up. The suite measured it plainly, 0 of 8000 tasks were taken by workers.

That is not a defect of the manager. Its header says what it is for, "routines intended for continuous execution", with a deadline in seconds. It was made for long lived routines, not for a fork and join per frame.

So the submission is paid only once, in the constructor. The executor keeps a crew of continuous routines living on the workers of the manager, and each 'RunAll' is a notify on a 'condition_variable' instead of N submissions.

class

CJobExecutor

Ethereal::Glue#

Runs the ECS system groups on the workers of the Concurrency module.

class CJobExecutor final : public Ecs::IExecutor

Initialize the CJobManager before using this, and stop it only after the executor is destroyed. This adapter neither initializes nor stops it: the manager is a process singleton, owned by whoever started it.

The constructor is where the crew is put to live, and the destructor is where it is sent away. One executor per world, created once. Creating and destroying one per frame would pay exactly the cost this design exists to avoid.

constructor

CJobExecutor

#
explicit CJobExecutor( std::size_t uWorkers = 0u ) noexcept;

Puts the crew to live on the workers of the manager.

Asking for more crew members than the manager has workers is not an error. The manager refuses the extra ones, and the barrier design copes with that without deadlocking (see the .cpp).

uWorkers
How many crew members to ask for. Zero asks the system.
function

RunAll

#
void RunAll( void ( * pFn )( void * pCtx, std::size_t i ), void * pCtx, std::size_t uCount ) noexcept override;

Runs the N tasks and returns when all of them are done.

pFn
Task function, called with the context and the task index.
pCtx
Context passed to every task.
uCount
Number of tasks.
function

Width

#
std::size_t Width() const noexcept override;

How many tasks run at the same time: the number asked for in the constructor, or the one of the system.

function

CrewSize

#
std::size_t CrewSize() const noexcept;

How many crew members the manager actually accepted.

Fewer than asked for means the manager refused jobs because it had no free workers. It is not an error, it is slowness: whatever is missing is run by the caller.

function

TasksRunByCaller

#
ETL_UINT64 TasksRunByCaller() const noexcept;

How many tasks the calling thread had to run itself.

A high number is a warning, not an error: either the crew is small, or the systems are too short to be worth waking someone up. Taking part is intended, and it is what keeps the wait from deadlocking when the manager gives no worker at all.

function

TasksRunByCrew

#
ETL_UINT64 TasksRunByCrew() const noexcept;

How many tasks the crew claimed.

function

Rounds

#
ETL_UINT64 Rounds() const noexcept;

Number of calls to RunAll.