385abae
Description: <short summary of the patch>
385abae
 TODO: Put a short summary on the line above and replace this paragraph
385abae
 with a longer explanation of this change. Complete the meta-information
385abae
 with other relevant fields (see below for details). To make it easier, the
385abae
 information below has been extracted from the changelog. Adjust it or drop
385abae
 it.
385abae
 .
385abae
 gcl (2.6.12-24) unstable; urgency=medium
385abae
 .
385abae
   * Version_2_6_13pre30
385abae
Author: Camm Maguire <camm@debian.org>
385abae
385abae
---
385abae
The information above should follow the Patch Tagging Guidelines, please
385abae
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
385abae
are templates for supplementary fields that you might want to add:
385abae
385abae
Origin: <vendor|upstream|other>, <url of original patch>
385abae
Bug: <url in upstream bugtracker>
385abae
Bug-Debian: https://bugs.debian.org/<bugnumber>
385abae
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
385abae
Forwarded: <no|not-needed|url proving that it has been forwarded>
385abae
Reviewed-By: <name and email of someone who approved the patch>
385abae
Last-Update: <YYYY-MM-DD>
385abae
385abae
--- gcl-2.6.12.orig/h/386-kfreebsd.h
385abae
+++ gcl-2.6.12/h/386-kfreebsd.h
385abae
@@ -46,3 +46,4 @@
385abae
 #define RELOC_H "elf32_i386_reloc.h"
385abae
 
385abae
 #define BRK_DOES_NOT_GUARANTEE_ALLOCATION
385abae
+#define FREEBSD
385abae
--- gcl-2.6.12.orig/h/amd64-kfreebsd.h
385abae
+++ gcl-2.6.12/h/amd64-kfreebsd.h
385abae
@@ -23,3 +23,4 @@
385abae
 #define RELOC_H "elf64_i386_reloc.h"
385abae
 
385abae
 #define BRK_DOES_NOT_GUARANTEE_ALLOCATION
385abae
+#define FREEBSD
385abae
--- gcl-2.6.12.orig/h/elf64_mips_reloc_special.h
385abae
+++ gcl-2.6.12/h/elf64_mips_reloc_special.h
385abae
@@ -23,7 +23,6 @@ write_stub(ul s,ul *got,ul *gote) {
385abae
   call_16_tramp *t=(void *)gote;
385abae
 
385abae
   *t=t1;
385abae
-  *got=can_gp;
385abae
 
385abae
   t->entry=(ul)(gote+2);
385abae
   t->gotoff=s;
385abae
--- gcl-2.6.12.orig/o/main.c
385abae
+++ gcl-2.6.12/o/main.c
385abae
@@ -152,6 +152,7 @@ mbrk(void *v) {
385abae
 
385abae
 static ufixnum
385abae
 get_phys_pages_no_malloc(char n) {
385abae
+
385abae
   MEMORYSTATUS m;
385abae
 
385abae
   m.dwLength=sizeof(m);
385abae
@@ -166,6 +167,7 @@ get_phys_pages_no_malloc(char n) {
385abae
 
385abae
 static ufixnum
385abae
 get_phys_pages_no_malloc(char n) {
385abae
+
385abae
   uint64_t s;
385abae
   size_t z=sizeof(s);
385abae
   int m[2]={CTL_HW,HW_MEMSIZE};
385abae
@@ -186,33 +188,30 @@ get_phys_pages_no_malloc(char n) {
385abae
 
385abae
 }
385abae
 
385abae
-#else 
385abae
+#elif defined(FREEBSD)
385abae
+
385abae
+#include <sys/types.h>
385abae
+#include <sys/sysctl.h>
385abae
+
385abae
+static ufixnum
385abae
+get_phys_pages_no_malloc(char n) {
385abae
+
385abae
+  size_t i,len=sizeof(i);
385abae
 
385abae
-ufixnum
385abae
-get_proc_meminfo_value_in_pages(const char *k) {
385abae
-  int l,m;
385abae
-  char b[PAGESIZE],*c;
385abae
-  ufixnum n;
385abae
+  return (sysctlbyname("hw.physmem",&i,&len,NULL,0) ? 0 : i)>>PAGEWIDTH;
385abae
   
385abae
-  massert((l=open("/proc/meminfo",O_RDONLY))!=-1);
385abae
-  massert((n=read(l,b,sizeof(b)))
385abae
-  b[n]=0;
385abae
-  massert(!close(l));
385abae
-  massert((c=strstr(b,k)));
385abae
-  c+=strlen(k);
385abae
-  massert(sscanf(c,"%lu%n",&n,&m)==1);
385abae
-  massert(!strncmp(c+m," kB\n",4));
385abae
-  return n>>(PAGEWIDTH-10);
385abae
 }
385abae
 
385abae
+#else /*Linux*/
385abae
+
385abae
 #include <sys/sysinfo.h>
385abae
 
385abae
 static ufixnum
385abae
 get_phys_pages_no_malloc(char freep) {
385abae
 
385abae
   struct sysinfo s;
385abae
-  sysinfo(&s);
385abae
-  return ((freep ? s.freeram : s.totalram)>>PAGEWIDTH)*s.mem_unit;
385abae
+
385abae
+  return sysinfo(&s) ? 0 : ((freep ? s.freeram : s.totalram)>>PAGEWIDTH)*s.mem_unit;
385abae
   
385abae
 }
385abae