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.10-39) unstable; urgency=medium
 .
   * earlier prelink_init, phys_pages w/o malloc
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: http://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.10.orig/h/386-kfreebsd.h
+++ gcl-2.6.10/h/386-kfreebsd.h
@@ -60,7 +60,4 @@
 
 #define RELOC_H "elf32_i386_reloc.h"
 
-#ifndef HAVE_SYSCONF_PHYS_PAGES
-#error need SYSCONF_PHYS_PAGES to set real_maxpage
-#endif
 #define BRK_DOES_NOT_GUARANTEE_ALLOCATION
--- gcl-2.6.10.orig/h/amd64-kfreebsd.h
+++ gcl-2.6.10/h/amd64-kfreebsd.h
@@ -36,8 +36,4 @@
 
 #define RELOC_H "elf64_i386_reloc.h"
 
-
-#ifndef HAVE_SYSCONF_PHYS_PAGES
-#error need SYSCONF_PHYS_PAGES to set real_maxpage
-#endif
 #define BRK_DOES_NOT_GUARANTEE_ALLOCATION
--- gcl-2.6.10.orig/o/main.c
+++ gcl-2.6.10/o/main.c
@@ -139,6 +139,46 @@ mbrk(void *v) {
   return uc==(ufixnum)sbrk(uv-uc) ? 0 : -1;
 }
     
+#if defined(__CYGWIN__)||defined(__MINGW32__)
+
+#include <Windows.h>
+
+ufixnum
+get_phys_pages_no_malloc(void) {
+  MEMORYSTATUS m;
+
+  m.dwLength=sizeof(m);
+  GlobalMemoryStatus(&m);
+  return m.dwTotalPhys>>PAGEWIDTH;
+
+}
+
+#elif defined (DARWIN)
+
+#include <sys/sysctl.h>
+
+ufixnum
+get_phys_pages_no_malloc(void) {
+  uint64_t s;
+  size_t z=sizeof(s);
+  int m[2]={CTL_HW,HW_MEMSIZE};
+  
+  if (sysctl(m,2,&s,&z,NULL,0)==0)
+    return s>>PAGEWIDTH;
+
+}
+
+#elif defined(__sun__)
+
+ufixnum
+get_phys_pages_no_malloc(void) {
+
+  return sysconf(_SC_PHYS_PAGES);
+
+}
+
+#else 
+
 ufixnum
 get_phys_pages_no_malloc(void) {
   int l;
@@ -157,6 +197,7 @@ get_phys_pages_no_malloc(void) {
   return res>>(PAGEWIDTH-10);
 }
 
+#endif
 
 int
 update_real_maxpage(void) {
