[Gs-commits] r594 - in trunk/code/src/gsl: . parser tests/correctness
Author: slang Date: 2009-06-23 13:37:58 -0500 (Tue, 23 Jun 2009) New Revision: 594 Added: trunk/code/src/gsl/tests/correctness/nested.gs Modified: trunk/code/src/gsl/Makefile.in trunk/code/src/gsl/parser/gs-parser.lhs Log: Fix blocking funcions that return void (nothing). Added test case. Modified: trunk/code/src/gsl/Makefile.in =================================================================== --- trunk/code/src/gsl/Makefile.in 2009-06-23 18:07:25 UTC (rev 593) +++ trunk/code/src/gsl/Makefile.in 2009-06-23 18:37:58 UTC (rev 594) @@ -277,7 +277,7 @@ $(E)$(call MCC_GS,$<) -D__blocking="" \ -Dpwait="while(0)" -Dpbranch="" -Dpbreak="break"\ -I$(srcdir)/include/ -x c -c -o $@ $(LIBCFLAGS) \ - -Wall -Wno-implicit -Wno-unused-function -Werror \ + -Wall -Wno-implicit -Wno-unused -Werror \ $(CFLAGS) $(call MODCFLAGS_GS,$<) $< %.gs.i: %.gs %.gs.dummyobj Modified: trunk/code/src/gsl/parser/gs-parser.lhs =================================================================== --- trunk/code/src/gsl/parser/gs-parser.lhs 2009-06-23 18:07:25 UTC (rev 593) +++ trunk/code/src/gsl/parser/gs-parser.lhs 2009-06-23 18:37:58 UTC (rev 594) @@ -1097,27 +1097,33 @@
++ nextBlockingPostStmts ++ [mkLabel "__gs_callback_end" [] $ getNI bctx]) $ getNI bctx
+> mkCallbackReturnParamDecl :: (CTypeSpec, [CDerivedDeclr]) -> String -> NodeInfo -> [CDecl] +> mkCallbackReturnParamDecl ret@(retType, derives) name ni = +> -- no parameter if the return type is void +> if isVoidType ret then [] else +> [mkCDecl retType (filter (not . isDerivedFun) derives) (mkCallbackRetParam name ni) ni] + function definition, blocking call, return expression, statements after blocking call up to next blocking, optional next blocking call
mkCallbackDecl :: BlockingContext -> CExpr -> (CTypeSpec, [CDerivedDeclr]) -> CExtDecl -> mkCallbackDecl bctx blockingCall (lBretType, lBDerives) = +> mkCallbackDecl bctx blockingCall returnType = let fname = getCallName blockingCall params = getCallParams blockingCall ni = getCallNodeInfo blockingCall in mkStaticFunDecl (CVoidType ni) -- return type (mkCallbackFunName (getParentName bctx) fname ni) -- function name -> [constructDeclFromC ni "void *__gs_ptr;", -- parameters -> mkCDecl lBretType (filter (not . isDerivedFun) lBDerives) (mkCallbackRetParam fname ni) ni] +> ([constructDeclFromC ni "void *__gs_ptr;"] ++ -- parameter for control state +> (mkCallbackReturnParamDecl returnType fname ni)) -- parameter for return type of blocking function
mkCallback :: String -> BlockingContext -> CExpr -> (CTypeSpec, [CDerivedDeclr]) -> [CStat] -> [CStat] -> CExtDecl -> mkCallback prefix bctx blockingCall (lBretType, lBDerives) stmts nextBlockingPostStmts = +> mkCallback prefix bctx blockingCall returnType stmts nextBlockingPostStmts = let fname = getCallName blockingCall params = getCallParams blockingCall ni = getCallNodeInfo blockingCall in mkStaticFunDef (CVoidType ni) -- return type (mkCallbackFunName (getParentName bctx) fname ni) -- function name -> [constructDeclFromC ni "void *__gs_ptr;", -- parameters -> mkCDecl lBretType (filter (not . isDerivedFun) lBDerives) (mkCallbackRetParam fname ni) ni] +> ([constructDeclFromC ni "void *__gs_ptr;"] ++ -- parameter for control state +> (mkCallbackReturnParamDecl returnType fname ni)) -- parameter for return type of blocking function (mkCallbackStmts prefix bctx stmts nextBlockingPostStmts) -- statements
Take a blocking statement and a list of statements that follow Added: trunk/code/src/gsl/tests/correctness/nested.gs =================================================================== --- trunk/code/src/gsl/tests/correctness/nested.gs (rev 0) +++ trunk/code/src/gsl/tests/correctness/nested.gs 2009-06-23 18:37:58 UTC (rev 594) @@ -0,0 +1,49 @@ +#include "include/gs.h" +#include "tests/correctness/btest.gsh" + +static int here = 0; + +static __blocking void run_inner(void) +{ + int ret; + int a = 0; + + ret = btest1(&a); + assert(ret == 0); + assert(a == 1); +} + +static __blocking void run_outer(void) +{ + run_inner(); + here = 1; +} + +static int done = 0; + +static void basic_cb(void *ptr) +{ + printf("%p\n", ptr); + printf("done\n"); + done = 1; +} + +int main(int argc, char *argv[]) +{ + gs_op_id_t op_id; + void *myptr = malloc(1); + + btest_init(); + printf("%p\n", myptr); + run_outer_post(basic_cb, myptr, NULL, NULL, &op_id); + + while(done == 0) + { + btest_poll(NULL, 0); + } + + assert(here == 1); + btest_finalize(); + free(myptr); + return 0; +}
participants (1)
-
slang@mcs.anl.gov