Blob Blame Raw
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gcl (2.6.12-5) unstable; urgency=medium
 .
   * Version_2_6_13pre4
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- gcl-2.6.12.orig/h/page.h
+++ gcl-2.6.12/h/page.h
@@ -85,10 +85,8 @@ extern int sgc_enabled;
 
 extern long resv_pages;
 extern int reserve_pages_for_signal_handler;
-/* #define CONT_MARK_PAGE (((page(heap_end)-first_data_page)*(PAGESIZE/(CPTR_SIZE*CHAR_SIZE))+PAGESIZE-1)/PAGESIZE) */
-/* #define	available_pages	((fixnum)(real_maxpage-page(heap_end)-2*nrbpage-CONT_MARK_PAGE-resv_pages)) */
 
-extern struct pageinfo *cell_list_head,*cell_list_tail/* ,*contblock_list_head,*contblock_list_tail */;
+extern struct pageinfo *cell_list_head,*cell_list_tail;
 extern object contblock_array;
 
 #define PAGE_MAGIC 0x2e
--- gcl-2.6.12.orig/o/alloc.c
+++ gcl-2.6.12/o/alloc.c
@@ -506,31 +506,25 @@ rebalance_maxpages(struct typemanager *m
 
   if (j+d>phys_pages) {
 
-    ufixnum k=0;
+    ufixnum k,e=j+d-phys_pages;
+    double f;
 
-    for (i=t_start;i<t_other;i++)
+    for (k=0,i=t_start;i<t_other;i++)
       if (tm_table+i!=my_tm)
 	k+=(tm_table[i].tm_maxpage-tm_table[i].tm_npage)*(i==t_relocatable ? 2 : 1);
 
-    d=d>k+phys_pages-j ? k+phys_pages-j : d;
-    if (d<=0)
+    e=e>k ? k : e;
+    if (e+phys_pages-j<=0)
       return 0;
 
+    f=1.0-(double)e/k;
+
     for (i=t_start;i<t_other;i++)
-      if (tm_table[i].tm_npage) {
-	if (tm_table+i==my_tm) {
-	  massert(set_tm_maxpage(tm_table+i,z) || !fprintf(stderr,"%lu %lu %lu %lu %lu\n",i,z,tm_table[i].tm_npage,tm_table[i].tm_maxpage,available_pages));
-	} else {
-	  massert(set_tm_maxpage(tm_table+i,tm_table[i].tm_npage+(1.0-(double)(j+d-phys_pages)/k)*(tm_table[i].tm_maxpage-tm_table[i].tm_npage)));
+      if (tm_table[i].tm_npage && tm_table+i!=my_tm) {
+	  massert(set_tm_maxpage(tm_table+i,tm_table[i].tm_npage+f*(tm_table[i].tm_maxpage-tm_table[i].tm_npage)));
 	}
-      }
     
-    /* for (i=t_start;i<t_other;i++) */
-    /*   if (tm_table[i].tm_npage && tm_table[i].tm_npage>((double)phys_pages/(j+d))*(tm_table+i==my_tm ? z : tm_table[i].tm_maxpage)) */
-    /* 	return 0; */
-    /* for (i=t_start;i<t_other;i++) */
-    /*   if (tm_table[i].tm_npage) */
-    /* 	massert(set_tm_maxpage(tm_table+i,((double)phys_pages/(j+d))*(tm_table+i==my_tm ? z : tm_table[i].tm_maxpage))); */
+    massert(set_tm_maxpage(my_tm,(my_tm->tm_maxpage+(phys_pages-sum_maxpages()))/(my_tm->tm_type==t_relocatable ? 2 : 1)));
 
     return 1;