1 /* System description file for Windows 9x and NT.
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Synched up with: FSF 19.31. */
23 /* Capsule summary of different preprocessor flags:
25 1. Keep in mind that there are two possible OS environments we are dealing
26 with -- Cygwin and Native Windows. Cygwin provides a POSIX emulation
27 layer on top of MS Windows -- in particular, providing the file-system,
28 process, tty, and signal semantics that are part of a modern, standard
29 Unix operating system. MS Windows also provides these services, but
30 through their own API, called Win32. When compiling in a Cygwin
31 environment, the Win32 API's are also available, and in fact are used
32 to do native GUI programming.
34 2. There are two windowing environments we can target XEmacs for when
35 running under MS Windows -- Windows native, and X. (It may seem strange
36 to write an X application under Windows, but there are in fact many X
37 servers out there running on Windows, and as far as I know there is no
38 real (or at least, that works well) networking Window-system extension
39 under MS Windows. Furthermore, if you're porting a Unix application to
40 Windows and use Cygwin to assist you, it might seem natural to use an
41 X server to avoid having to port all the code to Windows.) For XEmacs,
42 there are various reasons people could come up with for why we would
43 want to keep maintaining X Windows under MS Windows support.
45 That gives us four possible build environments. I (Ben) build
46 regularly on fully-native-everything, Andy builds on Cygwin + MS
47 Windows + X Windows for windowing.
49 The build flags used for these divisions are:
51 CYGWIN -- for Cygwin-only stuff.
52 WIN32_NATIVE -- Win32 native OS-level stuff (files, process, etc.).
53 HAVE_X_WINDOWS -- for X Windows (regardless of whether under MS Win)
54 HAVE_MS_WINDOWS -- MS Windows native windowing system (anything related to
55 the appearance of the graphical screen).
57 Finally, there's also the MINGW build environment, which uses GCC
58 \(similar to Cygwin), but native MS Windows libraries rather than a
59 POSIX emulation layer (the Cygwin approach). This environment defines
60 WIN32_NATIVE, but also defines MINGW, which is used mostly because
61 uses its own include files (related to Cygwin), which have a few
65 Formerly, we had a whole host of flags. Here's the conversion, for porting
66 code from GNU Emacs and such:
69 WINDOWSNT -> WIN32_NATIVE
71 _WIN32 -> WIN32_NATIVE
72 HAVE_WIN32 -> WIN32_NATIVE
73 DOS_NT -> WIN32_NATIVE
74 HAVE_NTGUI -> WIN32_NATIVE, unless it ends up already bracketed by this
75 HAVE_FACES -> always true
76 MSDOS -> determine whether this code is really specific to MS-DOS (and not
77 Windows -- e.g. DJGPP code); if so, delete the code; otherwise,
78 convert to WIN32_NATIVE (we do not support MS-DOS w/DOS Extender
82 __CYGWIN32__ -> CYGWIN
87 /* Identify ourselves */
92 /* In case non-Microsoft compiler is used, we fake _MSC_VER */
97 typedef unsigned short mode_t;
98 /* typedef long ptrdiff_t; -kkm */
103 /* If you are compiling with a non-C calling convention but need to
104 declare vararg routines differently, put it here */
105 #define _VARARGS_ __cdecl
107 /* If you are providing a function to something that will call the
108 function back (like a signal handler and signal, or main) its calling
109 convention must be whatever standard the libraries expect */
110 #define _CALLBACK_ __cdecl
112 /* SYSTEM_TYPE should indicate the kind of system you are using.
113 It sets the Lisp variable system-type. */
115 #define SYSTEM_TYPE "windows-nt"
119 #define SIZEOF_SHORT 2
121 #define SIZEOF_LONG 4
122 #define SIZEOF_LONG_LONG 0
123 #define SIZEOF_VOID_P 4
125 /* NOMULTIPLEJOBS should be defined if your system's shell
126 does not have "job control" (the ability to stop a program,
127 run some other program, then continue the first one). */
129 /* #define NOMULTIPLEJOBS */
131 /* Letter to use in finding device name of first pty,
132 if system supports pty's. 'a' means it is /dev/ptya0 */
134 #define FIRST_PTY_LETTER 'a'
137 * Define HAVE_TIMEVAL if the system supports the BSD style clock values.
138 * Look in <sys/time.h> for a timeval structure.
144 * Define HAVE_SELECT if the system supports the `select' system call.
147 /* #define HAVE_SELECT */
150 * Define HAVE_PTYS if the system supports pty devices.
153 /* #define HAVE_PTYS */
155 /* If your system uses COFF (Common Object File Format) then define the
156 preprocessor symbol "COFF". */
160 /* NT supports Winsock which is close enough (with some hacks) */
164 /* define MAIL_USE_FLOCK if the mailer uses flock
165 to interlock access to /usr/spool/mail/$USER.
166 The alternative is that a lock file named
167 /usr/spool/mail/$USER.lock. */
171 #define MAIL_USE_LOCKING
173 /* If the character used to separate elements of the executable path
174 is not ':', #define this to be the appropriate character constant. */
177 /* ============================================================ */
179 /* Here, add any special hacks needed
180 to make Emacs work on this system. For example,
181 you might define certain system call names that don't
182 exist on your system, or that do different things on
183 your system and must be used only through an encapsulation
184 (Which you should place, by convention, in sysdep.c). */
186 /* XEmacs file I/O for DOS text files requires FILE_CODING */
189 #define DIRECTORY_SEP ((char)XCHAR(Vdirectory_sep_char))
191 /* Define this to be the separator between devices and paths */
192 #define DEVICE_SEP ':'
194 /* We'll support either convention on NT. */
195 #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
196 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
198 /* The null device on Windows NT. */
199 #define NULL_DEVICE "NUL:"
200 #define EXEC_SUFFIXES ".exe:.com:.bat:.cmd:"
203 #define MAXPATHLEN _MAX_PATH
206 #define LISP_FLOAT_TYPE
208 #define HAVE_GETTIMEOFDAY
209 #define HAVE_GETHOSTNAME
212 #define HAVE_CLOSEDIR
216 #define HAVE_LONG_FILE_NAMES
230 /* Compatibility macros. Some used to be routines in nt.c */
231 #define strcasecmp(x,y) _stricmp(x,y)
232 #define random() (rand() << 15 | rand())
233 #define srandom(seed) (srand(seed))
234 #define setpgrp(pid,gid)
236 #define MODE_LINE_BINARY_TEXT(_b_) (NILP ((_b_)->buffer_file_type) ? "T" : "B")
241 /* subprocess calls that are emulated */
242 #ifndef DONT_ENCAPSULATE
243 #define spawnve sys_spawnve
244 int spawnve (int mode, const char *cmdname,
245 const char * const *argv, const char *const *envp);
248 /* IO calls that are emulated or shadowed */
249 #define pipe sys_pipe
250 int sys_pipe (int * phandles);
252 #ifndef HAVE_X_WINDOWS
253 #define sleep sys_sleep
254 void sleep (int seconds);
257 #define wait sys_wait
258 int wait (int *status);
260 #define kill sys_kill
261 int kill (int pid, int sig);
263 /* map to MSVC names */
265 #define pclose _pclose
272 /* Encapsulation of system calls */
273 #ifndef DONT_ENCAPSULATE
274 #define getpid sys_getpid
278 /* Random global functions called everywhere. Implemented in nt.c */
279 /* #### Most of these are FSFisms and must be avoided */
280 /* #### All of these are FSFisms and must be avoided */
281 void dostounix_filename (char *p);
282 void unixtodos_filename (char *p);
283 int crlf_to_lf (int n, unsigned char *buf, unsigned int *lf_count);
285 char *getwd (char *dir);
287 void *sbrk (unsigned long increment);
290 struct passwd *getpwuid (uid_t uid);
291 struct passwd *getpwnam (const char *name);
293 uid_t geteuid (void);
295 gid_t getegid (void);
297 /* Setitimer is emulated */
298 #define HAVE_SETITIMER
300 /* We now have emulation for some signals */
302 #define sigset(s,h) mswindows_sigset(s,h)
303 #define sighold(s) mswindows_sighold(s)
304 #define sigrelse(s) mswindows_sigrelse(s)
305 #define sigpause(s) mswindows_sigpause(s)
307 /* Defines that we need that aren't in the standard signal.h */
308 #define SIGHUP 1 /* Hang up */
309 #define SIGQUIT 3 /* Quit process */
310 #define SIGKILL 9 /* Die, die die */
311 #define SIGALRM 14 /* Alarm */
312 #define SIGPROF 29 /* Profiling timer exp */
314 /* Defines size_t and alloca (). */
317 #include <sys/stat.h>
319 /* Define for those source files that do not include enough NT
325 #define NULL ((void *)0)
329 /* For proper declaration of environ. */
333 /* Define process implementation */
334 #define HAVE_WIN32_PROCESSES
336 /* We need a little extra space, see ../../lisp/loadup.el */
337 #define SYSTEM_PURESIZE_EXTRA 15000
339 /* ============================================================ */
342 #if (_MSC_VER >= 1100)
343 #define DUMP_SEPARATE_SECTION
345 #ifdef DUMP_SEPARATE_SECTION
346 #pragma data_seg("xdata")
347 #pragma bss_seg("xdata")
350 #ifdef HAVE_SCROLLBARS
351 /* Ensure the NT 4 mouse definitions in winuser.h are available */
353 #define _WIN32_WINNT 0x0400
357 /* Force the various NT 4 structures and constants to be included; we're
358 careful not to call (or even link with) functions not in NT 3.51 when
359 running on 3.51, but when running on NT 4 or Win9x, we use the later
360 functions, and need their headers. */
361 /* The VC++ (5.0, at least) headers treat WINVER non-existent as 0x0400 */
362 #if defined (WINVER) && WINVER < 0x0400
364 # define WINVER 0x0400
367 /* MSVC 6.0 has a mechanism to declare functions which never return */
368 #if (_MSC_VER >= 1200)
369 #define DOESNT_RETURN __declspec(noreturn) void
370 #define DECLARE_DOESNT_RETURN(decl) __declspec(noreturn) extern void decl
371 #define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
372 __declspec(noreturn) extern void decl PRINTF_ARGS(str,idx)
373 #endif /* MSVC 6.0 */
375 #define CORRECT_DIR_SEPS(s) \
376 do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
377 else unixtodos_filename (s); \