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-3) unstable; urgency=high
 .
   * 2.6.11pre test 2
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/configure
+++ gcl-2.6.10/configure
@@ -4194,9 +4194,9 @@ fi
 if test "$GCC" = "yes" ; then
 	TCFLAGS="$TCFLAGS -pipe"
 	case $use in
-	     *mingw*)
-	        echo "WARNING: Remove -fno-zero-initialized-in-bss from makedefs if gcc less than 3.3.1."
-	        echo "         It is ptherwise needed for the Unexec stuff to work."
+	     *mingw*|*gnuwin*)
+#	        echo "WARNING: Remove -fno-zero-initialized-in-bss from makedefs if gcc less than 3.3.1."
+#	        echo "         It is otherwise needed for the Unexec stuff to work."
 #		if test "$enable_debug" = "yes" ; then TCFLAGS="$TCFLAGS -gstabs" ; fi
 		TCFLAGS="$TCFLAGS -fno-zero-initialized-in-bss -mms-bitfields";;
         esac
@@ -6349,6 +6349,9 @@ else
 
 	    #include <stdio.h>
             #include <unistd.h>
+            #ifdef __CYGWIN__
+            #define getpagesize() 4096
+            #endif
 
 int
 main ()
--- gcl-2.6.10.orig/configure.in
+++ gcl-2.6.10/configure.in
@@ -493,9 +493,9 @@ fi
 if test "$GCC" = "yes" ; then
 	TCFLAGS="$TCFLAGS -pipe"
 	case $use in
-	     *mingw*)
-	        echo "WARNING: Remove -fno-zero-initialized-in-bss from makedefs if gcc less than 3.3.1."
-	        echo "         It is ptherwise needed for the Unexec stuff to work."
+	     *mingw*|*gnuwin*)
+#	        echo "WARNING: Remove -fno-zero-initialized-in-bss from makedefs if gcc less than 3.3.1."
+#	        echo "         It is otherwise needed for the Unexec stuff to work."
 #		if test "$enable_debug" = "yes" ; then TCFLAGS="$TCFLAGS -gstabs" ; fi
 		TCFLAGS="$TCFLAGS -fno-zero-initialized-in-bss -mms-bitfields";;
         esac
@@ -1218,6 +1218,9 @@ AC_RUN_IFELSE([
 	AC_LANG_PROGRAM([[
 	    #include <stdio.h>
             #include <unistd.h>
+            #ifdef __CYGWIN__
+            #define getpagesize() 4096
+            #endif
 	    ]],[[
 	    size_t i=getpagesize(),j; 
 	    FILE *fp=fopen("conftest1","w");
--- gcl-2.6.10.orig/h/att_ext.h
+++ gcl-2.6.10/h/att_ext.h
@@ -287,7 +287,7 @@ EXTER object sSAsystem_directoryA;
 EXTER char *kcl_self;
 #endif
 #if !defined(IN_MAIN) || !defined(ATT)
-EXTER bool initflag,raw_image;
+EXTER bool raw_image;
 #endif
 char *merge_system_directory();
 
--- gcl-2.6.10.orig/h/gnuwin95.defs
+++ gcl-2.6.10/h/gnuwin95.defs
@@ -8,24 +8,27 @@ SHELL=bash
 
 LBINDIR=/usr/local/bin
 
-OFLAG	=  -O 
+#OFLAG	=  -O 
 #LIBS	= -lm 
-LIBC 	=
+#LIBC 	=
 
-ODIR_DEBUG= -O4
-ODIR_DEBUG= 
+#ODIR_DEBUG= -O4
+#ODIR_DEBUG= 
 
 # This CC string will be used for compilation of the system,
 # and also in the compiler::*cc* variable for later compilation of
 # lisp files.
-CC = gcc  -fwritable-strings  -DVOL=volatile  -I$(GCLDIR)/o -fsigned-char
-AS= as	
-AR= ar q
-RANLIB= ranlib
+#CC = gcc  -fwritable-strings  -DVOL=volatile  -I$(GCLDIR)/o -fsigned-char
+#AS= as	
+#AR= ar q
+#RANLIB= ranlib
 
 
 LDCC=${CC}
 
+# Unexec dependency
+UNIX_SAVE_DEP = unexnt.c
+
 # Enable the fastloading mechanism which does not use ld -A
 # requires c/rel_.. machine dependent code.
 
@@ -34,8 +37,8 @@ SFASL	= $(ODIR)/sfasl.o
 
 
 
-MPFILES= $(MPDIR)/mpi-386-winnt.o   $(MPDIR)/libmport.a
-MPFILES= $(MPDIR)/mpi.o   $(MPDIR)/libmport.a
+#MPFILES= $(MPDIR)/mpi-386-winnt.o   $(MPDIR)/libmport.a
+#MPFILES= $(MPDIR)/mpi.o   $(MPDIR)/libmport.a
 FIRST_FILE=$(ODIR)/firstfile.o
 LAST_FILE=$(ODIR)/lastfile.o
 
@@ -55,4 +58,4 @@ LIBFILES=bsearch.o
 KCP=kcp-bsd
 
 # using gcc so dont need
-GNULIB1=
+#GNULIB1=
--- gcl-2.6.10.orig/h/gnuwin95.h
+++ gcl-2.6.10/h/gnuwin95.h
@@ -3,9 +3,9 @@
 /* #include "386.h" */
 /* #include "fcntl.h" */
 
-#undef DBEGIN
-/* we want finer than config.h */
-#define DBEGIN 0x1a000000
+#define DBEGIN _dbegin
+#define DBEGIN_TY unsigned long
+extern DBEGIN_TY _dbegin;
 
 
 
@@ -19,8 +19,7 @@
 /* size to use for mallocs done  */
 /* #define BABY_MALLOC_SIZE 0x5000 */
 
-/* #define RECREATE_HEAP if (initflag) recreate_heap(argv[0]); */
-#define RECREATE_HEAP if (initflag) recreate_heap1();
+#define RECREATE_HEAP recreate_heap1();
 
 #ifdef IN_UNIXTIME
 #undef ATT
@@ -35,12 +34,6 @@
 #define BSD
 #endif
 
-#define NEED_TO_REINSTALL_SIGNALS 
-
-#ifndef SIGIO
-#define SIGIO 23
-#endif
-
 /* on most machines this will test in one instruction
    if the pointe/r is on the C stack or the 0 pointer
    in winnt our heap starts at DBEGIN
@@ -48,7 +41,7 @@
 /*  #define NULL_OR_ON_C_STACK(y)\ */
 /*      (((unsigned int)(y)) == 0 ||  \ */
 /*       (((unsigned int)(y)) < DBEGIN && ((unsigned int)(y)) &0xf000000)) */
-#define NULL_OR_ON_C_STACK(y) (((void *)(y)) < ((void *)0x400000))
+/* #define NULL_OR_ON_C_STACK(y) (((void *)(y)) < ((void *)0x400000)) */
      
       
 
@@ -58,16 +51,15 @@
 #define HAVE_SIGACTION
 /* a noop */
 #define SETUP_SIG_STACK
-#define SV_ONSTACK 0
-#if 0  /* Different definition in <sys/signal.h> - 2001-12-18 */
-#define SA_RESTART 0
-#endif
+#define SA_ONSTACK 0
 
 #define brk(x) printf("not doing break\n");
 #include <stdarg.h>     
 #include <stdio.h>
 #define UNIXSAVE "unexnt.c"
 
+#define MAXPATHLEN 260
+#define SEPARATE_SFASL_FILE "sfaslcoff.c"
 #define SPECIAL_RSYM "rsym_nt.c"
 
 #define HAVE_AOUT "wincoff.h"
@@ -92,6 +84,7 @@
 		
 #define FCLOSE_SETBUF_OK 
 
+#define RUN_PROCESS
 
 #define	IEEEFLOAT
   
@@ -99,10 +92,6 @@
 
 #define ADDITIONAL_FEATURES \
 		     ADD_FEATURE("I386"); ADD_FEATURE("WINNT")
-  
-#undef SET_REAL_MAXPAGE  
-#define SET_REAL_MAXPAGE \
-	real_maxpage=MAXPAGE;
 
 
 /* include some low level routines for maxima */
@@ -110,8 +99,12 @@
 
 #define RELOC_FILE "rel_coff.c"
 
-/*  FIONREAD not supported */
 #undef  LISTEN_FOR_INPUT
+#define LISTEN_FOR_INPUT(fp) do { \
+  int c = 0; \
+  if (((fp)->_r <= 0) && (ioctl((fp)->_file, FIONREAD, &c), c<=0)) \
+    return 0; \
+} while (0)
 
 /* adjust the start to the offset */
 #define ADJUST_RELOC_START(j) \
@@ -133,11 +126,22 @@
         error("Someone allocated my memory!");} \
 	if (core_end != (sbrk(PAGESIZE*(n - m))))
 
-  /* allow things like //c at beginning of pathnames, and c:/ */
-#define ALLOW_DRIVE_PATH
-
-
-#define USE_INTERNAL_REAL_TIME_FOR_RUNTIME     
+#include <limits.h>
+#include <sys/stat.h>
+#define GET_FULL_PATH_SELF(a_) do {\
+  char b[20];\
+  static char q[PATH_MAX];\
+  struct stat ss;\
+  if (snprintf(b,sizeof(b),"/proc/%d/exe",getpid())<=0)\
+    error("Cannot write proc exe pathname");\
+  if (stat(b,&ss)) \
+    (a_)=argv[0];\
+  else {\
+    if (!realpath(b,q)) \
+      error("realpath error");\
+    (a_)=q;\
+  }\
+} while(0)
 
 /* Begin for cmpinclude */
 
--- gcl-2.6.10.orig/h/mingw.h
+++ gcl-2.6.10/h/mingw.h
@@ -117,7 +117,7 @@ extern DBEGIN_TY _stacktop, _stackbottom
 /* use the slightly older unexec */
 #define UNIXSAVE "unexnt.c"
     
-#define RECREATE_HEAP if (initflag) { recreate_heap1(); \
+#define RECREATE_HEAP { recreate_heap1(); \
      terminal_io->sm.sm_object1->sm.sm_fp=stdout; \
      terminal_io->sm.sm_object0->sm.sm_fp=stdin; \
      init_shared_memory();}
--- gcl-2.6.10.orig/h/notcomp.h
+++ gcl-2.6.10/h/notcomp.h
@@ -13,7 +13,7 @@ EXTER int GBC_enable;
 EXTER object sSAnotify_gbcA;
 
 /* symbols which are not needed in compiled lisp code */
-EXTER int interrupt_flag,initflag,interrupt_enable;
+EXTER int interrupt_flag,interrupt_enable;
 void install_default_signals();
 /* void sigint(),sigalrm(); */
 void segmentation_catcher();
--- gcl-2.6.10.orig/h/protoize.h
+++ gcl-2.6.10/h/protoize.h
@@ -1785,7 +1785,7 @@ void recreate_heap1 ( void );
 void gcl_init_shared_memory ( void );
 void fix_filename ( object pathname, char *filename1 );
 void alarm ( int n );
-void *sbrk ( unsigned long increment );
+void *sbrk ( ptrdiff_t increment );
 void sigemptyset( sigset_t *set);
 void sigaddset ( sigset_t *set, int n);
 int sigismember ( sigset_t *set, int n );
--- gcl-2.6.10.orig/o/alloc.c
+++ gcl-2.6.10/o/alloc.c
@@ -1113,7 +1113,7 @@ gcl_init_alloc(void) {
   
   ncb = 0;
   ncbpage = 0;
-  set_tm_maxpage(tm_table+t_contiguous,19);
+  set_tm_maxpage(tm_table+t_contiguous,100);
 #ifdef GCL_GPROF
   if (maxcbpage<textpage)
     set_tm_maxpage(tm_table+t_contiguous,textpage);
@@ -1588,7 +1588,7 @@ malloc(size_t size) {
     return baby_malloc(size);
 #else	
 
-    if (!initflag)
+    if (raw_image)
       gcl_init_alloc();
 #ifdef RECREATE_HEAP
     else RECREATE_HEAP
@@ -1611,7 +1611,7 @@ malloc(size_t size) {
      startup.  In saved images, monstartup memory is only
      allocated with gprof-start. 20040804 CM*/
 #ifdef GCL_GPROF
-  if (!initflag && size>(textend-textstart) && !initial_monstartup_pointer) 
+  if (raw_image && size>(textend-textstart) && !initial_monstartup_pointer) 
     initial_monstartup_pointer=malloc_list->c.c_car->st.st_self;
   if (gprof_array==Cnil && capture_gprof_array && size>(textend-textstart)) {
     gprof_array=malloc_list->c.c_car;
--- gcl-2.6.10.orig/o/assignment.c
+++ gcl-2.6.10/o/assignment.c
@@ -156,7 +156,7 @@ DEFUNO_NEW("FSET",object,fSfset,SI
 	}
 	sym = clear_compiler_properties(sym,function);
 	if (sym->s.s_hpack == lisp_package &&
-	    sym->s.s_gfdef != OBJNULL && initflag) {
+	    sym->s.s_gfdef != OBJNULL && !raw_image) {
 		ifuncall2(sLwarn,make_simple_string("~S is being redefined."),
 			 sym);
 	}
@@ -247,7 +247,7 @@ DEFUNO_NEW("FMAKUNBOUND",object,fLfmakun
 	remf(&(sym->s.s_plist),sStraced);
 	clear_compiler_properties(sym,Cnil);
 	if (sym->s.s_hpack == lisp_package &&
-	    sym->s.s_gfdef != OBJNULL && initflag) {
+	    sym->s.s_gfdef != OBJNULL && !raw_image) {
 		ifuncall2(sLwarn, make_simple_string(
 			"~S is being redefined."), sym);
 	}
--- gcl-2.6.10.orig/o/error.c
+++ gcl-2.6.10/o/error.c
@@ -37,7 +37,7 @@ object sSterminal_interrupt;
 void
 assert_error(const char *a,unsigned l,const char *f,const char *n) {
 
-  if (initflag)
+  if (!raw_image)
     FEerror("The assertion ~a on line ~a of ~a in function ~a failed",4,
 	    make_simple_string(a),make_fixnum(l),
 	    make_simple_string(f),make_simple_string(n));
--- gcl-2.6.10.orig/o/file.d
+++ gcl-2.6.10/o/file.d
@@ -1252,7 +1252,7 @@ BEGIN:
 
 #ifdef HAVE_READLINE
 	  if (readline_on && strm->sm.sm_fp==rl_instream)
-	    return *rl_line_buffer ? TRUE : FALSE;
+	    if (rl_line_buffer) return *rl_line_buffer ? TRUE : FALSE;
 #endif
 		if (strm->sm.sm_fp == NULL)
 			closed_stream(strm);
--- gcl-2.6.10.orig/o/firstfile.c
+++ gcl-2.6.10/o/firstfile.c
@@ -21,7 +21,6 @@ Boston, MA 02111-1307, USA.  */
 
 #include "config.h"
 
-#ifdef _WIN32
 /* See comments in lastfile.c.  */
 char my_begdata[] = "Beginning of Emacs initialized data";
 char my_begbss[1];  /* Do not initialize this variable.  */
@@ -33,4 +32,3 @@ char * my_begbss_static = _my_begbss;
 extern int initialized;
 static int * dummy = &initialized;
 #endif
-#endif
--- gcl-2.6.10.orig/o/lastfile.c
+++ gcl-2.6.10/o/lastfile.c
@@ -40,7 +40,6 @@ Boston, MA 02111-1307, USA.  */
 
 char my_edata[] = "End of Emacs initialized data";
 
-#ifdef _WIN32
 /* Help unexec locate the end of the .bss area used by Emacs (which
    isn't always a separate section in NT executables).  */
 char my_endbss[1];
@@ -49,4 +48,3 @@ char my_endbss[1];
    of the bss area used by Emacs.  */
 static char _my_endbss[1];
 char * my_endbss_static = _my_endbss;
-#endif
--- gcl-2.6.10.orig/o/macros.c
+++ gcl-2.6.10/o/macros.c
@@ -45,7 +45,7 @@ FFN(siLdefine_macro)(void)
 	}
 	clear_compiler_properties(vs_base[0],MMcaddr(vs_base[1]));
 	if (vs_base[0]->s.s_hpack == lisp_package &&
-	    vs_base[0]->s.s_gfdef != OBJNULL && initflag) {
+	    vs_base[0]->s.s_gfdef != OBJNULL && !raw_image) {
 		vs_push(make_simple_string(
 			"~S is being redefined."));
 		ifuncall2(sLwarn, vs_head, vs_base[0]);
@@ -104,7 +104,7 @@ FFN(Fdefmacro)(object form)
 	}
 	clear_compiler_properties(name,MMcaddr(top[0]));
 	if (name->s.s_hpack == lisp_package &&
-	    name->s.s_gfdef != OBJNULL && initflag) {
+	    name->s.s_gfdef != OBJNULL && !raw_image) {
 		vs_push(make_simple_string(
 			"~S is being redefined."));
 		ifuncall2(sLwarn, vs_head, name);
--- gcl-2.6.10.orig/o/main.c
+++ gcl-2.6.10/o/main.c
@@ -78,8 +78,7 @@ char stdin_buf[BUFSIZ + EXTRA_BUFSIZE];
 char stdout_buf[BUFSIZ + EXTRA_BUFSIZE];
 
 int debug;			/* debug switch */
-int initflag = FALSE;		/* initialized flag */
-int raw_image = FALSE;		/* raw or saved image */
+int raw_image = TRUE;		/* raw or saved image -- CYGWIN will only place this in .data and not in .bss if initialized to non-zero */
 
 long real_maxpage;
 object sSAlisp_maxpagesA;
@@ -96,6 +95,9 @@ static object stack_space;
 #ifdef _WIN32
 unsigned int _dbegin = 0x10100000;
 #endif
+#ifdef __CYGWIN__
+unsigned long _dbegin = 0;
+#endif
 
 int cssize;
 
@@ -267,7 +269,7 @@ main(int argc, char **argv, char **envp)
 #endif
 
 #ifdef RECREATE_HEAP
-	RECREATE_HEAP
+	if (!raw_image) RECREATE_HEAP
 #endif
 	
 #ifdef UNIX
@@ -322,7 +324,7 @@ main(int argc, char **argv, char **envp)
 	ENVP = envp;
 #endif
 
-	if (!initflag) {
+	if (raw_image) {
 
 		system_directory= (char *) malloc(strlen(argv[1])+3);
 					
@@ -355,7 +357,7 @@ main(int argc, char **argv, char **envp)
 
 #endif
 
-	if (!initflag && argc > 1) {
+	if (raw_image && argc > 1) {
 #ifdef UNIX
 		if (argv[1][strlen(argv[1])-1] != '/')
 #endif
@@ -472,7 +474,7 @@ main(int argc, char **argv, char **envp)
 	  error("Cannot setup gprof_cleanup on exit");
 #endif
 
-	if (initflag) {
+	if (!raw_image) {
 
 #ifdef _WIN32
 	  detect_wine();
@@ -495,7 +497,6 @@ main(int argc, char **argv, char **envp)
 #endif			  
 		}
 
-		initflag = FALSE;
 		GBC_enable = TRUE;
 		vs_base = vs_top;
 		ihs_push(Cnil);
@@ -506,7 +507,6 @@ main(int argc, char **argv, char **envp)
 		install_default_signals();
 
 		sSAlisp_maxpagesA->s.s_dbind = make_fixnum(real_maxpage);
-		initflag = TRUE;
 #ifdef KCLOVM
 		ovm_user_context_change = change_contexts;
 		ovm_user_context_initialize = initialize_process;
@@ -557,12 +557,9 @@ main(int argc, char **argv, char **envp)
 
 	lex_new();
 	vs_base = vs_top;
-	initflag = TRUE;
 
 	interrupt_enable = TRUE;
 
-	raw_image=TRUE;
-
 	super_funcall(sStop_level);
 
 	return 0;
@@ -605,6 +602,8 @@ static void
 initlisp(void) {
 
         void *v=&v;
+	
+	gcl_init_alloc();
 
 	if (NULL_OR_ON_C_STACK(v) == 0
 #if defined(IM_FIX_BASE)
@@ -630,8 +629,6 @@ initlisp(void) {
 	  error("NULL_OR_ON_C_STACK macro invalid");
 	}
 	
-	gcl_init_alloc();
-	
 	Cnil->fw=0;
 	set_type_of(Cnil,t_symbol);
  	Cnil->c.c_cdr=Cnil;
--- gcl-2.6.10.orig/o/ntheap.h
+++ gcl-2.6.10/o/ntheap.h
@@ -60,7 +60,7 @@ enum {
 extern int os_subtype;
 
 /* Emulation of Unix sbrk().  */
-extern void *sbrk (unsigned long size);
+extern void *sbrk (ptrdiff_t size);
 
 /* Recreate the heap created during dumping.  */
 extern void recreate_heap (char *executable_path);
--- gcl-2.6.10.orig/o/pathname.d
+++ gcl-2.6.10/o/pathname.d
@@ -25,6 +25,7 @@ Foundation, 675 Mass Ave, Cambridge, MA
 	This file contains those functions that interpret namestrings.
 */
 
+#include <string.h>
 #include "include.h"
 
 
@@ -400,7 +401,7 @@ N:
 #ifdef FIX_FILENAME
         {char buf[MAXPATHLEN];
          if (i > MAXPATHLEN-1) i =MAXPATHLEN-1;
-         bcopy(token->st.st_self,buf,i);
+         memcpy(buf,token->st.st_self,i);
          buf[i]=0;
          FIX_FILENAME(x,buf);
          return (make_simple_string(buf));
--- gcl-2.6.10.orig/o/run_process.c
+++ gcl-2.6.10/o/run_process.c
@@ -386,7 +386,11 @@ int	server;
 		FEerror("Connection Failed.",0);
 	}
 	pid = getpid();
+#ifdef __CYGWIN__
+	if(fcntl(sock, F_SETOWN, pid) < 0)
+#else
 	if(ioctl(sock, SIOCSPGRP, (char *)&pid) < 0 )
+#endif
 	{
 		FEerror("Could not set process group of socket.",0);
 	}
--- gcl-2.6.10.orig/o/save.c
+++ gcl-2.6.10/o/save.c
@@ -16,38 +16,31 @@ memory_save(char *original_file, char *s
 extern void _cleanup();
 #endif
 
-LFD(Lsave)(void)
-{
-	char filename[256];
-        extern char *kcl_self ;
-	check_arg(1);
-	check_type_or_pathname_string_symbol_stream(&vs_base[0]);
-	coerce_to_filename(vs_base[0], filename);
+LFD(Lsave)(void) {
+
+  char filename[256];
+  extern char *kcl_self;
+
+  check_arg(1);
+  check_type_or_pathname_string_symbol_stream(&vs_base[0]);
+  coerce_to_filename(vs_base[0], filename);
+
 #ifdef CLEANUP_CODE
-	CLEANUP_CODE
-#else
-#ifdef USE_CLEANUP
-	_cleanup();
-#endif	
+  CLEANUP_CODE
+#elif defined(USE_CLEANUP)
+    _cleanup();
 #endif
+  
+  raw_image=FALSE;
+  cs_org=0;
 
-	if (raw_image) {
-
-	  raw_image=FALSE;
 #ifdef MEMORY_SAVE
-	  MEMORY_SAVE(kcl_self,filename);
+    MEMORY_SAVE(kcl_self,filename);
 #else	  
-	  memory_save(kcl_self, filename);
+    memory_save(kcl_self, filename);
 #endif	
-	  raw_image=TRUE;
 
-	} else {
-#ifdef MEMORY_SAVE
-	  MEMORY_SAVE(kcl_self,filename);
-#else	  
-	  memory_save(kcl_self, filename);
-#endif	
-	}
-	exit(0);
-	/*  no return  */
+  /*  no return  */
+  exit(0);
+
 }
--- gcl-2.6.10.orig/o/symbol.d
+++ gcl-2.6.10/o/symbol.d
@@ -56,7 +56,7 @@ object st;
 	x->s.s_stype = (short)stp_ordinary;
 	x->s.s_mflag = FALSE;
 	vs_push(x);
-	if (initflag==0 && st->st.st_self < heap_end)
+	if (raw_image && st->st.st_self < heap_end)
 		x->s.s_self = st->st.st_self;		
 	else {
 		x->s.s_self = alloc_relblock(x->s.s_fillp);
--- gcl-2.6.10.orig/o/toplevel.c
+++ gcl-2.6.10/o/toplevel.c
@@ -60,7 +60,7 @@ FFN(Fdefun)(object args)
 		 FEerror("~S, a special form, cannot be redefined.", 1, name);
 	}
 	if (name->s.s_hpack == lisp_package &&
-	    name->s.s_gfdef != OBJNULL && initflag) {
+	    name->s.s_gfdef != OBJNULL && !raw_image) {
 		vs_push(make_simple_string(
 			"~S is being redefined."));
 		ifuncall2(sLwarn, vs_head, name);
--- gcl-2.6.10.orig/o/unexnt.c
+++ gcl-2.6.10/o/unexnt.c
@@ -110,7 +110,6 @@ void recreate_heap1()
       printf ("Failed to find path for executable.\n");
       exit (1);
     }
-
     recreate_heap (executable_path);
   }
   heap_state = HEAP_LOADED;
@@ -970,20 +969,29 @@ allocate_heap (void)
      the region below the 256MB line for our malloc arena - 229MB is
      still a pretty decent arena to play in!  */
 
-  void *base = (void *)0x20000000,*ptr;/*FIXME, someday figure out how to let the heap start address default *//*(void *)0x10100000*/
+#if defined(__CYGWIN__)
+#define PROBE_BASE NULL
+#elif defined(__MINGW32__)
+#define PROBE_BASE (void *)0x20000000
+#else
+#error Need PROBE_BASE
+#endif
+
+  void *base = PROBE_BASE,*ptr;/*FIXME, someday figure out how to let the heap start address default *//*(void *)0x10100000*/
 
   reserved_heap_size=probe_heap_size(base,PAGESIZE,(1UL<<31),-1);
   ptr = VirtualAlloc ((void *) base,get_reserved_heap_size (),MEM_RESERVE,PAGE_NOACCESS);
-  printf("probe results: %lu at %p\n",reserved_heap_size,ptr);
+  /* printf("probe results: %lu at %p\n",reserved_heap_size,ptr); */
 
   DBEGIN = (DBEGIN_TY) ptr;
 
   return ptr;
+
 }
 
 /* Emulate Unix sbrk.  */
 void *
-sbrk (unsigned long increment)
+sbrk (ptrdiff_t increment)
 {
   void *result;
   long size = (long) increment;
@@ -1061,11 +1069,16 @@ sbrk (unsigned long increment)
   return result;
 }
 
+#ifdef __CYGWIN__
+/* Emulate Unix getpagesize.  */
+int getpagesize (void) { return 4096; }
+#endif
+
 /* Recreate the heap from the data that was dumped to the executable.
    EXECUTABLE_PATH tells us where to find the executable.  */
 void
-recreate_heap (char *executable_path)
-{
+recreate_heap (char *executable_path) {
+
   unsigned char *tmp;
 
   /* First reserve the upper part of our heap.  (We reserve first
@@ -1088,6 +1101,7 @@ recreate_heap (char *executable_path)
 
   /* Update system version information to match current system.  */
   cache_system_info ();
+
 }
 
 /* Round the heap up to the given alignment.  */
--- gcl-2.6.10.orig/o/unixtime.c
+++ gcl-2.6.10/o/unixtime.c
@@ -275,6 +275,12 @@ DEFUN_NEW("CURRENT-TIMEZONE",fixnum,fScu
   
 #elif defined NO_SYSTEM_TIME_ZONE
   return 0;
+#elif defined __CYGWIN__
+  struct tm gt,lt;
+  fixnum _t=0;
+  gmtime_r(&_t, &gt);
+  localtime_r(&_t, &lt);
+  return (lt.tm_mday == gt.tm_mday) ? -(lt.tm_hour) : (24 - lt.tm_hour);
 #else
   fixnum _t=time(0);
   return -localtime(&_t)->tm_gmtoff/3600;
--- gcl-2.6.10.orig/o/xdrfuns.c
+++ gcl-2.6.10/o/xdrfuns.c
@@ -24,7 +24,11 @@ License for more details.
 #ifdef AIX3
 #include <sys/select.h>
 #endif
+#ifdef __CYGWIN__
+#include <rpc/xdr.h>
+#else  /* __CYGWIN__ */
 #include <rpc/rpc.h>
+#endif /* __CYGWIN__ */
 
 extern short aet_sizes[];
 static object
