* scheme-io.texi: Removed obsolete section Binary IO. Added
[bpt/guile.git] / libguile / gc_os_dep.c
index f0e37bc..d05105a 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 /*
- * Copied from gc5.2, files "os_dep.c", "gc_priv.h"and "gcconfig.h",
+ * Copied from gc5.2, files "os_dep.c", "gc_priv.h", "mark.c" and "gcconfig.h",
  * and modified for Guile by Marius Vollmer.  
  */
 
@@ -45,6 +45,32 @@ typedef long GC_signed_word;
 typedef GC_word word;
 typedef GC_signed_word signed_word;
 
+typedef int GC_bool;
+# define TRUE 1
+# define FALSE 0
+
+#if defined(__STDC__)
+#   include <stdlib.h>
+#   if !(defined( sony_news ) )
+#       include <stddef.h>
+#   endif
+#   define VOLATILE volatile
+#else
+#   ifdef MSWIN32
+#      include <stdlib.h>
+#   endif
+#   define VOLATILE
+#endif
+
+/* Single argument version, robust against whole program analysis. */
+static void GC_noop1(x)
+word x;
+{
+    static VOLATILE word sink;
+
+    sink = x;
+}
+
 /* Machine dependent parameters.  Some tuning parameters can be found  */
 /* near the top of gc_private.h.                                       */
 
@@ -1353,16 +1379,21 @@ typedef GC_signed_word signed_word;
 # endif
 
 # if defined(LINUX) && !defined(POWERPC)
+
+# if 0 
 #   include <linux/version.h>
 #   if (LINUX_VERSION_CODE <= 0x10400)
-      /* Ugly hack to get struct sigcontext_struct definition.  Required      */
+      /* Ugly hack to get struct sigcontext_struct definition.  Required  */
       /* for some early 1.3.X releases.  Will hopefully go away soon. */
       /* in some later Linux releases, asm/sigcontext.h may have to   */
       /* be included instead.                                         */
 #     define __KERNEL__
 #     include <asm/signal.h>
 #     undef __KERNEL__
-#   else
+#  endif
+
+#  else
+
       /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */
       /* struct sigcontext.  libc6 (glibc2) uses "struct sigcontext" in     */
       /* prototypes, so we have to include the top-level sigcontext.h to    */
@@ -1388,7 +1419,6 @@ typedef GC_signed_word signed_word;
 #   endif
 # endif
 
-# include <stdio.h>
 # include <signal.h>
 
 /* Blatantly OS dependent routines, except for those that are related  */
@@ -1546,9 +1576,16 @@ void *scm_get_stack_base()
 {
     int dummy;
     ptr_t sp = (ptr_t)(&dummy);
-    ptr_t trunc_sp = (ptr_t)((word)sp & ~(GC_page_size - 1));
-    word size = GC_get_writable_length(trunc_sp, 0);
-   
+    ptr_t trunc_sp;
+    word size;
+    static word GC_page_size = 0;
+    if (!GC_page_size) {
+        SYSTEM_INFO sysinfo;
+        GetSystemInfo(&sysinfo);
+        GC_page_size = sysinfo.dwPageSize;
+    }
+    trunc_sp = (ptr_t)((word)sp & ~(GC_page_size - 1));
+    size = GC_get_writable_length(trunc_sp, 0);
     return(trunc_sp + size);
 }