ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
speed_opt.h File Reference

Build one file at a named optimization level instead of the framework's. More...

Go to the source code of this file.

Macros

#define PROTOCORE_TU_PRAGMA(directive)
 
#define PROTOCORE_OPTIMIZE_O2   PROTOCORE_TU_PRAGMA(GCC optimize("O2"))
 Build this file at optimization level 2, overriding the framework's size-optimized level.
 

Detailed Description

Build one file at a named optimization level instead of the framework's.

The framework's size-optimized level is appended after any build-system flags, so a consumer cannot raise it from outside. That level declines to inline small functions, and an appender chain that does not inline cannot fold: a literal's length stays a runtime scan and a bounded copy stays a call. Put PROTOCORE_OPTIMIZE_O2 at the top of such a .cpp, after its includes.

The level is in the name rather than behind a knob, so a file states what it is built at and a reader does not have to resolve a second macro to find out. A macro rather than the pragma itself because core carries no toolchain language.

O2 is the only level defined here (see docs/FEATURE_PERFORMANCE.md 2b). A file that needs another level adds the macro for it here rather than redefining this one.

Apply only where there are no secrets or the code is constant-time by structure. An optimizer can turn a branchless mask-select into a data-dependent branch; the OPT each crypto module states in its CMakeLists is the crypto policy layer with per-die levels and those caveats.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file speed_opt.h.

Macro Definition Documentation

◆ PROTOCORE_TU_PRAGMA

#define PROTOCORE_TU_PRAGMA (   directive)

Definition at line 38 of file speed_opt.h.

◆ PROTOCORE_OPTIMIZE_O2

#define PROTOCORE_OPTIMIZE_O2   PROTOCORE_TU_PRAGMA(GCC optimize("O2"))

Build this file at optimization level 2, overriding the framework's size-optimized level.

Definition at line 42 of file speed_opt.h.