From 32a4dfff3e7f8dc8c980c07fa37fa39551a16c6b Mon Sep 17 00:00:00 2001 From: colorglass <55863235+colorglass@users.noreply.github.com> Date: Mon, 29 Jan 2024 05:55:36 +0000 Subject: [PATCH] templates: fix mismatched type size in simple Fix a mismatched type size error in component.simple.c:485, which may causes data overflow when CONFIG_WORD_SIZE is 64 in the 64-bit machine. Using defined CLZL() macro to correctly handle the specified CONFIG_WORD_SIZE. Signed-off-by: colorglass <55863235+colorglass@users.noreply.github.com> --- camkes/templates/component.simple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/camkes/templates/component.simple.c b/camkes/templates/component.simple.c index 574babf4..f5f9d078 100644 --- a/camkes/templates/component.simple.c +++ b/camkes/templates/component.simple.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -482,7 +483,7 @@ void camkes_make_simple(simple_t *simple) { /*# If there is no size specified in the configuration then we assume the cnode will be as small as possible to hold all the capabilities that are currently defined #*/ - simple_data.cnodesizebits = CONFIG_WORD_SIZE - __builtin_clz(/*? holding_slot ?*/) + 1; + simple_data.cnodesizebits = CONFIG_WORD_SIZE - CLZL(/*? holding_slot ?*/) + 1; /*- endif -*/ /*# Find untyped physical addresses. We only care if the untyped is at least a page size #*/ /*- for u in untyped_obj_list -*/