ms-w32.h 11.4 KB
Newer Older
Richard M. Stallman's avatar
Richard M. Stallman committed
1
/* System description file for Windows NT.
2

3
Copyright (C) 1993-1995, 2001-2012  Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
4 5 6

This file is part of GNU Emacs.

7
GNU Emacs is free software: you can redistribute it and/or modify
Richard M. Stallman's avatar
Richard M. Stallman committed
8
it under the terms of the GNU General Public License as published by
9 10
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Richard M. Stallman's avatar
Richard M. Stallman committed
11 12 13 14 15 16 17

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

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/>.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
19

20 21
/* Define symbols to identify the version of Unix this is.
   Define all the symbols that apply correctly.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
22 23 24 25 26 27 28 29

#ifndef WINDOWSNT
#define WINDOWSNT
#endif
#ifndef DOS_NT
#define DOS_NT 	/* MSDOS or WINDOWSNT */
#endif

30 31
/* #undef const */

Karl Heuer's avatar
Karl Heuer committed
32
/* If you are compiling with a non-C calling convention but need to
33
   declare vararg routines differently, put it here.  */
Karl Heuer's avatar
Karl Heuer committed
34 35 36 37
#define _VARARGS_ __cdecl

/* If you are providing a function to something that will call the
   function back (like a signal handler and signal, or main) its calling
38
   convention must be whatever standard the libraries expect.  */
Karl Heuer's avatar
Karl Heuer committed
39 40
#define _CALLBACK_ __cdecl

41 42
/* Define HAVE_TIMEVAL if the system supports the BSD style clock values.
   Look in <sys/time.h> for a timeval structure.  */
43
#define HAVE_TIMEVAL 1
Richard M. Stallman's avatar
Richard M. Stallman committed
44

45 46 47 48
/* But our select implementation doesn't allow us to make non-blocking
   connects.  So until that is fixed, this is necessary:  */
#define BROKEN_NON_BLOCKING_CONNECT 1

49 50 51 52
/* And the select implementation does 1-byte read-ahead waiting
   for received packets, so datagrams are broken too.  */
#define BROKEN_DATAGRAM_SOCKETS 1

53
#define MAIL_USE_SYSTEM_LOCK 1
Richard M. Stallman's avatar
Richard M. Stallman committed
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68
/* Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works. */
#ifdef __GNUC__
#define HAVE_ATTRIBUTE_ALIGNED 1
#endif

/* Define to 1 if strtold conforms to C99. */
#ifdef __GNUC__
#define HAVE_C99_STRTOLD 1
#endif

#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
#define HAVE___BUILTIN_UNWIND_INIT 1
#endif

Richard M. Stallman's avatar
Richard M. Stallman committed
69 70
/* ============================================================ */

71 72 73 74 75
/* Here, add any special hacks needed to make Emacs work on this
   system.  For example, you might define certain system call names
   that don't exist on your system, or that do different things on
   your system and must be used only through an encapsulation (which
   you should place, by convention, in sysdep.c).  */
Richard M. Stallman's avatar
Richard M. Stallman committed
76

77
/* Define this to be the separator between devices and paths.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
78 79 80 81 82 83
#define DEVICE_SEP ':'

/* We'll support either convention on NT.  */
#define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
#ifdef __GNUC__
#ifndef __cplusplus
#undef inline
#endif
#else  /* MSVC */
#define inline __inline
#endif

#ifdef __GNUC__
# define restrict __restrict__
#else
# define restrict
#endif

/* `mode_t' is not defined for MSVC. Define. */
#ifdef _MSC_VER
typedef unsigned short mode_t;
#endif

/* A va_copy replacement for MSVC.  */
#ifdef _MSC_VER
# ifdef _WIN64
#  ifndef va_copy               /* Need to be checked (?) */
#   define va_copy(d,s) ((d) = (s))
#  endif
# else	/* not _WIN64 */
#  define va_copy(d,s) ((d) = (s))
# endif	 /* not _WIN64 */
#endif	 /* _MSC_VER */

#ifndef WINDOWSNT
/* Some of the files of Emacs which are intended for use with other
   programs assume that if you have a config.h file, you must declare
   the type of getenv.  */
extern char *getenv ();
#endif

#ifdef HAVE_STRINGS_H
#include "strings.h"
#endif
124
#include <sys/types.h>
125 126 127 128 129 130

#ifdef _MSC_VER
typedef unsigned long sigset_t;
typedef int ssize_t;
#endif

131 132 133 134 135 136 137 138 139
struct sigaction {
  int sa_flags;
  void (*sa_handler)(int);
  sigset_t sa_mask;
};
#define SIG_BLOCK       1
#define SIG_SETMASK     2
#define SIG_UNBLOCK     3

Richard M. Stallman's avatar
Richard M. Stallman committed
140 141 142 143
#ifndef MAXPATHLEN
#define MAXPATHLEN      _MAX_PATH
#endif

144
#ifdef HAVE_NTGUI
145 146
#define HAVE_WINDOW_SYSTEM 1
#define HAVE_MENUS 1
147 148
#endif

149
/* Get some redefinitions in place.  */
Geoff Voelker's avatar
Geoff Voelker committed
150

151 152
#ifdef emacs

153 154 155 156
#ifdef _MSC_VER
#include <sys/timeb.h>
#include <sys/stat.h>
#include <signal.h>
Eli Zaretskii's avatar
Eli Zaretskii committed
157 158 159 160 161

/* MSVC gets link-time errors without these redirections.  */
#define fstat(a, b) sys_fstat(a, b)
#define stat(a, b)  sys_stat(a, b)
#define utime       sys_utime
162 163
#endif

164
/* Calls that are emulated or shadowed.  */
165
#undef access
Geoff Voelker's avatar
Geoff Voelker committed
166
#define access  sys_access
167
#undef chdir
Geoff Voelker's avatar
Geoff Voelker committed
168
#define chdir   sys_chdir
169
#undef chmod
Geoff Voelker's avatar
Geoff Voelker committed
170
#define chmod   sys_chmod
171
#define chown   sys_chown
172
#undef close
Geoff Voelker's avatar
Geoff Voelker committed
173
#define close   sys_close
174
#undef creat
Geoff Voelker's avatar
Geoff Voelker committed
175 176
#define creat   sys_creat
#define ctime	sys_ctime
177
#undef dup
Geoff Voelker's avatar
Geoff Voelker committed
178
#define dup     sys_dup
179
#undef dup2
Geoff Voelker's avatar
Geoff Voelker committed
180 181 182
#define dup2    sys_dup2
#define fopen   sys_fopen
#define link    sys_link
183
#define localtime sys_localtime
Geoff Voelker's avatar
Geoff Voelker committed
184
#define mkdir   sys_mkdir
185
#undef mktemp
Geoff Voelker's avatar
Geoff Voelker committed
186
#define mktemp  sys_mktemp
187
#undef open
Geoff Voelker's avatar
Geoff Voelker committed
188 189
#define open    sys_open
#define pipe    sys_pipe
190
#undef read
Geoff Voelker's avatar
Geoff Voelker committed
191 192 193 194
#define read    sys_read
#define rename  sys_rename
#define rmdir   sys_rmdir
#define select  sys_select
195
#define pselect sys_select
Geoff Voelker's avatar
Geoff Voelker committed
196
#define sleep   sys_sleep
197
#define strerror sys_strerror
198
#undef unlink
Geoff Voelker's avatar
Geoff Voelker committed
199
#define unlink  sys_unlink
200
#undef write
Geoff Voelker's avatar
Geoff Voelker committed
201 202
#define write   sys_write

203
/* Subprocess calls that are emulated.  */
Geoff Voelker's avatar
Geoff Voelker committed
204 205 206 207 208
#define spawnve sys_spawnve
#define wait    sys_wait
#define kill    sys_kill
#define signal  sys_signal

209
/* termcap.c calls that are emulated.  */
210 211 212
#define tputs   sys_tputs
#define tgetstr sys_tgetstr

213
/* cm.c calls that are emulated.  */
214 215 216 217 218 219
#define chcheckmagic sys_chcheckmagic
#define cmcostinit   sys_cmcostinit
#define cmgoto       sys_cmgoto
#define cmputc       sys_cmputc
#define Wcm_clear    sys_Wcm_clear

220 221
#endif /* emacs */

222
/* Map to MSVC names.  */
Geoff Voelker's avatar
Geoff Voelker committed
223 224 225
#define execlp    _execlp
#define execvp    _execvp
#define fdopen	  _fdopen
226
#ifndef fileno
Geoff Voelker's avatar
Geoff Voelker committed
227
#define fileno	  _fileno
228
#endif
Andrew Innes's avatar
Andrew Innes committed
229 230
#define fsync	  _commit
#define ftruncate _chsize
Geoff Voelker's avatar
Geoff Voelker committed
231
#define getpid    _getpid
232 233
#ifdef _MSC_VER
typedef int pid_t;
234 235
#define snprintf  _snprintf
#define strtoll   _strtoi64
236
#endif
Geoff Voelker's avatar
Geoff Voelker committed
237 238 239 240 241 242 243
#define isatty    _isatty
#define logb      _logb
#define _longjmp  longjmp
#define lseek     _lseek
#define popen     _popen
#define pclose    _pclose
#define umask	  _umask
244
#ifndef _MSC_VER
Geoff Voelker's avatar
Geoff Voelker committed
245
#define utimbuf	  _utimbuf
246
#endif
247 248 249 250 251
#define strdup    _strdup
#define strupr    _strupr
#define strnicmp  _strnicmp
#define stricmp   _stricmp
#define tzset     _tzset
252

253 254 255 256 257 258
/* Include time.h before redirecting tzname, since MSVC's time.h
   defines _tzname to call a function, but also declares tzname a
   2-element array.  Having the redirection before including the
   header thus has the effect of declaring a function that returns an
   array, and triggers an error message.  */
#include <time.h>
259
#define tzname    _tzname
260
#if !defined (_MSC_VER) || (_MSC_VER < 1400)
Eli Zaretskii's avatar
Eli Zaretskii committed
261
#undef  utime
262
#define utime	  _utime
263
#endif
Richard M. Stallman's avatar
Richard M. Stallman committed
264

265 266 267 268 269 270 271 272 273
/* 'struct timespec' is used by time-related functions in lib/ and
   elsewhere, but we don't use lib/time.h where the structure is
   defined.  */
struct timespec
{
  time_t	tv_sec;		/* seconds */
  long int	tv_nsec;	/* nanoseconds */
};

274 275
/* This is hacky, but is necessary to avoid warnings about macro
   redefinitions using the SDK compilers.  */
276 277 278 279 280 281 282 283 284 285 286 287
#ifndef __STDC__
#define __STDC__ 1
#define MUST_UNDEF__STDC__
#endif
#include <direct.h>
#include <io.h>
#include <stdio.h>
#ifdef MUST_UNDEF__STDC__
#undef __STDC__
#undef MUST_UNDEF__STDC__
#endif

288
/* Defines that we need that aren't in the standard signal.h.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
289 290 291 292 293 294 295 296
#define SIGHUP  1               /* Hang up */
#define SIGQUIT 3               /* Quit process */
#define SIGTRAP 5               /* Trace trap */
#define SIGKILL 9               /* Die, die die */
#define SIGPIPE 13              /* Write on pipe with no readers */
#define SIGALRM 14              /* Alarm */
#define SIGCHLD 18              /* Death of child */

297 298 299 300
#ifndef NSIG
#define NSIG 23
#endif

Richard M. Stallman's avatar
Richard M. Stallman committed
301 302
/* For integration with MSDOS support.  */
#define getdisk()               (_getdrive () - 1)
Richard M. Stallman's avatar
Richard M. Stallman committed
303 304 305
#ifdef emacs
#define getdefdir(_drv, _buf)   ((_buf[0] = (_drv + 'A' - 1), _buf[1] = ':', _buf[2] = '/', _buf[3] = 0), 1)
#else
Richard M. Stallman's avatar
Richard M. Stallman committed
306
#define getdefdir(_drv, _buf)   _getdcwd (_drv, _buf, MAXPATHLEN)
Richard M. Stallman's avatar
Richard M. Stallman committed
307
#endif
Richard M. Stallman's avatar
Richard M. Stallman committed
308

309 310
extern char *get_emacs_configuration (void);
extern char *get_emacs_configuration_options (void);
Karl Heuer's avatar
Karl Heuer committed
311
#define EMACS_CONFIGURATION 	get_emacs_configuration ()
312
#define EMACS_CONFIG_OPTIONS	get_emacs_configuration_options ()
Karl Heuer's avatar
Karl Heuer committed
313

Geoff Voelker's avatar
Geoff Voelker committed
314 315 316
/* Define this so that winsock.h definitions don't get included with
   windows.h.  For this to have proper effect, config.h must always be
   included before windows.h.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
317
#define _WINSOCKAPI_    1
318
#define _WINSOCK_H
Richard M. Stallman's avatar
Richard M. Stallman committed
319

320 321 322 323 324 325 326
/* Prevent accidental use of features unavailable in
   older Windows versions we still support.  */
#define _WIN32_WINNT 0x0400

/* Make a leaner executable.  */
#define WIN32_LEAN_AND_MEAN 1

Karl Heuer's avatar
Karl Heuer committed
327
/* Defines size_t and alloca ().  */
328
#ifdef emacs
329 330 331 332 333
#define malloc e_malloc
#define free   e_free
#define realloc e_realloc
#define calloc e_calloc
#endif
334 335 336
#ifdef _MSC_VER
#define alloca _alloca
#else
Karl Heuer's avatar
Karl Heuer committed
337
#include <malloc.h>
338
#endif
Karl Heuer's avatar
Karl Heuer committed
339

340 341 342 343 344 345 346 347 348 349
/* stdlib.h must be included after redefining malloc & friends, but
   before redefining abort.  Isn't library redefinition funny?  */
#include <stdlib.h>

/* Redefine abort.  */
#ifdef HAVE_NTGUI
#define abort	w32_abort
extern _Noreturn void w32_abort (void);
#endif

Karl Heuer's avatar
Karl Heuer committed
350 351
#include <sys/stat.h>

352
/* Define for those source files that do not include enough NT system files.  */
Karl Heuer's avatar
Karl Heuer committed
353 354 355 356 357 358 359
#ifndef NULL
#ifdef __cplusplus
#define NULL	0
#else
#define NULL	((void *)0)
#endif
#endif
360

361
/* For proper declaration of environ.  */
362 363 364
#ifndef sys_nerr
#define sys_nerr _sys_nerr
#endif
365

366 367
extern int getloadavg (double *, int);

368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
#if defined (__MINGW32__) || _MSC_VER >= 1400

/* Define to 1 if the system has the type `long long int'. */
# define HAVE_LONG_LONG_INT 1

/* Define to 1 if the system has the type `unsigned long long int'. */
# define HAVE_UNSIGNED_LONG_LONG_INT 1

#elif _MSC_VER >= 1200

/* Temporarily disable wider-than-pointer integers until they're tested more.
   Build with CFLAGS='-DWIDE_EMACS_INT' to try them out.  */

# ifdef WIDE_EMACS_INT

/* Use pre-C99-style 64-bit integers.  */
384 385
typedef __int64 EMACS_INT;
typedef unsigned __int64 EMACS_UINT;
386 387 388 389 390 391 392
# define EMACS_INT_MAX _I64_MAX
# define pI "I64"

# endif

#endif

Juanma Barranquero's avatar
Juanma Barranquero committed
393
/* We need a little extra space, see ../../lisp/loadup.el.  */
394
#define SYSTEM_PURESIZE_EXTRA 50000
395

Paul Eggert's avatar
Paul Eggert committed
396 397
#define DATA_START 	get_data_start ()

398 399 400 401 402 403 404 405 406
/* For unexec to work on Alpha systems, we need to put Emacs'
   initialized data into a separate section from the CRT initialized
   data (because the Alpha linker freely reorders data variables, even
   across libraries, so our data and the CRT data get intermingled).

   Starting with MSVC 5.0, we must also place the uninitialized data
   into its own section.  VC5 intermingles uninitialized data from the CRT
   between Emacs' static uninitialized data and its public uninitialized
   data.  A separate .bss section for Emacs groups both static and
Juanma Barranquero's avatar
Juanma Barranquero committed
407
   public uninitialized together.
408

Juanma Barranquero's avatar
Juanma Barranquero committed
409
   Note that unexw32.c relies on this fact, and must be modified
410 411 412 413
   accordingly if this section name is changed, or if this pragma is
   removed.  Also, obviously, all files that define initialized data
   must include config.h to pick up this pragma.  */

414
/* Names must be < 8 bytes.  */
415
#ifdef _MSC_VER
416 417
#pragma data_seg("EMDATA")
#pragma bss_seg("EMBSS")
418
#endif
419 420 421 422 423 424 425 426 427 428 429

/* #define FULL_DEBUG */
/* #define EMACSDEBUG */

#ifdef EMACSDEBUG
extern void _DebPrint (const char *fmt, ...);
#define DebPrint(stuff) _DebPrint stuff
#else
#define DebPrint(stuff)
#endif

Karl Heuer's avatar
Karl Heuer committed
430
/* ============================================================ */