Adapt the MS-DOS build to the latest changes.
[bpt/emacs.git] / src / s / ms-w32.h
1 /* System description file for Windows NT.
2
3 Copyright (C) 1993-1995, 2001-2012 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* Define symbols to identify the version of Unix this is.
21 Define all the symbols that apply correctly. */
22
23 #ifndef WINDOWSNT
24 #define WINDOWSNT
25 #endif
26 #ifndef DOS_NT
27 #define DOS_NT /* MSDOS or WINDOWSNT */
28 #endif
29
30 /* If you are compiling with a non-C calling convention but need to
31 declare vararg routines differently, put it here. */
32 #define _VARARGS_ __cdecl
33
34 /* If you are providing a function to something that will call the
35 function back (like a signal handler and signal, or main) its calling
36 convention must be whatever standard the libraries expect. */
37 #define _CALLBACK_ __cdecl
38
39 #define NO_MATHERR 1
40
41 /* Letter to use in finding device name of first pty,
42 if system supports pty's. 'a' means it is /dev/ptya0 */
43 #define FIRST_PTY_LETTER 'a'
44
45 /* Define HAVE_TIMEVAL if the system supports the BSD style clock values.
46 Look in <sys/time.h> for a timeval structure. */
47 #define HAVE_TIMEVAL 1
48
49 /* NT supports Winsock which is close enough (with some hacks). */
50 #define HAVE_SOCKETS 1
51
52 /* But our select implementation doesn't allow us to make non-blocking
53 connects. So until that is fixed, this is necessary: */
54 #define BROKEN_NON_BLOCKING_CONNECT 1
55
56 /* And the select implementation does 1-byte read-ahead waiting
57 for received packets, so datagrams are broken too. */
58 #define BROKEN_DATAGRAM_SOCKETS 1
59
60 #define MAIL_USE_POP 1
61 #define MAIL_USE_SYSTEM_LOCK 1
62
63 /* If the character used to separate elements of the executable path
64 is not ':', #define this to be the appropriate character constant. */
65 #define SEPCHAR ';'
66
67 #define ORDINARY_LINK 1
68
69 /* ============================================================ */
70
71 /* Here, add any special hacks needed to make Emacs work on this
72 system. For example, you might define certain system call names
73 that don't exist on your system, or that do different things on
74 your system and must be used only through an encapsulation (which
75 you should place, by convention, in sysdep.c). */
76
77 /* Define this to be the separator between devices and paths. */
78 #define DEVICE_SEP ':'
79
80 /* We'll support either convention on NT. */
81 #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
82 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
83
84 #include <sys/types.h>
85
86 #ifdef _MSC_VER
87 typedef unsigned long sigset_t;
88 typedef int ssize_t;
89 #endif
90
91 struct sigaction {
92 int sa_flags;
93 void (*sa_handler)(int);
94 sigset_t sa_mask;
95 };
96 #define SIG_BLOCK 1
97 #define SIG_SETMASK 2
98 #define SIG_UNBLOCK 3
99
100 /* The null device on Windows NT. */
101 #define NULL_DEVICE "NUL:"
102
103 #ifndef MAXPATHLEN
104 #define MAXPATHLEN _MAX_PATH
105 #endif
106
107 #define HAVE_SOUND 1
108 #define LISP_FLOAT_TYPE 1
109
110 #define HAVE_SYS_TIMEB_H 1
111 #define HAVE_SYS_TIME_H 1
112 #define HAVE_UNISTD_H 1
113 #undef HAVE_UTIME_H
114 #undef HAVE_LINUX_VERSION_H
115 #undef HAVE_SYS_SYSTEMINFO_H
116 #define HAVE_PWD_H 1
117 #define TIME_WITH_SYS_TIME 1
118
119 #define HAVE_GETTIMEOFDAY 1
120 #define HAVE_GETHOSTNAME 1
121 #define HAVE_DUP2 1
122 #define HAVE_RENAME 1
123 #define HAVE_CLOSEDIR 1
124 #define HAVE_FSYNC 1 /* fsync is called _commit in MSVC. */
125
126 #undef TM_IN_SYS_TIME
127 #undef HAVE_TM_ZONE
128
129 #define HAVE_LONG_FILE_NAMES 1
130
131 #define HAVE_MKDIR 1
132 #define HAVE_RMDIR 1
133 #define HAVE_RANDOM 1
134 #undef HAVE_SYSINFO
135 #undef HAVE_LRAND48
136 #define HAVE_MEMCMP 1
137 #define HAVE_MEMCPY 1
138 #define HAVE_MEMMOVE 1
139 #define HAVE_MEMSET 1
140 #define HAVE_LOGB 1
141 #define HAVE_FREXP 1
142 #define HAVE_FMOD 1
143 #undef HAVE_RINT
144 #undef HAVE_CBRT
145 #undef HAVE_RES_INIT /* For -lresolv on Suns. */
146 #undef HAVE_SETSID
147 #undef HAVE_FPATHCONF
148 #define HAVE_SELECT 1
149 #undef HAVE_EUIDACCESS
150 #define HAVE_GETPAGESIZE 1
151 #define HAVE_TZSET 1
152 #define HAVE_SETLOCALE 1
153 #undef HAVE_UTIMES
154 #undef HAVE_SETRLIMIT
155 #undef HAVE_SETPGID
156 /* If you think about defining HAVE_GETCWD, don't: the alternative
157 getwd is redefined on w32.c, and does not really return the current
158 directory, to get the desired results elsewhere in Emacs */
159 #undef HAVE_GETCWD
160 #define HAVE_SHUTDOWN 1
161
162 #define LOCALTIME_CACHE
163 #define HAVE_INET_SOCKETS 1
164
165 #undef HAVE_AIX_SMT_EXP
166 #define USE_TOOLKIT_SCROLL_BARS 1
167
168 /* MinGW has these in its library; MSVC doesn't. */
169 #ifdef _MSC_VER
170 #define strcasecmp(s1,s2) _stricmp(s1,s2)
171 #define strncasecmp(s1,s2) _strnicmp(s1,s2)
172 #endif
173 #define HAVE_STRCASECMP 1
174 #define HAVE_STRNCASECMP 1
175
176 /* Define if you have the ANSI `strerror' function.
177 Otherwise you must have the variable `char *sys_errlist[]'. */
178 #define HAVE_STRERROR 1
179
180 /* Define if `struct utimbuf' is declared by <utime.h>. */
181 #undef HAVE_STRUCT_UTIMBUF
182
183 #define HAVE_MOUSE 1
184 #define HAVE_H_ERRNO 1
185
186 #ifdef HAVE_NTGUI
187 #define HAVE_WINDOW_SYSTEM 1
188 #define HAVE_MENUS 1
189 #endif
190
191 /* Get some redefinitions in place. */
192
193 #ifdef emacs
194
195 #ifdef _MSC_VER
196 #include <sys/timeb.h>
197 #include <sys/stat.h>
198 #include <signal.h>
199
200 /* MSVC gets link-time errors without these redirections. */
201 #define fstat(a, b) sys_fstat(a, b)
202 #define stat(a, b) sys_stat(a, b)
203 #define utime sys_utime
204 #endif
205
206 /* Calls that are emulated or shadowed. */
207 #undef access
208 #define access sys_access
209 #undef chdir
210 #define chdir sys_chdir
211 #undef chmod
212 #define chmod sys_chmod
213 #define chown sys_chown
214 #undef close
215 #define close sys_close
216 #undef creat
217 #define creat sys_creat
218 #define ctime sys_ctime
219 #undef dup
220 #define dup sys_dup
221 #undef dup2
222 #define dup2 sys_dup2
223 #define fopen sys_fopen
224 #define link sys_link
225 #define localtime sys_localtime
226 #define mkdir sys_mkdir
227 #undef mktemp
228 #define mktemp sys_mktemp
229 #undef open
230 #define open sys_open
231 #define pipe sys_pipe
232 #undef read
233 #define read sys_read
234 #define rename sys_rename
235 #define rmdir sys_rmdir
236 #define sleep sys_sleep
237 #define strerror sys_strerror
238 #undef unlink
239 #define unlink sys_unlink
240 #undef write
241 #define write sys_write
242
243 /* Subprocess calls that are emulated. */
244 #define spawnve sys_spawnve
245 #define wait sys_wait
246 #define kill sys_kill
247 #define signal sys_signal
248
249 /* termcap.c calls that are emulated. */
250 #define tputs sys_tputs
251 #define tgetstr sys_tgetstr
252
253 /* cm.c calls that are emulated. */
254 #define chcheckmagic sys_chcheckmagic
255 #define cmcostinit sys_cmcostinit
256 #define cmgoto sys_cmgoto
257 #define cmputc sys_cmputc
258 #define Wcm_clear sys_Wcm_clear
259
260 #endif /* emacs */
261
262 /* Map to MSVC names. */
263 #define execlp _execlp
264 #define execvp _execvp
265 #define fdopen _fdopen
266 #ifndef fileno
267 #define fileno _fileno
268 #endif
269 #define fsync _commit
270 #define ftruncate _chsize
271 #define getpid _getpid
272 #ifdef _MSC_VER
273 typedef int pid_t;
274 #define snprintf _snprintf
275 #define strtoll _strtoi64
276 #endif
277 #define isatty _isatty
278 #define logb _logb
279 #define _longjmp longjmp
280 #define lseek _lseek
281 #define popen _popen
282 #define pclose _pclose
283 #define umask _umask
284 #ifndef _MSC_VER
285 #define utimbuf _utimbuf
286 #endif
287 #define strdup _strdup
288 #define strupr _strupr
289 #define strnicmp _strnicmp
290 #define stricmp _stricmp
291 #define tzset _tzset
292
293 /* Include time.h before redirecting tzname, since MSVC's time.h
294 defines _tzname to call a function, but also declares tzname a
295 2-element array. Having the redirection before including the
296 header thus has the effect of declaring a function that returns an
297 array, and triggers an error message. */
298 #include <time.h>
299 #define tzname _tzname
300 #if !defined (_MSC_VER) || (_MSC_VER < 1400)
301 #undef utime
302 #define utime _utime
303 #endif
304
305 /* 'struct timespec' is used by time-related functions in lib/ and
306 elsewhere, but we don't use lib/time.h where the structure is
307 defined. */
308 struct timespec
309 {
310 time_t tv_sec; /* seconds */
311 long int tv_nsec; /* nanoseconds */
312 };
313
314 /* This is hacky, but is necessary to avoid warnings about macro
315 redefinitions using the SDK compilers. */
316 #ifndef __STDC__
317 #define __STDC__ 1
318 #define MUST_UNDEF__STDC__
319 #endif
320 #include <direct.h>
321 #include <io.h>
322 #include <stdio.h>
323 #ifdef MUST_UNDEF__STDC__
324 #undef __STDC__
325 #undef MUST_UNDEF__STDC__
326 #endif
327
328 /* Defines that we need that aren't in the standard signal.h. */
329 #define SIGHUP 1 /* Hang up */
330 #define SIGQUIT 3 /* Quit process */
331 #define SIGTRAP 5 /* Trace trap */
332 #define SIGKILL 9 /* Die, die die */
333 #define SIGPIPE 13 /* Write on pipe with no readers */
334 #define SIGALRM 14 /* Alarm */
335 #define SIGCHLD 18 /* Death of child */
336
337 #ifndef NSIG
338 #define NSIG 23
339 #endif
340
341 /* For integration with MSDOS support. */
342 #define getdisk() (_getdrive () - 1)
343 #ifdef emacs
344 #define getdefdir(_drv, _buf) ((_buf[0] = (_drv + 'A' - 1), _buf[1] = ':', _buf[2] = '/', _buf[3] = 0), 1)
345 #else
346 #define getdefdir(_drv, _buf) _getdcwd (_drv, _buf, MAXPATHLEN)
347 #endif
348
349 extern char *get_emacs_configuration (void);
350 extern char *get_emacs_configuration_options (void);
351 #define EMACS_CONFIGURATION get_emacs_configuration ()
352 #define EMACS_CONFIG_OPTIONS get_emacs_configuration_options ()
353
354 /* Define this so that winsock.h definitions don't get included with
355 windows.h. For this to have proper effect, config.h must always be
356 included before windows.h. */
357 #define _WINSOCKAPI_ 1
358 #define _WINSOCK_H
359
360 /* Defines size_t and alloca (). */
361 #ifdef emacs
362 #define malloc e_malloc
363 #define free e_free
364 #define realloc e_realloc
365 #define calloc e_calloc
366 #endif
367 #ifdef _MSC_VER
368 #define alloca _alloca
369 #else
370 #include <malloc.h>
371 #endif
372
373 #include <sys/stat.h>
374
375 /* Define for those source files that do not include enough NT system files. */
376 #ifndef NULL
377 #ifdef __cplusplus
378 #define NULL 0
379 #else
380 #define NULL ((void *)0)
381 #endif
382 #endif
383
384 /* For proper declaration of environ. */
385 #include <stdlib.h>
386 #ifndef sys_nerr
387 #define sys_nerr _sys_nerr
388 #endif
389 #include <string.h>
390
391 extern int getloadavg (double *, int);
392
393 /* We need a little extra space, see ../../lisp/loadup.el. */
394 #define SYSTEM_PURESIZE_EXTRA 50000
395
396 #define DATA_START get_data_start ()
397
398 /* For unexec to work on Alpha systems, we need to put Emacs'
399 initialized data into a separate section from the CRT initialized
400 data (because the Alpha linker freely reorders data variables, even
401 across libraries, so our data and the CRT data get intermingled).
402
403 Starting with MSVC 5.0, we must also place the uninitialized data
404 into its own section. VC5 intermingles uninitialized data from the CRT
405 between Emacs' static uninitialized data and its public uninitialized
406 data. A separate .bss section for Emacs groups both static and
407 public uninitialized together.
408
409 Note that unexw32.c relies on this fact, and must be modified
410 accordingly if this section name is changed, or if this pragma is
411 removed. Also, obviously, all files that define initialized data
412 must include config.h to pick up this pragma. */
413
414 /* Names must be < 8 bytes. */
415 #ifdef _MSC_VER
416 #pragma data_seg("EMDATA")
417 #pragma bss_seg("EMBSS")
418 #endif
419
420 /* #define FULL_DEBUG */
421 /* #define EMACSDEBUG */
422
423 #ifdef EMACSDEBUG
424 extern void _DebPrint (const char *fmt, ...);
425 #define DebPrint(stuff) _DebPrint stuff
426 #else
427 #define DebPrint(stuff)
428 #endif
429
430
431 /* ============================================================ */