diff: svar.m changes
Fergus Henderson
fjh at kryten.cs.mu.OZ.AU
Tue Aug 26 03:57:31 AEST 1997
clpr/svar.m:
Restore `stamp' after a commit. This is necessary to ensure that
`stamp' stays in sync with MR_ticket_counter, so that the test
`stamp != MR_current_choicepoint_id()' remains valid.
Check for doing a commit when `nlin_count' is non-zero,
and if so, issue a warning. (Any such commit is potentially
unsound, and might lead to wrong answers.)
Also add a couple of comments.
Index: svar.m
===================================================================
RCS file: /home/staff/zs/imp/clpr/svar.m,v
retrieving revision 1.5
diff -u -u -r1.5 svar.m
--- 1.5 1997/08/24 10:33:01
+++ svar.m 1997/08/25 17:38:53
@@ -306,7 +306,7 @@
/*
** There are three trails:
** - the Mercury trail
-** - the svar.m trail
+** - the svar.m trail-info free list
** - the CLP(R) trail
** The Mercury trail contains function trail entries which point to
** the svar.m trail. (The reason why those two are separate is modularity.)
@@ -314,6 +314,7 @@
** The svar.m trail entries store the CLP(R) global variables, including
** the `trtop' variable, which points to the top of the CLP(R) trail.
*/
+/* XXX rename as `choicepoint' */
typedef struct ML_svar_trail_entry {
int stamp;
int slack_id;
@@ -326,9 +327,12 @@
ML_svar_trail_entry ML_svar_first_trail_entry;
ML_svar_trail_entry * ML_svar_trail_ptr = &ML_svar_first_trail_entry;
+/* XXX efficiency could be improved -- we should use a free list here */
+
#define ML_svar_next_trail_entry() \
( ML_svar_trail_ptr->next == NULL ? \
(ML_svar_trail_ptr->next = make(ML_svar_trail_entry), \
+ ML_svar_trail_ptr->next->next = NULL, \
ML_svar_trail_ptr->next->prev = ML_svar_trail_ptr, \
ML_svar_trail_ptr = ML_svar_trail_ptr->next) \
: \
@@ -339,7 +343,7 @@
#define ML_svar_maybe_trail_solver() \
do { \
- if(stamp != MR_current_choicepoint_id()) { \
+ if (stamp != MR_current_choicepoint_id()) { \
save_transient_registers(); \
ML_svar_trail_solver(); \
restore_transient_registers(); \
@@ -381,10 +385,16 @@
trtop = old_trtop;
break;
}
- case MR_gc:
case MR_commit:
+ stamp = trail_entry->stamp;
+ if (nlin_count != 0) {
+ fprintf(stderr, ""svar.m: warning: ""
+ ""non-linear goals delayed, ""
+ ""but committing anyway\n"");
+ }
+ break;
default:
- /* do nothing */ ;
+ fatal_error(""svar.m: unknown MR_untrail_reason"");
}
ML_svar_prev_trail_entry();
}
@@ -469,7 +479,7 @@
/*
INIT init_svar_module
*/
-void init_svar_module(void) __attribute__((constructor)); /* XXX */
+void init_svar_module(void) __attribute__((constructor)); /* XXX gcc-ism */
void init_svar_module(void) {
extern ModuleFunc svar_module;
svar_module();
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list