Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/sysdep.c Mon Aug 13 11:18:12 2007 +0200 +++ b/src/sysdep.c Mon Aug 13 11:19:21 2007 +0200 @@ -31,9 +31,8 @@ #include <config.h> -#ifdef WINDOWSNT -#include <direct.h> -#ifdef __MINGW32__ +#ifdef WIN32_NATIVE +#ifdef MINGW #include <mingw32/process.h> #else /* <process.h> should not conflict with "process.h", as per ANSI definition. @@ -45,13 +44,11 @@ which will conflict with the macro defined in lisp.h */ #include <../include/process.h> -#endif /* __MINGW32__ */ -#endif /* WINDOWSNT */ +#endif /* MINGW */ +#endif /* WIN32_NATIVE */ #include "lisp.h" -#include <stdlib.h> - /* ------------------------------- */ /* basic includes */ /* ------------------------------- */ @@ -81,16 +78,20 @@ #include "syswait.h" #include "sysdir.h" #include "systime.h" -#if defined(WINDOWSNT) || defined(__CYGWIN32__) +#if defined(WIN32_NATIVE) || defined(CYGWIN) #include "syssignal.h" #endif -#ifndef WINDOWSNT + +#include "sysproc.h" + +#ifndef WIN32_NATIVE #include <sys/times.h> #endif -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE #include <sys/utime.h> #include "ntheap.h" +#include "nt.h" #endif /* ------------------------------- */ @@ -233,7 +234,7 @@ #endif /* NO_SUBPROCESSES */ -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE void wait_for_termination (HANDLE pHandle) #else void wait_for_termination (int pid) @@ -347,7 +348,7 @@ Since implementations may add their own error indicators on top, we ignore it by default. */ -#elif defined (WINDOWSNT) +#elif defined (WIN32_NATIVE) int ret = 0, status = 0; if (pHandle == NULL) { @@ -421,7 +422,7 @@ Try defining BROKEN_WAIT_FOR_SIGNAL. */ EMACS_WAIT_FOR_SIGNAL (SIGCHLD); } -#else /* not HAVE_WAITPID and not WINDOWSNT and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */ +#else /* not HAVE_WAITPID and not WIN32_NATIVE and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */ /* This approach is kind of cheesy but is guaranteed(?!) to work for all systems. */ while (1) @@ -459,7 +460,7 @@ #endif } -#ifndef WINDOWSNT +#ifndef WIN32_NATIVE /* Set up the terminal at the other end of a pseudo-terminal that we will be controlling an inferior through. It should not echo or do line-editing, since that is done @@ -570,7 +571,7 @@ } #endif /* RTU */ } -#endif /* WINDOWSNT */ +#endif /* WIN32_NATIVE */ #endif /* not NO_SUBPROCESSES */ @@ -611,7 +612,7 @@ } } -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE pid_t sys_getpid (void) @@ -619,13 +620,13 @@ return abs (getpid ()); } -#endif /* WINDOWSNT */ +#endif /* WIN32_NATIVE */ /* Fork a subshell. */ static void sys_subshell (void) { -#ifndef WINDOWSNT +#ifndef WIN32_NATIVE int pid; #endif struct save_signal saved_handlers[5]; @@ -665,13 +666,13 @@ str[len] = 0; xyzzy: -#ifndef WINDOWSNT +#ifndef WIN32_NATIVE pid = fork (); if (pid == -1) error ("Can't spawn subshell"); if (pid == 0) -#endif /* not WINDOWSNT */ +#endif /* not WIN32_NATIVE */ { char *sh = 0; @@ -684,7 +685,7 @@ if (str) sys_chdir (str); -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE /* Waits for process completion */ if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0) @@ -714,7 +715,7 @@ wait_for_termination (pid); restore_signal_handlers (saved_handlers); -#endif /* not WINDOWSNT */ +#endif /* not WIN32_NATIVE */ } @@ -961,7 +962,7 @@ assert (DEVICE_TTY_P (d)); { int input_fd = CONSOLE_TTY_DATA (con)->infd; -#if defined (WINDOWSNT) +#if defined (WIN32_NATIVE) DEVICE_TTY_DATA (d)->ospeed = 15; #elif defined (HAVE_TERMIOS) struct termios sg; @@ -1387,7 +1388,7 @@ /* It's wrong to encase these into #ifdef HAVE_TTY because we need them for child TTY processes. */ /* However, this does break NT support while we don't do child TTY processes */ -#ifndef WINDOWSNT +#ifndef WIN32_NATIVE /* Set *TC to the parameters associated with the terminal FD. Return zero if all's well, or -1 if we ran into an error we @@ -1406,7 +1407,7 @@ if (ioctl (fd, TCGETA, &settings->main) < 0) return -1; -#elif !defined (WINDOWSNT) +#elif !defined (WIN32_NATIVE) /* I give up - I hope you have the BSD ioctls. */ if (ioctl (fd, TIOCGETP, &settings->main) < 0) return -1; @@ -1480,7 +1481,7 @@ if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0) return -1; -#elif !defined (WINDOWSNT) +#elif !defined (WIN32_NATIVE) /* I give up - I hope you have the BSD ioctls. */ if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) return -1; @@ -1503,7 +1504,7 @@ return 0; } -#endif /* WINDOWSNT */ +#endif /* WIN32_NATIVE */ /* ------------------------------------------------------ */ /* Initializing a device */ @@ -1663,14 +1664,14 @@ tty.main.c_iflag &= ~BRKINT; #endif /* AIX */ #else /* if not HAVE_TERMIO */ -#if !defined (WINDOWSNT) +#if !defined (WIN32_NATIVE) con->tty_erase_char = make_char (tty.main.sg_erase); tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); if (TTY_FLAGS (con).meta_key) tty.main.sg_flags |= ANYP; /* #### should we be using RAW mode here? */ tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK; -#endif /* not WINDOWSNT */ +#endif /* not WIN32_NATIVE */ #endif /* not HAVE_TERMIO */ /* If going to use CBREAK mode, we must request C-g to interrupt @@ -2153,24 +2154,15 @@ #if !defined(HAVE_TEXT_START) && !defined(PDUMP) -#ifdef __cplusplus - extern "C" int _start (void); -#else - extern int _start (void); -#endif +EXTERN_C int _start (void); char * start_of_text (void) { #ifdef TEXT_START - return ((char *) TEXT_START); + return (char *) TEXT_START; #else -#ifdef GOULD - extern csrt (); - return ((char *) csrt); -#else /* not GOULD */ - return ((char *) _start); -#endif /* GOULD */ + return (char *) _start; #endif /* TEXT_START */ } #endif /* !defined(HAVE_TEXT_START) && !defined(PDUMP) */ @@ -2201,7 +2193,7 @@ * */ -#if defined(ORDINARY_LINK) && !defined(__MINGW32__) +#if defined(ORDINARY_LINK) && !defined(MINGW) extern char **environ; #endif @@ -2279,15 +2271,10 @@ extern Lisp_Object Vsystem_name; -#ifdef HAVE_SOCKETS -# include <sys/socket.h> -# include <netdb.h> -#endif /* HAVE_SOCKETS */ - void init_system_name (void) { -#if defined (WINDOWSNT) +#if defined (WIN32_NATIVE) char hostname [MAX_COMPUTERNAME_LENGTH + 1]; size_t size = sizeof (hostname); GetComputerName (hostname, &size); @@ -2525,7 +2512,7 @@ #endif /* ! HAVE_STRERROR */ -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE struct errentry { unsigned long oscode; /* Win32 error */ @@ -2622,7 +2609,7 @@ mswindows_set_errno (GetLastError ()); } -#endif /* WINDOWSNT */ +#endif /* WIN32_NATIVE */ /************************************************************************/ @@ -2665,7 +2652,7 @@ PATHNAME_CONVERT_OUT (path); -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE /* Make all handles non-inheritable */ oflag |= _O_NOINHERIT; #endif @@ -2705,7 +2692,7 @@ PATHNAME_CONVERT_OUT (nonreloc); -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE /* Make all handles non-inheritable */ oflag |= _O_NOINHERIT; #endif @@ -2819,7 +2806,7 @@ sys_fopen (const char *path, const char *type) { PATHNAME_CONVERT_OUT (path); -#if defined (WINDOWSNT) +#if defined (WIN32_NATIVE) { int fd; int oflag; @@ -2972,7 +2959,7 @@ sys_mkdir (const char *path, mode_t mode) { PATHNAME_CONVERT_OUT (path); -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE return mkdir (path); #else return mkdir (path, mode); @@ -3120,26 +3107,31 @@ } #endif /* ENCAPSULATE_READLINK */ - #ifdef ENCAPSULATE_FSTAT int sys_fstat (int fd, struct stat *buf) { +#ifdef WIN32_NATIVE + return mswindows_fstat (fd, buf); +#else return fstat (fd, buf); +#endif } #endif /* ENCAPSULATE_FSTAT */ - #ifdef ENCAPSULATE_STAT int sys_stat (const char *path, struct stat *buf) { PATHNAME_CONVERT_OUT (path); +#ifdef WIN32_NATIVE + return mswindows_stat (path, buf); +#else return stat (path, buf); +#endif } #endif /* ENCAPSULATE_STAT */ - /****************** file-manipulation calls *****************/ #ifdef ENCAPSULATE_CHMOD @@ -3179,14 +3171,14 @@ { PATHNAME_CONVERT_OUT (old); PATHNAME_CONVERT_OUT (new); -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE /* Windows rename fails if NEW exists */ if (rename (old, new) == 0) return 0; if (errno != EEXIST) return -1; unlink (new); -#endif /* WINDOWSNT */ +#endif /* WIN32_NATIVE */ return rename (old, new); } #endif /* ENCAPSULATE_RENAME */ @@ -3401,7 +3393,7 @@ static int get_process_times_1 (long *user_ticks, long *system_ticks) { -#if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WINDOWSNT) +#if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WIN32_NATIVE) /* We have the POSIX times() function available. */ struct tms tttt; times (&tttt); @@ -3543,7 +3535,7 @@ #if !defined (SYS_SIGLIST_DECLARED) && !defined (HAVE_SYS_SIGLIST) -#if defined(WINDOWSNT) || defined(__CYGWIN32__) +#if defined(WIN32_NATIVE) || defined(CYGWIN) const char *sys_siglist[] = { "bum signal!!",