aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-11-01 08:39:49 +0000
committerRichard M. Stallman1994-11-01 08:39:49 +0000
commitfe03522be20223eb522838cb115e8a97b6aac1b0 (patch)
treeea21565a4fd299355027fb3a86fa7ac91cdf0a97
parente98d950b325d0d123035613177685f9aaf2b487e (diff)
downloademacs-fe03522be20223eb522838cb115e8a97b6aac1b0.tar.gz
emacs-fe03522be20223eb522838cb115e8a97b6aac1b0.zip
[WINDOWSNT]: Add includes for NT.
Define _P_WAIT. Declare _spawnlp, _getpid. [WINDOWSNT] (select, strerror, vfork): Don't use these definitions. (init_sys_modes): Test DOS_NT, not MSDOS. (emacs_get_tty, emacs_set_tty,(child_setup_tty, init_baud_rate): Ditto. (sys_subshell) [WINDOWSNT]: Use _spawnlp. not vfork. (wait_for_termination) [WINDOWSNT]: Use wait. (discard_tty_input) [WINDOWSNT]: Do nothing at all.
-rw-r--r--src/sysdep.c100
1 files changed, 70 insertions, 30 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 3067fe2ccbe..63e6eb4f0ac 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -40,6 +40,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
40#undef read 40#undef read
41#undef write 41#undef write
42 42
43#ifdef WINDOWSNT
44#define read _read
45#define write _write
46#include <windows.h>
47extern int errno;
48#endif /* not WINDOWSNT */
49
43#ifndef close 50#ifndef close
44#define sys_close close 51#define sys_close close
45#else 52#else
@@ -97,7 +104,7 @@ extern int errno;
97#ifndef RAB$C_BID 104#ifndef RAB$C_BID
98#include <rab.h> 105#include <rab.h>
99#endif 106#endif
100#define MAXIOSIZE ( 32 * PAGESIZE ) /* Don't I/O more than 32 blocks at a time */ 107#define MAXIOSIZE (32 * PAGESIZE) /* Don't I/O more than 32 blocks at a time */
101#endif /* VMS */ 108#endif /* VMS */
102 109
103#ifndef BSD4_1 110#ifndef BSD4_1
@@ -150,6 +157,14 @@ extern int quit_char;
150#include "dispextern.h" 157#include "dispextern.h"
151#include "process.h" 158#include "process.h"
152 159
160#ifdef WINDOWSNT
161#include <direct.h>
162/* In process.h which conflicts with the local copy. */
163#define _P_WAIT 0
164int _CRTAPI1 _spawnlp (int, const char *, const char *, ...);
165int _CRTAPI1 _getpid (void);
166#endif
167
153#ifdef NONSYSTEM_DIR_LIBRARY 168#ifdef NONSYSTEM_DIR_LIBRARY
154#include "ndir.h" 169#include "ndir.h"
155#endif /* NONSYSTEM_DIR_LIBRARY */ 170#endif /* NONSYSTEM_DIR_LIBRARY */
@@ -210,6 +225,7 @@ change_input_fd (fd)
210 225
211discard_tty_input () 226discard_tty_input ()
212{ 227{
228#ifndef WINDOWSNT
213 struct emacs_tty buf; 229 struct emacs_tty buf;
214 230
215 if (noninteractive) 231 if (noninteractive)
@@ -232,15 +248,16 @@ discard_tty_input ()
232 ioctl (input_fd, TIOCFLUSH, &zero); 248 ioctl (input_fd, TIOCFLUSH, &zero);
233 } 249 }
234#else /* not Apollo */ 250#else /* not Apollo */
235#ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ 251#ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */
236 while (dos_keyread () != -1) 252 while (dos_keyread () != -1)
237 ; 253 ;
238#else /* not MSDOS */ 254#else /* not MSDOS */
239 EMACS_GET_TTY (input_fd, &buf); 255 EMACS_GET_TTY (input_fd, &buf);
240 EMACS_SET_TTY (input_fd, &buf, 0); 256 EMACS_SET_TTY (input_fd, &buf, 0);
241#endif /* not MSDOS */ 257#endif /* not MSDOS */
242#endif /* not Apollo */ 258#endif /* not Apollo */
243#endif /* not VMS */ 259#endif /* not VMS */
260#endif /* not WINDOWSNT */
244} 261}
245 262
246#ifdef SIGTSTP 263#ifdef SIGTSTP
@@ -270,9 +287,9 @@ init_baud_rate ()
270 ospeed = 0; 287 ospeed = 0;
271 else 288 else
272 { 289 {
273#ifdef MSDOS 290#ifdef DOS_NT
274 ospeed = 15; 291 ospeed = 15;
275#else 292#else /* not DOS_NT */
276#ifdef VMS 293#ifdef VMS
277 struct sensemode sg; 294 struct sensemode sg;
278 295
@@ -312,11 +329,11 @@ init_baud_rate ()
312#endif /* not HAVE_TERMIO */ 329#endif /* not HAVE_TERMIO */
313#endif /* not HAVE_TERMIOS */ 330#endif /* not HAVE_TERMIOS */
314#endif /* not VMS */ 331#endif /* not VMS */
315#endif /* not MSDOS */ 332#endif /* not DOS_NT */
316 } 333 }
317 334
318 baud_rate = (ospeed < sizeof baud_convert / sizeof baud_convert[0] 335 baud_rate = (ospeed < sizeof baud_convert / sizeof baud_convert[0]
319 ? baud_convert[ospeed] : 9600); 336 ? baud_convert[ospeed] : 9600);
320 if (baud_rate == 0) 337 if (baud_rate == 0)
321 baud_rate = 1200; 338 baud_rate = 1200;
322} 339}
@@ -346,7 +363,7 @@ wait_without_blocking ()
346#endif /* not subprocesses */ 363#endif /* not subprocesses */
347 364
348int wait_debugging; /* Set nonzero to make following function work under dbx 365int wait_debugging; /* Set nonzero to make following function work under dbx
349 (at least for bsd). */ 366 (at least for bsd). */
350 367
351SIGTYPE 368SIGTYPE
352wait_for_termination_signal () 369wait_for_termination_signal ()
@@ -377,7 +394,7 @@ wait_for_termination (pid)
377 if that causes the problem to go away or get worse. */ 394 if that causes the problem to go away or get worse. */
378 sigsetmask (sigmask (SIGCHLD)); 395 sigsetmask (sigmask (SIGCHLD));
379 if (0 > kill (pid, 0)) 396 if (0 > kill (pid, 0))
380 { 397 {
381 sigsetmask (SIGEMPTYMASK); 398 sigsetmask (SIGEMPTYMASK);
382 kill (getpid (), SIGCHLD); 399 kill (getpid (), SIGCHLD);
383 break; 400 break;
@@ -392,7 +409,7 @@ wait_for_termination (pid)
392 break; 409 break;
393 wait (0); 410 wait (0);
394#else /* neither BSD nor UNIPLUS: random sysV */ 411#else /* neither BSD nor UNIPLUS: random sysV */
395#ifdef POSIX_SIGNALS /* would this work for LINUX as well? */ 412#ifdef POSIX_SIGNALS /* would this work for LINUX as well? */
396 sigblock (sigmask (SIGCHLD)); 413 sigblock (sigmask (SIGCHLD));
397 if (0 > kill (pid, 0)) 414 if (0 > kill (pid, 0))
398 { 415 {
@@ -410,12 +427,17 @@ wait_for_termination (pid)
410 } 427 }
411 sigpause (SIGCHLD); 428 sigpause (SIGCHLD);
412#else /* not HAVE_SYSV_SIGPAUSE */ 429#else /* not HAVE_SYSV_SIGPAUSE */
430#ifdef WINDOWSNT
431 wait (0);
432 break;
433#else /* not WINDOWSNT */
413 if (0 > kill (pid, 0)) 434 if (0 > kill (pid, 0))
414 break; 435 break;
415 /* Using sleep instead of pause avoids timing error. 436 /* Using sleep instead of pause avoids timing error.
416 If the inferior dies just before the sleep, 437 If the inferior dies just before the sleep,
417 we lose just one second. */ 438 we lose just one second. */
418 sleep (1); 439 sleep (1);
440#endif /* not WINDOWSNT */
419#endif /* not HAVE_SYSV_SIGPAUSE */ 441#endif /* not HAVE_SYSV_SIGPAUSE */
420#endif /* not POSIX_SIGNALS */ 442#endif /* not POSIX_SIGNALS */
421#endif /* not UNIPLUS */ 443#endif /* not UNIPLUS */
@@ -473,7 +495,7 @@ flush_pending_output (channel)
473child_setup_tty (out) 495child_setup_tty (out)
474 int out; 496 int out;
475{ 497{
476#ifndef MSDOS 498#ifndef DOS_NT
477 struct emacs_tty s; 499 struct emacs_tty s;
478 500
479 EMACS_GET_TTY (out, &s); 501 EMACS_GET_TTY (out, &s);
@@ -561,7 +583,7 @@ child_setup_tty (out)
561 ioctl (out, FIOASYNC, &zero); 583 ioctl (out, FIOASYNC, &zero);
562 } 584 }
563#endif /* RTU */ 585#endif /* RTU */
564#endif /* not MSDOS */ 586#endif /* not DOS_NT */
565} 587}
566#endif /* not VMS */ 588#endif /* not VMS */
567 589
@@ -686,15 +708,19 @@ sys_subshell ()
686 str[len] = 0; 708 str[len] = 0;
687 xyzzy: 709 xyzzy:
688 710
711#ifdef WINDOWSNT
712 pid = -1;
713#else /* not WINDOWSNT */
689 pid = vfork (); 714 pid = vfork ();
690 715
691 if (pid == -1) 716 if (pid == -1)
692 error ("Can't spawn subshell"); 717 error ("Can't spawn subshell");
693 if (pid == 0) 718 if (pid == 0)
719#endif /* not WINDOWSNT */
694 { 720 {
695 char *sh; 721 char *sh;
696 722
697#ifdef MSDOS /* MW, Aug 1993 */ 723#ifdef MSDOS /* MW, Aug 1993 */
698 getwd (oldwd); 724 getwd (oldwd);
699#endif 725#endif
700 sh = (char *) egetenv ("SHELL"); 726 sh = (char *) egetenv ("SHELL");
@@ -718,15 +744,26 @@ sys_subshell ()
718 } 744 }
719#endif 745#endif
720 746
721#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ 747#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */
722 st = system (sh); 748 st = system (sh);
723 chdir (oldwd); 749 chdir (oldwd);
724 if (st) 750 if (st)
725 report_file_error ("Can't execute subshell", Fcons (build_string (sh), Qnil)); 751 report_file_error ("Can't execute subshell", Fcons (build_string (sh), Qnil));
726#else /* not MSDOS */ 752#else /* not MSDOS */
753#ifdef WINDOWSNT
754 restore_console ();
755
756 /* Waits for process completion */
757 pid = _spawnlp (_P_WAIT, sh, sh, NULL);
758 if (pid == -1)
759 write (1, "Can't execute subshell", 22);
760
761 take_console ();
762#else /* not WINDOWSNT */
727 execlp (sh, sh, 0); 763 execlp (sh, sh, 0);
728 write (1, "Can't execute subshell", 22); 764 write (1, "Can't execute subshell", 22);
729 _exit (1); 765 _exit (1);
766#endif /* not WINDOWSNT */
730#endif /* not MSDOS */ 767#endif /* not MSDOS */
731 } 768 }
732 769
@@ -963,11 +1000,11 @@ emacs_get_tty (fd, settings)
963 return -1; 1000 return -1;
964 1001
965#else 1002#else
966#ifndef MSDOS 1003#ifndef DOS_NT
967 /* I give up - I hope you have the BSD ioctls. */ 1004 /* I give up - I hope you have the BSD ioctls. */
968 if (ioctl (fd, TIOCGETP, &settings->main) < 0) 1005 if (ioctl (fd, TIOCGETP, &settings->main) < 0)
969 return -1; 1006 return -1;
970#endif /* not MSDOS */ 1007#endif /* not DOS_NT */
971#endif 1008#endif
972#endif 1009#endif
973#endif 1010#endif
@@ -1055,11 +1092,11 @@ emacs_set_tty (fd, settings, waitp)
1055 return -1; 1092 return -1;
1056 1093
1057#else 1094#else
1058#ifndef MSDOS 1095#ifndef DOS_NT
1059 /* I give up - I hope you have the BSD ioctls. */ 1096 /* I give up - I hope you have the BSD ioctls. */
1060 if (ioctl (fd, (waitp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) 1097 if (ioctl (fd, (waitp) ? TIOCSETP : TIOCSETN, &settings->main) < 0)
1061 return -1; 1098 return -1;
1062#endif /* not MSDOS */ 1099#endif /* not DOS_NT */
1063 1100
1064#endif 1101#endif
1065#endif 1102#endif
@@ -1282,12 +1319,12 @@ init_sys_modes ()
1282 tty.main.tt_char &= ~TT$M_TTSYNC; 1319 tty.main.tt_char &= ~TT$M_TTSYNC;
1283 tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON; 1320 tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON;
1284#else /* not VMS (BSD, that is) */ 1321#else /* not VMS (BSD, that is) */
1285#ifndef MSDOS 1322#ifndef DOS_NT
1286 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); 1323 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
1287 if (meta_key) 1324 if (meta_key)
1288 tty.main.sg_flags |= ANYP; 1325 tty.main.sg_flags |= ANYP;
1289 tty.main.sg_flags |= interrupt_input ? RAW : CBREAK; 1326 tty.main.sg_flags |= interrupt_input ? RAW : CBREAK;
1290#endif 1327#endif /* not DOS_NT */
1291#endif /* not VMS (BSD, that is) */ 1328#endif /* not VMS (BSD, that is) */
1292#endif /* not HAVE_TERMIO */ 1329#endif /* not HAVE_TERMIO */
1293 1330
@@ -2181,6 +2218,7 @@ select_alarm ()
2181 longjmp (read_alarm_throw, 1); 2218 longjmp (read_alarm_throw, 1);
2182} 2219}
2183 2220
2221#ifndef WINDOWSNT
2184/* Only rfds are checked. */ 2222/* Only rfds are checked. */
2185int 2223int
2186select (nfds, rfds, wfds, efds, timeout) 2224select (nfds, rfds, wfds, efds, timeout)
@@ -2311,6 +2349,7 @@ select (nfds, rfds, wfds, efds, timeout)
2311 } 2349 }
2312 return ravail; 2350 return ravail;
2313} 2351}
2352#endif /* not WINDOWSNT */
2314 2353
2315/* Read keyboard input into the standard buffer, 2354/* Read keyboard input into the standard buffer,
2316 waiting for at least one character. */ 2355 waiting for at least one character. */
@@ -2801,6 +2840,7 @@ char *sys_errlist[] =
2801#endif /* VMS */ 2840#endif /* VMS */
2802 2841
2803#ifndef HAVE_STRERROR 2842#ifndef HAVE_STRERROR
2843#ifndef WINDOWSNT
2804char * 2844char *
2805strerror (errnum) 2845strerror (errnum)
2806 int errnum; 2846 int errnum;
@@ -2812,7 +2852,7 @@ strerror (errnum)
2812 return sys_errlist[errnum]; 2852 return sys_errlist[errnum];
2813 return (char *) "Unknown error"; 2853 return (char *) "Unknown error";
2814} 2854}
2815 2855#endif /* not WINDOWSNT */
2816#endif /* ! HAVE_STRERROR */ 2856#endif /* ! HAVE_STRERROR */
2817 2857
2818#ifdef INTERRUPTIBLE_OPEN 2858#ifdef INTERRUPTIBLE_OPEN
@@ -2893,16 +2933,16 @@ sys_write (fildes, buf, nbyte)
2893#endif /* INTERRUPTIBLE_IO */ 2933#endif /* INTERRUPTIBLE_IO */
2894 2934
2895#ifndef HAVE_VFORK 2935#ifndef HAVE_VFORK
2896 2936#ifndef WINDOWSNT
2897/* 2937/*
2898 * Substitute fork for vfork on USG flavors. 2938 * Substitute fork for vfork on USG flavors.
2899 */ 2939 */
2900 2940
2901vfork () 2941vfork ()
2902{ 2942{
2903 return (fork ()); 2943 return (fork ());
2904} 2944}
2905 2945#endif /* not WINDOWSNT */
2906#endif /* not HAVE_VFORK */ 2946#endif /* not HAVE_VFORK */
2907 2947
2908#ifdef USG 2948#ifdef USG
@@ -3662,8 +3702,8 @@ sys_access (path, mode)
3662#else /* not VMS4_4 */ 3702#else /* not VMS4_4 */
3663 3703
3664#include <prvdef.h> 3704#include <prvdef.h>
3665#define ACE$M_WRITE 2 3705#define ACE$M_WRITE 2
3666#define ACE$C_KEYID 1 3706#define ACE$C_KEYID 1
3667 3707
3668static unsigned short memid, grpid; 3708static unsigned short memid, grpid;
3669static unsigned int uic; 3709static unsigned int uic;
@@ -3696,13 +3736,13 @@ sys_access (filename, type)
3696 grpid = uic >> 16; 3736 grpid = uic >> 16;
3697 } 3737 }
3698 3738
3699 if (type != 2) /* not checking write access */ 3739 if (type != 2) /* not checking write access */
3700 return access (filename, type); 3740 return access (filename, type);
3701 3741
3702 /* Check write protection. */ 3742 /* Check write protection. */
3703 3743
3704#define CHECKPRIV(bit) (prvmask.bit) 3744#define CHECKPRIV(bit) (prvmask.bit)
3705#define WRITEABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE)) 3745#define WRITEABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE))
3706 3746
3707 /* Find privilege bits */ 3747 /* Find privilege bits */
3708 status = SYS$SETPRV (0, 0, 0, prvmask); 3748 status = SYS$SETPRV (0, 0, 0, prvmask);