diff src/nt.c @ 239:41f2f0e326e9 r20-5b18

Import from CVS: tag r20-5b18
author cvs
date Mon, 13 Aug 2007 10:15:48 +0200
parents 2c611d1463a6
children 727739f917cb
line wrap: on
line diff
--- a/src/nt.c	Mon Aug 13 10:15:04 2007 +0200
+++ b/src/nt.c	Mon Aug 13 10:15:48 2007 +0200
@@ -38,6 +38,7 @@
 #include "config.h"
 #include "systime.h"
 #include "syssignal.h"
+#include "sysproc.h"
 
 #undef access
 #undef chdir
@@ -300,19 +301,6 @@
     CloseHandle (token);
 }
 
-int
-random ()
-{
-  /* rand () on NT gives us 15 random bits...hack together 30 bits.  */
-  return ((rand () << 15) | rand ());
-}
-
-void
-srandom (int seed)
-{
-  srand (seed);
-}
-
 /* Normalize filename by converting all path separators to
    the specified separator.  Also conditionally convert upper
    case path name components to lower case.  */
@@ -557,13 +545,7 @@
 
 /* Routines that are no-ops on NT but are defined to get Emacs to compile.  */
 
-int 
-setpgrp (int pid, int gid) 
-{ 
-  return 0;
-}
-
-
+#if 0 /* #### We do not need those, do we? -kkm */
 int 
 unrequest_sigio (void) 
 { 
@@ -575,6 +557,7 @@
 { 
   return 0;
 }
+#endif /* 0 */
 
 #define REG_ROOT "SOFTWARE\\GNU\\XEmacs"
 
@@ -829,6 +812,9 @@
 }
 #endif
 
+/* #### This is an evil dirty hack. We must get rid of it.
+   Word "munging" is not in XEmacs lexicon. - kkm */
+
 /* Internal MSVC data and functions for low-level descriptor munging */
 #if (_MSC_VER == 900)
 extern char _osfile[];
@@ -1447,10 +1433,18 @@
 int
 sys_open (const char * path, int oflag, int mode)
 {
-  int		fd;
+  int fd;
 
   /* Force all file handles to be non-inheritable. */
   fd = _open (map_win32_filename (path, NULL), oflag | _O_NOINHERIT, mode);
+
+  if (fd >= MAXDESC)
+    {
+      _close (fd);
+      errno = EMFILE;
+      return -1;
+    }
+
   if (fd >= 0)
     {
       fd_info[fd].cp = 0;