changes to the CLP(R) interface stuff

Fergus Henderson fjh at hydra.cs.mu.oz.au
Sun Aug 24 20:32:27 AEST 1997


clpr/mercury_solver.h:
	Removed.  The stuff that was in here has migrated;
	some of it is in clpr/clpr_misc.h, and some is in
	svar.m.

svar.m:
	Various changes to make it use the new trailing interface.
	(It still doesn't quite work, though.)

The first 200 lines of this diff are intersting; after that,
it is all boiler-plate stuff.  Peter, can you please review this?

Index: svar.m
===================================================================
RCS file: /home/staff/zs/imp/clpr/svar.m,v
retrieving revision 1.4
diff -u -u -r1.4 svar.m
--- svar.m	1996/07/22 03:58:00	1.4
+++ svar.m	1997/08/24 10:31:19
@@ -292,15 +292,151 @@
 
 :- type svar.	  % The svar is stored as an int (the CLP(R) solver_id for it).
 
-:- pragma(c_header_code, "#include ""./mercury_solver.h""").
-:- pragma(c_header_code, "#include ""./clpr/emul.h""").
-:- pragma(c_header_code, "#ifndef CONSTRAINTS").
-%:- pragma(c_header_code, "#error ""this module may only be used in a constraint grade""").
+:- pragma(c_header_code, "
 
-:- pragma(c_header_code, "#endif").
+#include ""./clpr/emul.h""
+#include ""./clpr/solver.h""
+#include ""./clpr/clpr_misc.h""
+#include <stdio.h>
+
+#ifndef MR_USE_TRAIL
+  #error This module may only be used in a trailed grade (*.tr).
+#endif
+
+/*
+** There are three trails:
+**	- the Mercury trail
+**	- the svar.m trail
+**	- 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.)
+** The svar.m trail is organized as a doubly-linked list.
+** 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.
+*/
+typedef struct ML_svar_trail_entry {
+	int stamp;
+	int slack_id;
+	int solver_id;
+	int trtop;
+	struct ML_svar_trail_entry *prev;
+	struct ML_svar_trail_entry *next;
+} ML_svar_trail_entry;
+
+ML_svar_trail_entry ML_svar_first_trail_entry;
+ML_svar_trail_entry * ML_svar_trail_ptr = &ML_svar_first_trail_entry;
+
+#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->prev = ML_svar_trail_ptr,	\
+		ML_svar_trail_ptr = ML_svar_trail_ptr->next)		\
+	:								\
+		(ML_svar_trail_ptr = ML_svar_trail_ptr->next)		\
+	)
+#define ML_svar_prev_trail_entry() \
+	(ML_svar_trail_ptr = ML_svar_trail_ptr->prev)
+		
+#define ML_svar_maybe_trail_solver()				\
+	do {							\
+		if(stamp != MR_current_choicepoint_id()) {	\
+			save_transient_registers();		\
+			ML_svar_trail_solver();			\
+			restore_transient_registers();		\
+		} 						\
+	} while(0)
 
+void ML_svar_trail_solver(void);
+void ML_svar_untrail_func(Word datum, MR_untrail_reason reason);
 
-:- pragma(c_header_code, "
+").
+
+:- pragma(c_code, "
+
+void ML_svar_trail_solver(void) {
+	ML_svar_trail_entry *trail_entry = ML_svar_next_trail_entry();
+	trail_entry->stamp = stamp;
+	trail_entry->slack_id = slack_id;
+	trail_entry->solver_id = solver_id;
+	trail_entry->trtop = trtop;
+	MR_trail_function(ML_svar_untrail_func, (Word) trail_entry);
+	stamp = MR_current_choicepoint_id();
+}
+
+void ML_svar_untrail_func(Word datum, MR_untrail_reason reason) {
+	ML_svar_trail_entry *trail_entry = (ML_svar_trail_entry *) datum;
+	switch (reason) {
+		case MR_undo:
+		case MR_exception:
+		{
+			int old_trtop, i;
+
+			stamp = trail_entry->stamp;
+			slack_id = trail_entry->slack_id;
+			solver_id = trail_entry->solver_id;
+			old_trtop = trail_entry->trtop;
+			for (i = trtop - 1; i >= old_trtop; i--) {
+				solver_backtrack((Word) trail[i]);
+			}
+			trtop = old_trtop;
+			break;
+		}
+		case MR_gc:
+		case MR_commit:
+		default:
+			/* do nothing */ ;
+	}
+	ML_svar_prev_trail_entry();
+}
+").
+
+:- pragma c_header_code("
+
+#define ML_svar_init_solver_var(x) \
+	((x) = ++solver_id)
+
+#define ML_svar_add_solver_vars(Svar1, Svar2, Svar3)	\
+	{					\
+	ML_svar_maybe_trail_solver();		\
+	init_eqn();				\
+	s_evar(1.0, Svar1);			\
+	s_evar(1.0, Svar2);			\
+	s_evar(-1.0, Svar3);			\
+	s_econ(0.0);				\
+	}
+
+#define ML_svar_add_float_and_svars(Svar1, Val, Svar2)	\
+	{					\
+	ML_svar_maybe_trail_solver();		\
+	init_eqn();				\
+	s_evar(1.0, Svar1);			\
+	eqn_scratch->constant += (double)Val;	\
+	s_evar(-1.0, Svar2);			\
+	s_econ(0.0);				\
+	}
+
+").
+
+:- pragma(c_code, "
+
+	/* base_type_functors for `svar' */
+
+const struct mercury_data_svar__base_type_functors_svar_0_struct {
+	Integer f1;
+} mercury_data_svar__base_type_functors_svar_0 = {
+	MR_TYPEFUNCTORS_SPECIAL
+};
+
+	/* base_type_layout for `svar' */
+
+const struct mercury_data_svar__base_type_layout_svar_0_struct {
+	TYPE_LAYOUT_FIELDS
+} mercury_data_svar__base_type_layout_svar_0 = {
+	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
+		mkbody(TYPELAYOUT_C_POINTER_VALUE))
+};
+
+	/* unify/2, compare/3, and index/2 predicates for `svar' */
 
 Define_extern_entry(mercury____Unify___svar__svar_0_0);
 Define_extern_entry(mercury____Compare___svar__svar_0_0);
@@ -314,6 +450,7 @@
 BEGIN_CODE
 
 Define_entry(mercury____Unify___svar__svar_0_0);
+	ML_svar_maybe_trail_solver();
 	init_eqn();
 	s_evar(1.0, r2);
 	s_evar(-1.0, r3);
@@ -328,51 +465,64 @@
 
 END_MODULE
 
+/* Ensure that the initialization code for the above module gets run. */
+/*
+INIT init_svar_module
+*/
+void init_svar_module(void) __attribute__((constructor)); /* XXX */
+void init_svar_module(void) {
+	extern ModuleFunc svar_module;
+	svar_module();
+	CLPR_init();
+}
+
 ").
-:- pragma(c_code, svar__init(Svar::co), "init_solver_var(Svar);").
+
+:- pragma(c_code, svar__init(Svar::co), "ML_svar_init_solver_var(Svar);").
 
 :- pragma(c_code, svar__plus(Svar1::ca, Svar2::ca, Svar3::co),
 		"
-		init_solver_var(Svar3);
-		add_solver_vars(Svar1, Svar2, Svar3);
+		ML_svar_init_solver_var(Svar3);
+		ML_svar_add_solver_vars(Svar1, Svar2, Svar3);
 		").
 :- pragma(c_code, svar__plus(Svar1::ca, Svar2::co, Svar3::ca),
 		"
-		init_solver_var(Svar2);
-		add_solver_vars(Svar1, Svar2, Svar3);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_add_solver_vars(Svar1, Svar2, Svar3);
 		").
 :- pragma(c_code, svar__plus(Svar1::ca, Svar2::co, Svar3::co),
 		"
-		init_solver_var(Svar2);
-		init_solver_var(Svar3);
-		add_solver_vars(Svar1, Svar2, Svar3);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar3);
+		ML_svar_add_solver_vars(Svar1, Svar2, Svar3);
 		").
 :- pragma(c_code, svar__plus(Svar1::co, Svar2::ca, Svar3::ca),
 		"
-		init_solver_var(Svar1);
-		add_solver_vars(Svar1, Svar2, Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_add_solver_vars(Svar1, Svar2, Svar3);
 		").
 :- pragma(c_code, svar__plus(Svar1::co, Svar2::ca, Svar3::co),
 		"
-		init_solver_var(Svar1);
-		init_solver_var(Svar3);
-		add_solver_vars(Svar1, Svar2, Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar3);
+		ML_svar_add_solver_vars(Svar1, Svar2, Svar3);
 		").
 :- pragma(c_code, svar__plus(Svar1::co, Svar2::co, Svar3::ca),
 		"
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
-		add_solver_vars(Svar1, Svar2, Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_add_solver_vars(Svar1, Svar2, Svar3);
 		").
 :- pragma(c_code, svar__plus(Svar1::co, Svar2::co, Svar3::co),
 		"
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
-		init_solver_var(Svar3);
-		add_solver_vars(Svar1, Svar2, Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar3);
+		ML_svar_add_solver_vars(Svar1, Svar2, Svar3);
 		").
 :- pragma(c_code, svar__plus(Svar1::ca, Svar2::ca, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(1.0, Svar1);
 		s_evar(1.0, Svar2);
@@ -382,22 +532,23 @@
 
 :- pragma(c_code, svar__plus_float(Svar1::co, Val::in, Svar2::ca),
 		"
-		init_solver_var(Svar1);
-		add_float_and_svars(Svar1, Val, Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_add_float_and_svars(Svar1, Val, Svar2);
 		").
 :- pragma(c_code, svar__plus_float(Svar1::ca, Val::in, Svar2::co),
 		"
-		init_solver_var(Svar2);
-		add_float_and_svars(Svar1, Val, Svar2);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_add_float_and_svars(Svar1, Val, Svar2);
 		").
 :- pragma(c_code, svar__plus_float(Svar1::co, Val::in, Svar2::co),
 		"
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
-		add_float_and_svars(Svar1, Val, Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_add_float_and_svars(Svar1, Val, Svar2);
 		").
 :- pragma(c_code, svar__plus_float(Svar1::ca, Val::in, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		eqn_scratch->constant += (double)Val;
 		s_evar(1.0, Svar1);
@@ -408,60 +559,69 @@
 
 :- pragma(c_code, svar__mult(Svar1::ca, Svar2::ca, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		SUCCESS_INDICATOR = s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__mult(Svar1::ca, Svar2::co, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		SUCCESS_INDICATOR = s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__mult(Svar1::co, Svar2::ca, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		SUCCESS_INDICATOR = s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__mult(Svar1::ca, Svar2::ca, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar3);
 		s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__mult(Svar1::co, Svar2::co, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__mult(Svar1::ca, Svar2::co, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar3);
 		s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__mult(Svar1::co, Svar2::ca, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar3);
 		s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__mult(Svar1::co, Svar2::co, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar3);
 		s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 
 
 :- pragma(c_code,svar__mult_float(Svar1::ca, Val::in, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar((double)Val, Svar1);
 		s_evar(-1.0, Svar2);
@@ -469,25 +629,28 @@
 		").
 :- pragma(c_code,svar__mult_float(Svar1::co, Val::in, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		s_evar((double)Val, Svar1);
 		s_evar(-1.0, Svar2);
 		SUCCESS_INDICATOR = s_econ(0.0);
 		").
 :- pragma(c_code,svar__mult_float(Svar1::ca, Val::in, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		s_evar((double)Val, Svar1);
 		s_evar(-1.0, Svar2);
 		s_econ(0.0);
 		").
 :- pragma(c_code,svar__mult_float(Svar1::co, Val::in, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_evar((double)Val, Svar1);
 		s_evar(-1.0, Svar2);
 		s_econ(0.0);
@@ -496,60 +659,69 @@
 
 :- pragma(c_code, svar__div(Svar1::ca, Svar2::ca, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
 		").	
 :- pragma(c_code, svar__div(Svar1::ca, Svar2::co, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		SUCCESS_INDICATOR = s_mult(1.0, Svar3, Svar2, Svar1);
 		").	
 :- pragma(c_code, svar__div(Svar1::co, Svar2::ca, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
 		").	
 :- pragma(c_code, svar__div(Svar1::ca, Svar2::ca, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar3);
 		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
 		").	
 :- pragma(c_code, svar__div(Svar1::co, Svar2::co, Svar3::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_mult(1.0, Svar1, Svar2, Svar3);
 		").	
 :- pragma(c_code, svar__div(Svar1::ca, Svar2::co, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar3);
 		s_mult(1.0, Svar1, Svar2, Svar3);
 		").	
 :- pragma(c_code, svar__div(Svar1::co, Svar2::ca, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar3);
 		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
 		").	
 :- pragma(c_code, svar__div(Svar1::co, Svar2::co, Svar3::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
-		init_solver_var(Svar3);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar3);
 		s_mult(1.0, Svar1, Svar2, Svar3);
 		").	
 
 
 :- pragma(c_code,svar__div_float(Svar1::ca, Val::in, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(1/(double)Val, Svar1);
 		s_evar(-1.0, Svar2);
@@ -557,25 +729,28 @@
 		").
 :- pragma(c_code,svar__div_float(Svar1::co, Val::in, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		s_evar(1/(double)Val, Svar1);
 		s_evar(-1.0, Svar2);
 		SUCCESS_INDICATOR = s_econ(0.0);
 		").
 :- pragma(c_code,svar__div_float(Svar1::ca, Val::in, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1/(double)Val, Svar1);
 		s_evar(-1.0, Svar2);
 		SUCCESS_INDICATOR = s_econ(0.0);
 		").
 :- pragma(c_code,svar__div_float(Svar1::co, Val::in, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1/(double)Val, Svar1);
 		s_evar(-1.0, Svar2);
 		SUCCESS_INDICATOR = s_econ(0.0);
@@ -585,6 +760,7 @@
 
 :- pragma(c_code, svar__eq(Svar1::ca, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
@@ -593,8 +769,9 @@
 		).
 :- pragma(c_code, svar__eq(Svar1::co, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_econ(0.0);
@@ -602,8 +779,9 @@
 		).
 :- pragma(c_code, svar__eq(Svar1::ca, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_econ(0.0);
@@ -611,9 +789,10 @@
 		).
 :- pragma(c_code, svar__eq(Svar1::co, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_econ(0.0);
@@ -622,6 +801,7 @@
 
 :- pragma(c_code, svar__eq_float(Svar::ca, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(-1.0, Svar);
 		SUCCESS_INDICATOR = s_econ(Val);
@@ -629,8 +809,9 @@
 		).
 :- pragma(c_code, svar__eq_float(Svar::co, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar);
+		ML_svar_init_solver_var(Svar);
 		s_evar(-1.0, Svar);
 		s_econ(Val);
 		"
@@ -638,6 +819,7 @@
 
 :- pragma(c_code, '>'(Svar1::ca, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
@@ -646,8 +828,9 @@
 		).
 :- pragma(c_code, '>'(Svar1::co, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_gt0(0.0);
@@ -655,8 +838,9 @@
 		).
 :- pragma(c_code, '>'(Svar1::ca, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_gt0(0.0);
@@ -664,9 +848,10 @@
 		).
 :- pragma(c_code, '>'(Svar1::co, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_gt0(0.0);
@@ -675,6 +860,7 @@
 
 :- pragma(c_code, '>='(Svar1::ca, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
@@ -683,8 +869,9 @@
 		).
 :- pragma(c_code, '>='(Svar1::co, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_ge0(0.0);
@@ -692,8 +879,9 @@
 		).
 :- pragma(c_code, '>='(Svar1::ca, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_ge0(0.0);
@@ -701,9 +889,10 @@
 		).
 :- pragma(c_code, '>='(Svar1::co, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(1.0, Svar1);
 		s_evar(-1.0, Svar2);
 		s_ge0(0.0);
@@ -712,34 +901,39 @@
 
 :- pragma(c_code, svar__gt_float(Svar::ca, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(1.0, Svar);
 		SUCCESS_INDICATOR = s_gt0((double)Val);
 		").
 :- pragma(c_code, svar__gt_float(Svar::co, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar);
+		ML_svar_init_solver_var(Svar);
 		s_evar(1.0, Svar);
 		s_gt0((double)Val);
 		").
 
 :- pragma(c_code, svar__ge_float(Svar::ca, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(1.0, Svar);
 		SUCCESS_INDICATOR = s_ge0((double)Val);
 		").
 :- pragma(c_code, svar__ge_float(Svar::co, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar);
+		ML_svar_init_solver_var(Svar);
 		s_evar(1.0, Svar);
 		s_ge0((double)Val);
 		").
 
 :- pragma(c_code, '<'(Svar1::ca, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
@@ -748,8 +942,9 @@
 		).
 :- pragma(c_code, '<'(Svar1::ca, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
 		s_gt0(0.0);
@@ -757,8 +952,9 @@
 		).
 :- pragma(c_code, '<'(Svar1::co, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
 		s_gt0(0.0);
@@ -766,9 +962,10 @@
 		).
 :- pragma(c_code, '<'(Svar1::co, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
 		s_gt0(0.0);
@@ -777,6 +974,7 @@
 
 :- pragma(c_code, '=<'(Svar1::ca, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
@@ -786,8 +984,9 @@
 
 :- pragma(c_code, '=<'(Svar1::ca, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
 		s_ge0(0.0);
@@ -796,8 +995,9 @@
 
 :- pragma(c_code, '=<'(Svar1::co, Svar2::ca),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar1);
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
 		s_ge0(0.0);
@@ -806,9 +1006,10 @@
 
 :- pragma(c_code, '=<'(Svar1::co, Svar2::co),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar1);
-		init_solver_var(Svar2);
+		ML_svar_init_solver_var(Svar1);
+		ML_svar_init_solver_var(Svar2);
 		s_evar(-1.0, Svar1);
 		s_evar(1.0, Svar2);
 		s_ge0(0.0);
@@ -817,28 +1018,32 @@
 
 :- pragma(c_code, svar__lt_float(Svar::ca, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(-1.0, Svar);
 		SUCCESS_INDICATOR = s_gt0((double)(-(Val)));
 		").
 :- pragma(c_code, svar__lt_float(Svar::co, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar);
+		ML_svar_init_solver_var(Svar);
 		s_evar(-1.0, Svar);
 		s_gt0((double)(-(Val)));
 		").
 
 :- pragma(c_code, svar__le_float(Svar::ca, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
 		s_evar(-1.0, Svar);
 		SUCCESS_INDICATOR = s_ge0((double)(-(Val)));
 		").
 :- pragma(c_code, svar__le_float(Svar::co, Val::in),
 		"
+		ML_svar_maybe_trail_solver();
 		init_eqn();
-		init_solver_var(Svar);
+		ML_svar_init_solver_var(Svar);
 		s_evar(-1.0, Svar);
 		s_ge0((double)(-(Val)));
 		").

-- 
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