From 6ef50c959863f376bc1ef55be761da8a4a5b04b9 Mon Sep 17 00:00:00 2001 From: Peizhao Ou Date: Wed, 23 Oct 2013 17:23:07 -0700 Subject: [PATCH] new strategy --- .../simplified_cliffc_hashtable.h | 1 + notes/generated_code_examples.txt | 77 ++++++++++++++----- test.cc | 28 +++++++ 3 files changed, 88 insertions(+), 18 deletions(-) diff --git a/benchmark/cliffc-hashtable/simplified_cliffc_hashtable.h b/benchmark/cliffc-hashtable/simplified_cliffc_hashtable.h index a37ebdb..299e7a3 100644 --- a/benchmark/cliffc-hashtable/simplified_cliffc_hashtable.h +++ b/benchmark/cliffc-hashtable/simplified_cliffc_hashtable.h @@ -85,6 +85,7 @@ class cliffc_hashtable { @Begin @Options: LANG = C; + CLASS = cliffc_hashtable; @Global_define: @DeclareVar: spec_hashtable map; diff --git a/notes/generated_code_examples.txt b/notes/generated_code_examples.txt index e1eed19..506c5af 100644 --- a/notes/generated_code_examples.txt +++ b/notes/generated_code_examples.txt @@ -9,29 +9,73 @@ Global Variable Declaration #ifndef __SPEC_SEQUENTIAL_GENERATED_H #define __SPEC_SEQUENTIAL_GENERATED_H #include -#include #include -/* Beginning of struct Sequential */ -typedef struct Sequential { - spec_private_hashtable interface; - Tag global_call_sequence; +/* Include all the header files that contains the interface declaration */ +#include +#inlcude +#include +#include + +/* All other user-defined functions */ +ALL_USER_DEFINED_FUNCTIONS - /* Beginning of other user-defined variables */ - bool lock_acquired; - int reader_lock_cnt; - /* End of other user-defined variables */ +/* Definition of interface info struct (per interface) */ +typedef struct Put_info { + shared_ptr __RET__; + TypeK & key; + TypeV & value; +} Put_info; + +typedef struct Get_info { + shared_ptr __RET__; + TypeK & key; +} Get_info; +/* End of info struct definition */ + + +/* All function of action and check of interfaces */ +bool Put_check_action(void *info) { + bool check_passed; + Put_info *theInfo = (Put_info) info; + shared_ptr __RET__ = theInfo->__RET__; + TypeK & key = theInfo->key; + TypeV & value = theInfo->value; + + // Check + check_passed = PUT_CHECK_EXPRESSION; + if (!check_passed) + return false; + + // Action + PUT_ACTION + + /* DefineVars */ + TypeV *_Old_Val = DefineVarExpr; + + // Post_check + check_passed = PUT_POST_CHECK_EXPRESSION; + if (!check_passed) + return false; + + // Post_action + PUT_POST_ACTION +} -} Sequential; /* End of struct Sequential */ +id_t Put_id() { + id_t id = PUT_ID; + return id; +} + + +/* Beginning of other user-defined variables */ +bool lock_acquired; +int reader_lock_cnt; +/* End of other user-defined variables */ -/* Instance of the struct */ -Sequential __sequential; /* Define function for sequential code initialization */ void __sequential_init() { - /* Init internal variables */ - init(&__sequential.interface); - init(&global_call_sequence); /* Init user-defined variables */ lock_acquired = false; reader_lock_cnt = 0; @@ -49,9 +93,6 @@ void __sequential_init() { cdsannotate(SPEC_ANALYSIS, &hb_init0); } -/* All other user-defined functions */ -ALL_USER_DEFINED_FUNCTIONS - #endif diff --git a/test.cc b/test.cc index e69de29..b9b6ed3 100644 --- a/test.cc +++ b/test.cc @@ -0,0 +1,28 @@ +#include + +typedef void (*action_t)(void*); + +class Class { + public: + struct A { + int &a; + }; + + void action(void *info) { + printf("abc\n"); + } + + Class() { + action_t inst = (action_t) &Class::action; + //(*inst)(NULL); + } +}; + +int main() { + Class a; + Class &b = a; + Class *c = &b; + printf("%d\n", &b); + printf("%d\n", &c); + return 1; +} -- 2.34.1