Fix permissions handling (CVE-2010-0825).
[emacs.git] / src / s / ms-w32.h
blob3e5c65eaab534055a452f0d2fb95c409c3769286
1 /* System description file for Windows NT.
2 Copyright (C) 1993, 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006,
3 2007, 2008, 2009, 2010 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/>. */
21 * Define symbols to identify the version of Unix this is.
22 * Define all the symbols that apply correctly.
25 #ifndef WINDOWSNT
26 #define WINDOWSNT
27 #endif
28 #ifndef DOS_NT
29 #define DOS_NT /* MSDOS or WINDOWSNT */
30 #endif
32 /* If you are compiling with a non-C calling convention but need to
33 declare vararg routines differently, put it here */
34 #define _VARARGS_ __cdecl
36 /* If you are providing a function to something that will call the
37 function back (like a signal handler and signal, or main) its calling
38 convention must be whatever standard the libraries expect */
39 #define _CALLBACK_ __cdecl
41 /* SYSTEM_TYPE should indicate the kind of system you are using.
42 It sets the Lisp variable system-type. */
44 #define SYSTEM_TYPE "windows-nt"
45 #define SYMS_SYSTEM syms_of_ntterm ()
47 #define NO_MATHERR 1
49 /* Letter to use in finding device name of first pty,
50 if system supports pty's. 'a' means it is /dev/ptya0 */
52 #define FIRST_PTY_LETTER 'a'
55 * Define HAVE_TIMEVAL if the system supports the BSD style clock values.
56 * Look in <sys/time.h> for a timeval structure.
59 #define HAVE_TIMEVAL 1
61 /* NT supports Winsock which is close enough (with some hacks) */
63 #define HAVE_SOCKETS 1
65 /* But our select implementation doesn't allow us to make non-blocking
66 connects. So until that is fixed, this is necessary: */
68 #define BROKEN_NON_BLOCKING_CONNECT 1
70 /* And the select implementation does 1-byte read-ahead waiting
71 for received packets, so datagrams are broken too. */
73 #define BROKEN_DATAGRAM_SOCKETS 1
75 /* Define this symbol if your system has the functions bcopy, etc. */
77 #define BSTRING
78 #define bzero(b, l) memset(b, 0, l)
79 #define bcopy(s, d, l) memmove(d, s, l)
80 #define bcmp(a, b, l) memcmp(a, b, l)
82 /* bcopy (aka memmove aka memcpy at least on x86) under MSVC is quite safe */
83 #define GAP_USE_BCOPY 1
84 #define BCOPY_UPWARD_SAFE 1
85 #define BCOPY_DOWNWARD_SAFE 1
87 /* If your system uses COFF (Common Object File Format) then define the
88 preprocessor symbol "COFF". */
90 #define COFF 1
92 /* define MAIL_USE_FLOCK if the mailer uses flock
93 to interlock access to /usr/spool/mail/$USER.
94 The alternative is that a lock file named
95 /usr/spool/mail/$USER.lock. */
97 /* #define MAIL_USE_FLOCK */
98 #define MAIL_USE_POP 1
99 #define MAIL_USE_SYSTEM_LOCK 1
101 /* If the character used to separate elements of the executable path
102 is not ':', #define this to be the appropriate character constant. */
103 #define SEPCHAR ';'
105 #define ORDINARY_LINK 1
107 /* ============================================================ */
109 /* Here, add any special hacks needed
110 to make Emacs work on this system. For example,
111 you might define certain system call names that don't
112 exist on your system, or that do different things on
113 your system and must be used only through an encapsulation
114 (Which you should place, by convention, in sysdep.c). */
116 /* Define this to be the separator between path elements */
117 #define DIRECTORY_SEP XINT (Vdirectory_sep_char)
119 /* Define this to be the separator between devices and paths */
120 #define DEVICE_SEP ':'
122 /* We'll support either convention on NT. */
123 #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
124 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
126 /* The null device on Windows NT. */
127 #define NULL_DEVICE "NUL:"
129 #ifndef MAXPATHLEN
130 #define MAXPATHLEN _MAX_PATH
131 #endif
133 #define HAVE_SOUND 1
134 #define LISP_FLOAT_TYPE 1
136 #undef HAVE_SYS_SELECT_H
137 #define HAVE_SYS_TIMEB_H 1
138 #define HAVE_SYS_TIME_H 1
139 #define HAVE_UNISTD_H 1
140 #undef HAVE_UTIME_H
141 #undef HAVE_LINUX_VERSION_H
142 #undef HAVE_SYS_SYSTEMINFO_H
143 #undef HAVE_TERMIOS_H
144 #define HAVE_LIMITS_H 1
145 #define HAVE_STRING_H 1
146 #define HAVE_STDLIB_H 1
147 #define HAVE_PWD_H 1
148 #define STDC_HEADERS 1
149 #define TIME_WITH_SYS_TIME 1
151 #define HAVE_GETTIMEOFDAY 1
152 #define HAVE_GETHOSTNAME 1
153 #undef HAVE_GETDOMAINNAME
154 #define HAVE_DUP2 1
155 #define HAVE_RENAME 1
156 #define HAVE_CLOSEDIR 1
157 #define HAVE_FSYNC 1 /* fsync is called _commit in MSVC. */
159 #undef TM_IN_SYS_TIME
160 #undef HAVE_TM_ZONE
162 #define HAVE_LONG_FILE_NAMES 1
164 #define HAVE_MKDIR 1
165 #define HAVE_RMDIR 1
166 #define HAVE_RANDOM 1
167 #undef HAVE_SYSINFO
168 #undef HAVE_LRAND48
169 #define HAVE_BCOPY 1
170 #define HAVE_BCMP 1
171 #define HAVE_LOGB 1
172 #define HAVE_FREXP 1
173 #define HAVE_FMOD 1
174 #undef HAVE_RINT
175 #undef HAVE_CBRT
176 #define HAVE_FTIME 1
177 #undef HAVE_RES_INIT /* For -lresolv on Suns. */
178 #undef HAVE_SETSID
179 #undef HAVE_FPATHCONF
180 #define HAVE_SELECT 1
181 #define HAVE_MKTIME 1
182 #undef HAVE_EUIDACCESS
183 #define HAVE_GETPAGESIZE 1
184 #define HAVE_TZSET 1
185 #define HAVE_SETLOCALE 1
186 #undef HAVE_UTIMES
187 #undef HAVE_SETRLIMIT
188 #undef HAVE_SETPGID
189 #undef HAVE_GETCWD
190 #define HAVE_SHUTDOWN 1
191 #define HAVE_STRFTIME 1
193 #define LOCALTIME_CACHE
194 #define HAVE_INET_SOCKETS 1
196 #undef HAVE_AIX_SMT_EXP
197 #define USE_TOOLKIT_SCROLL_BARS 1
199 /* Define if you have the ANSI `strerror' function.
200 Otherwise you must have the variable `char *sys_errlist[]'. */
201 #define HAVE_STRERROR 1
203 /* Define if `struct utimbuf' is declared by <utime.h>. */
204 #undef HAVE_STRUCT_UTIMBUF
206 #define HAVE_MOUSE 1
207 #define HAVE_H_ERRNO 1
209 #ifdef HAVE_NTGUI
210 #define HAVE_WINDOW_SYSTEM 1
211 #define HAVE_MENUS 1
212 #endif
214 #define MODE_LINE_BINARY_TEXT(_b_) (NILP ((_b_)->buffer_file_type) ? "T" : "B")
216 /* get some redefinitions in place */
218 #ifdef emacs
220 /* calls that are emulated or shadowed */
221 #undef access
222 #define access sys_access
223 #undef chdir
224 #define chdir sys_chdir
225 #undef chmod
226 #define chmod sys_chmod
227 #define chown sys_chown
228 #undef close
229 #define close sys_close
230 #undef creat
231 #define creat sys_creat
232 #define ctime sys_ctime
233 #undef dup
234 #define dup sys_dup
235 #undef dup2
236 #define dup2 sys_dup2
237 #define fopen sys_fopen
238 #define link sys_link
239 #define mkdir sys_mkdir
240 #undef mktemp
241 #define mktemp sys_mktemp
242 #undef open
243 #define open sys_open
244 #define pipe sys_pipe
245 #undef read
246 #define read sys_read
247 #define rename sys_rename
248 #define rmdir sys_rmdir
249 #define select sys_select
250 #define sleep sys_sleep
251 #define strerror sys_strerror
252 #undef unlink
253 #define unlink sys_unlink
254 #undef write
255 #define write sys_write
257 /* subprocess calls that are emulated */
258 #define spawnve sys_spawnve
259 #define wait sys_wait
260 #define kill sys_kill
261 #define signal sys_signal
263 #endif /* emacs */
265 /* map to MSVC names */
266 #define execlp _execlp
267 #define execvp _execvp
268 #define fdopen _fdopen
269 #ifndef fileno
270 #define fileno _fileno
271 #endif
272 #define fsync _commit
273 #define ftruncate _chsize
274 #define getpid _getpid
275 #ifdef _MSC_VER
276 typedef int pid_t;
277 #endif
278 #define isatty _isatty
279 #define logb _logb
280 #define _longjmp longjmp
281 #define lseek _lseek
282 #define popen _popen
283 #define pclose _pclose
284 #define umask _umask
285 #define utimbuf _utimbuf
286 #define index strchr
287 #define rindex strrchr
288 #define strdup _strdup
289 #define strupr _strupr
290 #define strnicmp _strnicmp
291 #define stricmp _stricmp
292 #define tzset _tzset
294 #if !defined (_MSC_VER) || (_MSC_VER < 1400)
295 #define tzname _tzname
296 #define utime _utime
297 #endif
299 /* this is hacky, but is necessary to avoid warnings about macro
300 redefinitions using the SDK compilers */
301 #ifndef __STDC__
302 #define __STDC__ 1
303 #define MUST_UNDEF__STDC__
304 #endif
305 #include <direct.h>
306 #include <io.h>
307 #include <stdio.h>
308 #ifdef MUST_UNDEF__STDC__
309 #undef __STDC__
310 #undef MUST_UNDEF__STDC__
311 #endif
313 /* Defines that we need that aren't in the standard signal.h */
314 #define SIGHUP 1 /* Hang up */
315 #define SIGQUIT 3 /* Quit process */
316 #define SIGTRAP 5 /* Trace trap */
317 #define SIGKILL 9 /* Die, die die */
318 #define SIGPIPE 13 /* Write on pipe with no readers */
319 #define SIGALRM 14 /* Alarm */
320 #define SIGCHLD 18 /* Death of child */
322 #ifndef NSIG
323 #define NSIG 23
324 #endif
326 /* For integration with MSDOS support. */
327 #define getdisk() (_getdrive () - 1)
328 #ifdef emacs
329 #define getdefdir(_drv, _buf) ((_buf[0] = (_drv + 'A' - 1), _buf[1] = ':', _buf[2] = '/', _buf[3] = 0), 1)
330 #else
331 #define getdefdir(_drv, _buf) _getdcwd (_drv, _buf, MAXPATHLEN)
332 #endif
334 extern char *get_emacs_configuration (void);
335 extern char *get_emacs_configuration_options (void);
336 #define EMACS_CONFIGURATION get_emacs_configuration ()
337 #define EMACS_CONFIG_OPTIONS get_emacs_configuration_options ()
339 /* Define this so that winsock.h definitions don't get included with
340 windows.h. For this to have proper effect, config.h must always be
341 included before windows.h. */
342 #define _WINSOCKAPI_ 1
343 #define _WINSOCK_H
345 /* Defines size_t and alloca (). */
346 #ifdef USE_CRT_DLL
347 #define malloc e_malloc
348 #define free e_free
349 #define realloc e_realloc
350 #define calloc e_calloc
351 #endif
352 #include <malloc.h>
354 #include <sys/stat.h>
356 /* Define for those source files that do not include enough NT
357 system files. */
358 #ifndef NULL
359 #ifdef __cplusplus
360 #define NULL 0
361 #else
362 #define NULL ((void *)0)
363 #endif
364 #endif
366 /* For proper declaration of environ. */
367 #include <stdlib.h>
368 #ifndef sys_nerr
369 #define sys_nerr _sys_nerr
370 #endif
371 #include <string.h>
373 /* We need a little extra space, see ../../lisp/loadup.el. */
374 #define SYSTEM_PURESIZE_EXTRA 50000
376 /* For unexec to work on Alpha systems, we need to put Emacs'
377 initialized data into a separate section from the CRT initialized
378 data (because the Alpha linker freely reorders data variables, even
379 across libraries, so our data and the CRT data get intermingled).
381 Starting with MSVC 5.0, we must also place the uninitialized data
382 into its own section. VC5 intermingles uninitialized data from the CRT
383 between Emacs' static uninitialized data and its public uninitialized
384 data. A separate .bss section for Emacs groups both static and
385 public uninitialized together.
387 Note that unexw32.c relies on this fact, and must be modified
388 accordingly if this section name is changed, or if this pragma is
389 removed. Also, obviously, all files that define initialized data
390 must include config.h to pick up this pragma. */
392 /* Names must be < 8 bytes */
393 #ifdef _MSC_VER
394 #pragma data_seg("EMDATA")
395 #pragma bss_seg("EMBSS")
396 #endif
398 /* #define FULL_DEBUG */
399 /* #define EMACSDEBUG */
401 #ifdef EMACSDEBUG
402 extern void _DebPrint (const char *fmt, ...);
403 #define DebPrint(stuff) _DebPrint stuff
404 #else
405 #define DebPrint(stuff)
406 #endif
409 /* ============================================================ */
411 /* arch-tag: 5d4a3a1c-40dc-4dea-9c7c-38fed9ae0eae
412 (do not change this comment) */