From owner-ntemacs-users@june  Wed Sep 25 07:52:21 1996
X-VM-v5-Data: ([nil nil nil nil t nil nil nil nil]
	[nil "Wed" "25" "September" "1996" "14:55:35" "+0100" "Pat Knight" "pat@ktgroup.co.uk" "<1.5.4.32.19960925135535.0068f330@vcsmail>" "57" "Re: Building NT Emacs 19.34 on Windows 95" "^From:" nil nil "9" nil nil nil nil]
	nil)
Received: from joker.cs.washington.edu (joker.cs.washington.edu [128.95.1.42]) by june.cs.washington.edu (8.7.5/7.2ju) with SMTP id HAA02978 for <voelker@june.cs.washington.edu>; Wed, 25 Sep 1996 07:52:21 -0700
Received: from june.cs.washington.edu (june.cs.washington.edu [128.95.1.4]) by joker.cs.washington.edu (8.6.12/7.2ws+) with ESMTP id HAA16449 for <voelker@joker.cs.washington.edu>; Wed, 25 Sep 1996 07:52:19 -0700
Received: from tcupboard.ktgroup.co.uk (www.ktgroup.co.uk [194.70.85.1]) by june.cs.washington.edu (8.7.5/7.2ju) with ESMTP id GAA28685 for <ntemacs-users@cs.washington.edu>; Wed, 25 Sep 1996 06:55:43 -0700
Received: from lurch.ktgroup.co.uk (lurch.ktgroup.co.uk [194.70.85.4]) by tcupboard.ktgroup.co.uk (8.7.4/8.7.3) with ESMTP id OAA06454 for <ntemacs-users@cs.washington.edu>; Wed, 25 Sep 1996 14:55:37 +0100
Received: from pcpat.ktgroup.co.uk (pcpat.ktgroup.co.uk [194.70.85.30]) by lurch.ktgroup.co.uk (8.7.4/8.7.3) with SMTP id OAA03875 for <ntemacs-users@cs.washington.edu>; Wed, 25 Sep 1996 14:55:35 +0100
Message-Id: <1.5.4.32.19960925135535.0068f330@vcsmail>
X-Sender: pat@vcsmail
X-Mailer: Windows Eudora Light Version 1.5.4 (32)
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
From: Pat Knight <pat@ktgroup.co.uk>
To: ntemacs-users@cs.washington.edu
Subject: Re: Building NT Emacs 19.34 on Windows 95
Date: Wed, 25 Sep 1996 14:55:35 +0100

In a message sent at 10:30 25/09/96 +0100, I wrote that:
>I'm trying to build NT Emacs 19.34 on Windows 95 so that I can modify the
>packages in loaddefs before dumping. I'm using MSVC++ 4.2. The make runs
>fine up to the point where temacs is called to do the loadup and dump.
>temacs fails to start up correctly as the Emacs internal malloc cannot get
>any system memory.
>

OK - cracked it. MSVC++ 4.2 changed the way it initialised its runtime heap,
so that it now called VirtualAlloc earlier in the start up process than the
code in ntheap.c. This meant that the call in ntheap.c failed. I've patched
ntheap.c so that it supplies the _heap_init function VC++ uses to initialise
its runtime heap and everything's wonderful again.

Here are the diffs for building with 4.2:

diff -c -r1.1 ntheap.c
*** ntheap.c    1996/09/24 20:36:40     1.1
--- ntheap.c    1996/09/25 12:43:36
***************
*** 282,284 ****
--- 282,313 ----
    if (need_to_alloc)
      sbrk (need_to_alloc);
  }
+
+ #define EMULATE_MSVC42_HEAP
+ #ifdef EMULATE_MSVC42_HEAP
+
+ /* MSVC 4.2 introduced a "small heap" which it initialises early in start
+    up processing. As part of this processing, it does a call to HeapCreate,
+    which calls VirtualAlloc, breaking our call to VirtualAlloc in
+    allocate_heap (above). Replace the runtime _heap_init function with one
+    of our own which causes our heap to be allocated and initialised.
+ */
+ int __cdecl
+ _heap_init (void)
+ {
+   char *ptr = malloc(1);
+   if (ptr)
+     free (ptr);
+ }
+
+ /* C runtime wants to call this, and we don't want the normal version called,
+    as we replaced the normal version of _heap_init.
+ */
+ void __cdecl
+ _heap_term (void)
+ {
+   return;
+ }
+
+ #endif
+

Cheers,
	Pat

