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-2) unstable; urgency=medium
 .
   * Version_2_6_13pre1
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/bsd.h
+++ gcl-2.6.12/h/bsd.h
@@ -33,39 +33,7 @@ filecpy(save, original, stsize - sizeof(
 
 extern char etext;
 
-
-
-
-/* #define SET_REAL_MAXPAGE do { struct rlimit data_rlimit; \ */
-/* 				extern char etext; \ */
-/* 			     real_maxpage = MAXPAGE ; \ */
-/*      	getrlimit(RLIMIT_DATA, &data_rlimit); \ */
-/* 	real_maxpage = ((unsigned int)&etext/PAGESIZE + data_rlimit.rlim_cur/PAGESIZE); \ */
-/* 	if (real_maxpage > MAXPAGE) \ */
-/* 		real_maxpage = MAXPAGE ; } while(0) */
-     
-#define ROUND_UP_SBRK(x)  \
-       do {long i; \
-	     if ((i = ((long)x & (PAGESIZE - 1)))) \
-	       x=sbrk(PAGESIZE - i); } while(0);
-
-#define FIX_RANDOM_SBRK \
-do {char *x=sbrk(0); \
-  if (core_end != x) \
-   { ROUND_UP_SBRK(x); x=sbrk(0);\
-     while (core_end < x) \
-       { \
-	 core_end = core_end + PAGESIZE;} \
-     if (core_end !=x) error("Someone allocated my memory");}} while (0)
- 
-     
-#define INIT_ALLOC \
-     	heap_end = sbrk(0); ROUND_UP_SBRK(heap_end);\
-	heap_end = core_end = sbrk(0);
-
-#define IF_ALLOCATE_ERR \
-        FIX_RANDOM_SBRK; \
-	if (core_end != sbrk(PAGESIZE*(n - m)))
+#define INIT_ALLOC heap_end = core_end = sbrk(0);
 
 #define SYM_EXTERNAL_P(sym) ((sym)->n_type & N_EXT)
      
--- gcl-2.6.12.orig/h/protoize.h
+++ gcl-2.6.12/h/protoize.h
@@ -1935,3 +1935,6 @@ empty_relblock(void);
 
 fixnum
 check_avail_pages(void);
+
+inline int
+mbrk(void *);
--- gcl-2.6.12.orig/o/alloc.c
+++ gcl-2.6.12/o/alloc.c
@@ -223,61 +223,53 @@ resize_hole(ufixnum hp,enum type tp) {
 inline void *
 alloc_page(long n) {
 
-  fixnum d,m;
-
-  if (n>=0) {
+  bool s=n<0;
+  ufixnum nn=s ? -n : n;
+  void *v,*e;
+  
+  if (!s) {
 
-    if (n>(holepage - (in_signal_handler? 0 :
+    if (nn>(holepage - (in_signal_handler? 0 :
 		       available_pages-n<=reserve_pages_for_signal_handler ? 0 : 
 		       reserve_pages_for_signal_handler))) {
 
 
-      if (in_signal_handler) {
-	fprintf(stderr,"Cant do relocatable gc in signal handler. \
-Try to allocate more space to save for allocation during signals: \
-eg to add 20 more do (si::set-hole-size %ld %d)\n...start over ", 
-		new_holepage, 20+ reserve_pages_for_signal_handler); fflush(stderr); exit(1);
-      }
-
+      fixnum d=available_pages-nn;
 
-      d=available_pages-n;
       d*=0.2;
       d=d<0.01*real_maxpage ? available_pages-n : d;
       d=d<0 ? 0 : d;
       d=new_holepage<d ? new_holepage : d;
       
-      resize_hole(d+n,t_relocatable);
-
-    }
+      if (in_signal_handler)/*FIXME*/
+	fprintf(stderr,"Can't do relocatable gc in signal handler. \
+Try to allocate more space to save for allocation during signals: \
+eg to add 20 more do (si::set-hole-size %ld %d)\n...start over ", 
+		new_holepage, 20+ reserve_pages_for_signal_handler); fflush(stderr); exit(1);
 
-    holepage -= n;
+      resize_hole(d+nn,t_relocatable);
 
-    if (heap_end==core_end) {
-      /* can happen when mallocs occur before rel block set up..*/
-      sbrk(PAGESIZE*n);
-      core_end+=PAGESIZE*n;
     }
+  }
 
-    {
-      void *e=heap_end;
-      heap_end+=PAGESIZE*n;
+  e=heap_end;
+  v=e+nn*PAGESIZE;
 
-      return(e);
-    }
+  if (!s) {
 
-  }
+    holepage -= nn;
+    heap_end=v;
+    return e;
 
-  /* n < 0 , then this says ensure there are -n pages
-     starting at heap_end, and return pointer to heap_end */
-  n=-n;
-  m=(core_end-heap_end)/PAGESIZE;
+  }
 
-  if (n<=m)
+  if (nn<=(core_end-heap_end)/PAGESIZE)
     return(heap_end);
 
-  IF_ALLOCATE_ERR error("Can't allocate.  Good-bye!");
+  if (mbrk(v))
+    error("Can't allocate.  Good-bye!");
 
-  core_end+=PAGESIZE*(n-m);
+  core_end=v;
 
   return(heap_end);
 
@@ -692,7 +684,7 @@ print_cb(int print) {
     massert(**cbppp==cbp);
     for (k=0;cbp && cbp->cb_size==(**cbppp)->cb_size;cbpp=&cbp->cb_link,cbp=cbp->cb_link,k++);
     if (print)
-      fprintf(stderr,"%lu %p %p %lu %lu\n",cbppp-cbsrch1,*cbppp,**cbppp,(**cbppp)->cb_size,k);
+      fprintf(stderr,"%lu %p %p %lu %lu\n",(unsigned long)(cbppp-cbsrch1),*cbppp,**cbppp,(**cbppp)->cb_size,k);
   }
   massert(cbppp==cbsrche);
   massert(*cbppp==cbpp);
--- gcl-2.6.12.orig/o/main.c
+++ gcl-2.6.12/o/main.c
@@ -120,6 +120,7 @@ fixnum log_maxpage_bound=sizeof(fixnum)*
 
 inline int
 mbrk(void *v) {
+
   ufixnum uv=(ufixnum)v,uc=(ufixnum)sbrk(0),ux,um;
   fixnum m=((1UL<<(sizeof(fixnum)*8-1))-1);
 
@@ -134,9 +135,12 @@ mbrk(void *v) {
     um=uc;
     ux=uv;
   }
+
   if (((fixnum)(ux-um))<0)
     return mbrk((void *)uc+(uv<uc ? -m : m)) || mbrk(v);
+
   return uc==(ufixnum)sbrk(uv-uc) ? 0 : -1;
+
 }
     
 #if defined(__CYGWIN__)||defined(__MINGW32__)
@@ -451,7 +455,6 @@ main(int argc, char **argv, char **envp)
 #ifdef NEED_STACK_CHK_GUARD
     __stack_chk_guard=random_ulong();/*Cannot be safely set inside a function which returns*/
 #endif
-    allocate_code_block_reserve();
   
   }
 
--- gcl-2.6.12.orig/o/sfaslelf.c
+++ gcl-2.6.12/o/sfaslelf.c
@@ -268,20 +268,6 @@ alloc_memory(ul sz) {
 
 }
 
-void
-allocate_code_block_reserve(void) {
-
-  const char *s=getenv("GCL_CODESPACE");
-  ul n;
-
-  if (!s || sscanf(s,"%lu",&n)!=1)
-    return;
-
-  sSAcode_block_reserveA->s.s_dbind=alloc_simple_string(n);
-  sSAcode_block_reserveA->s.s_dbind->st.st_self=alloc_memory(n);
-
-}
-
 static object
 load_memory(Shdr *sec1,Shdr *sece,void *v1,ul **got,ul **gote) {