1 /* System description file for Windows NT.
3 Copyright (C) 1993-1995, 2001-2013 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
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.
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.
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/>. */
20 /* Define symbols to identify the version of Unix this is.
21 Define all the symbols that apply correctly. */
29 /* Number of chars of output in the buffer of a stdio stream. */
30 #ifdef __GNU_LIBRARY__
31 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->__bufp - (FILE)->__buffer)
33 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base)
36 /* If you are compiling with a non-C calling convention but need to
37 declare vararg routines differently, put it here. */
38 #define _VARARGS_ __cdecl
40 /* If you are providing a function to something that will call the
41 function back (like a signal handler and signal, or main) its calling
42 convention must be whatever standard the libraries expect. */
43 #define _CALLBACK_ __cdecl
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
49 /* But our select implementation doesn't allow us to make non-blocking
50 connects. So until that is fixed, this is necessary: */
51 #define BROKEN_NON_BLOCKING_CONNECT 1
53 /* And the select implementation does 1-byte read-ahead waiting
54 for received packets, so datagrams are broken too. */
55 #define BROKEN_DATAGRAM_SOCKETS 1
57 #define MAIL_USE_SYSTEM_LOCK 1
59 /* Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works. */
61 #define HAVE_ATTRIBUTE_ALIGNED 1
64 /* Define to 1 if strtold conforms to C99. */
66 #define HAVE_C99_STRTOLD 1
69 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
70 #define HAVE___BUILTIN_UNWIND_INIT 1
73 /* This isn't perfect, as some systems might have the page file in
74 another place. Also, I suspect that the time stamp of that file
75 might also change when Windows enlarges the file due to
76 insufficient VM. Still, this seems to be the most reliable way;
77 the alternative (of using GetSystemTimes) won't work on laptops
78 that hibernate, because the system clock is stopped then. Other
79 possibility would be to run "net statistics workstation" and parse
80 the output, but that's gross. So this should do; if the file is
81 not there, the boot time will be returned as zero, and filelock.c
82 already handles that. */
83 #define BOOT_TIME_FILE "C:/pagefile.sys"
85 /* ============================================================ */
87 /* Here, add any special hacks needed to make Emacs work on this
88 system. For example, you might define certain system call names
89 that don't exist on your system, or that do different things on
90 your system and must be used only through an encapsulation (which
91 you should place, by convention, in sysdep.c). */
98 #define inline __inline
102 # define restrict __restrict__
107 /* `mode_t' is not defined for MSVC. Define. */
109 typedef unsigned short mode_t
;
112 /* A va_copy replacement for MSVC. */
115 # ifndef va_copy /* Need to be checked (?) */
116 # define va_copy(d,s) ((d) = (s))
118 # else /* not _WIN64 */
119 # define va_copy(d,s) ((d) = (s))
120 # endif /* not _WIN64 */
121 #endif /* _MSC_VER */
124 /* Some of the files of Emacs which are intended for use with other
125 programs assume that if you have a config.h file, you must declare
126 the type of getenv. */
127 extern char *getenv ();
130 /* Prevent accidental use of features unavailable in older Windows
131 versions we still support. MinGW64 defines this to a higher value
132 in its system headers, and is not really compatible with values
133 lower than 0x0500, so leave it alone. */
135 # define _WIN32_WINNT 0x0400
138 /* Make a leaner executable. */
139 #define WIN32_LEAN_AND_MEAN 1
141 #ifdef HAVE_STRINGS_H
144 #include <sys/types.h>
147 #define MAXPATHLEN _MAX_PATH
151 #define HAVE_WINDOW_SYSTEM 1
155 /* Get some redefinitions in place. */
160 /* MinGW64 specific stuff. */
161 /* Make sure 'struct timespec' and 'struct timezone' are defined. */
162 #include <sys/types.h>
164 /* This prototype avoids MinGW64 compiler warnings due to the fact
165 that time.h is included before localtime is redirected to
166 sys_localtime below. */
167 extern struct tm
* sys_localtime (const time_t *);
168 /* MinGW64 uses a 2-argument _setjmp, and setjmp is a macro defined to
169 supply the 2nd arg correctly, so don't use _setjmp directly in that
175 #include <sys/timeb.h>
176 #include <sys/stat.h>
179 /* MSVC gets link-time errors without these redirections. */
180 #define fstat(a, b) sys_fstat(a, b)
181 #define stat(a, b) sys_stat(a, b)
182 #define utime sys_utime
185 /* Calls that are emulated or shadowed. */
187 #define chdir sys_chdir
189 #define chmod sys_chmod
191 #define close sys_close
193 #define creat sys_creat
194 #define ctime sys_ctime
198 #define dup2 sys_dup2
199 #define fopen sys_fopen
200 #define link sys_link
201 #define localtime sys_localtime
202 #define mkdir sys_mkdir
204 #define mktemp sys_mktemp
206 #define open sys_open
207 #define pipe sys_pipe
209 #define read sys_read
210 #define rename sys_rename
211 #define rmdir sys_rmdir
212 #define select sys_select
213 #define pselect sys_select
214 #define sleep sys_sleep
215 #define strerror sys_strerror
217 #define unlink sys_unlink
218 /* This prototype is needed because some files include config.h
219 _after_ the standard headers, so sys_unlink gets no prototype from
221 extern int sys_unlink (const char *);
223 #define write sys_write
225 /* Subprocess calls that are emulated. */
226 #define spawnve sys_spawnve
227 #define kill sys_kill
228 #define signal sys_signal
230 /* Internal signals. */
231 #define emacs_raise(sig) emacs_abort()
233 /* termcap.c calls that are emulated. */
234 #define tputs sys_tputs
235 #define tgetstr sys_tgetstr
237 /* cm.c calls that are emulated. */
238 #define chcheckmagic sys_chcheckmagic
239 #define cmcostinit sys_cmcostinit
240 #define cmgoto sys_cmgoto
241 #define cmputc sys_cmputc
242 #define Wcm_clear sys_Wcm_clear
246 /* Map to MSVC names. */
247 #define execlp _execlp
248 #define execvp _execvp
249 #define fdatasync _commit
250 #define fdopen _fdopen
252 #define fileno _fileno
254 #define fsync _commit
255 #define ftruncate _chsize
256 #define getpid _getpid
259 #define snprintf _snprintf
260 #define strtoll _strtoi64
262 #define isatty _isatty
263 #define _longjmp longjmp
266 #define pclose _pclose
269 #define utimbuf _utimbuf
271 #define strdup _strdup
272 #define strupr _strupr
273 #define strnicmp _strnicmp
274 #define stricmp _stricmp
277 /* We cannot include system header process.h, since there's src/process.h. */
280 /* Include time.h before redirecting tzname, since MSVC's time.h
281 defines _tzname to call a function, but also declares tzname a
282 2-element array. Having the redirection before including the
283 header thus has the effect of declaring a function that returns an
284 array, and triggers an error message. */
286 #define tzname _tzname
287 #if !defined (_MSC_VER) || (_MSC_VER < 1400)
292 /* 'struct timespec' is used by time-related functions in lib/ and
293 elsewhere, but we don't use lib/time.h where the structure is
295 /* MinGW64 defines 'struct timespec' and _TIMESPEC_DEFINED in sys/types.h. */
296 #ifndef _TIMESPEC_DEFINED
299 time_t tv_sec
; /* seconds */
300 long int tv_nsec
; /* nanoseconds */
304 /* Required for functions in lib/time_r.c, since we don't use lib/time.h. */
305 extern struct tm
*gmtime_r (time_t const * restrict
, struct tm
* restrict
);
306 extern struct tm
*localtime_r (time_t const * restrict
, struct tm
* restrict
);
309 /* This is hacky, but is necessary to avoid warnings about macro
310 redefinitions using the MSVC compilers, since, when __STDC__ is
311 undefined or zero, those compilers declare functions like fileno,
312 lseek, and chdir, for which we defined macros above. */
315 #define MUST_UNDEF__STDC__
320 #ifdef MUST_UNDEF__STDC__
322 #undef MUST_UNDEF__STDC__
324 #else /* !_MSC_VER */
328 #endif /* !_MSC_VER */
330 /* Defines that we need that aren't in the standard signal.h. */
331 #define SIGHUP 1 /* Hang up */
332 #define SIGQUIT 3 /* Quit process */
333 #define SIGTRAP 5 /* Trace trap */
334 #define SIGKILL 9 /* Die, die die */
335 #define SIGPIPE 13 /* Write on pipe with no readers */
336 #define SIGALRM 14 /* Alarm */
337 #define SIGCHLD 18 /* Death of child */
338 #define SIGPROF 19 /* Profiling */
345 #define ENOTSUP ENOSYS
349 typedef int sigset_t
;
353 #ifndef _POSIX /* MinGW64 */
354 typedef _sigset_t sigset_t
;
357 typedef void (_CALLBACK_
*signal_handler
) (int);
358 extern signal_handler
sys_signal (int, signal_handler
);
362 void (_CALLBACK_
*sa_handler
)(int);
367 #define SIG_SETMASK 2
368 #define SIG_UNBLOCK 3
370 extern int sigemptyset (sigset_t
*);
371 extern int sigaddset (sigset_t
*, int);
372 extern int sigfillset (sigset_t
*);
373 extern int sigprocmask (int, const sigset_t
*, sigset_t
*);
374 extern int pthread_sigmask (int, const sigset_t
*, sigset_t
*);
375 extern int sigismember (const sigset_t
*, int);
376 extern int setpgrp (int, int);
377 extern int sigaction (int, const struct sigaction
*, struct sigaction
*);
378 extern int alarm (int);
380 extern int sys_kill (int, int);
383 /* For integration with MSDOS support. */
384 #define getdisk() (_getdrive () - 1)
386 #define getdefdir(_drv, _buf) ((_buf[0] = (_drv + 'A' - 1), _buf[1] = ':', _buf[2] = '/', _buf[3] = 0), 1)
388 #define getdefdir(_drv, _buf) _getdcwd (_drv, _buf, MAXPATHLEN)
391 extern char *get_emacs_configuration (void);
392 extern char *get_emacs_configuration_options (void);
393 #define EMACS_CONFIGURATION get_emacs_configuration ()
394 #define EMACS_CONFIG_OPTIONS get_emacs_configuration_options ()
396 /* Define this so that winsock.h definitions don't get included with
397 windows.h. For this to have proper effect, config.h must always be
398 included before windows.h. */
399 #define _WINSOCKAPI_ 1
402 /* Defines size_t and alloca (). */
404 #define malloc e_malloc
406 #define realloc e_realloc
407 #define calloc e_calloc
410 #define alloca _alloca
416 #include <sys/stat.h>
418 /* Define for those source files that do not include enough NT system files. */
423 #define NULL ((void *)0)
427 /* For proper declaration of environ. */
429 #define sys_nerr _sys_nerr
432 /* This must be after including stdlib.h, which defines putenv on MinGW. */
436 #define putenv sys_putenv
437 extern int sys_putenv (char *);
439 extern int getloadavg (double *, int);
440 extern int getpagesize (void);
442 extern void * memrchr (void const *, int, size_t);
445 #if defined (__MINGW32__)
447 /* Define to 1 if the system has the type `long long int'. */
448 # define HAVE_LONG_LONG_INT 1
450 /* Define to 1 if the system has the type `unsigned long long int'. */
451 # define HAVE_UNSIGNED_LONG_LONG_INT 1
457 typedef __int64 EMACS_INT
;
458 typedef unsigned __int64 EMACS_UINT
;
459 # define EMACS_INT_MAX LLONG_MAX
460 # define PRIuMAX "llu"
462 /* Fix a bug in MSVC headers : stdint.h */
464 # elif defined(_WIN32)
465 /* Temporarily disable wider-than-pointer integers until they're tested more.
466 Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */
468 # ifdef WIDE_EMACS_INT
470 /* Use pre-C99-style 64-bit integers. */
471 typedef __int64 EMACS_INT
;
472 typedef unsigned __int64 EMACS_UINT
;
473 # define EMACS_INT_MAX LLONG_MAX
474 # define PRIuMAX "llu"
477 typedef int EMACS_INT
;
478 typedef unsigned int EMACS_UINT
;
479 # define EMACS_INT_MAX LONG_MAX
480 # define PRIuMAX "lu"
486 /* We need a little extra space, see ../../lisp/loadup.el. */
487 #define SYSTEM_PURESIZE_EXTRA 50000
489 #define DATA_START get_data_start ()
491 /* For unexec to work on Alpha systems, we need to put Emacs'
492 initialized data into a separate section from the CRT initialized
493 data (because the Alpha linker freely reorders data variables, even
494 across libraries, so our data and the CRT data get intermingled).
496 Starting with MSVC 5.0, we must also place the uninitialized data
497 into its own section. VC5 intermingles uninitialized data from the CRT
498 between Emacs' static uninitialized data and its public uninitialized
499 data. A separate .bss section for Emacs groups both static and
500 public uninitialized together.
502 Note that unexw32.c relies on this fact, and must be modified
503 accordingly if this section name is changed, or if this pragma is
504 removed. Also, obviously, all files that define initialized data
505 must include config.h to pick up this pragma. */
507 /* Names must be < 8 bytes. */
509 #pragma data_seg("EMDATA")
510 #pragma bss_seg("EMBSS")
513 /* #define FULL_DEBUG */
514 /* #define EMACSDEBUG */
517 extern void _DebPrint (const char *fmt
, ...);
518 #define DebPrint(stuff) _DebPrint stuff
520 #define DebPrint(stuff)
524 #if _MSC_VER >= 800 && !defined(__cplusplus)
525 /* Unnamed type definition in parentheses.
526 A structure, union, or enumerated type with no name is defined in a
527 parenthetical expression. The type definition is meaningless. */
528 #pragma warning(disable:4116)
529 /* 'argument' : conversion from 'type1' to 'type2', possible loss of
530 data A floating point type was converted to an integer type. A
531 possible loss of data may have occurred. */
532 #pragma warning(disable:4244)
533 /* Negative integral constant converted to unsigned type.
534 An expression converts a negative integer constant to an unsigned type.
535 The result of the expression is probably meaningless. */
536 #pragma warning(disable:4308)
539 #define TERM_HEADER "w32term.h"
542 /* ============================================================ */