Skip to content

Commit

Permalink
CN-exec: Minor changes to CN assert implementation for Zain's PBT
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rbanerjee20 committed Jun 21, 2024
1 parent a18c9da commit ec8db7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions runtime/libcn/include/cn-executable/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct cn_error_message_info {
char *cn_source_loc;
};

void (*cn_exit)(void);

/* Wrappers for C types */

/* Signed bitvectors */
Expand Down
12 changes: 10 additions & 2 deletions runtime/libcn/src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ec8db7e

Please sign in to comment.