From ec8db7e3173758e3adbecb2dcaebb53e14508f36 Mon Sep 17 00:00:00 2001 From: Rini Banerjee Date: Fri, 21 Jun 2024 17:41:23 +0100 Subject: [PATCH] CN-exec: Minor changes to CN assert implementation for Zain's PBT Testing frameworks being used by Zain are written in C++, so generated runtime checking code needs to be both C and C++ compliant, and not exit every time a CN assertion fails, since that cuts the PBT pipeline short too early. --- runtime/libcn/include/cn-executable/utils.h | 2 ++ runtime/libcn/src/utils.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/runtime/libcn/include/cn-executable/utils.h b/runtime/libcn/include/cn-executable/utils.h index 544e3c760..a1eb68d54 100644 --- a/runtime/libcn/include/cn-executable/utils.h +++ b/runtime/libcn/include/cn-executable/utils.h @@ -16,6 +16,8 @@ struct cn_error_message_info { char *cn_source_loc; }; +void (*cn_exit)(void); + /* Wrappers for C types */ /* Signed bitvectors */ diff --git a/runtime/libcn/src/utils.c b/runtime/libcn/src/utils.c index 91f872d46..5bb6f295f 100644 --- a/runtime/libcn/src/utils.c +++ b/runtime/libcn/src/utils.c @@ -11,6 +11,14 @@ typedef struct cn_bool { */ + +void cn_exit_aux(void) { + exit(SIGABRT); +} + +void (*cn_exit)(void) = &cn_exit_aux; + + cn_bool *convert_to_cn_bool(_Bool b) { cn_bool *res = alloc(sizeof(cn_bool)); if (!res) exit(1); @@ -30,7 +38,7 @@ void cn_assert(cn_bool *cn_b, struct cn_error_message_info *error_msg_info) { if (error_msg_info->cn_source_loc) { printf("CN source location: \n%s\n", error_msg_info->cn_source_loc); } - exit(SIGABRT); + cn_exit(); } // assert(cn_b->val); } @@ -149,7 +157,7 @@ cn_bool *cn_map_equality(cn_map *m1, cn_map *m2, cn_bool *(value_equality_fun)(v cn_pointer *convert_to_cn_pointer(void *ptr) { - cn_pointer *res = alloc(sizeof(cn_pointer)); + cn_pointer *res = (cn_pointer *) alloc(sizeof(cn_pointer)); res->ptr = ptr; // Carries around an address return res; }