X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=notes%2Fgenerated_code_examples.txt;h=2a7241c6156c00721d753f8592f1ab9938a779ec;hb=31be39ff19f3508790959f95847a9547c83cf322;hp=ce405807c27e47d1ae27c6460a0a0958d51b283f;hpb=1c89b92ed0363b0c283fc49cdd4f53451eb47d3d;p=cdsspec-compiler.git diff --git a/notes/generated_code_examples.txt b/notes/generated_code_examples.txt index ce40580..2a7241c 100644 --- a/notes/generated_code_examples.txt +++ b/notes/generated_code_examples.txt @@ -2,17 +2,17 @@ Global Variable Declaration /* Include all the header files that contains the interface declaration */ -#include #inlcude #include #include /* Other necessary header files */ +#include #include -#include +#include /* All other user-defined functions */ -ALL_USER_DEFINED_FUNCTIONS +ALL_USER_DEFINED_FUNCTIONS // Make them static /* Definition of interface info struct (per interface) */ typedef struct Put_info { @@ -29,7 +29,7 @@ typedef struct Get_info { /* ID functions of interface */ static id_t Put_id() { - id_t id = PUT_ID; + id_t id = PUT_ID; // Default ID == 0; return id; } @@ -39,10 +39,7 @@ static id_t Get_id() { } /* End of ID functions */ -/* Initialization of interface<->function_ptr table */ -#define INTERFACE_SIZE 2 -void* func_ptr_table[INTERFACE_SIZE * 2] = { - CLASS + /* Check_action function of interfaces */ bool Put_check_action(void *info, id_t __ID__) { @@ -78,6 +75,9 @@ bool Get_check_action(void *info, id_t __ID__) { } /* End of check_action function definitions */ +/* Initialization of interface<->function_ptr table */ +#define INTERFACE_SIZE 2 +void** func_ptr_table; /* Beginning of other user-defined variables */ bool lock_acquired; @@ -87,10 +87,26 @@ 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; @@ -121,8 +137,7 @@ Interface Wrapper #include #include #include -#include -#include +#include TypeReturn interfaceName(ARGType1 arg1, ARGType2 arg2) { @@ -149,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; @@ -157,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); @@ -167,11 +182,8 @@ TypeReturn interfaceName(ARGType1 arg1, ARGType2 arg2) Potential Commit Point -#include -#include -#include -#include #include +#include /* Should add the __ATOMIC_RET__ if necessary */ uint64_t __ATOMIC_RET = somevar.compare_exchange_explicit(...); @@ -189,10 +201,7 @@ if (POTENTIAL_CP_DEFINE_CONDITION) { Commit Point Define #include -#include #include -#include -#include <_spec_sequential_generated.h> #include /* Should add the __ATOMIC_RET__ if necessary */ @@ -220,10 +229,7 @@ Commit Point Define Check #include -#include #include -#include -#include <_spec_sequential_generated.h> #include /* Should add the __ATOMIC_RET__ if necessary */