X-Git-Url: http://plrg.eecs.uci.edu/git/?p=cdsspec-compiler.git;a=blobdiff_plain;f=notes%2Fgenerated_code_examples.txt;h=2a7241c6156c00721d753f8592f1ab9938a779ec;hp=16580011f0406d370ca48a06cec4518a5cf397cc;hb=a85b48f48d41dcd8b5acf190b3f7ab8c1edee3b6;hpb=efb1d30419ff984d1c06d338ec453fd8b0780d74 diff --git a/notes/generated_code_examples.txt b/notes/generated_code_examples.txt index 1658001..2a7241c 100644 --- a/notes/generated_code_examples.txt +++ b/notes/generated_code_examples.txt @@ -77,7 +77,7 @@ bool Get_check_action(void *info, id_t __ID__) { /* Initialization of interface<->function_ptr table */ #define INTERFACE_SIZE 2 -void* func_ptr_table[INTERFACE_SIZE * 2]; +void** func_ptr_table; /* Beginning of other user-defined variables */ bool lock_acquired; @@ -88,11 +88,25 @@ int reader_lock_cnt; /* Define function for sequential code initialization */ void __sequential_init() { /* Init func_ptr_table */ + func_ptr_table = (void**) malloc(sizeof(void*) * 2); + func_ptr_table[0] = (void*) &Put_id; + func_ptr_table[1] = (void*) &Put_check_action; + func_ptr_table[2] = (void*) &Get_id; + func_ptr_table[3] = (void*) &Get_check_action; /* Init user-defined variables */ lock_acquired = false; reader_lock_cnt = 0; + /* Pass function table info */ + anno_func_table_init func_table; + func_table.size = INTERFACE_SIZE; + func_table.table = func_ptr_table; + spec_annotation func_init; + func_init.type = FUNC_TABLE_INIT; + func_init.annotation = &anno_func_table_init; + cdsannotate(SPEC_ANALYSIS, &func_init); + /* Pass the happens-before initialization here */ /* PutIfAbsent (putIfAbsent_Succ) -> Get (true) */ anno_hb_init hbConditionInit0; @@ -150,7 +164,6 @@ TypeReturn interfaceName(ARGType1 arg1, ARGType2 arg2) // And more (if any) // Interface ends - spec_annotation annotation_interface_end; INTERFACE_LABEL_info info = (INTERFACE_LABEL_info*) malloc(sizeof(INTERFACE_LABEL_info)); info->__RET__ = __RET__; info->arg1 = arg1; @@ -158,6 +171,7 @@ TypeReturn interfaceName(ARGType1 arg1, ARGType2 arg2) anno_interface_end interface_end; interface_end.interface_num = 0; // Interface number interface_end.info = info; // Info + spec_annotation annotation_interface_end; annotation_interface_end.type = INTERFACE_END; annotation_interface_end.annotation = &interface_end; cdsannotate(SPEC_ANALYSIS, &annoation_interface_end);