diff: clp(R): port to Linux

Fergus Henderson fjh at hydra.cs.mu.oz.au
Mon Oct 6 22:32:17 AEST 1997


Some changes that were needed to port CLP(R) to Linux.

clpr/clpr/solver.c:
	Call alloc_mem() rather than malloc().

clpr/clpr/init.c:
	Add a comment to the definition of alloc_mem() explaining
	why we need to call alloc_mem() rather than malloc() on Linux.

Index: solver.c
===================================================================
RCS file: /home/staff/zs/imp/clpr/clpr/solver.c,v
retrieving revision 1.7
diff -u -u -r1.7 solver.c
--- solver.c	1997/09/15 08:26:54	1.7
+++ solver.c	1997/10/06 12:28:16
@@ -505,7 +505,11 @@
 	slack_id = SOLVER_SZ;
 	nlin_count = 0;
 	sms_blocks = 1;
+/*******
 	sms = (SOLVER_NODE_ptr) malloc(SOLVER_MALLOC_NODES*sizeof(SOLVER_NODE));
+********/
+	sms = (SOLVER_NODE_ptr) alloc_mem(
+	    (SOLVER_MALLOC_NODES*sizeof(SOLVER_NODE))/sizeof(CLPR_int) + 1);
 	if (!sms) fatal("Not enough memory to initialize solver");
 	tmp1 = sms;
 	tmp2 = &tmp1[SOLVER_MALLOC_NODES - 1];
@@ -541,7 +545,11 @@
 	fflush(stdout);
 ***/
 	sms_blocks++;
+/********
 	tmp0 = (SOLVER_NODE_ptr) malloc(SOLVER_MALLOC_NODES*sizeof(SOLVER_NODE));
+********/
+	tmp0 = (SOLVER_NODE_ptr) alloc_mem(
+	    (SOLVER_MALLOC_NODES*sizeof(SOLVER_NODE))/sizeof(CLPR_int) + 1);
 	if (!tmp0) fatal("Not enough memory (solver)");
 	tmp1 = tmp0;
 	tmp2 = &tmp1[SOLVER_MALLOC_NODES - 1];
Index: init.c
===================================================================
RCS file: /home/staff/zs/imp/clpr/clpr/init.c,v
retrieving revision 1.8
diff -u -u -r1.8 init.c
--- init.c	1997/09/15 08:26:42	1.8
+++ init.c	1997/10/06 12:29:30
@@ -306,6 +306,12 @@
 extern char *sbrk(CLPR_int);
 #endif
 
+/*
+On some Unix systems, e.g. Linux, we need to allocate memory
+with sbrk() rather than malloc(), otherwise our scheme of
+using the top four bits of pointers as tags won't work.
+*/
+  
 CLPR_int *alloc_mem(CLPR_int n)
 {
     char *p;
-- 
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