comparison src/sysdep.c @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents b8cc9ab3f761
children 697ef44129c6
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
29 29
30 #define DONT_ENCAPSULATE 30 #define DONT_ENCAPSULATE
31 31
32 #include <config.h> 32 #include <config.h>
33 33
34 #ifdef WINDOWSNT 34 #ifdef WIN32_NATIVE
35 #include <direct.h> 35 #ifdef MINGW
36 #ifdef __MINGW32__
37 #include <mingw32/process.h> 36 #include <mingw32/process.h>
38 #else 37 #else
39 /* <process.h> should not conflict with "process.h", as per ANSI definition. 38 /* <process.h> should not conflict with "process.h", as per ANSI definition.
40 This is not true with visual c though. The trick below works with 39 This is not true with visual c though. The trick below works with
41 VC4.2b, 5.0 and 6.0. It assumes that VC is installed in a kind of 40 VC4.2b, 5.0 and 6.0. It assumes that VC is installed in a kind of
43 42
44 Unfortunately, this must go before lisp.h, since process.h defines abort() 43 Unfortunately, this must go before lisp.h, since process.h defines abort()
45 which will conflict with the macro defined in lisp.h 44 which will conflict with the macro defined in lisp.h
46 */ 45 */
47 #include <../include/process.h> 46 #include <../include/process.h>
48 #endif /* __MINGW32__ */ 47 #endif /* MINGW */
49 #endif /* WINDOWSNT */ 48 #endif /* WIN32_NATIVE */
50 49
51 #include "lisp.h" 50 #include "lisp.h"
52
53 #include <stdlib.h>
54 51
55 /* ------------------------------- */ 52 /* ------------------------------- */
56 /* basic includes */ 53 /* basic includes */
57 /* ------------------------------- */ 54 /* ------------------------------- */
58 55
79 #endif 76 #endif
80 #include "sysfile.h" 77 #include "sysfile.h"
81 #include "syswait.h" 78 #include "syswait.h"
82 #include "sysdir.h" 79 #include "sysdir.h"
83 #include "systime.h" 80 #include "systime.h"
84 #if defined(WINDOWSNT) || defined(__CYGWIN32__) 81 #if defined(WIN32_NATIVE) || defined(CYGWIN)
85 #include "syssignal.h" 82 #include "syssignal.h"
86 #endif 83 #endif
87 #ifndef WINDOWSNT 84
85 #include "sysproc.h"
86
87 #ifndef WIN32_NATIVE
88 #include <sys/times.h> 88 #include <sys/times.h>
89 #endif 89 #endif
90 90
91 #ifdef WINDOWSNT 91 #ifdef WIN32_NATIVE
92 #include <sys/utime.h> 92 #include <sys/utime.h>
93 #include "ntheap.h" 93 #include "ntheap.h"
94 #include "nt.h"
94 #endif 95 #endif
95 96
96 /* ------------------------------- */ 97 /* ------------------------------- */
97 /* TTY definitions */ 98 /* TTY definitions */
98 /* ------------------------------- */ 99 /* ------------------------------- */
231 #endif /* BSD */ 232 #endif /* BSD */
232 233
233 #endif /* NO_SUBPROCESSES */ 234 #endif /* NO_SUBPROCESSES */
234 235
235 236
236 #ifdef WINDOWSNT 237 #ifdef WIN32_NATIVE
237 void wait_for_termination (HANDLE pHandle) 238 void wait_for_termination (HANDLE pHandle)
238 #else 239 #else
239 void wait_for_termination (int pid) 240 void wait_for_termination (int pid)
240 #endif 241 #endif
241 { 242 {
345 - EINVAL (incorrect arguments), 346 - EINVAL (incorrect arguments),
346 which are both program bugs. 347 which are both program bugs.
347 348
348 Since implementations may add their own error indicators on top, 349 Since implementations may add their own error indicators on top,
349 we ignore it by default. */ 350 we ignore it by default. */
350 #elif defined (WINDOWSNT) 351 #elif defined (WIN32_NATIVE)
351 int ret = 0, status = 0; 352 int ret = 0, status = 0;
352 if (pHandle == NULL) 353 if (pHandle == NULL)
353 { 354 {
354 warn_when_safe (Qprocess, Qwarning, "Cannot wait for unknown process to terminate"); 355 warn_when_safe (Qprocess, Qwarning, "Cannot wait for unknown process to terminate");
355 return; 356 return;
419 sigpause()/sigsuspend(), then your OS doesn't implement 420 sigpause()/sigsuspend(), then your OS doesn't implement
420 this properly (this applies under hpux9, for example). 421 this properly (this applies under hpux9, for example).
421 Try defining BROKEN_WAIT_FOR_SIGNAL. */ 422 Try defining BROKEN_WAIT_FOR_SIGNAL. */
422 EMACS_WAIT_FOR_SIGNAL (SIGCHLD); 423 EMACS_WAIT_FOR_SIGNAL (SIGCHLD);
423 } 424 }
424 #else /* not HAVE_WAITPID and not WINDOWSNT and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */ 425 #else /* not HAVE_WAITPID and not WIN32_NATIVE and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */
425 /* This approach is kind of cheesy but is guaranteed(?!) to work 426 /* This approach is kind of cheesy but is guaranteed(?!) to work
426 for all systems. */ 427 for all systems. */
427 while (1) 428 while (1)
428 { 429 {
429 QUIT; 430 QUIT;
457 and nonzero means something different. */ 458 and nonzero means something different. */
458 ioctl (channel, TIOCFLUSH, &zero); 459 ioctl (channel, TIOCFLUSH, &zero);
459 #endif 460 #endif
460 } 461 }
461 462
462 #ifndef WINDOWSNT 463 #ifndef WIN32_NATIVE
463 /* Set up the terminal at the other end of a pseudo-terminal that 464 /* Set up the terminal at the other end of a pseudo-terminal that
464 we will be controlling an inferior through. 465 we will be controlling an inferior through.
465 It should not echo or do line-editing, since that is done 466 It should not echo or do line-editing, since that is done
466 in Emacs. No padding needed for insertion into an Emacs buffer. */ 467 in Emacs. No padding needed for insertion into an Emacs buffer. */
467 468
568 int zero = 0; 569 int zero = 0;
569 ioctl (out, FIOASYNC, &zero); 570 ioctl (out, FIOASYNC, &zero);
570 } 571 }
571 #endif /* RTU */ 572 #endif /* RTU */
572 } 573 }
573 #endif /* WINDOWSNT */ 574 #endif /* WIN32_NATIVE */
574 575
575 #endif /* not NO_SUBPROCESSES */ 576 #endif /* not NO_SUBPROCESSES */
576 577
577 578
578 #if !defined (SIGTSTP) && !defined (USG_JOBCTRL) 579 #if !defined (SIGTSTP) && !defined (USG_JOBCTRL)
609 signal (saved_handlers->code, saved_handlers->handler); 610 signal (saved_handlers->code, saved_handlers->handler);
610 saved_handlers++; 611 saved_handlers++;
611 } 612 }
612 } 613 }
613 614
614 #ifdef WINDOWSNT 615 #ifdef WIN32_NATIVE
615 616
616 pid_t 617 pid_t
617 sys_getpid (void) 618 sys_getpid (void)
618 { 619 {
619 return abs (getpid ()); 620 return abs (getpid ());
620 } 621 }
621 622
622 #endif /* WINDOWSNT */ 623 #endif /* WIN32_NATIVE */
623 624
624 /* Fork a subshell. */ 625 /* Fork a subshell. */
625 static void 626 static void
626 sys_subshell (void) 627 sys_subshell (void)
627 { 628 {
628 #ifndef WINDOWSNT 629 #ifndef WIN32_NATIVE
629 int pid; 630 int pid;
630 #endif 631 #endif
631 struct save_signal saved_handlers[5]; 632 struct save_signal saved_handlers[5];
632 Lisp_Object dir; 633 Lisp_Object dir;
633 unsigned char *str = 0; 634 unsigned char *str = 0;
663 if (!IS_ANY_SEP (str[len - 1])) 664 if (!IS_ANY_SEP (str[len - 1]))
664 str[len++] = DIRECTORY_SEP; 665 str[len++] = DIRECTORY_SEP;
665 str[len] = 0; 666 str[len] = 0;
666 xyzzy: 667 xyzzy:
667 668
668 #ifndef WINDOWSNT 669 #ifndef WIN32_NATIVE
669 pid = fork (); 670 pid = fork ();
670 671
671 if (pid == -1) 672 if (pid == -1)
672 error ("Can't spawn subshell"); 673 error ("Can't spawn subshell");
673 if (pid == 0) 674 if (pid == 0)
674 #endif /* not WINDOWSNT */ 675 #endif /* not WIN32_NATIVE */
675 { 676 {
676 char *sh = 0; 677 char *sh = 0;
677 678
678 if (sh == 0) 679 if (sh == 0)
679 sh = (char *) egetenv ("SHELL"); 680 sh = (char *) egetenv ("SHELL");
682 683
683 /* Use our buffer's default directory for the subshell. */ 684 /* Use our buffer's default directory for the subshell. */
684 if (str) 685 if (str)
685 sys_chdir (str); 686 sys_chdir (str);
686 687
687 #ifdef WINDOWSNT 688 #ifdef WIN32_NATIVE
688 689
689 /* Waits for process completion */ 690 /* Waits for process completion */
690 if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0) 691 if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0)
691 error ("Can't spawn subshell"); 692 error ("Can't spawn subshell");
692 else 693 else
712 save_signal_handlers (saved_handlers); 713 save_signal_handlers (saved_handlers);
713 synch_process_alive = 1; 714 synch_process_alive = 1;
714 wait_for_termination (pid); 715 wait_for_termination (pid);
715 restore_signal_handlers (saved_handlers); 716 restore_signal_handlers (saved_handlers);
716 717
717 #endif /* not WINDOWSNT */ 718 #endif /* not WIN32_NATIVE */
718 719
719 } 720 }
720 721
721 #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */ 722 #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */
722 723
959 960
960 #ifdef HAVE_TTY 961 #ifdef HAVE_TTY
961 assert (DEVICE_TTY_P (d)); 962 assert (DEVICE_TTY_P (d));
962 { 963 {
963 int input_fd = CONSOLE_TTY_DATA (con)->infd; 964 int input_fd = CONSOLE_TTY_DATA (con)->infd;
964 #if defined (WINDOWSNT) 965 #if defined (WIN32_NATIVE)
965 DEVICE_TTY_DATA (d)->ospeed = 15; 966 DEVICE_TTY_DATA (d)->ospeed = 15;
966 #elif defined (HAVE_TERMIOS) 967 #elif defined (HAVE_TERMIOS)
967 struct termios sg; 968 struct termios sg;
968 969
969 sg.c_cflag = B9600; 970 sg.c_cflag = B9600;
1385 /* ------------------------------------------------------ */ 1386 /* ------------------------------------------------------ */
1386 1387
1387 /* It's wrong to encase these into #ifdef HAVE_TTY because we need 1388 /* It's wrong to encase these into #ifdef HAVE_TTY because we need
1388 them for child TTY processes. */ 1389 them for child TTY processes. */
1389 /* However, this does break NT support while we don't do child TTY processes */ 1390 /* However, this does break NT support while we don't do child TTY processes */
1390 #ifndef WINDOWSNT 1391 #ifndef WIN32_NATIVE
1391 1392
1392 /* Set *TC to the parameters associated with the terminal FD. 1393 /* Set *TC to the parameters associated with the terminal FD.
1393 Return zero if all's well, or -1 if we ran into an error we 1394 Return zero if all's well, or -1 if we ran into an error we
1394 couldn't deal with. */ 1395 couldn't deal with. */
1395 int 1396 int
1404 #elif defined HAVE_TERMIO 1405 #elif defined HAVE_TERMIO
1405 /* The SYSV-style interface? */ 1406 /* The SYSV-style interface? */
1406 if (ioctl (fd, TCGETA, &settings->main) < 0) 1407 if (ioctl (fd, TCGETA, &settings->main) < 0)
1407 return -1; 1408 return -1;
1408 1409
1409 #elif !defined (WINDOWSNT) 1410 #elif !defined (WIN32_NATIVE)
1410 /* I give up - I hope you have the BSD ioctls. */ 1411 /* I give up - I hope you have the BSD ioctls. */
1411 if (ioctl (fd, TIOCGETP, &settings->main) < 0) 1412 if (ioctl (fd, TIOCGETP, &settings->main) < 0)
1412 return -1; 1413 return -1;
1413 #endif /* HAVE_TCATTR */ 1414 #endif /* HAVE_TCATTR */
1414 1415
1478 #elif defined HAVE_TERMIO 1479 #elif defined HAVE_TERMIO
1479 /* The SYSV-style interface? */ 1480 /* The SYSV-style interface? */
1480 if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0) 1481 if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0)
1481 return -1; 1482 return -1;
1482 1483
1483 #elif !defined (WINDOWSNT) 1484 #elif !defined (WIN32_NATIVE)
1484 /* I give up - I hope you have the BSD ioctls. */ 1485 /* I give up - I hope you have the BSD ioctls. */
1485 if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) 1486 if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0)
1486 return -1; 1487 return -1;
1487 #endif /* HAVE_TCATTR */ 1488 #endif /* HAVE_TCATTR */
1488 1489
1501 1502
1502 /* We have survived the tempest. */ 1503 /* We have survived the tempest. */
1503 return 0; 1504 return 0;
1504 } 1505 }
1505 1506
1506 #endif /* WINDOWSNT */ 1507 #endif /* WIN32_NATIVE */
1507 1508
1508 /* ------------------------------------------------------ */ 1509 /* ------------------------------------------------------ */
1509 /* Initializing a device */ 1510 /* Initializing a device */
1510 /* ------------------------------------------------------ */ 1511 /* ------------------------------------------------------ */
1511 1512
1661 or via TELNET or the like, but does no harm elsewhere. */ 1662 or via TELNET or the like, but does no harm elsewhere. */
1662 tty.main.c_iflag &= ~IGNBRK; 1663 tty.main.c_iflag &= ~IGNBRK;
1663 tty.main.c_iflag &= ~BRKINT; 1664 tty.main.c_iflag &= ~BRKINT;
1664 #endif /* AIX */ 1665 #endif /* AIX */
1665 #else /* if not HAVE_TERMIO */ 1666 #else /* if not HAVE_TERMIO */
1666 #if !defined (WINDOWSNT) 1667 #if !defined (WIN32_NATIVE)
1667 con->tty_erase_char = make_char (tty.main.sg_erase); 1668 con->tty_erase_char = make_char (tty.main.sg_erase);
1668 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); 1669 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
1669 if (TTY_FLAGS (con).meta_key) 1670 if (TTY_FLAGS (con).meta_key)
1670 tty.main.sg_flags |= ANYP; 1671 tty.main.sg_flags |= ANYP;
1671 /* #### should we be using RAW mode here? */ 1672 /* #### should we be using RAW mode here? */
1672 tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK; 1673 tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK;
1673 #endif /* not WINDOWSNT */ 1674 #endif /* not WIN32_NATIVE */
1674 #endif /* not HAVE_TERMIO */ 1675 #endif /* not HAVE_TERMIO */
1675 1676
1676 /* If going to use CBREAK mode, we must request C-g to interrupt 1677 /* If going to use CBREAK mode, we must request C-g to interrupt
1677 and turn off start and stop chars, etc. If not going to use 1678 and turn off start and stop chars, etc. If not going to use
1678 CBREAK mode, do this anyway so as to turn off local flow 1679 CBREAK mode, do this anyway so as to turn off local flow
2151 * 2152 *
2152 */ 2153 */
2153 2154
2154 #if !defined(HAVE_TEXT_START) && !defined(PDUMP) 2155 #if !defined(HAVE_TEXT_START) && !defined(PDUMP)
2155 2156
2156 #ifdef __cplusplus 2157 EXTERN_C int _start (void);
2157 extern "C" int _start (void);
2158 #else
2159 extern int _start (void);
2160 #endif
2161 2158
2162 char * 2159 char *
2163 start_of_text (void) 2160 start_of_text (void)
2164 { 2161 {
2165 #ifdef TEXT_START 2162 #ifdef TEXT_START
2166 return ((char *) TEXT_START); 2163 return (char *) TEXT_START;
2167 #else 2164 #else
2168 #ifdef GOULD 2165 return (char *) _start;
2169 extern csrt ();
2170 return ((char *) csrt);
2171 #else /* not GOULD */
2172 return ((char *) _start);
2173 #endif /* GOULD */
2174 #endif /* TEXT_START */ 2166 #endif /* TEXT_START */
2175 } 2167 }
2176 #endif /* !defined(HAVE_TEXT_START) && !defined(PDUMP) */ 2168 #endif /* !defined(HAVE_TEXT_START) && !defined(PDUMP) */
2177 2169
2178 /* 2170 /*
2199 * at the normal shared text boundary and the startofdata variable 2191 * at the normal shared text boundary and the startofdata variable
2200 * will be patched by unexec to the correct value. 2192 * will be patched by unexec to the correct value.
2201 * 2193 *
2202 */ 2194 */
2203 2195
2204 #if defined(ORDINARY_LINK) && !defined(__MINGW32__) 2196 #if defined(ORDINARY_LINK) && !defined(MINGW)
2205 extern char **environ; 2197 extern char **environ;
2206 #endif 2198 #endif
2207 2199
2208 void * 2200 void *
2209 start_of_data (void) 2201 start_of_data (void)
2277 /* init_system_name sets up the string for the Lisp function 2269 /* init_system_name sets up the string for the Lisp function
2278 system-name to return. */ 2270 system-name to return. */
2279 2271
2280 extern Lisp_Object Vsystem_name; 2272 extern Lisp_Object Vsystem_name;
2281 2273
2282 #ifdef HAVE_SOCKETS
2283 # include <sys/socket.h>
2284 # include <netdb.h>
2285 #endif /* HAVE_SOCKETS */
2286
2287 void 2274 void
2288 init_system_name (void) 2275 init_system_name (void)
2289 { 2276 {
2290 #if defined (WINDOWSNT) 2277 #if defined (WIN32_NATIVE)
2291 char hostname [MAX_COMPUTERNAME_LENGTH + 1]; 2278 char hostname [MAX_COMPUTERNAME_LENGTH + 1];
2292 size_t size = sizeof (hostname); 2279 size_t size = sizeof (hostname);
2293 GetComputerName (hostname, &size); 2280 GetComputerName (hostname, &size);
2294 Vsystem_name = build_string (hostname); 2281 Vsystem_name = build_string (hostname);
2295 #elif !defined (HAVE_GETHOSTNAME) 2282 #elif !defined (HAVE_GETHOSTNAME)
2523 return ((const char *) GETTEXT ("Unknown error")); 2510 return ((const char *) GETTEXT ("Unknown error"));
2524 } 2511 }
2525 2512
2526 #endif /* ! HAVE_STRERROR */ 2513 #endif /* ! HAVE_STRERROR */
2527 2514
2528 #ifdef WINDOWSNT 2515 #ifdef WIN32_NATIVE
2529 2516
2530 struct errentry { 2517 struct errentry {
2531 unsigned long oscode; /* Win32 error */ 2518 unsigned long oscode; /* Win32 error */
2532 int errnocode; /* unix errno */ 2519 int errnocode; /* unix errno */
2533 }; 2520 };
2620 mswindows_set_last_errno (void) 2607 mswindows_set_last_errno (void)
2621 { 2608 {
2622 mswindows_set_errno (GetLastError ()); 2609 mswindows_set_errno (GetLastError ());
2623 } 2610 }
2624 2611
2625 #endif /* WINDOWSNT */ 2612 #endif /* WIN32_NATIVE */
2626 2613
2627 2614
2628 /************************************************************************/ 2615 /************************************************************************/
2629 /* Encapsulations of system calls */ 2616 /* Encapsulations of system calls */
2630 /************************************************************************/ 2617 /************************************************************************/
2663 mode = va_arg (ap, int); 2650 mode = va_arg (ap, int);
2664 va_end (ap); 2651 va_end (ap);
2665 2652
2666 PATHNAME_CONVERT_OUT (path); 2653 PATHNAME_CONVERT_OUT (path);
2667 2654
2668 #ifdef WINDOWSNT 2655 #ifdef WIN32_NATIVE
2669 /* Make all handles non-inheritable */ 2656 /* Make all handles non-inheritable */
2670 oflag |= _O_NOINHERIT; 2657 oflag |= _O_NOINHERIT;
2671 #endif 2658 #endif
2672 2659
2673 #ifdef INTERRUPTIBLE_OPEN 2660 #ifdef INTERRUPTIBLE_OPEN
2703 which could be relocated by GC when checking for QUIT. */ 2690 which could be relocated by GC when checking for QUIT. */
2704 memcpy (nonreloc, path, len + 1); 2691 memcpy (nonreloc, path, len + 1);
2705 2692
2706 PATHNAME_CONVERT_OUT (nonreloc); 2693 PATHNAME_CONVERT_OUT (nonreloc);
2707 2694
2708 #ifdef WINDOWSNT 2695 #ifdef WIN32_NATIVE
2709 /* Make all handles non-inheritable */ 2696 /* Make all handles non-inheritable */
2710 oflag |= _O_NOINHERIT; 2697 oflag |= _O_NOINHERIT;
2711 #endif 2698 #endif
2712 2699
2713 for (;;) 2700 for (;;)
2817 #ifdef ENCAPSULATE_FOPEN 2804 #ifdef ENCAPSULATE_FOPEN
2818 FILE * 2805 FILE *
2819 sys_fopen (const char *path, const char *type) 2806 sys_fopen (const char *path, const char *type)
2820 { 2807 {
2821 PATHNAME_CONVERT_OUT (path); 2808 PATHNAME_CONVERT_OUT (path);
2822 #if defined (WINDOWSNT) 2809 #if defined (WIN32_NATIVE)
2823 { 2810 {
2824 int fd; 2811 int fd;
2825 int oflag; 2812 int oflag;
2826 const char * type_save = type; 2813 const char * type_save = type;
2827 2814
2970 #ifdef ENCAPSULATE_MKDIR 2957 #ifdef ENCAPSULATE_MKDIR
2971 int 2958 int
2972 sys_mkdir (const char *path, mode_t mode) 2959 sys_mkdir (const char *path, mode_t mode)
2973 { 2960 {
2974 PATHNAME_CONVERT_OUT (path); 2961 PATHNAME_CONVERT_OUT (path);
2975 #ifdef WINDOWSNT 2962 #ifdef WIN32_NATIVE
2976 return mkdir (path); 2963 return mkdir (path);
2977 #else 2964 #else
2978 return mkdir (path, mode); 2965 return mkdir (path, mode);
2979 #endif 2966 #endif
2980 } 2967 }
3118 /* #### currently we don't do conversions on the incoming data */ 3105 /* #### currently we don't do conversions on the incoming data */
3119 return readlink (path, buf, bufsiz); 3106 return readlink (path, buf, bufsiz);
3120 } 3107 }
3121 #endif /* ENCAPSULATE_READLINK */ 3108 #endif /* ENCAPSULATE_READLINK */
3122 3109
3123
3124 #ifdef ENCAPSULATE_FSTAT 3110 #ifdef ENCAPSULATE_FSTAT
3125 int 3111 int
3126 sys_fstat (int fd, struct stat *buf) 3112 sys_fstat (int fd, struct stat *buf)
3127 { 3113 {
3114 #ifdef WIN32_NATIVE
3115 return mswindows_fstat (fd, buf);
3116 #else
3128 return fstat (fd, buf); 3117 return fstat (fd, buf);
3118 #endif
3129 } 3119 }
3130 #endif /* ENCAPSULATE_FSTAT */ 3120 #endif /* ENCAPSULATE_FSTAT */
3131
3132 3121
3133 #ifdef ENCAPSULATE_STAT 3122 #ifdef ENCAPSULATE_STAT
3134 int 3123 int
3135 sys_stat (const char *path, struct stat *buf) 3124 sys_stat (const char *path, struct stat *buf)
3136 { 3125 {
3137 PATHNAME_CONVERT_OUT (path); 3126 PATHNAME_CONVERT_OUT (path);
3127 #ifdef WIN32_NATIVE
3128 return mswindows_stat (path, buf);
3129 #else
3138 return stat (path, buf); 3130 return stat (path, buf);
3131 #endif
3139 } 3132 }
3140 #endif /* ENCAPSULATE_STAT */ 3133 #endif /* ENCAPSULATE_STAT */
3141
3142 3134
3143 /****************** file-manipulation calls *****************/ 3135 /****************** file-manipulation calls *****************/
3144 3136
3145 #ifdef ENCAPSULATE_CHMOD 3137 #ifdef ENCAPSULATE_CHMOD
3146 int 3138 int
3177 int 3169 int
3178 sys_rename (const char *old, const char *new) 3170 sys_rename (const char *old, const char *new)
3179 { 3171 {
3180 PATHNAME_CONVERT_OUT (old); 3172 PATHNAME_CONVERT_OUT (old);
3181 PATHNAME_CONVERT_OUT (new); 3173 PATHNAME_CONVERT_OUT (new);
3182 #ifdef WINDOWSNT 3174 #ifdef WIN32_NATIVE
3183 /* Windows rename fails if NEW exists */ 3175 /* Windows rename fails if NEW exists */
3184 if (rename (old, new) == 0) 3176 if (rename (old, new) == 0)
3185 return 0; 3177 return 0;
3186 if (errno != EEXIST) 3178 if (errno != EEXIST)
3187 return -1; 3179 return -1;
3188 unlink (new); 3180 unlink (new);
3189 #endif /* WINDOWSNT */ 3181 #endif /* WIN32_NATIVE */
3190 return rename (old, new); 3182 return rename (old, new);
3191 } 3183 }
3192 #endif /* ENCAPSULATE_RENAME */ 3184 #endif /* ENCAPSULATE_RENAME */
3193 3185
3194 3186
3399 for increased accuracy. */ 3391 for increased accuracy. */
3400 3392
3401 static int 3393 static int
3402 get_process_times_1 (long *user_ticks, long *system_ticks) 3394 get_process_times_1 (long *user_ticks, long *system_ticks)
3403 { 3395 {
3404 #if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WINDOWSNT) 3396 #if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WIN32_NATIVE)
3405 /* We have the POSIX times() function available. */ 3397 /* We have the POSIX times() function available. */
3406 struct tms tttt; 3398 struct tms tttt;
3407 times (&tttt); 3399 times (&tttt);
3408 *user_ticks = (long) tttt.tms_utime; 3400 *user_ticks = (long) tttt.tms_utime;
3409 *system_ticks = (long) tttt.tms_stime; 3401 *system_ticks = (long) tttt.tms_stime;
3541 /* Strings corresponding to defined signals */ 3533 /* Strings corresponding to defined signals */
3542 /************************************************************************/ 3534 /************************************************************************/
3543 3535
3544 #if !defined (SYS_SIGLIST_DECLARED) && !defined (HAVE_SYS_SIGLIST) 3536 #if !defined (SYS_SIGLIST_DECLARED) && !defined (HAVE_SYS_SIGLIST)
3545 3537
3546 #if defined(WINDOWSNT) || defined(__CYGWIN32__) 3538 #if defined(WIN32_NATIVE) || defined(CYGWIN)
3547 const char *sys_siglist[] = 3539 const char *sys_siglist[] =
3548 { 3540 {
3549 "bum signal!!", 3541 "bum signal!!",
3550 "hangup", 3542 "hangup",
3551 "interrupt", 3543 "interrupt",