Skip to content
Commit ab762134 authored by Gerard Marull-Paretas's avatar Gerard Marull-Paretas Committed by Carles Cufí
Browse files

init: add INIT_LEVEL_ORD



This patch introduces a new helper: INIT_LEVEL_ORD, which given a level
token, e.g. EARLY, PRE_KERNEL_1, etc. returns its ordinal. This can be
useful for sorting purposes, as level tokens do not result in the right
initialization order if sorted, e.g. POST_KERNEL < APPLICATION, but P >
A.

The implementation uses a bit of macrobatics to achieve this. First, we
define some helpers Z_INIT_XX_XX that evaluate to 1, and where XX
correspond to init levels. With them, we can perform equality checks
like this:

COND_CODE_1(Z_INIT_XX_##level, (VAL_IF_EXISTS), (VAL_IF_NOT_EXISTS))

It's a bit obscure, but it seems to work.

Signed-off-by: default avatarGerard Marull-Paretas <gerard.marull@nordicsemi.no>
parent a7e8b3af
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment