#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.
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 */
/* ------------------------------- */
#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
/* ------------------------------- */
#endif /* NO_SUBPROCESSES */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
void wait_for_termination (HANDLE pHandle)
#else
void wait_for_termination (int pid)
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)
{
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)
#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
}
#endif /* RTU */
}
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
#endif /* not NO_SUBPROCESSES */
}
}
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
pid_t
sys_getpid (void)
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];
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;
if (str)
sys_chdir (str);
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
/* Waits for process completion */
if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0)
wait_for_termination (pid);
restore_signal_handlers (saved_handlers);
-#endif /* not WINDOWSNT */
+#endif /* not WIN32_NATIVE */
}
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;
/* 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
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;
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;
return 0;
}
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
\f
/* ------------------------------------------------------ */
/* Initializing a device */
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
#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) */
*
*/
-#if defined(ORDINARY_LINK) && !defined(__MINGW32__)
+#if defined(ORDINARY_LINK) && !defined(MINGW)
extern char **environ;
#endif
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);
#endif /* ! HAVE_STRERROR */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
struct errentry {
unsigned long oscode; /* Win32 error */
mswindows_set_errno (GetLastError ());
}
-#endif /* WINDOWSNT */
+#endif /* WIN32_NATIVE */
\f
/************************************************************************/
PATHNAME_CONVERT_OUT (path);
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
/* Make all handles non-inheritable */
oflag |= _O_NOINHERIT;
#endif
PATHNAME_CONVERT_OUT (nonreloc);
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
/* Make all handles non-inheritable */
oflag |= _O_NOINHERIT;
#endif
sys_fopen (const char *path, const char *type)
{
PATHNAME_CONVERT_OUT (path);
-#if defined (WINDOWSNT)
+#if defined (WIN32_NATIVE)
{
int fd;
int oflag;
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);
}
#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
{
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 */
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);
#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!!",