diff --git a/H/cut_c.h b/H/cut_c.h index eb26e0388..047b3204f 100755 --- a/H/cut_c.h +++ b/H/cut_c.h @@ -18,11 +18,11 @@ struct cut_c_str{ #define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL))) #define EXTRA_CBACK_CUT_ARG(Type,Offset) \ -((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.lds.extra)) + (Offset-1))) +((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->u.OtapFs.extra)) + (Offset-1))) #define CUT_C_PUSH(YAMOP,S_YREG) \ { \ - if ((YAMOP)->u.lds.f){ \ + if ((YAMOP)->u.OtapFs.f){ \ S_YREG = S_YREG - CUT_C_STR_SIZE; \ cut_c_str_ptr new_top = (cut_c_str_ptr) S_YREG; \ new_top->try_userc_cut_yamop = YAMOP; \ @@ -38,8 +38,8 @@ struct cut_c_str{ #define POP_EXECUTE() \ cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \ - CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.lds.f; \ - PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.lds.p; \ + CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \ + PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \ YAP_Execute(pred,func); \ cut_c_pop(); diff --git a/Makefile.in b/Makefile.in index f515abeb9..0d586fbf2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,7 +49,7 @@ DOCSDIR=$(SHAREDIR)/docs/yap # # check also optimisation options in INSTALL file. # -YAP_EXTRAS=@YAP_EXTRAS@ +YAP_EXTRAS=-DCUT_C=1 @YAP_EXTRAS@ YAPSTARTUP=startup.yss diff --git a/docs/yap.tex b/docs/yap.tex index 74088159c..13483fb6c 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -14921,14 +14921,16 @@ YAP, in the initialization routine, with a call to where @var{name} is the name of the predicate, @var{fn} is the C function implementing the predicate and @var{arity} is its arity. -@findex YAP_UserBackCPredicate (C-Interface function) +@findex YAP_UserBackCPredicate (C-Interface function, deprecated) +@findex YAP_UserBackCutCPredicate (C-Interface function) @findex YAP_PRESERVE_DATA (C-Interface function) @findex YAP_PRESERVED_DATA (C-Interface function) @findex YAP_cutsucceed (C-Interface function) @findex YAP_cutfail (C-Interface function) -For the second kind of predicates we need two C functions. The first one -which is called when the predicate is first activated, and the second one -to be called on backtracking to provide (possibly) other solutions. Note +For the second kind of predicates we need three C functions. The first one + is called when the predicate is first activated; the second one +is called on backtracking to provide (possibly) other solutions; the + last one is called on pruning. Note also that we normally also need to preserve some information to find out the next solution. @@ -15050,25 +15052,26 @@ Backtrackable predicates should be declared to YAP, in a way similar to what happened with deterministic ones, but using instead a call to @example - void YAP_UserBackCPredicate(char *@var{name}, - int *@var{init}(), int *@var{cont}(), + void YAP_UserBackCutCPredicate(char *@var{name}, + int *@var{init}(), int *@var{cont}(), int *@var{cut}(), unsigned long int @var{arity}, unsigned int @var{sizeof}); @end example @noindent -where @var{name} is a string with the name of the predicate, @var{init} and -@var{cont} are the C functions used to start and continue the execution of -the predicate, @var{arity} is the predicate arity, and @var{sizeof} is -the size of the data to be preserved in the stack. In this example, we -would have something like +where @var{name} is a string with the name of the predicate, @var{init}, +@var{cont}, @var{cut} are the C functions used to start, continue and +when pruning the execution of the predicate, @var{arity} is the +predicate arity, and @var{sizeof} is the size of the data to be +preserved in the stack. In this example, we would have something like @example void init_n100(void) @{ - YAP_UserBackCPredicate("n100", start_n100, continue_n100, 1, 1); + YAP_UserBackCutCPredicate("n100", start_n100, continue_n100, NULL, 1, 1); @} @end example - +Notice that we do not actually need to do anything on receiving a cut in +this case. @node Loading Objects, Save&Rest, Writing C, C-Interface @section Loading Object Files diff --git a/library/yap2swi/yap2swi.c b/library/yap2swi/yap2swi.c index 6c035241c..8debc7b8e 100644 --- a/library/yap2swi/yap2swi.c +++ b/library/yap2swi/yap2swi.c @@ -2088,7 +2088,7 @@ X_API void PL_register_foreign_in_module(const char *module, const char *name, i nflags |= CArgsPredFlag; } if (flags & PL_FA_NONDETERMINISTIC) { - Yap_InitCPredBack((char *)name, arity, sizeof(struct foreign_context)/sizeof(CELL), (CPredicate)function, (CPredicate)function, UserCPredFlag|nflags); + Yap_InitCutCPredBack((char *)name, arity, sizeof(struct foreign_context)/sizeof(CELL), (CPredicate)function, (CPredicate)function, (CPredicate)function, UserCPredFlag|nflags); } else { UserCPredicate((char *)name,(CPredicate)function,arity,tmod,nflags); } diff --git a/packages/chr b/packages/chr index 5f7abe62f..f6bb78212 160000 --- a/packages/chr +++ b/packages/chr @@ -1 +1 @@ -Subproject commit 5f7abe62fc770d680b78c3f3e8b65951c7004850 +Subproject commit f6bb7821268b5c6df1ce83a9d60af1f90a9dd673 diff --git a/packages/jpl b/packages/jpl index 25bfaa337..d661852f7 160000 --- a/packages/jpl +++ b/packages/jpl @@ -1 +1 @@ -Subproject commit 25bfaa3370ca6f6a2b23d8dcc6dda84a2773d40a +Subproject commit d661852f76fe24441d983ef6f4e60ba90cfe17c4