1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #ifndef WINDOWSNT
24 #define WINDOWSNT
25 #endif
26
27 #include <mingw_time.h>
28
29
30
31
32 #ifdef __MINGW32__
33 # include <_mingw.h>
34 # ifdef __MINGW64_VERSION_MAJOR
35 # define MINGW_W64
36 # endif
37 # if defined __MINGW32_VERSION && __MINGW32_VERSION >= 5001000L
38
39 # undef __POSIX_2008_DEPRECATED
40 # define __POSIX_2008_DEPRECATED
41 # endif
42
43
44 # ifndef _WIN32_WINNT_WIN2K
45 # define _WIN32_WINNT_WIN2K 0x0500
46 # endif
47 # ifndef _WIN32_WINNT_WINXP
48 # define _WIN32_WINNT_WINXP 0x0501
49 # endif
50 # ifndef _WIN32_WINNT_WS03
51 # define _WIN32_WINNT_WS03 0x0502
52 # endif
53 # ifndef _WIN32_WINNT_VISTA
54 # define _WIN32_WINNT_VISTA 0x0600
55 # endif
56 # ifndef _WIN32_WINNT_WIN7
57 # define _WIN32_WINNT_WIN7 0x0601
58 # endif
59 # ifndef _WIN32_WINNT_WIN8
60 # define _WIN32_WINNT_WIN8 0x0602
61 # endif
62 # ifndef _WIN32_WINNT_WINBLUE
63 # define _WIN32_WINNT_WINBLUE 0x0603
64 # endif
65 # ifndef _WIN32_WINNT_WIN10
66 # define _WIN32_WINNT_WIN10 0x0A00
67 # endif
68 #endif
69
70
71
72
73 #ifdef __GNU_LIBRARY__
74 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->__bufp - (FILE)->__buffer)
75 #else
76 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base)
77 #endif
78
79
80
81 #define _VARARGS_ __cdecl
82
83
84
85
86 #define _CALLBACK_ __cdecl
87
88
89
90 #define HAVE_TIMEVAL 1
91
92
93
94 #define BROKEN_DATAGRAM_SOCKETS 1
95
96 #define MAIL_USE_SYSTEM_LOCK 1
97
98
99 #ifdef __GNUC__
100 #define HAVE_ATTRIBUTE_ALIGNED 1
101 #endif
102
103
104 #ifdef __GNUC__
105 #define HAVE_C99_STRTOLD 1
106 #endif
107
108 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
109 # ifndef HAVE___BUILTIN_UNWIND_INIT
110 # define HAVE___BUILTIN_UNWIND_INIT 1
111 # endif
112 #endif
113
114
115
116
117
118
119
120
121
122 #ifdef __GNUC__
123 #ifndef __cplusplus
124 #undef inline
125 #endif
126 #else
127 #define inline __inline
128 #endif
129
130 #ifdef __GNUC__
131
132 # ifndef restrict
133 # define restrict __restrict__
134 # endif
135 #else
136
137 # define restrict
138 #endif
139
140
141 #ifdef _MSC_VER
142 typedef unsigned short mode_t;
143 #endif
144
145
146 #ifdef _MSC_VER
147 # ifdef _WIN64
148 # ifndef va_copy
149 # define va_copy(d,s) ((d) = (s))
150 # endif
151 # else
152 # define va_copy(d,s) ((d) = (s))
153 # endif
154 #endif
155
156 #ifndef WINDOWSNT
157
158
159
160 extern char *getenv ();
161 #endif
162
163
164
165
166
167 #ifndef MINGW_W64
168 # undef _WIN32_WINNT
169 # define _WIN32_WINNT 0x0400
170 #endif
171
172
173 #define WIN32_LEAN_AND_MEAN
174
175 #include <sys/types.h>
176
177 #ifndef MAXPATHLEN
178 #define MAXPATHLEN _MAX_PATH
179 #endif
180
181
182 #define MAX_UTF8_PATH (MAXPATHLEN * 4)
183
184 #ifdef HAVE_NTGUI
185 # ifndef HAVE_WINDOW_SYSTEM
186 # define HAVE_WINDOW_SYSTEM 1
187 # define POLL_FOR_INPUT 1
188 # endif
189 #endif
190
191
192
193 #ifdef emacs
194
195 #ifdef MINGW_W64
196
197
198 #include <sys/types.h>
199 #include <time.h>
200
201
202
203 extern struct tm * sys_localtime (const time_t *);
204
205
206
207 #undef HAVE__SETJMP
208
209
210
211
212
213
214 #undef HAVE_GAI_STRERROR
215 #endif
216
217
218 #include <setjmp.h>
219 typedef jmp_buf sigjmp_buf;
220 #ifdef MINGW_W64
221
222
223
224
225 #define sigsetjmp(j,m) __builtin_setjmp(j)
226 #else
227 #define sigsetjmp(j,m) setjmp(j)
228 #endif
229 extern void w32_reset_stack_overflow_guard (void);
230
231 #ifdef _MSC_VER
232 #include <sys/timeb.h>
233 #include <sys/stat.h>
234 #include <signal.h>
235
236
237 #define fstat(a, b) sys_fstat(a, b)
238 #define stat(a, b) sys_stat(a, b)
239 #define utime sys_utime
240 #endif
241
242
243 #undef chdir
244 #define chdir sys_chdir
245 #undef chmod
246 #define chmod sys_chmod
247 #undef close
248 #define close sys_close
249 #undef creat
250 #define creat sys_creat
251 #define ctime sys_ctime
252 #undef dup
253 #define dup sys_dup
254 #undef dup2
255 #define dup2 sys_dup2
256 #define fopen sys_fopen
257 #define link sys_link
258 #define localtime sys_localtime
259 #undef read
260 #define read sys_read
261 #define rename sys_rename
262 #define rmdir sys_rmdir
263 #define select sys_select
264 #define pselect sys_select
265 #define sleep sys_sleep
266 #define strerror sys_strerror
267 #undef unlink
268 #define unlink sys_unlink
269 #undef opendir
270 #define opendir sys_opendir
271 #undef closedir
272 #define closedir sys_closedir
273 #undef readdir
274 #define readdir sys_readdir
275 #undef seekdir
276 #define seekdir sys_seekdir
277
278
279
280 extern int sys_unlink (const char *);
281 #undef write
282 #define write sys_write
283 #undef umask
284 #define umask sys_umask
285 extern int sys_umask (int);
286 #define clock sys_clock
287
288
289 #define spawnve sys_spawnve
290 #define kill sys_kill
291 #define signal sys_signal
292
293
294 #define emacs_raise(sig) emacs_abort()
295
296
297 #define tputs sys_tputs
298 #define tgetstr sys_tgetstr
299
300
301 #define chcheckmagic sys_chcheckmagic
302 #define cmcostinit sys_cmcostinit
303 #define cmgoto sys_cmgoto
304 #define cmputc sys_cmputc
305 #define Wcm_clear sys_Wcm_clear
306
307 #endif
308
309
310 #undef open
311 #define open sys_open
312
313
314 #define execlp _execlp
315 #define execvp _execvp
316 #include <stdint.h>
317 extern intptr_t _execvp (const char *, char **);
318 #define tcdrain _commit
319 #define fdopen _fdopen
320 #define fsync _commit
321 #define ftruncate _chsize
322 #define getpid _getpid
323 #ifdef _MSC_VER
324 typedef int pid_t;
325 #define snprintf _snprintf
326 #define strtoll _strtoi64
327 #define copysign _copysign
328 #endif
329 #define isatty _isatty
330 #define _longjmp longjmp
331
332 #ifndef lseek
333 #define lseek _lseek
334 #endif
335 #define popen _popen
336 #define pclose _pclose
337 #define strdup _strdup
338 #define strupr _strupr
339 #define strnicmp _strnicmp
340 #define stricmp _stricmp
341 #define tzset _tzset
342
343
344 int _getpid (void);
345
346
347
348
349
350
351 #include <time.h>
352 #define tzname _tzname
353
354
355 extern struct tm *gmtime_r (time_t const * restrict, struct tm * restrict);
356 extern struct tm *localtime_r (time_t const * restrict, struct tm * restrict);
357
358 #ifdef _MSC_VER
359
360
361
362
363 #ifndef __STDC__
364 #define __STDC__ 1
365 #define MUST_UNDEF__STDC__
366 #endif
367 #include <direct.h>
368 #include <io.h>
369 #include <stdio.h>
370 #ifdef MUST_UNDEF__STDC__
371 #undef __STDC__
372 #undef MUST_UNDEF__STDC__
373 #endif
374 #else
375 #include <direct.h>
376 #include <io.h>
377 #include <stdio.h>
378 #endif
379 #ifndef fileno
380 #define fileno _fileno
381 #endif
382
383
384 #define SIGHUP 1
385 #define SIGQUIT 3
386 #define SIGTRAP 5
387 #define SIGKILL 9
388 #define SIGPIPE 13
389 #define SIGALRM 14
390 #define SIGCHLD 18
391 #define SIGPROF 19
392
393 #ifndef NSIG
394 #define NSIG 23
395 #endif
396
397 #ifndef ENOTSUP
398 #define ENOTSUP ENOSYS
399 #endif
400
401
402 #ifndef EOPNOTSUPP
403 #define EOPNOTSUPP 130
404 #endif
405
406 #ifdef _MSC_VER
407 typedef int sigset_t;
408 typedef int ssize_t;
409 #endif
410
411 #ifdef MINGW_W64
412 #ifndef _POSIX
413 typedef _sigset_t sigset_t;
414 #endif
415 #endif
416
417 typedef void (_CALLBACK_ *signal_handler) (int);
418 extern signal_handler sys_signal (int, signal_handler);
419
420 struct sigaction {
421 int sa_flags;
422 void (_CALLBACK_ *sa_handler)(int);
423 sigset_t sa_mask;
424 };
425 #define SA_RESTART 0
426 #define SIG_BLOCK 1
427 #define SIG_SETMASK 2
428 #define SIG_UNBLOCK 3
429
430 extern int sigemptyset (sigset_t *);
431 extern int sigaddset (sigset_t *, int);
432 extern int sigfillset (sigset_t *);
433 extern int sigprocmask (int, const sigset_t *, sigset_t *);
434
435
436 #ifdef pthread_sigmask
437 #undef pthread_sigmask
438 #endif
439 extern int pthread_sigmask (int, const sigset_t *, sigset_t *);
440 extern int sigismember (const sigset_t *, int);
441 extern int setpgrp (int, int);
442 extern int sigaction (int, const struct sigaction *, struct sigaction *);
443 extern int alarm (int);
444
445 extern int sys_kill (pid_t, int);
446
447 extern void explicit_bzero (void *, size_t);
448
449
450 #define getdisk() (_getdrive () - 1)
451 #ifdef emacs
452 #define getdefdir(_drv, _buf) ((_buf[0] = (_drv + 'A' - 1), _buf[1] = ':', _buf[2] = '/', _buf[3] = 0), 1)
453 #else
454 #define getdefdir(_drv, _buf) _getdcwd (_drv, _buf, MAXPATHLEN)
455 #endif
456
457 #ifndef EMACS_CONFIGURATION
458 extern char *get_emacs_configuration (void);
459 extern char *get_emacs_configuration_options (void);
460 #define EMACS_CONFIGURATION get_emacs_configuration ()
461 #define EMACS_CONFIG_OPTIONS get_emacs_configuration_options ()
462 #endif
463
464
465
466
467 #define _WINSOCKAPI_ 1
468 #if !(defined __MINGW32_VERSION && __MINGW32_VERSION >= 5000002L)
469
470
471
472 # define _WINSOCK_H
473 #endif
474
475
476 #include <stdlib.h>
477 #include <sys/stat.h>
478 #ifdef _MSC_VER
479 #define alloca _alloca
480 #else
481 #include <malloc.h>
482 #endif
483
484
485
486 #undef mkdir
487 #define mkdir(d,f) sys_mkdir(d,f)
488 int sys_mkdir (const char *, mode_t);
489
490 #ifdef emacs
491
492 typedef void * (* malloc_fn)(size_t);
493 typedef void * (* realloc_fn)(void *, size_t);
494 typedef void (* free_fn)(void *);
495
496 extern void *malloc_before_dump(size_t);
497 extern void *realloc_before_dump(void *, size_t);
498 extern void free_before_dump(void *);
499 extern void *malloc_after_dump(size_t);
500 extern void *realloc_after_dump(void *, size_t);
501 extern void free_after_dump(void *);
502
503 extern void *malloc_after_dump_9x(size_t);
504 extern void *realloc_after_dump_9x(void *, size_t);
505 extern void free_after_dump_9x(void *);
506
507 extern void *sys_calloc(size_t, size_t);
508
509 extern malloc_fn the_malloc_fn;
510 extern realloc_fn the_realloc_fn;
511 extern free_fn the_free_fn;
512
513 #define malloc(size) (*the_malloc_fn)(size)
514 #define free(ptr) (*the_free_fn)(ptr)
515 #define realloc(ptr, size) (*the_realloc_fn)(ptr, size)
516 #define calloc(num, size) sys_calloc(num, size)
517
518 #endif
519
520
521 #ifndef NULL
522 #ifdef __cplusplus
523 #define NULL 0
524 #else
525 #define NULL ((void *)0)
526 #endif
527 #endif
528
529
530 #ifndef sys_nerr
531 #define sys_nerr _sys_nerr
532 #endif
533
534
535 #ifdef putenv
536 # undef putenv
537 #endif
538 #define putenv sys_putenv
539 extern int sys_putenv (char *);
540
541 extern int getloadavg (double *, int);
542 extern int getpagesize (void);
543
544 extern void * memrchr (void const *, int, size_t);
545
546
547 extern int mkostemp (char *, int);
548
549 #if defined (__MINGW32__)
550
551
552 # ifndef HAVE_LONG_LONG_INT
553 # define HAVE_LONG_LONG_INT 1
554 # endif
555
556
557 # ifndef HAVE_UNSIGNED_LONG_LONG_INT
558 # define HAVE_UNSIGNED_LONG_LONG_INT 1
559 # endif
560
561 #endif
562
563 #ifdef _MSC_VER
564 # if defined(_WIN64)
565 typedef __int64 EMACS_INT;
566 typedef unsigned __int64 EMACS_UINT;
567 # define EMACS_INT_MAX LLONG_MAX
568 # define PRIuMAX "llu"
569 # define pI "ll"
570
571 # define _INTPTR 2
572 # elif defined(_WIN32)
573
574
575
576 # ifdef WIDE_EMACS_INT
577
578
579 typedef __int64 EMACS_INT;
580 typedef unsigned __int64 EMACS_UINT;
581 # define EMACS_INT_MAX LLONG_MAX
582 # define PRIuMAX "llu"
583 # define pI "I64"
584 # else
585 typedef int EMACS_INT;
586 typedef unsigned int EMACS_UINT;
587 # define EMACS_INT_MAX LONG_MAX
588 # define PRIuMAX "lu"
589 # define pI "l"
590 # endif
591 # endif
592 #endif
593
594
595 #define SYSTEM_PURESIZE_EXTRA 50000
596
597 #define DATA_START get_data_start ()
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616 #ifdef _MSC_VER
617 #pragma data_seg("EMDATA")
618 #pragma bss_seg("EMBSS")
619 #endif
620
621
622
623
624 #ifdef _MSC_VER
625 #if _MSC_VER >= 800 && !defined(__cplusplus)
626
627
628
629 #pragma warning(disable:4116)
630
631
632
633 #pragma warning(disable:4244)
634
635
636
637 #pragma warning(disable:4308)
638 #endif
639 #endif
640
641
642 #define W32_DAEMON_EVENT "EmacsServerEvent"
643
644