6175a2cba55ff6d2080d146baa665fa00dbaa234
[chise/xemacs-chise.git.1] / src / s / windowsnt.h
1 /* System description file for Windows 9x and NT.
2    Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
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)
9 any later version.
10
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.
15
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.  */
20
21 /* Synched up with: FSF 19.31. */
22
23 /* Capsule summary of different preprocessor flags:
24
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.
33
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.
44
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.
48
49 The build flags used for these divisions are:
50
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).
56
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
62 things messed up.
63
64
65 Formerly, we had a whole host of flags.  Here's the conversion, for porting
66 code from GNU Emacs and such:
67
68
69 WINDOWSNT -> WIN32_NATIVE
70 WIN32 -> 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
79          under XEmacs)
80
81 __CYGWIN__ -> CYGWIN
82 __CYGWIN32__ -> CYGWIN
83 __MINGW32__ -> MINGW
84
85 */
86
87 /* Identify ourselves */
88 #ifndef WIN32_NATIVE
89 #define WIN32_NATIVE
90 #endif
91
92 /* In case non-Microsoft compiler is used, we fake _MSC_VER */
93 #ifndef _MSC_VER
94 #define _MSC_VER  1
95 #endif
96
97 typedef unsigned short mode_t;
98 /* typedef long ptrdiff_t; -kkm */
99 typedef int pid_t;
100
101 #include <stddef.h>
102
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
106
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
111
112 /* SYSTEM_TYPE should indicate the kind of system you are using.
113  It sets the Lisp variable system-type.  */
114
115 #define SYSTEM_TYPE "windows-nt"
116
117 #define NO_MATHERR
118
119 #define SIZEOF_SHORT 2
120 #define SIZEOF_INT 4
121 #define SIZEOF_LONG 4
122 #define SIZEOF_LONG_LONG 0
123 #define SIZEOF_VOID_P 4
124
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).  */
128
129 /* #define NOMULTIPLEJOBS */
130
131 /* Letter to use in finding device name of first pty,
132   if system supports pty's.  'a' means it is /dev/ptya0  */
133
134 #define FIRST_PTY_LETTER 'a'
135
136 /*
137  *      Define HAVE_TIMEVAL if the system supports the BSD style clock values.
138  *      Look in <sys/time.h> for a timeval structure.
139  */
140
141 #define HAVE_TIMEVAL
142
143 /*
144  *      Define HAVE_SELECT if the system supports the `select' system call.
145  */
146
147 /* #define HAVE_SELECT */
148
149 /*
150  *      Define HAVE_PTYS if the system supports pty devices.
151  */
152
153 /* #define HAVE_PTYS */
154
155 /* If your system uses COFF (Common Object File Format) then define the
156    preprocessor symbol "COFF". */
157
158 #define COFF
159
160 /* NT supports Winsock which is close enough (with some hacks) */
161
162 #define HAVE_SOCKETS
163
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.  */
168
169 #define MAIL_USE_POP
170 #define HAVE_LOCKING
171 #define MAIL_USE_LOCKING
172
173 /* If the character used to separate elements of the executable path
174    is not ':', #define this to be the appropriate character constant.  */
175 #define SEPCHAR ';'
176
177 /* ============================================================ */
178
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).  */
185
186 /* XEmacs file I/O for DOS text files requires FILE_CODING */
187 #define FILE_CODING
188
189 #define DIRECTORY_SEP ((char)XCHAR(Vdirectory_sep_char))
190
191 /* Define this to be the separator between devices and paths */
192 #define DEVICE_SEP ':'
193
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_))
197
198 /* The null device on Windows NT. */
199 #define NULL_DEVICE     "NUL:"
200 #define EXEC_SUFFIXES   ".exe:.com:.bat:.cmd:"
201
202 #ifndef MAXPATHLEN
203 #define MAXPATHLEN      _MAX_PATH
204 #endif
205
206 #define LISP_FLOAT_TYPE
207
208 #define HAVE_GETTIMEOFDAY
209 #define HAVE_GETHOSTNAME
210 #define HAVE_DUP2
211 #define HAVE_RENAME
212 #define HAVE_CLOSEDIR
213
214 #define HAVE_TZNAME
215
216 #define HAVE_LONG_FILE_NAMES
217
218 #define HAVE_MKDIR
219 #define HAVE_RMDIR
220 #define HAVE_RANDOM
221 #define HAVE_LOGB
222 #define HAVE_FREXP
223 #define HAVE_FMOD
224 #define HAVE_FTIME
225 #define HAVE_MKTIME
226
227 #define HAVE_MOUSE
228 #define HAVE_H_ERRNO
229 #define HAVE_STRUCT_UTIMBUF
230
231 #define HAVE_STRCASECMP
232
233 /* Compatibility macros. Some used to be routines in nt.c */
234 #define strcasecmp(x,y) _stricmp(x,y)
235 #define random() (rand() << 15 | rand())
236 #define srandom(seed) (srand(seed))
237 #define setpgrp(pid,gid)
238
239 #define MODE_LINE_BINARY_TEXT(_b_) (NILP ((_b_)->buffer_file_type) ? "T" : "B")
240
241
242 #include <stdio.h>
243
244 /* subprocess calls that are emulated */
245 #ifndef DONT_ENCAPSULATE
246 #define spawnve sys_spawnve
247 int spawnve (int mode, const char *cmdname, 
248              const char * const *argv, const char *const *envp);
249 #endif
250
251 /* IO calls that are emulated or shadowed */
252 #define pipe    sys_pipe
253 int sys_pipe (int * phandles);
254
255 #ifndef HAVE_X_WINDOWS
256 #define sleep   sys_sleep
257 void sleep (int seconds);
258 #endif
259
260 #define wait    sys_wait
261 int wait (int *status);
262
263 #define kill    sys_kill
264 int kill (int pid, int sig);
265
266 /* map to MSVC names */
267 #define popen     _popen
268 #define pclose    _pclose
269
270 typedef int uid_t;
271 typedef int gid_t;
272 typedef int pid_t;
273 typedef int ssize_t;
274
275 /* Encapsulation of system calls */
276 #ifndef DONT_ENCAPSULATE
277 #define getpid sys_getpid
278 pid_t getpid (void);
279 #endif
280
281 /* Random global functions called everywhere. Implemented in nt.c */
282 /* #### Most of these are FSFisms and must be avoided */
283 /* #### All of these are FSFisms and must be avoided */
284 void dostounix_filename (char *p);
285 void unixtodos_filename (char *p);
286 int crlf_to_lf (int n, unsigned char *buf, unsigned int *lf_count);
287
288 char *getwd (char *dir);
289
290 void *sbrk (unsigned long increment);
291
292 struct passwd;
293 struct passwd *getpwuid (uid_t uid);
294 struct passwd *getpwnam (const char *name);
295 uid_t getuid (void);
296 uid_t geteuid (void);
297 gid_t getgid (void);
298 gid_t getegid (void);
299
300 /* Setitimer is emulated */
301 #define HAVE_SETITIMER
302
303 /* We now have emulation for some signals */
304 #define HAVE_SIGHOLD
305 #define sigset(s,h) mswindows_sigset(s,h)
306 #define sighold(s) mswindows_sighold(s)
307 #define sigrelse(s) mswindows_sigrelse(s)
308 #define sigpause(s) mswindows_sigpause(s)
309
310 /* Defines that we need that aren't in the standard signal.h  */
311 #define SIGHUP  1               /* Hang up */
312 #define SIGQUIT 3               /* Quit process */
313 #define SIGKILL 9               /* Die, die die */
314 #define SIGALRM 14              /* Alarm */
315 #define SIGPROF 29              /* Profiling timer exp */
316
317 /* Defines size_t and alloca ().  */
318 #include <malloc.h>
319
320 #include <sys/stat.h>
321
322 /* Define for those source files that do not include enough NT 
323    system files.  */
324 #ifndef NULL
325 #ifdef __cplusplus
326 #define NULL    0
327 #else
328 #define NULL    ((void *)0)
329 #endif
330 #endif
331
332 /* For proper declaration of environ.  */
333 #include <stdlib.h>
334 #include <string.h>
335
336 /* Define process implementation */
337 #define HAVE_WIN32_PROCESSES
338
339 /* We need a little extra space, see ../../lisp/loadup.el */
340 #define SYSTEM_PURESIZE_EXTRA 15000
341
342 /* ============================================================ */
343
344 /* See unexnt.c */
345 #if (_MSC_VER >= 1100)
346 #define DUMP_SEPARATE_SECTION
347 #endif
348 #ifdef DUMP_SEPARATE_SECTION
349 #pragma data_seg("xdata")
350 #pragma bss_seg("xdata")
351 #endif
352
353 #ifdef HAVE_SCROLLBARS
354 /* Ensure the NT 4 mouse definitions in winuser.h are available */
355  #ifndef _WIN32_WINNT
356   #define _WIN32_WINNT 0x0400
357  #endif
358 #endif
359
360 /* MSVC 6.0 has a mechanism to declare functions which never return */
361 #if (_MSC_VER >= 1200)
362 #define DOESNT_RETURN __declspec(noreturn) void
363 #define DECLARE_DOESNT_RETURN(decl) __declspec(noreturn) extern void decl
364 #define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
365           __declspec(noreturn) extern void decl PRINTF_ARGS(str,idx)
366 #endif /* MSVC 6.0 */
367
368 #define CORRECT_DIR_SEPS(s) \
369   do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
370        else unixtodos_filename (s); \
371   } while (0)