Initial revision
authorRichard M. Stallman <rms@gnu.org>
Tue, 1 Nov 1994 10:27:02 +0000 (10:27 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 1 Nov 1994 10:27:02 +0000 (10:27 +0000)
lib-src/makefile.nt [new file with mode: 0644]
lib-src/ntlib.c [new file with mode: 0644]
lisp/makefile.nt [new file with mode: 0644]
lisp/w32-fns.el [new file with mode: 0644]
src/makefile.nt [new file with mode: 0644]
src/s/ms-w32.h [new file with mode: 0644]
src/w32.c [new file with mode: 0644]
src/w32.h [new file with mode: 0644]
src/w32heap.c [new file with mode: 0644]
src/w32heap.h [new file with mode: 0644]

diff --git a/lib-src/makefile.nt b/lib-src/makefile.nt
new file mode 100644 (file)
index 0000000..68239dd
--- /dev/null
@@ -0,0 +1,326 @@
+#  Makefile for GNU Emacs lib-src directory.
+#   Geoff Voelker (voelker@cs.washington.edu)
+#  Copyright (C) 1994 Free Software Foundation, Inc.
+#
+#  This file is part of GNU Emacs.
+#  
+#  GNU Emacs is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2, or (at your option)
+#  any later version.
+#  
+#  GNU Emacs is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#  
+#  You should have received a copy of the GNU General Public License
+#  along with GNU Emacs; see the file COPYING.  If not, write to
+#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+#
+
+# 
+# Sets up the system dependent macros.
+#
+!include ..\nt\makefile.def
+
+LOCAL_FLAGS    = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 -DNO_ARCHIVES=1 -I..\src
+OBJDIR         = obj
+BLD            = $(OBJDIR)\$(ARCH)
+
+LINK_FLAGS     = $(ARCH_LDFLAGS) -debug:PARTIAL -machine:$(ARCH) -subsystem:console -entry:mainCRTStartup
+
+ALL            = $(BLD)\make-docfile.exe \
+               $(BLD)\hexl.exe         \
+               $(BLD)\wakeup.exe       \
+               $(BLD)\ctags.exe        \
+               $(BLD)\etags.exe
+
+               
+# don't know what (if) to do with these yet...
+#
+#              $(BLD)\sorted-doc.exe   \
+#              $(BLD)\env.exe          \
+#              $(BLD)\server.exe       \
+#              $(BLD)\emacstool.exe    \
+#              $(BLD)\fakemail.exe     \
+#              $(BLD)\leditcfns.exe    \
+#              $(BLD)\movemail.exe     \
+#              $(BLD)\emacsclient.exe  \
+#              $(BLD)\cvtmail.exe      \
+#              $(BLD)\digest-doc.exe   \
+#              $(BLD)\test-distrib.exe \
+
+
+LIBS         = $(SYS_LIB_DIR)\setargv.obj      \
+               $(SYS_LIB_DIR)\kernel32.lib     \
+               $(SYS_LIB_DIR)\libc.lib
+
+#              $(SYS_LIB_DIR)\advapi32.lib     \
+
+$(BLD)\make-docfile.exe:       $(LIBS) $(BLD)\make-docfile.obj
+$(BLD)\hexl.exe:               $(LIBS) $(BLD)\hexl.obj
+$(BLD)\ctags.exe:              $(BLD)\etags.exe
+       copy $(BLD)\etags.exe $(BLD)\ctags.exe
+$(BLD)\wakeup.exe:             $(LIBS) $(BLD)\wakeup.obj $(BLD)\ntlib.obj
+               $(LINK) -out:$@ $(LINK_FLAGS) $(BLD)\wakeup.obj $(BLD)\ntlib.obj $(LIBS)
+
+make-docfile:  $(BLD)\make-docfile.exe
+wakeup:                $(BLD)\wakeup.exe
+etags:         $(BLD)\etags.exe
+hexl:          $(BLD)\hexl.exe
+
+ETAGSOBJ      = $(BLD)\etags.obj \
+               $(BLD)\getopt.obj \
+               $(BLD)\getopt1.obj \
+               $(BLD)\ntlib.obj
+
+$(BLD)\etags.exe:              $(LIBS) $(ETAGSOBJ)
+       link32 -out:$@ -debug:PARTIAL -machine:$(ARCH) -align:0x1000 -subsystem:console -entry:mainCRTStartup $(ETAGSOBJ) $(LIBS)
+
+#
+# don't know what to do with these yet...
+#
+# $(BLD)\sorted-doc.exe:               $(LIBS) $(BLD)\sorted-doc.obj
+# $(BLD)\yow.exe:              $(LIBS) $(BLD)\yow.obj
+# $(BLD)\emacstool.exe:        $(LIBS) $(BLD)\emacstool.obj
+# $(BLD)\env.exe:              $(LIBS) $(BLD)\env.obj
+# $(BLD)\fakemail.exe:                 $(LIBS) $(BLD)\fakemail.obj
+# $(BLD)\leditcfns.exe:        $(LIBS) $(BLD)\leditcfns.obj
+# $(BLD)\server.exe:           $(LIBS) $(BLD)\server.obj
+# $(BLD)\wakeup.exe:           $(LIBS) $(BLD)\wakeup.obj
+# $(BLD)\movemail.exe:                 $(LIBS) $(BLD)\movemail.obj
+# $(BLD)\cvtmail.exe:          $(LIBS) $(BLD)\cvtmail.obj
+# $(BLD)\digest-doc.exe:       $(LIBS) $(BLD)\digest-doc.obj
+# $(BLD)\emacsclient.exe:      $(LIBS) $(BLD)\emacsclient.obj
+# $(BLD)\qsort.exe:            $(LIBS) $(BLD)\qsort.obj
+# $(BLD)\test-distrib.exe:     $(LIBS) $(BLD)\test-distrib.obj
+
+#
+# From ..\makefile.nt, with .obj changed to .o
+#
+obj = abbrev.o alloc.o alloca.o buffer.o bytecode.o callint.o callproc.o casefiddle.o cm.o cmds.o data.o dired.o dispnew.o doc.o  doprnt.o editfns.o eval.o fileio.o filelock.o filemode.o fns.o  indent.o insdel.o keyboard.o keymap.o lastfile.o lread.o macros.o marker.o minibuf.o xfaces.o mocklisp.o nt.o ntheap.o ntinevt.o ntproc.o ntterm.o print.o process.o regex.o scroll.o search.o syntax.o sysdep.o term.o termcap.o tparam.o undo.o unexnt.o window.o xdisp.o casetab.o floatfns.o frame.o gmalloc.o intervals.o ralloc.o textprop.o vm-limit.o
+
+lispdir = ..\lisp
+
+#
+# These are the lisp files that are loaded up in loadup.el
+#
+lisp= \
+       $(lispdir)\subr.elc \
+       $(lispdir)\byte-run.elc \
+       $(lispdir)\map-ynp.elc \
+       $(lispdir)\loaddefs.el \
+       $(lispdir)\simple.elc \
+       $(lispdir)\help.elc \
+       $(lispdir)\files.elc \
+       $(lispdir)\indent.elc \
+       $(lispdir)\window.elc \
+       $(lispdir)\frame.elc \
+       $(lispdir)\mouse.elc \
+       $(lispdir)\menu-bar.elc \
+       $(lispdir)\scroll-bar.elc \
+       $(lispdir)\select.elc \
+       $(lispdir)\paths.el \
+       $(lispdir)\startup.elc \
+       $(lispdir)\lisp.elc \
+       $(lispdir)\page.elc \
+       $(lispdir)\register.elc \
+       $(lispdir)\paragraphs.elc \
+       $(lispdir)\lisp-mode.elc \
+       $(lispdir)\text-mode.elc \
+       $(lispdir)\fill.elc \
+       $(lispdir)\c-mode.elc \
+       $(lispdir)\isearch.elc \
+       $(lispdir)\replace.elc \
+       $(lispdir)\abbrev.elc \
+       $(lispdir)\buff-menu.elc \
+       $(lispdir)\winnt.elc \
+       $(lispdir)\float-sup.elc \
+       $(lispdir)\vc-hooks.elc \
+       $(lispdir)\version.el
+
+DOC          = DOC 
+$(DOC):                $(BLD)\make-docfile.exe
+               - rm -f $(DOC)
+               $(BLD)\make-docfile -d ..\src $(obj) > $(DOC)
+               $(BLD)\make-docfile -d ..\src $(lisp) >> $(DOC)
+               $(CP) $(DOC) ..\etc
+               - mkdir ..\src\$(OBJDIR)
+               - mkdir ..\src\$(OBJDIR)\etc
+               $(CP) $(DOC) ..\src\$(OBJDIR)\etc
+
+{$(BLD)}.obj{$(BLD)}.exe:
+               $(LINK) -out:$@ $(LINK_FLAGS) $*.obj $(LIBS)
+
+.c{$(BLD)}.obj:
+               $(CC) $(CFLAGS) -Fo$@ $<
+
+#
+# Build the executables
+#
+all:           $(BLD) $(ALL) $(DOC)
+
+#
+# Assuming INSTALL_DIR is defined, build and install emacs in it.
+#
+INSTALL_FILES = $(ALL)
+install:       $(INSTALL_FILES)
+               - mkdir $(INSTALL_DIR)\bin
+               $(CP) $(BLD)\etags.exe $(INSTALL_DIR)\bin
+               $(CP) $(BLD)\ctags.exe $(INSTALL_DIR)\bin
+               $(CP) $(BLD)\hexl.exe $(INSTALL_DIR)\bin
+               $(CP) $(BLD)\wakeup.exe $(INSTALL_DIR)\bin\wakeup
+               - mkdir $(INSTALL_DIR)\etc
+               $(CP) $(DOC) $(INSTALL_DIR)\etc
+
+#
+# Maintenance
+# 
+clean:;                - del /q *~
+               - delnode /q deleted
+               - delnode /q obj
+               - del /q DOC
+
+#
+# Headers we would preprocess if we could.
+#
+..\src\config.h:       ..\nt\src\config.h
+                       cp ..\nt\src\config.h ..\src\config.h
+..\src\paths.h:                ..\nt\src\paths.h
+                       cp ..\nt\src\paths.h ..\src\paths.h
+
+### DEPENDENCIES ###
+
+EMACS_ROOT     = ..
+SRC            = .
+
+$(BLD)\alloca.obj : \
+       $(SRC)\alloca.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(EMACS_ROOT)\src\blockinput.h
+
+$(BLD)\b2m.obj : \
+       $(SRC)\b2m.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h
+
+$(BLD)\cvtmail.obj : \
+       $(SRC)\cvtmail.c
+
+$(BLD)\digest-doc.obj : \
+       $(SRC)\digest-doc.c
+
+$(BLD)\emacsclient.obj : \
+       $(SRC)\emacsclient.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h
+
+$(BLD)\emacsserver.obj : \
+       $(SRC)\emacsserver.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h
+
+$(BLD)\emacstool.obj : \
+       $(SRC)\emacstool.c \
+       $(EMACS_ROOT)\nt\inc\sys\file.h
+
+$(BLD)\etags.obj : \
+       $(SRC)\etags.c \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h \
+       $(SRC)\getopt.h
+
+$(BLD)\fakemail.obj : \
+       $(SRC)\fakemail.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h \
+       $(EMACS_ROOT)\nt\inc\pwd.h
+
+$(BLD)\getdate.obj : \
+       $(SRC)\getdate.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(MSTOOLS_SYS)\types.h
+
+$(BLD)\getopt.obj : \
+       $(SRC)\getopt.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\getopt.h
+
+$(BLD)\getopt1.obj : \
+       $(SRC)\getopt1.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\getopt.h
+
+$(BLD)\hexl.obj : \
+       $(SRC)\hexl.c
+
+$(BLD)\leditcfns.obj : \
+       $(SRC)\leditcfns.c
+
+$(BLD)\make-docfile.obj : \
+       $(SRC)\make-docfile.c
+
+$(BLD)\make-path.obj : \
+       $(SRC)\make-path.c
+
+$(BLD)\movemail.obj : \
+       $(SRC)\movemail.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(EMACS_ROOT)\src\vmsproc.h \
+       $(EMACS_ROOT)\lib-src\..\src\syswait.h \
+       $(EMACS_ROOT)\nt\inc\pwd.h
+
+$(BLD)\profile.obj : \
+       $(SRC)\profile.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h \
+       $(EMACS_ROOT)\src\vmstime.h \
+       $(EMACS_ROOT)\lib-src\..\src\systime.h
+
+$(BLD)\qsort.obj : \
+       $(SRC)\qsort.c
+
+$(BLD)\sorted-doc.obj : \
+       $(SRC)\sorted-doc.c
+
+$(BLD)\tcp.obj : \
+       $(SRC)\tcp.c
+
+$(BLD)\test-distrib.obj : \
+       $(SRC)\test-distrib.c
+
+$(BLD)\timer.obj : \
+       $(SRC)\timer.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\lib-src\..\src\config.h
+
+$(BLD)\wakeup.obj : \
+       $(SRC)\wakeup.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h
+
+$(BLD)\yow.obj : \
+       $(SRC)\yow.c \
+       $(EMACS_ROOT)\lib-src\..\src\paths.h
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c
new file mode 100644 (file)
index 0000000..1e1fc86
--- /dev/null
@@ -0,0 +1,90 @@
+/* Utility and Unix shadow routines for GNU Emacs support programs on NT.
+   Copyright (C) 1994 Free Software Foundation, Inc.
+
+   This file is part of GNU Emacs.
+
+   GNU Emacs is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any later
+   version.
+
+   GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   You should have received a copy of the GNU General Public License along
+   with GNU Emacs; see the file COPYING.  If not, write to the Free Software
+   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+   Geoff Voelker (voelker@cs.washington.edu)                         10-8-94
+*/
+
+#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define MAXPATHLEN _MAX_PATH
+
+/* Emulate sleep...we could have done this with a define, but that
+   would necessitate including windows.h in the files that used it.
+   This is much easier.  */
+void
+nt_sleep(int seconds)
+{
+  Sleep (seconds * 1000);
+}
+
+/* Get the current working directory.  */
+int
+getwd (char *dir)
+{
+  return GetCurrentDirectory (MAXPATHLEN, dir);
+}
+
+static HANDLE getppid_parent;
+static int    getppid_ppid;
+
+int
+getppid(void)
+{
+  char *ppid;
+  DWORD result;
+
+  ppid = getenv ("__PARENT_PROCESS_ID");
+  if (!ppid) 
+    {
+      printf("no pid.\n");
+      return 0;
+    } 
+  else 
+    {
+      getppid_ppid = atoi (ppid);
+    }
+
+  if (!getppid_parent) 
+    {
+      getppid_parent = OpenProcess (SYNCHRONIZE, FALSE, atoi(ppid));
+      if (!getppid_parent) 
+       {
+         printf ("Failed to open handle to parent process: %d\n",
+                GetLastError());
+         exit (1);
+       }
+    }
+
+  result = WaitForSingleObject (getppid_parent, 0);
+  switch (result) 
+    {
+    case WAIT_TIMEOUT:
+      /* The parent is still alive.  */
+      return getppid_ppid;
+    case WAIT_OBJECT_0:
+      /* The parent is gone.  Return the pid of Unix init (1).  */
+      return 1;
+    case WAIT_FAILED:
+    default:
+      printf ("Checking parent status failed: %d\n", GetLastError());
+      exit (1);
+    }
+}
diff --git a/lisp/makefile.nt b/lisp/makefile.nt
new file mode 100644 (file)
index 0000000..61246b8
--- /dev/null
@@ -0,0 +1,42 @@
+#  Hacked up Nmake makefile for GNU Emacs
+#   Geoff Voelker (voelker@cs.washington.edu)
+#  Copyright (c) 1994 Free Software Foundation, Inc.
+#
+#  This file is part of GNU Emacs.
+#  
+#  GNU Emacs is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2, or (at your option)
+#  any later version.
+#  
+#  GNU Emacs is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#  
+#  You should have received a copy of the GNU General Public License
+#  along with GNU Emacs; see the file COPYING.  If not, write to
+#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+#
+
+!include ..\nt\makefile.def
+
+all:
+
+#
+# Assuming INSTALL_DIR is defined, copy the elisp files to it
+#
+install:;      - mkdir $(INSTALL_DIR)\lisp
+               - del /q .\same-dir.tst
+               - del /q $(INSTALL_DIR)\lisp\same-dir.tst
+               echo SameDirTest > .\same-dir.tst
+               if not exist $(INSTALL_DIR)\lisp\same-dir.tst $(CP_DIR) . $(INSTALL_DIR)\lisp
+               - del /q .\same-dir.tst
+               
+
+#
+# Maintenance
+# 
+clean:;                - del /q *~
+               - delnode /q deleted
+
diff --git a/lisp/w32-fns.el b/lisp/w32-fns.el
new file mode 100644 (file)
index 0000000..388a5dd
--- /dev/null
@@ -0,0 +1,115 @@
+;; winnt.el --- Lisp routines for Windows NT.
+;; Copyright (C) 1994 Free Software Foundation, Inc.
+
+;; Author: Geoff Voelker (voelker@cs.washington.edu)
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Commentary:
+
+;; (August 12, 1993)
+;; NT switches placed in:
+;;
+;; compile.el, dired-new.el, dired.el, loadup.el, startup.el, subr.el
+
+;; (November 21, 1993)
+;; General stuffing for supporting Windows NT.  
+
+;;; Code:
+
+;; Map delete and backspace
+(define-key function-key-map [backspace] "\177")
+(define-key function-key-map [delete] "\C-d")
+(define-key function-key-map [M-backspace] [?\M-\177])
+
+;; Ignore case on file-name completion
+(setq completion-ignore-case t)
+
+;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch
+;; for executing its command line argument (from simple.el).
+(setq shell-command-switch "/c")
+
+;; Taken from dos-fn.el ... don't want all that's in the file, maybe
+;; separate it out someday.
+
+(defvar file-name-buffer-file-type-alist
+  '(
+    ("[:/].*config.sys$" . nil)                ; config.sys text
+    ("\\.elc$" . t)                    ; emacs stuff
+    ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t)
+                                       ; MS-Dos stuff
+    ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t)
+                                       ; Packers
+    ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t)
+                                       ; Unix stuff
+    ("\\.tp[ulpw]$" . t)
+                                       ; Borland Pascal stuff
+    ("[:/]tags$" . t)
+                                       ; Emacs TAGS file
+    )
+  "*Alist for distinguishing text files from binary files.
+Each element has the form (REGEXP . TYPE), where REGEXP is matched
+against the file name, and TYPE is nil for text, t for binary.")
+
+(defun find-buffer-file-type (filename)
+  (let ((alist file-name-buffer-file-type-alist)
+       (found nil)
+       (code nil))
+    (let ((case-fold-search t))
+      (setq filename (file-name-sans-versions filename))
+      (while (and (not found) alist)
+       (if (string-match (car (car alist)) filename)
+           (setq code (cdr (car alist))
+                 found t))
+       (setq alist (cdr alist))))
+    (if found
+       (cond((memq code '(nil t)) code)
+            ((and (symbolp code) (fboundp code))
+             (funcall code filename)))
+      default-buffer-file-type)))
+
+(defun find-file-binary (filename) 
+  "Visit file FILENAME and treat it as binary."
+  (interactive "FFind file binary: ")
+  (let ((file-name-buffer-file-type-alist '(("" . t))))
+    (find-file filename)))
+
+(defun find-file-text (filename) 
+  "Visit file FILENAME and treat it as a text file."
+  (interactive "FFind file text: ")
+  (let ((file-name-buffer-file-type-alist '(("" . nil))))
+    (find-file filename)))
+
+(defun find-file-not-found-set-buffer-file-type ()
+  (save-excursion
+    (set-buffer (current-buffer))
+    (setq buffer-file-type (find-buffer-file-type (buffer-file-name))))
+  nil)
+
+;;; To set the default file type on new files.
+(add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type)
+
+;;; Fix interface to (X-specific) mouse.el
+(defalias 'window-frame 'ignore)
+(defalias 'x-set-selection 'ignore)
+(fset 'x-get-selection '(lambda (&rest rest) ""))
+(fmakunbound 'font-menu-add-default)
+(global-unset-key [C-down-mouse-1])
+(global-unset-key [C-down-mouse-2])
+(global-unset-key [C-down-mouse-3])
+
+;;; winnt.el ends here
diff --git a/src/makefile.nt b/src/makefile.nt
new file mode 100644 (file)
index 0000000..ade4184
--- /dev/null
@@ -0,0 +1,940 @@
+#  Makefile for GNU Emacs on Windows NT
+#  Copyright (c) 1992, 1993, 1994 Free Software Foundation, Inc.
+#   Tim Fleehart (apollo@online.com)
+#   Geoff Voelker (voelker@cs.washington.edu)
+#
+#  This file is part of GNU Emacs.
+#  
+#  GNU Emacs is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2, or (at your option)
+#  any later version.
+#  
+#  GNU Emacs is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#  
+#  You should have received a copy of the GNU General Public License
+#  along with GNU Emacs; see the file COPYING.  If not, write to
+#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+#
+
+# 
+# Sets up the system dependent macros.
+#
+!include ..\nt\makefile.def
+
+#
+# HAVE_CONFIG_H is required by some generic gnu sources stuck into
+# the emacs source tree.
+#
+LOCAL_FLAGS     = -Demacs=1 -DWINDOWSNT -DDOS_NT -DHAVE_CONFIG_H -I..\nt\inc -Zi
+
+EMACS           = $(BLD)\emacs.exe
+TEMACS          = $(BLD)\temacs.exe
+TLIB            = $(BLD)\temacs.lib
+TOBJ            = $(BLD)\emacs.obj
+
+LINK_FLAGS      = $(ARCH_LDFLAGS) -stack:0x1000000 -base:0xD00000 -debug:full -debugtype:cv -machine:$(ARCH) -subsystem:console -entry:_start 
+
+# -debug:PARTIAL -debugtype:COFF
+
+#
+# Split up the objects into two sets so that we don't run out of
+# command line space when we link them into a library.
+#
+OBJ1 =  $(BLD)\abbrev.obj       \
+       $(BLD)\alloc.obj        \
+       $(BLD)\alloca.obj       \
+       $(BLD)\buffer.obj       \
+       $(BLD)\bytecode.obj     \
+       $(BLD)\callint.obj      \
+       $(BLD)\callproc.obj     \
+       $(BLD)\casefiddle.obj   \
+       $(BLD)\cm.obj           \
+       $(BLD)\cmds.obj         \
+       $(BLD)\data.obj         \
+       $(BLD)\dired.obj        \
+       $(BLD)\dispnew.obj      \
+       $(BLD)\doc.obj          \
+       $(BLD)\doprnt.obj       \
+       $(BLD)\editfns.obj      \
+       $(BLD)\eval.obj         \
+       $(BLD)\fileio.obj       \
+       $(BLD)\filelock.obj     \
+       $(BLD)\filemode.obj     \
+       $(BLD)\fns.obj          \
+       $(BLD)\indent.obj       \
+       $(BLD)\insdel.obj       \
+       $(BLD)\keyboard.obj     \
+       $(BLD)\keymap.obj       \
+       $(BLD)\lastfile.obj     \
+       $(BLD)\lread.obj        \
+       $(BLD)\macros.obj       \
+       $(BLD)\marker.obj       \
+       $(BLD)\minibuf.obj      \
+       $(BLD)\xfaces.obj       \
+       $(BLD)\mocklisp.obj
+
+OBJ2 =  $(BLD)\nt.obj           \
+       $(BLD)\ntheap.obj       \
+       $(BLD)\ntinevt.obj      \
+       $(BLD)\ntproc.obj       \
+       $(BLD)\ntterm.obj       \
+       $(BLD)\print.obj        \
+       $(BLD)\process.obj      \
+       $(BLD)\regex.obj        \
+       $(BLD)\scroll.obj       \
+       $(BLD)\search.obj       \
+       $(BLD)\syntax.obj       \
+       $(BLD)\sysdep.obj       \
+       $(BLD)\term.obj         \
+       $(BLD)\termcap.obj      \
+       $(BLD)\tparam.obj       \
+       $(BLD)\undo.obj         \
+       $(BLD)\unexnt.obj       \
+       $(BLD)\window.obj       \
+       $(BLD)\xdisp.obj        \
+       $(BLD)\casetab.obj      \
+       $(BLD)\floatfns.obj     \
+       $(BLD)\frame.obj        \
+       $(BLD)\gmalloc.obj      \
+       $(BLD)\intervals.obj    \
+       $(BLD)\ralloc.obj       \
+       $(BLD)\textprop.obj     \
+       $(BLD)\vm-limit.obj
+
+LIBS =  $(TLIB)                         \
+       $(SYS_LIB_DIR)\setargv.obj      \
+       $(SYS_LIB_DIR)\kernel32.lib     \
+       $(SYS_LIB_DIR)\advapi32.lib     \
+       $(SYS_LIB_DIR)\libc.lib
+
+#
+# Build the executable and dump it.
+#
+all:            $(BLD) $(EMACS) 
+
+#
+# Headers we would preprocess if we could.
+#
+PREPARED_HEADERS = config.h paths.h
+config.h:      ..\nt\src\config.h
+               cp ..\nt\src\config.h config.h
+paths.h:       ..\nt\src\paths.h
+               cp ..\nt\src\paths.h paths.h
+
+#
+# The dumped executable
+#
+emacs:          $(EMACS)
+$(EMACS):       $(PREPARED_HEADERS) $(TEMACS)
+               cd $(BLD)
+               temacs.exe -batch -l loadup dump
+               cd ..\..
+
+#
+# The undumped executable
+#
+temacs:         $(BLD) $(TEMACS)
+$(TEMACS):      $(LIBS) $(TOBJ)
+               $(LINK) -out:$(TEMACS) $(LINK_FLAGS) $(TOBJ) $(LIBS)
+
+#
+# Build the library.  Split up the build into two phases...otherwise we 
+# run out of command line space.
+#
+$(TLIB):        $(OBJ1) $(OBJ2)
+               @- $(AR) -out:$(TLIB) $(OBJ1)
+               @- $(AR) -out:$(TLIB) $(TLIB) $(OBJ2)
+
+#
+# Object files.
+#
+.c{$(BLD)}.obj:
+               $(CC) $(CFLAGS) -Fo$@ $<
+
+#
+# Assuming INSTALL_DIR is defined, build and install emacs in it.
+#
+install:        all
+               - mkdir $(INSTALL_DIR)\bin
+               $(CP) $(EMACS) $(INSTALL_DIR)\bin
+
+#
+# Maintenance
+# 
+clean:;         - del /q *~
+               - delnode /q deleted
+               - delnode /q obj
+
+#
+# These files are the ones that compile conditionally on CANNOT_DUMP...
+# this target is mostly used for debugging.
+#
+cleandump:;     cd $(BLD) && - del callproc.obj data.obj dispnew.obj doc.obj editfns.obj emacs.obj lread.obj process.obj sysdep.obj term.obj ntheap.obj unexnt.obj
+
+
+### DEPENDENCIES ###
+
+EMACS_ROOT     = ..
+SRC            = .
+
+$(BLD)\abbrev.obj : \
+       $(SRC)\abbrev.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\window.h
+
+$(BLD)\alloc.obj : \
+       $(SRC)\alloc.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\puresize.h \
+       $(SRC)\buffer.h \
+       $(SRC)\window.h \
+       $(SRC)\frame.h \
+       $(SRC)\blockinput.h \
+       $(SRC)\syssignal.h
+
+$(BLD)\alloca.obj : \
+       $(SRC)\alloca.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(SRC)\blockinput.h
+
+$(BLD)\buffer.obj : \
+       $(SRC)\buffer.c \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\window.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\indent.h \
+       $(SRC)\blockinput.h
+
+$(BLD)\bytecode.obj : \
+       $(SRC)\bytecode.c \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\syntax.h
+
+$(BLD)\callint.obj : \
+       $(SRC)\callint.c \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\commands.h \
+       $(SRC)\keyboard.h \
+       $(SRC)\window.h \
+       $(SRC)\mocklisp.h
+
+$(BLD)\callproc.obj : \
+       $(SRC)\callproc.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\msdos.h \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\process.h \
+       $(SRC)\syssignal.h \
+       $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\systty.h
+
+$(BLD)\casefiddle.obj : \
+       $(SRC)\casefiddle.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\commands.h \
+       $(SRC)\syntax.h
+       $(CC) $(CFLAGS) -Fo$@ casefiddle.c
+
+$(BLD)\casetab.obj : \
+       $(SRC)\casetab.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h
+
+$(BLD)\cm.obj : \
+       $(SRC)\cm.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\cm.h \
+       $(SRC)\termhooks.h
+
+$(BLD)\cmds.obj : \
+       $(SRC)\cmds.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\syntax.h
+
+$(BLD)\data.obj : \
+       $(SRC)\data.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\puresize.h \
+       $(SRC)\buffer.h \
+       $(SRC)\syssignal.h
+
+$(BLD)\dired.obj : \
+       $(SRC)\dired.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\vmsdir.h \
+       $(SRC)\ndir.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\commands.h \
+       $(SRC)\regex.h
+
+$(BLD)\dispnew.obj : \
+       $(SRC)\dispnew.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\termchar.h \
+       $(SRC)\termopts.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\cm.h \
+       $(SRC)\buffer.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\commands.h \
+       $(SRC)\disptab.h \
+       $(SRC)\indent.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\systty.h \
+       $(SRC)\xterm.h \
+       $(SRC)\vmstime.h \
+       $(SRC)\systime.h
+
+$(BLD)\doc.obj : \
+       $(SRC)\doc.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\keyboard.h
+
+$(BLD)\doprnt.obj : \
+       $(SRC)\doprnt.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h
+
+$(BLD)\dosfns.obj : \
+       $(SRC)\dosfns.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\termchar.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\frame.h \
+       $(SRC)\dosfns.h \
+       $(SRC)\msdos.h
+
+$(BLD)\editfns.obj : \
+       $(SRC)\editfns.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\uaf.h \
+       $(SRC)\vms-pwd.h \
+       $(EMACS_ROOT)\nt\inc\pwd.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\buffer.h \
+       $(SRC)\window.h \
+       $(SRC)\vmstime.h \
+       $(SRC)\systime.h
+
+$(BLD)\emacs.obj : \
+       $(SRC)\emacs.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\systty.h \
+       $(SRC)\syssignal.h \
+       $(SRC)\process.h
+
+$(BLD)\eval.obj : \
+       $(SRC)\eval.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\blockinput.h \
+       $(SRC)\commands.h \
+       $(SRC)\keyboard.h
+
+$(BLD)\fileio.obj : \
+       $(SRC)\fileio.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\uaf.h \
+       $(SRC)\vms-pwd.h \
+       $(EMACS_ROOT)\nt\inc\pwd.h \
+       $(SRC)\msdos.h \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(SRC)\vmsdir.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\buffer.h \
+       $(SRC)\window.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\vmstime.h \
+       $(SRC)\systime.h
+
+$(BLD)\filelock.obj : \
+       $(SRC)\filelock.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\uaf.h \
+       $(SRC)\vms-pwd.h \
+       $(EMACS_ROOT)\nt\inc\pwd.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\lisp.h \
+       $(EMACS_ROOT)\src\paths.h \
+       $(SRC)\buffer.h \
+       $(SRC)\vmsdir.h \
+       $(SRC)\ndir.h
+
+$(BLD)\filemode.obj : \
+       $(SRC)\filemode.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h
+
+$(BLD)\floatfns.obj : \
+       $(SRC)\floatfns.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\syssignal.h
+
+$(BLD)\fns.obj : \
+       $(SRC)\fns.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\keyboard.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h
+
+$(BLD)\frame.obj : \
+       $(SRC)\frame.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\frame.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\window.h \
+       $(SRC)\buffer.h \
+       $(SRC)\commands.h \
+       $(SRC)\keyboard.h
+
+$(BLD)\getloadavg.obj : \
+       $(SRC)\getloadavg.c \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h
+
+$(BLD)\gmalloc.obj : \
+       $(SRC)\gmalloc.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(SRC)\getpagesize.h
+       $(CC) $(CFLAGS) -D__STDC__ -Fo$@ gmalloc.c
+
+$(BLD)\hftctl.obj : \
+       $(SRC)\hftctl.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\ioctl.h
+
+$(BLD)\indent.obj : \
+       $(SRC)\indent.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\indent.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\termchar.h \
+       $(SRC)\termopts.h \
+       $(SRC)\disptab.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h
+
+$(BLD)\insdel.obj : \
+       $(SRC)\insdel.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\buffer.h \
+       $(SRC)\window.h \
+       $(SRC)\blockinput.h
+
+$(BLD)\intervals.obj : \
+       $(SRC)\intervals.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\buffer.h \
+       $(SRC)\puresize.h
+       $(CC) $(CFLAGS) -Fo$@ intervals.c
+
+$(BLD)\keyboard.obj : \
+       $(SRC)\keyboard.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\termchar.h \
+       $(SRC)\termopts.h \
+       $(SRC)\lisp.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\macros.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\disptab.h \
+       $(SRC)\keyboard.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\blockinput.h \
+       $(SRC)\msdos.h \
+       $(SRC)\syssignal.h \
+       $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\systty.h \
+       $(SRC)\xterm.h \
+       $(SRC)\vmstime.h \
+       $(SRC)\systime.h
+
+$(BLD)\keymap.obj : \
+       $(SRC)\keymap.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\keyboard.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\blockinput.h
+
+$(BLD)\lastfile.obj : \
+       $(SRC)\lastfile.c
+
+$(BLD)\lread.obj : \
+       $(SRC)\lread.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(EMACS_ROOT)\src\paths.h \
+       $(SRC)\commands.h \
+       $(SRC)\keyboard.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\msdos.h
+
+$(BLD)\macros.obj : \
+       $(SRC)\macros.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\macros.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\window.h
+
+$(BLD)\marker.obj : \
+       $(SRC)\marker.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h
+
+$(BLD)\minibuf.obj : \
+       $(SRC)\minibuf.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\syntax.h
+
+$(BLD)\mocklisp.obj : \
+       $(SRC)\mocklisp.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h
+
+$(BLD)\nt.obj : \
+       $(SRC)\nt.c \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(SRC)\lisp.h \
+       $(EMACS_ROOT)\nt\inc\pwd.h \
+       $(SRC)\ntheap.h
+
+$(BLD)\ntheap.obj : \
+       $(SRC)\ntheap.c \
+       $(SRC)\ntheap.h
+
+$(BLD)\ntinevt.obj : \
+       $(SRC)\ntinevt.c \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\frame.h \
+       $(SRC)\blockinput.h \
+       $(SRC)\termhooks.h
+
+$(BLD)\ntproc.obj : \
+       $(SRC)\ntproc.c \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\nt.h \
+       $(SRC)\vmstime.h \
+       $(SRC)\systime.h
+
+$(BLD)\ntterm.obj : \
+       $(SRC)\ntterm.c \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\frame.h \
+       $(SRC)\disptab.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\ntinevt.h
+
+$(BLD)\prefix-args.obj : \
+       $(SRC)\prefix-args.c
+
+$(BLD)\print.obj : \
+       $(SRC)\print.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\process.h \
+       $(SRC)\termchar.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h
+
+$(BLD)\process.obj : \
+       $(SRC)\process.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\systty.h \
+       $(SRC)\window.h \
+       $(SRC)\buffer.h \
+       $(SRC)\process.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\commands.h \
+       $(SRC)\frame.h \
+       $(SRC)\syssignal.h \
+       $(SRC)\vmsproc.h \
+       $(SRC)\syswait.h \
+       $(SRC)\lisp.h \
+       $(SRC)\vmstime.h \
+       $(SRC)\systime.h \
+       $(SRC)\termopts.h
+
+$(BLD)\ralloc.obj : \
+       $(SRC)\ralloc.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(SRC)\getpagesize.h
+
+$(BLD)\regex.obj : \
+       $(SRC)\regex.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\s\s-windowsnt.h \
+       $(SRC)\m\m-windowsnt.h \
+       $(SRC)\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\syntax.h \
+       $(SRC)\regex.h
+
+$(BLD)\scroll.obj : \
+       $(SRC)\scroll.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\termchar.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\frame.h
+
+$(BLD)\search.obj : \
+       $(SRC)\search.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\syntax.h \
+       $(SRC)\buffer.h \
+       $(SRC)\commands.h \
+       $(SRC)\blockinput.h \
+       $(SRC)\regex.h
+
+$(BLD)\sunfns.obj : \
+       $(SRC)\sunfns.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\window.h \
+       $(SRC)\buffer.h \
+       $(SRC)\termhooks.h
+
+$(BLD)\syntax.obj : \
+       $(SRC)\syntax.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\commands.h \
+       $(SRC)\buffer.h \
+       $(SRC)\syntax.h
+
+$(BLD)\sysdep.obj : \
+       $(SRC)\sysdep.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\blockinput.h \
+       $(SRC)\dosfns.h \
+       $(SRC)\msdos.h \
+       $(EMACS_ROOT)\nt\inc\sys\param.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(EMACS_ROOT)\nt\inc\sys\ioctl.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h \
+       $(SRC)\systty.h \
+       $(SRC)\vmsproc.h \
+       $(SRC)\syswait.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\termchar.h \
+       $(SRC)\termopts.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\process.h \
+       $(SRC)\vmsdir.h \
+       $(SRC)\ndir.h \
+       $(SRC)\syssignal.h \
+       $(SRC)\vmstime.h \
+       $(SRC)\systime.h \
+       $(SRC)\uaf.h \
+       $(SRC)\vms-pwd.h \
+       $(EMACS_ROOT)\src\acldef.h \
+       $(EMACS_ROOT)\src\chpdef.h
+
+$(BLD)\term.obj : \
+       $(SRC)\term.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\termchar.h \
+       $(SRC)\termopts.h \
+       $(SRC)\cm.h \
+       $(SRC)\lisp.h \
+       $(SRC)\frame.h \
+       $(SRC)\disptab.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\keyboard.h
+
+$(BLD)\termcap.obj : \
+       $(SRC)\termcap.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(EMACS_ROOT)\nt\inc\sys\file.h
+
+$(BLD)\terminfo.obj : \
+       $(SRC)\terminfo.c
+
+$(BLD)\textprop.obj : \
+       $(SRC)\textprop.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h \
+       $(SRC)\buffer.h \
+       $(SRC)\window.h
+
+$(BLD)\tparam.obj : \
+       $(SRC)\tparam.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h
+
+$(BLD)\undo.obj : \
+       $(SRC)\undo.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\commands.h
+
+$(BLD)\unexnt.obj : \
+       $(SRC)\unexnt.c \
+       $(SRC)\ntheap.h
+
+$(BLD)\widget.obj : \
+       $(SRC)\widget.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\xterm.h \
+       $(SRC)\frame.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\widget.h \
+       $(SRC)\widgetprv.h
+
+$(BLD)\window.obj : \
+       $(SRC)\window.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\buffer.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\commands.h \
+       $(SRC)\indent.h \
+       $(SRC)\termchar.h \
+       $(SRC)\disptab.h \
+       $(SRC)\keyboard.h
+
+$(BLD)\xdisp.obj : \
+       $(SRC)\xdisp.c \
+       $(EMACS_ROOT)\src\s\s-windowsnt.h \
+       $(EMACS_ROOT)\src\m\m-windowsnt.h \
+       $(EMACS_ROOT)\src\config.h \
+       $(SRC)\lisp.h \
+       $(SRC)\frame.h \
+       $(SRC)\window.h \
+       $(SRC)\termchar.h \
+       $(SRC)\buffer.h \
+       $(SRC)\indent.h \
+       $(SRC)\commands.h \
+       $(SRC)\macros.h \
+       $(SRC)\disptab.h \
+       $(SRC)\termhooks.h \
+       $(SRC)\dispextern.h \
+       $(SRC)\intervals.h
diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h
new file mode 100644 (file)
index 0000000..53df90e
--- /dev/null
@@ -0,0 +1,264 @@
+/* System description file for Windows NT.
+   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/*
+ *      Define symbols to identify the version of Unix this is.
+ *      Define all the symbols that apply correctly.
+ */
+
+/* #define UNIPLUS */
+/* #define USG5 */
+/* #define USG */
+/* #define HPUX */
+/* #define UMAX */
+/* #define BSD4_1 */
+/* #define BSD4_2 */
+/* #define BSD4_3 */
+/* #define BSD */
+/* #define VMS */
+#ifndef WINDOWSNT
+#define WINDOWSNT
+#endif
+#ifndef DOS_NT
+#define DOS_NT         /* MSDOS or WINDOWSNT */
+#endif
+
+/* SYSTEM_TYPE should indicate the kind of system you are using.
+ It sets the Lisp variable system-type.  */
+
+#define SYSTEM_TYPE "windows-nt"
+#define SYMS_SYSTEM syms_of_ntterm ()
+
+#define NO_MATHERR
+#define HAVE_FREXP
+#define HAVE_FMOD
+
+/* NOMULTIPLEJOBS should be defined if your system's shell
+ does not have "job control" (the ability to stop a program,
+ run some other program, then continue the first one).  */
+
+/* #define NOMULTIPLEJOBS */
+
+/* Emacs can read input using SIGIO and buffering characters itself,
+   or using CBREAK mode and making C-g cause SIGINT.
+   The choice is controlled by the variable interrupt_input.
+
+   Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
+
+   Emacs uses the presence or absence of the SIGIO macro to indicate
+   whether or not signal-driven I/O is possible.  It uses
+   INTERRUPT_INPUT to decide whether to use it by default.
+
+   SIGIO can be used only on systems that implement it (4.2 and 4.3).
+   CBREAK mode has two disadvantages
+     1) At least in 4.2, it is impossible to handle the Meta key properly.
+       I hear that in system V this problem does not exist.
+     2) Control-G causes output to be discarded.
+       I do not know whether this can be fixed in system V.
+
+   Another method of doing input is planned but not implemented.
+   It would have Emacs fork off a separate process
+   to read the input and send it to the true Emacs process
+   through a pipe. */
+
+#define INTERRUPT_INPUT
+
+/* Letter to use in finding device name of first pty,
+  if system supports pty's.  'a' means it is /dev/ptya0  */
+
+#define FIRST_PTY_LETTER 'a'
+
+/*
+ *      Define HAVE_TERMIOS if the system provides POSIX-style
+ *      functions and macros for terminal control.
+ *
+ *      Define HAVE_TERMIO if the system provides sysV-style ioctls
+ *      for terminal control.
+ *
+ *      Do not define both.  HAVE_TERMIOS is preferred, if it is
+ *      supported on your system.
+ */
+
+/* #define HAVE_TERMIOS */
+/* #define HAVE_TERMIO */
+
+/*
+ *      Define HAVE_TIMEVAL if the system supports the BSD style clock values.
+ *      Look in <sys/time.h> for a timeval structure.
+ */
+
+/* #define HAVE_TIMEVAL */
+
+/*
+ *      Define HAVE_SELECT if the system supports the `select' system call.
+ */
+
+/* #define HAVE_SELECT */
+
+/*
+ *      Define HAVE_PTYS if the system supports pty devices.
+ */
+
+/* #define HAVE_PTYS */
+
+/*
+ *      Define NONSYSTEM_DIR_LIBRARY to make Emacs emulate
+ *      The 4.2 opendir, etc., library functions.
+ */
+
+/* #define NONSYSTEM_DIR_LIBRARY */
+
+/* Define this symbol if your system has the functions bcopy, etc. */
+
+#define BSTRING
+#define bzero(b, l) memset(b, 0, l)
+#define bcopy(s, d, l) memcpy(d, s, l)
+#define bcmp(a, b, l) memcmp(a, b, l)
+
+/* subprocesses should be defined if you want to
+   have code for asynchronous subprocesses
+   (as used in M-x compile and M-x shell).
+   This is generally OS dependent, and not supported
+   under most USG systems. */
+
+#define subprocesses
+
+/* If your system uses COFF (Common Object File Format) then define the
+   preprocessor symbol "COFF". */
+
+#define COFF
+
+/* define MAIL_USE_FLOCK if the mailer uses flock
+   to interlock access to /usr/spool/mail/$USER.
+   The alternative is that a lock file named
+   /usr/spool/mail/$USER.lock.  */
+
+/* #define MAIL_USE_FLOCK */
+
+/* Define CLASH_DETECTION if you want lock files to be written
+   so that Emacs can tell instantly when you try to modify
+   a file that someone else has modified in his Emacs.  */
+
+/* #define CLASH_DETECTION */
+
+/* Define this if your operating system declares signal handlers to
+   have a type other than the usual.  `The usual' is `void' for ANSI C
+   systems (i.e. when the __STDC__ macro is defined), and `int' for
+   pre-ANSI systems.  If you're using GCC on an older system, __STDC__
+   will be defined, but the system's include files will still say that
+   signal returns int or whatever; in situations like that, define
+   this to be what the system's include files want.  */
+/* #define SIGTYPE int */
+
+/* If the character used to separate elements of the executable path
+   is not ':', #define this to be the appropriate character constant.  */
+#define SEPCHAR ';'
+
+/* ============================================================ */
+
+/* Here, add any special hacks needed
+   to make Emacs work on this system.  For example,
+   you might define certain system call names that don't
+   exist on your system, or that do different things on
+   your system and must be used only through an encapsulation
+   (Which you should place, by convention, in sysdep.c).  */
+
+/* Some compilers tend to put everything declared static
+   into the initialized data area, which becomes pure after dumping Emacs.
+   On these systems, you must #define static as nothing to foil this.
+   Note that emacs carefully avoids static vars inside functions.  */
+
+/* Define this to be the separator between path elements */
+#define DIRECTORY_SEP '\\'
+
+/* Define this to be the separator between devices and paths */
+#define DEVICE_SEP ':'
+
+/* We'll support either convention on NT.  */
+#define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
+#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
+
+/* The null device on Windows NT. */
+#define NULL_DEVICE     "NUL:"
+#define EXEC_SUFFIXES   ".exe:.com:.bat:"
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN      _MAX_PATH
+#endif
+
+#define HAVE_DUP2       1
+#define HAVE_RENAME     1
+#define HAVE_RMDIR      1
+#define HAVE_MKDIR      1
+#define HAVE_GETHOSTNAME       1
+
+/* These have to be defined because our compilers treat __STDC__ as being
+   defined (most of them anyway). */
+
+#define access  _access
+#define chdir   _chdir
+#define chmod   _chmod
+#define close   _close
+#define creat   _creat
+#define dup     _dup
+#define dup2    _dup2
+#define execlp  _execlp
+#define execvp  _execvp
+#define getpid  _getpid
+#define index   strchr
+#define isatty  _isatty
+#define link    _link
+#define lseek   _lseek
+#define mkdir   _mkdir
+#define mktemp  _mktemp
+#define open    _open
+#define pipe    _pipe
+#define random  rand
+#define read    _read
+#define rmdir   _rmdir
+#define sleep   nt_sleep
+#define srandom srand
+#define unlink  _unlink
+#define umask  _umask
+#define write   _write
+#define _longjmp        longjmp
+#define spawnve win32_spawnve
+#define wait    win32_wait
+#define signal  win32_signal
+#define rindex  strrchr
+
+/* Defines that we need that aren't in the standard signal.h  */
+#define SIGHUP  1               /* Hang up */
+#define SIGQUIT 3               /* Quit process */
+#define SIGTRAP 5               /* Trace trap */
+#define SIGKILL 9               /* Die, die die */
+#define SIGPIPE 13              /* Write on pipe with no readers */
+#define SIGALRM 14              /* Alarm */
+#define SIGCHLD 18              /* Death of child */
+
+/* For integration with MSDOS support.  */
+#define getdisk()               (_getdrive () - 1)
+#define getdefdir(_drv, _buf)   _getdcwd (_drv, _buf, MAXPATHLEN)
+
+/* Define this so that winsock.h definitions don't get included when windows.h
+   is...  I don't know if they do the right thing for emacs.  For this to
+   have proper effect, config.h must always be included before windows.h.  */
+#define _WINSOCKAPI_    1
+
+/* ============================================================ */
diff --git a/src/w32.c b/src/w32.c
new file mode 100644 (file)
index 0000000..2a091d4
--- /dev/null
+++ b/src/w32.c
@@ -0,0 +1,610 @@
+/* Utility and Unix shadow routines for GNU Emacs on Windows NT.
+   Copyright (C) 1994 Free Software Foundation, Inc.
+
+   This file is part of GNU Emacs.
+
+   GNU Emacs is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 1, or (at your option) any later
+   version.
+
+   GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   You should have received a copy of the GNU General Public License along
+   with GNU Emacs; see the file COPYING.  If not, write to the Free Software
+   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+   Geoff Voelker (voelker@cs.washington.edu)                         7-29-94
+*/
+
+#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <io.h>
+#include <fcntl.h>
+#include <ctype.h>
+
+#include "config.h"
+#define getwd _getwd
+#include "lisp.h"
+#undef getwd
+
+#include <pwd.h>
+
+#include "ndir.h"
+#include "ntheap.h"
+
+extern int report_file_error (char *, Lisp_Object);
+
+/* Get the current working directory.  */
+int
+getwd (char *dir)
+{
+  return GetCurrentDirectory (MAXPATHLEN, dir);
+}
+
+/* Emulate gethostname.  */
+int
+gethostname (char *buffer, int size)
+{
+  /* NT only allows small host names, so the buffer is 
+     certainly large enough.  */
+  return !GetComputerName (buffer, &size);
+}
+
+/* Emulate getloadavg.  */
+int
+getloadavg (double loadavg[], int nelem)
+{
+  int i;
+
+  /* A faithful emulation is going to have to be saved for a rainy day.  */
+  for (i = 0; i < nelem; i++) 
+    {
+      loadavg[i] = 0.0;
+    }
+  return i;
+}
+
+/* Emulate sleep...we could have done this with a define, but that
+   would necessitate including windows.h in the files that used it.
+   This is much easier.  */
+void
+nt_sleep (int seconds)
+{
+  Sleep (seconds * 1000);
+}
+
+/* Emulate the Unix directory procedures opendir, closedir, 
+   and readdir.  We can't use the procedures supplied in sysdep.c,
+   so we provide them here.  */
+
+struct direct dir_static;       /* simulated directory contents */
+static int    dir_finding;
+static HANDLE dir_find_handle;
+
+DIR *
+opendir (char *filename)
+{
+  DIR *dirp;
+
+  /* Opening is done by FindFirstFile.  However, a read is inherent to
+     this operation, so we have a flag to handle the open at read
+     time.  This flag essentially means "there is a find-handle open and
+     it needs to be closed."  */
+
+  if (!(dirp = (DIR *) malloc (sizeof (DIR)))) 
+    {
+      return 0;
+    }
+
+  dirp->dd_fd = 0;
+  dirp->dd_loc = 0;
+  dirp->dd_size = 0;
+
+  /* This is tacky, but we need the directory name for our
+     implementation of readdir.  */
+  strncpy (dirp->dd_buf, filename, DIRBLKSIZ);
+  return dirp;
+}
+
+void
+closedir (DIR *dirp)
+{
+  /* If we have a find-handle open, close it.  */
+  if (dir_finding) 
+    {
+      FindClose (dir_find_handle);
+      dir_finding = 0;
+    }
+  xfree ((char *) dirp);
+}
+
+struct direct *
+readdir (DIR *dirp)
+{
+  WIN32_FIND_DATA find_data;
+  
+  /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */
+  if (!dir_finding) 
+    {
+      char filename[MAXNAMLEN + 3];
+      int ln;
+
+      strncpy (filename, dirp->dd_buf, MAXNAMLEN);
+      ln = strlen (filename)-1;
+      if (filename[ln] != '\\' && filename[ln] != ':')
+       strcat (filename, "\\");
+      strcat (filename, "*.*");
+
+      dir_find_handle = FindFirstFile (filename, &find_data);
+
+      if (dir_find_handle == INVALID_HANDLE_VALUE) 
+       return NULL;
+
+      dir_finding = 1;
+    } 
+  else 
+    {
+      if (!FindNextFile (dir_find_handle, &find_data))
+       return NULL;
+    }
+  
+  /* Don't return . or .. since it doesn't look like any of the
+     readdir calling code expects them.  */
+  while (strcmp (find_data.cFileName, ".") == 0
+        || strcmp (find_data.cFileName, "..") == 0)
+    {
+      if (!FindNextFile (dir_find_handle, &find_data))
+       return 0;
+    }
+  
+  /* NT's unique ID for a file is 64 bits, so we have to fake it here.  
+     This should work as long as we never use 0.  */
+  dir_static.d_ino = 1;
+  
+  dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 +
+    dir_static.d_namlen - dir_static.d_namlen % 4;
+  
+  dir_static.d_namlen = strlen (find_data.cFileName);
+  strncpy (dir_static.d_name, find_data.cFileName, MAXNAMLEN);
+  
+  return &dir_static;
+}
+
+/* Emulate getpwuid and getpwnam.  */
+
+int getuid (); /* forward declaration */
+
+static char the_passwd_name[256];
+static char the_passwd_passwd[256];
+static char the_passwd_gecos[256];
+static char the_passwd_dir[256];
+static char the_passwd_shell[256];
+
+static struct passwd the_passwd = 
+{
+  the_passwd_name,
+  the_passwd_passwd,
+  0,
+  0,
+  0,
+  the_passwd_gecos,
+  the_passwd_dir,
+  the_passwd_shell,
+};
+
+struct passwd *
+getpwuid (int uid)
+{
+  int size = 256;
+  
+  if (!GetUserName (the_passwd.pw_name, &size))
+    return NULL;
+
+  the_passwd.pw_passwd[0] = '\0';
+  the_passwd.pw_uid = 0;
+  the_passwd.pw_gid = 0;
+  strcpy (the_passwd.pw_gecos, the_passwd.pw_name);
+  the_passwd.pw_dir[0] = '\0';
+  the_passwd.pw_shell[0] = '\0';
+
+  return &the_passwd;
+}
+
+struct passwd *
+getpwnam (char *name)
+{
+  struct passwd *pw;
+  
+  pw = getpwuid (getuid ());
+  if (!pw)
+    return pw;
+
+  if (strcmp (name, pw->pw_name))
+    return NULL;
+
+  return pw;
+}
+
+
+/* We don't have scripts to automatically determine the system configuration
+   for Emacs before it's compiled, and we don't want to have to make the
+   user enter it, so we define EMACS_CONFIGURATION to invoke this runtime
+   routine.  */
+
+static char configuration_buffer[16];
+
+char *
+get_emacs_configuration (void)
+{
+    char *arch, *oem;
+
+    /* Determine the processor type.  */
+    switch (get_processor_type ()) 
+      {
+      case PROCESSOR_INTEL_386:
+      case PROCESSOR_INTEL_486:
+      case PROCESSOR_INTEL_PENTIUM:
+       arch = "i386";
+       break;
+      case PROCESSOR_INTEL_860:
+       arch = "i860";
+       break;
+      case PROCESSOR_MIPS_R2000:
+      case PROCESSOR_MIPS_R3000:
+      case PROCESSOR_MIPS_R4000:
+       arch = "mips";
+       break;
+      case PROCESSOR_ALPHA_21064:
+       arch = "alpha";
+       break;
+      default:
+       arch = "unknown";
+       break;
+      }
+
+    /* Let oem be "*" until we figure out how to decode the OEM field.  */
+    oem = "*";
+
+    sprintf (configuration_buffer, "%s-%s-nt%d.%d", arch, oem,
+            get_nt_major_version (), get_nt_minor_version ());
+    return configuration_buffer;
+}
+
+/* Conjure up inode and device numbers that will serve the purpose
+   of Emacs.  Return 1 upon success, 0 upon failure.  */
+int
+get_inode_and_device_vals (Lisp_Object filename, Lisp_Object *p_inode, 
+                          Lisp_Object *p_device)
+{
+  /* File uids on NT are found using a handle to a file, which
+     implies that it has been opened.  Since we want to be able
+     to stat an arbitrary file, we must open it, get the info,
+     and then close it.
+     
+     Also, NT file uids are 64-bits.  This is a problem.  */
+
+  HANDLE handle;
+  BOOL result;
+  BY_HANDLE_FILE_INFORMATION info;
+
+  /* FIXME:  It shouldn't be opened without READ access, but NT on x86
+     doesn't allow GetFileInfo in that case (NT on mips does).  */
+     
+  handle = CreateFile (XSTRING (filename)->data,
+                      GENERIC_READ,
+                      FILE_SHARE_READ | FILE_SHARE_WRITE,
+                      NULL,
+                      OPEN_EXISTING,
+                      FILE_ATTRIBUTE_NORMAL,
+                      NULL);
+  if (handle == INVALID_HANDLE_VALUE)
+    return 0;
+
+  result = GetFileInformationByHandle (handle, &info);
+  CloseHandle (handle);
+  if (!result)
+    return 0;
+
+  *p_inode = make_number (info.nFileIndexLow);         /* use the low value */
+  *p_device = make_number (info.dwVolumeSerialNumber);
+
+  return 1;
+}
+
+/* The following pipe routines are used to support our fork emulation.
+   Since NT's crt dup always creates inherited handles, we
+   must be careful in setting up pipes.  First create 
+   non-inherited pipe handles, then create an inherited handle
+   to the write end by dup-ing it, and then close the non-inherited
+   end that was just duped.  This gives us one non-inherited handle
+   on the read end and one inherited handle to the write end.  As
+   the parent, we close the inherited handle to the write end after
+   spawning the child.  */
+
+/* From callproc.c  */
+extern Lisp_Object Vbinary_process_input;
+extern Lisp_Object Vbinary_process_output;
+
+void
+pipe_with_inherited_out (int fds[2])
+{
+  int inherit_out;
+  unsigned int flags = _O_NOINHERIT;
+
+  if (!NILP (Vbinary_process_output))
+    flags |= _O_BINARY;
+
+  _pipe (fds, 0, flags);
+  inherit_out = dup (fds[1]);
+  close (fds[1]);
+  fds[1] = inherit_out;
+}
+
+void
+pipe_with_inherited_in (int fds[2])
+{
+  int inherit_in;
+  unsigned int flags = _O_NOINHERIT;
+
+  if (!NILP (Vbinary_process_input))
+    flags |= _O_BINARY;
+
+  _pipe (fds, 0, flags);
+  inherit_in = dup (fds[0]);
+  close (fds[0]);
+  fds[0] = inherit_in;
+}
+
+/* The following two routines are used to manipulate stdin, stdout, and
+   stderr of our child processes.
+
+   Assuming that in, out, and err are inherited, we make them stdin,
+   stdout, and stderr of the child as follows:
+
+   - Save the parent's current standard handles.
+   - Set the parent's standard handles to the handles being passed in.
+     (Note that _get_osfhandle is an io.h procedure that 
+     maps crt file descriptors to NT file handles.)
+   - Spawn the child, which inherits in, out, and err as stdin,
+     stdout, and stderr. (see Spawnve)
+   - Reset the parent's standard handles to the saved handles.
+     (see reset_standard_handles)
+   We assume that the caller closes in, out, and err after calling us.  */
+
+void
+prepare_standard_handles (int in, int out, int err, HANDLE handles[4])
+{
+  HANDLE parent, stdin_save, stdout_save, stderr_save, err_handle;
+  
+  parent = GetCurrentProcess ();
+  if (!DuplicateHandle (parent, 
+                      GetStdHandle (STD_INPUT_HANDLE), 
+                      parent,
+                      &stdin_save, 
+                      0, 
+                      FALSE, 
+                      DUPLICATE_SAME_ACCESS))
+    report_file_error ("Duplicating parent's input handle", Qnil);
+  
+  if (!DuplicateHandle (parent,
+                      GetStdHandle (STD_OUTPUT_HANDLE),
+                      parent,
+                      &stdout_save,
+                      0,
+                      FALSE,
+                      DUPLICATE_SAME_ACCESS))
+    report_file_error ("Duplicating parent's output handle", Qnil);
+  
+  if (!DuplicateHandle (parent,
+                      GetStdHandle (STD_ERROR_HANDLE),
+                      parent,
+                      &stderr_save,
+                      0,
+                      FALSE,
+                      DUPLICATE_SAME_ACCESS))
+    report_file_error ("Duplicating parent's error handle", Qnil);
+  
+  if (!SetStdHandle (STD_INPUT_HANDLE, (HANDLE) _get_osfhandle (in)))
+    report_file_error ("Changing stdin handle", Qnil);
+  
+  if (!SetStdHandle (STD_OUTPUT_HANDLE, (HANDLE) _get_osfhandle (out)))
+    report_file_error ("Changing stdout handle", Qnil);
+  
+  /* We lose data if we use the same handle to the pipe for stdout and
+     stderr, so make a duplicate.  This took a while to find.  */
+  if (out == err) 
+    {
+      if (!DuplicateHandle (parent,
+                          (HANDLE) _get_osfhandle (err),
+                          parent,
+                          &err_handle,
+                          0,
+                          TRUE,
+                          DUPLICATE_SAME_ACCESS))
+       report_file_error ("Duplicating out handle to make err handle.",
+                         Qnil);
+    } 
+  else 
+    {
+      err_handle = (HANDLE) _get_osfhandle (err);
+    }
+
+  if (!SetStdHandle (STD_ERROR_HANDLE, err_handle))
+    report_file_error ("Changing stderr handle", Qnil);
+
+  handles[0] = stdin_save;
+  handles[1] = stdout_save;
+  handles[2] = stderr_save;
+  handles[3] = err_handle;
+}
+
+void
+reset_standard_handles (int in, int out, int err, HANDLE handles[4])
+{
+  HANDLE stdin_save = handles[0];
+  HANDLE stdout_save = handles[1];
+  HANDLE stderr_save = handles[2];
+  HANDLE err_handle = handles[3];
+  
+  if (!SetStdHandle (STD_INPUT_HANDLE, stdin_save))
+    report_file_error ("Resetting input handle", Qnil);
+  
+  if (!SetStdHandle (STD_OUTPUT_HANDLE, stdout_save))
+    report_file_error ("Resetting output handle", Qnil);
+  
+  if (!SetStdHandle (STD_ERROR_HANDLE, stderr_save))
+    report_file_error ("Resetting error handle", Qnil);
+  
+  if (out == err) 
+    {
+      /* If out and err are the same handle, then we duplicated out
+        and stuck it in err_handle.  Close the duplicate to clean up.  */
+      if (!CloseHandle (err_handle))
+       report_file_error ("Closing error handle duplicated from out.", 
+                         Qnil);
+    }
+}
+
+/* Destructively turn backslashes into slashes.  */
+void
+dostounix_filename (p)
+     register char *p;
+{
+  while (*p)
+    {
+      if (*p == '\\')
+       *p = '/';
+      p++;
+    }
+}
+
+/* Routines that are no-ops on NT but are defined to get Emacs to compile.  */
+
+
+int 
+sigsetmask (int signal_mask) 
+{ 
+  return 0;
+}
+
+int 
+sigblock (int sig) 
+{ 
+  return 0;
+}
+
+int 
+kill (int pid, int signal) 
+{ 
+  return 0;
+}
+
+int 
+setpgrp (int pid, int gid) 
+{ 
+  return 0;
+}
+
+int 
+alarm (int seconds) 
+{ 
+  return 0;
+}
+
+int 
+unrequest_sigio (void) 
+{ 
+  return 0;
+}
+
+int 
+request_sigio (void) 
+{ 
+  return 0;
+}
+
+int 
+getuid () 
+{ 
+  return 0; 
+}
+
+int 
+geteuid () 
+{ 
+  return 0; 
+}
+
+/* Remove all CR's that are followed by a LF.
+   (From msdos.c...probably should figure out a way to share it,
+   although this code isn't going to ever change.)  */
+int
+crlf_to_lf (n, buf)
+     register int n;
+     register unsigned char *buf;
+{
+  unsigned char *np = buf;
+  unsigned char *startp = buf;
+  unsigned char *endp = buf + n;
+
+  if (n == 0)
+    return n;
+  while (buf < endp - 1)
+    {
+      if (*buf == 0x0d)
+       {
+         if (*(++buf) != 0x0a)
+           *np++ = 0x0d;
+       }
+      else
+       *np++ = *buf++;
+    }
+  if (buf < endp)
+    *np++ = *buf++;
+  return np - startp;
+}
+
+
+#ifdef PIGSFLY
+Keep this around...we might need it later.
+#ifdef WINDOWSNT
+{
+  /*
+   * Find the user's real name by opening the process token and looking
+   * up the name associated with the user-sid in that token.
+   */
+
+  char            b[256], Name[256], RefD[256];
+  DWORD           length = 256, rlength = 256, trash;
+  HANDLE          Token;
+  SID_NAME_USE    User;
+
+  if (1)
+    Vuser_real_name = build_string ("foo");
+  else if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &Token))
+    {
+      Vuser_real_name = build_string ("unknown");
+    }
+  else if (!GetTokenInformation (Token, TokenUser, (PVOID)b, 256,
+                                &trash))
+    {
+      CloseHandle (Token);
+      Vuser_real_name = build_string ("unknown");
+    }
+  else if (!LookupAccountSid ((void *)0, (PSID)b, Name, &length, RefD,
+                             &rlength, &User))
+    {
+      CloseHandle (Token);
+      Vuser_real_name = build_string ("unknown");
+    }
+  else
+    Vuser_real_name = build_string (Name);
+}
+#else   /* not WINDOWSNT */
+#endif  /* not WINDOWSNT */
+#endif  /* PIGSFLY */
diff --git a/src/w32.h b/src/w32.h
new file mode 100644 (file)
index 0000000..f5a701d
--- /dev/null
+++ b/src/w32.h
@@ -0,0 +1,50 @@
+/* Support routines for the NT version of Emacs.
+   Copyright (C) 1994 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/* File descriptor set emulation.  */
+
+#ifdef FD_SET
+/* We could get this from param.h, but better not to depend on finding that.
+   And better not to risk that it might define other symbols used in this
+   file.  */
+#ifdef FD_SETSIZE
+#define MAXDESC FD_SETSIZE
+#else
+#define MAXDESC 64
+#endif
+#define SELECT_TYPE fd_set
+#else /* no FD_SET */
+#define MAXDESC 32
+#define SELECT_TYPE int
+
+/* Define the macros to access a single-int bitmap of descriptors.  */
+#define FD_SET(n, p) (*(p) |= (1 << (n)))
+#define FD_CLR(n, p) (*(p) &= ~(1 << (n)))
+#define FD_ISSET(n, p) (*(p) & (1 << (n)))
+#define FD_ZERO(p) (*(p) = 0)
+#endif /* no FD_SET */
+
+/* Prepare our standard handles for proper inheritance by child processes.  */
+extern void prepare_standard_handles (int in, int out, 
+                                     int err, HANDLE handles[4]);
+
+/* Reset our standard handles to their original state.  */
+extern void reset_standard_handles (int in, int out, 
+                                   int err, HANDLE handles[4]);
+
diff --git a/src/w32heap.c b/src/w32heap.c
new file mode 100644 (file)
index 0000000..aac860e
--- /dev/null
@@ -0,0 +1,198 @@
+/* Heap management routines for GNU Emacs on Windows NT.
+   Copyright (C) 1994 Free Software Foundation, Inc.
+
+   This file is part of GNU Emacs.
+
+   GNU Emacs is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any later
+   version.
+
+   GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   You should have received a copy of the GNU General Public License along
+   with GNU Emacs; see the file COPYING.  If not, write to the Free Software
+   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+   Geoff Voelker (voelker@cs.washington.edu)                        7-29-94
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "ntheap.h"
+
+/* This gives us the page size and the size of the allocation unit on NT.  */
+SYSTEM_INFO sysinfo_cache;
+
+/* These are defined to get Emacs to compile, but are not used.  */
+int edata;
+int etext;
+
+/* The major and minor versions of NT.  */
+int nt_major_version;
+int nt_minor_version;
+
+/* Cache information describing the NT system for later use.  */
+void
+cache_system_info (void)
+{
+  union 
+    {
+      struct info 
+       {
+         char  major;
+         char  minor;
+         short platform;
+       } info;
+      DWORD data;
+    } version;
+
+  /* Cache the version of the operating system.  */
+  version.data = GetVersion ();
+  nt_major_version = version.info.major;
+  nt_minor_version = version.info.minor;
+
+  /* Cache page size, allocation unit, processor type, etc.  */
+  GetSystemInfo (&sysinfo_cache);
+}
+
+/* Round ADDRESS up to be aligned with ALIGN.  */
+unsigned char *
+round_to_next (unsigned char *address, unsigned long align)
+{
+  unsigned long tmp;
+
+  tmp = (unsigned long) address;
+  tmp = (tmp + align - 1) / align;
+
+  return (unsigned char *) (tmp * align);
+}
+
+/* Info for keeping track of our heap.  */
+unsigned char *data_region_base = NULL;
+unsigned char *data_region_end = NULL;
+unsigned long  data_region_size = 0;
+
+/* The start of the data segment.  */
+unsigned char *
+get_data_start (void)
+{
+  return data_region_base;
+}
+
+/* The end of the data segment.  */
+unsigned char *
+get_data_end (void)
+{
+  return data_region_end;
+}
+
+/* Emulate Unix sbrk.  */
+void *
+sbrk (unsigned long increment)
+{
+  void *result;
+  long size = (long) increment;
+  
+  /* Allocate our heap if we haven't done so already.  */
+  if (!data_region_base) 
+    {
+      data_region_base = VirtualAlloc ((void *) get_data_region_base (),
+                                      get_reserved_heap_size (),
+                                      MEM_RESERVE,
+                                      PAGE_NOACCESS);
+      if (!data_region_base)
+       return NULL;
+
+      /* Ensure that the addresses don't use the upper 8 bits since
+        the Lisp type goes there (yucko).  */
+      if (((unsigned long) data_region_base & 0xFF000000) != 0) 
+       {
+         printf ("Error: The heap was allocated in upper memory.\n");
+         exit (1);
+       }
+
+      data_region_end = data_region_base;
+      data_region_size = get_reserved_heap_size ();
+    }
+  
+  result = data_region_end;
+  
+  /* If size is negative, shrink the heap by decommitting pages.  */
+  if (size < 0) 
+    {
+      size = -size;
+
+      /* Sanity checks.  */
+      if (size % get_page_size () != 0)
+       return NULL;
+      if ((data_region_end - size) < data_region_base)
+       return NULL;
+
+      /* Decommit size bytes from the end of the heap.  */
+      if (!VirtualFree (data_region_end - size, size, MEM_DECOMMIT))
+       return NULL;
+
+      data_region_end -= size;
+    } 
+  /* If size is positive, grow the heap by committing reserved pages.  */
+  else if (size > 0) 
+    {
+      /* Sanity checks.  */
+      if (size % get_page_size () != 0)
+       return NULL;
+      if ((data_region_end + size) >
+         (data_region_base + get_reserved_heap_size ()))
+       return NULL;
+
+      /* Commit more of our heap. */
+      if (VirtualAlloc (data_region_end, size, MEM_COMMIT,
+                       PAGE_READWRITE) == NULL)
+       return NULL;
+      data_region_end += size;
+    }
+  
+  return result;
+}
+
+/* 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)
+{
+  unsigned char *tmp;
+
+  /* First reserve the upper part of our heap.  (We reserve first
+     because there have been problems in the past where doing the
+     mapping first has loaded DLLs into the VA space of our heap.)  */
+  tmp = VirtualAlloc ((void *) get_heap_end (),
+                     get_reserved_heap_size () - get_committed_heap_size (),
+                     MEM_RESERVE,
+                     PAGE_NOACCESS);
+  if (!tmp)
+    exit (1);
+
+  /* We read in the data for the .bss section from the executable
+     first and map in the heap from the executable second to prevent
+     any funny interactions between file I/O and file mapping.  */
+  read_in_bss (executable_path);
+  map_in_heap (executable_path);
+}
+
+/* Round the heap up to the given alignment.  */
+void
+round_heap (unsigned long align)
+{
+  unsigned long needs_to_be;
+  unsigned long need_to_alloc;
+  
+  needs_to_be = (unsigned long) round_to_next (get_heap_end (), align);
+  need_to_alloc = needs_to_be - (unsigned long) get_heap_end ();
+  
+  if (need_to_alloc) 
+    sbrk (need_to_alloc);
+}
diff --git a/src/w32heap.h b/src/w32heap.h
new file mode 100644 (file)
index 0000000..9cf2882
--- /dev/null
@@ -0,0 +1,72 @@
+/* Heap management routines (including unexec) for GNU Emacs on Windows NT.
+   Copyright (C) 1994 Free Software Foundation, Inc.
+
+   This file is part of GNU Emacs.
+
+   GNU Emacs is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any later
+   version.
+
+   GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   You should have received a copy of the GNU General Public License along
+   with GNU Emacs; see the file COPYING.  If not, write to the Free Software
+   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+   Geoff Voelker (voelker@cs.washington.edu)                        7-29-94
+*/
+
+#ifndef NTHEAP_H_
+#define NTHEAP_H_
+
+#include <windows.h>
+
+/*
+ * Heap related stuff.
+ */
+#define get_data_region_base()         (char *) 0x00030000
+#define get_reserved_heap_size()       (0x00d00000 - 0x00030000)
+#define get_committed_heap_size()      (get_data_end () - get_data_start ())
+#define get_heap_start()               get_data_start ()
+#define get_heap_end()                 get_data_end ()
+#define get_page_size()                        sysinfo_cache.dwPageSize
+#define get_allocation_unit()          sysinfo_cache.dwAllocationGranularity
+#define get_processor_type()           sysinfo_cache.dwProcessorType
+#define get_nt_major_version()         nt_major_version
+#define get_nt_minor_version()         nt_minor_version
+
+extern unsigned char *get_data_start();
+extern unsigned char *get_data_end();
+extern unsigned long  data_region_size;
+extern SYSTEM_INFO    sysinfo_cache;
+extern BOOL          need_to_recreate_heap;
+extern int           nt_major_version;
+extern int           nt_minor_version;
+
+/* Emulation of Unix sbrk().  */
+extern void *sbrk (unsigned long size);
+
+/* Recreate the heap created during dumping.  */
+extern void recreate_heap (char *executable_path);
+
+/* Round the heap to this size.  */
+extern void round_heap (unsigned long size);
+
+/* Load in the dumped .bss section.  */
+extern void read_in_bss (char *name);
+
+/* Map in the dumped heap.  */
+extern void map_in_heap (char *name);
+
+/* Cache system info, e.g., the NT page size.  */
+extern void cache_system_info (void);
+
+/* Round ADDRESS up to be aligned with ALIGN.  */
+extern unsigned char *round_to_next (unsigned char *address, 
+                                    unsigned long align);
+
+#endif /* NTHEAP_H_ */