This commit was generated by cvs2svn to compensate for changes in r1705,
[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 /* Compatibility macros. Some used to be routines in nt.c */
232 #define strcasecmp(x,y) _stricmp(x,y)
233 #define random() (rand() << 15 | rand())
234 #define srandom(seed) (srand(seed))
235 #define setpgrp(pid,gid)
236
237 #define MODE_LINE_BINARY_TEXT(_b_) (NILP ((_b_)->buffer_file_type) ? "T" : "B")
238
239
240 #include <stdio.h>
241
242 /* subprocess calls that are emulated */
243 #ifndef DONT_ENCAPSULATE
244 #define spawnve sys_spawnve
245 int spawnve (int mode, const char *cmdname, 
246              const char * const *argv, const char *const *envp);
247 #endif
248
249 /* IO calls that are emulated or shadowed */
250 #define pipe    sys_pipe
251 int sys_pipe (int * phandles);
252
253 #ifndef HAVE_X_WINDOWS
254 #define sleep   sys_sleep
255 void sleep (int seconds);
256 #endif
257
258 #define wait    sys_wait
259 int wait (int *status);
260
261 #define kill    sys_kill
262 int kill (int pid, int sig);
263
264 /* map to MSVC names */
265 #define popen     _popen
266 #define pclose    _pclose
267
268 typedef int uid_t;
269 typedef int gid_t;
270 typedef int pid_t;
271 typedef int ssize_t;
272
273 /* Encapsulation of system calls */
274 #ifndef DONT_ENCAPSULATE
275 #define getpid sys_getpid
276 pid_t getpid (void);
277 #endif
278
279 /* Random global functions called everywhere. Implemented in nt.c */
280 /* #### Most of these are FSFisms and must be avoided */
281 /* #### All of these are FSFisms and must be avoided */
282 void dostounix_filename (char *p);
283 void unixtodos_filename (char *p);
284 int crlf_to_lf (int n, unsigned char *buf, unsigned int *lf_count);
285
286 char *getwd (char *dir);
287
288 void *sbrk (unsigned long increment);
289
290 struct passwd;
291 struct passwd *getpwuid (uid_t uid);
292 struct passwd *getpwnam (const char *name);
293 uid_t getuid (void);
294 uid_t geteuid (void);
295 gid_t getgid (void);
296 gid_t getegid (void);
297
298 /* Setitimer is emulated */
299 #define HAVE_SETITIMER
300
301 /* We now have emulation for some signals */
302 #define HAVE_SIGHOLD
303 #define sigset(s,h) mswindows_sigset(s,h)
304 #define sighold(s) mswindows_sighold(s)
305 #define sigrelse(s) mswindows_sigrelse(s)
306 #define sigpause(s) mswindows_sigpause(s)
307
308 /* Defines that we need that aren't in the standard signal.h  */
309 #define SIGHUP  1               /* Hang up */
310 #define SIGQUIT 3               /* Quit process */
311 #define SIGKILL 9               /* Die, die die */
312 #define SIGALRM 14              /* Alarm */
313 #define SIGPROF 29              /* Profiling timer exp */
314
315 /* Defines size_t and alloca ().  */
316 #include <malloc.h>
317
318 #include <sys/stat.h>
319
320 /* Define for those source files that do not include enough NT 
321    system files.  */
322 #ifndef NULL
323 #ifdef __cplusplus
324 #define NULL    0
325 #else
326 #define NULL    ((void *)0)
327 #endif
328 #endif
329
330 /* For proper declaration of environ.  */
331 #include <stdlib.h>
332 #include <string.h>
333
334 /* Define process implementation */
335 #define HAVE_WIN32_PROCESSES
336
337 /* We need a little extra space, see ../../lisp/loadup.el */
338 #define SYSTEM_PURESIZE_EXTRA 15000
339
340 /* ============================================================ */
341
342 /* See unexnt.c */
343 #if (_MSC_VER >= 1100)
344 #define DUMP_SEPARATE_SECTION
345 #endif
346 #ifdef DUMP_SEPARATE_SECTION
347 #pragma data_seg("xdata")
348 #pragma bss_seg("xdata")
349 #endif
350
351 #ifdef HAVE_SCROLLBARS
352 /* Ensure the NT 4 mouse definitions in winuser.h are available */
353  #ifndef _WIN32_WINNT
354   #define _WIN32_WINNT 0x0400
355  #endif
356 #endif
357
358 /* Force the various NT 4 structures and constants to be included; we're
359    careful not to call (or even link with) functions not in NT 3.51 when
360    running on 3.51, but when running on NT 4 or Win9x, we use the later
361    functions, and need their headers. */
362 /* The VC++ (5.0, at least) headers treat WINVER non-existent as 0x0400 */
363 #if defined (WINVER) && WINVER < 0x0400
364 # undef WINVER
365 # define WINVER 0x0400
366 #endif
367
368 /* MSVC 6.0 has a mechanism to declare functions which never return */
369 #if (_MSC_VER >= 1200)
370 #define DOESNT_RETURN __declspec(noreturn) void
371 #define DECLARE_DOESNT_RETURN(decl) __declspec(noreturn) extern void decl
372 #define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
373           __declspec(noreturn) extern void decl PRINTF_ARGS(str,idx)
374 #endif /* MSVC 6.0 */
375
376 #define CORRECT_DIR_SEPS(s) \
377   do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
378        else unixtodos_filename (s); \
379   } while (0)