Import Upstream version 20180207
[hcoop/debian/mlton.git] / runtime / platform / mingw.h
1 /* Many of the functions used in mingw.c are Win2000+ */
2 #ifndef _WIN32_WINNT
3 #define _WIN32_WINNT 0x0500
4 #endif
5
6 #include <inttypes.h>
7 #include <stdint.h>
8
9 #include <unistd.h>
10 #include <winsock2.h>
11 #include <windows.h>
12
13 #include <dirent.h>
14 #include <fcntl.h>
15 #include <sys/stat.h>
16 #include <sys/stat.h>
17 #include <sys/time.h>
18 #include <sys/timeb.h>
19 #include <sys/types.h>
20 #include <utime.h>
21 #include <time.h>
22
23 #include <io.h>
24 #include <lm.h>
25 #include <process.h>
26 //#include <psapi.h>
27 #include <ws2tcpip.h>
28 #include <psapi.h>
29
30 #undef max
31
32 // As of 20080807, MinGW has a broken fesetround. Use the runtime's.
33 #define HAS_FEROUND FALSE
34 #define HAS_MSG_DONTWAIT FALSE
35 #define HAS_REMAP TRUE
36 #define HAS_SIGALTSTACK FALSE
37 #define NEEDS_SIGALTSTACK_EXEC FALSE
38 #define HAS_SPAWN TRUE
39 #define HAS_TIME_PROFILING TRUE
40
41 #define MLton_Platform_OS_host "mingw"
42
43 /** MinGW is a moving target. MLton seems to break every release.
44 * Often new releases add new emulation for POSIX functions.
45 * We need to provide wrappers for some POSIX functions, but
46 * these wrappers end up conflicting with MinGW if they're added.
47 * Therefore, all wrapper stuff we add will be #define'd to use
48 * a MLton_prefix, thus avoiding collision with MinGW versions,
49 * current, old, or future. Macros themselves can conflict, so
50 * we need to #undef any old value, and in the case of constants,
51 * wrap the define in an ifndef. It's ugly and verbose, but safe.
52 */
53
54 #define MLTON_WRAPPER
55
56 typedef unsigned short MLton_gid_t;
57 typedef unsigned short MLton_uid_t;
58 typedef long MLton_suseconds_t; // type of timeval.tv_usec in sys/time.h
59 typedef short MLton_nlink_t; // type of st_nlink in sys/stat.h
60 typedef unsigned int MLton_nfds_t; // we have a fake poll() with this many fds
61
62 #undef gid_t
63 #undef uid_t
64 #undef suseconds_t
65 #undef nlink_t
66 #undef nfds_t
67
68 #define gid_t MLton_gid_t
69 #define uid_t MLton_uid_t
70 #define suseconds_t MLton_suseconds_t
71 #define nlink_t MLton_nlink_t
72 #define nfds_t MLton_nfds_t
73
74 MLTON_WRAPPER int MLton_getpagesize (void);
75 MLTON_WRAPPER int MLton_mkstemp (char *template);
76
77 #undef getpagesize
78 #undef mkstemp
79
80 #define getpagesize MLton_getpagesize
81 #define mkstemp MLton_mkstemp
82
83 #ifndef POLLIN
84 #define POLLIN 1
85 #endif
86
87 #ifndef POLLPRI
88 #define POLLPRI 2
89 #endif
90
91 #ifndef POLLOUT
92 #define POLLOUT 4
93 #endif
94
95 #ifndef _PC_CHOWN_RESTRICTED
96 #define _PC_CHOWN_RESTRICTED 6
97 #endif
98
99 #ifndef _PC_LINK_MAX
100 #define _PC_LINK_MAX 0
101 #endif
102
103 #ifndef _PC_MAX_CANON
104 #define _PC_MAX_CANON 1
105 #endif
106
107 #ifndef _PC_MAX_INPUT
108 #define _PC_MAX_INPUT 2
109 #endif
110
111 #ifndef _PC_NAME_MAX
112 #define _PC_NAME_MAX 3
113 #endif
114
115 #ifndef _PC_NO_TRUNC
116 #define _PC_NO_TRUNC 7
117 #endif
118
119 #ifndef _PC_PATH_MAX
120 #define _PC_PATH_MAX 4
121 #endif
122
123 #ifndef _PC_PIPE_BUF
124 #define _PC_PIPE_BUF 5
125 #endif
126
127 #ifndef _PC_VDISABLE
128 #define _PC_VDISABLE 8
129 #endif
130
131 #ifndef F_DUPFD
132 #define F_DUPFD 0
133 #endif
134
135 #ifndef F_GETFD
136 #define F_GETFD 1
137 #endif
138
139 #ifndef F_SETFD
140 #define F_SETFD 2
141 #endif
142
143 #ifndef F_GETFL
144 #define F_GETFL 3
145 #endif
146
147 #ifndef F_SETFL
148 #define F_SETFL 4
149 #endif
150
151 #ifndef F_GETOWN
152 #define F_GETOWN 5
153 #endif
154
155 #ifndef F_SETOWN
156 #define F_SETOWN 6
157 #endif
158
159 #ifndef F_GETLK
160 #define F_GETLK 7
161 #endif
162
163 #ifndef F_SETLK
164 #define F_SETLK 8
165 #endif
166
167 #ifndef F_RDLCK
168 #define F_RDLCK 1
169 #endif
170
171 #ifndef F_WRLCK
172 #define F_WRLCK 2
173 #endif
174
175 #ifndef F_UNLCK
176 #define F_UNLCK 3
177 #endif
178
179 #ifndef F_SETLKW
180 #define F_SETLKW 9
181 #endif
182
183 #ifndef FD_CLOEXEC
184 #define FD_CLOEXEC 1
185 #endif
186
187 #ifndef SHUT_RD
188 #define SHUT_RD SD_RECEIVE
189 #endif
190
191 #ifndef SHUT_WR
192 #define SHUT_WR SD_SEND
193 #endif
194
195 #ifndef SHUT_RDWR
196 #define SHUT_RDWR SD_BOTH
197 #endif
198
199 /* ------------------------------------------------- */
200 /* Date */
201 /* ------------------------------------------------- */
202
203 /* MinGW provides gettimeofday in -lmingwex, which we don't link.
204 * In order to avoid a name conflict, we use a different name.
205 */
206 struct MLton_timezone {
207 int unused;
208 };
209 #undef timezone
210 #define timezone MLton_timezone
211
212 MLTON_WRAPPER int MLton_gettimeofday (struct timeval *tv, struct timezone *tz);
213 #undef gettimeofday
214 #define gettimeofday MLton_gettimeofday
215
216 /* ------------------------------------------------- */
217 /* MLton.Itimer */
218 /* ------------------------------------------------- */
219
220 #ifndef ITIMER_REAL
221 #define ITIMER_REAL 0 /*generates sigalrm */
222 #endif
223
224 #ifndef ITIMER_VIRTUAL
225 #define ITIMER_VIRTUAL 1 /*generates sigvtalrm */
226 #endif
227
228 #ifndef ITIMER_VIRT
229 #define ITIMER_VIRT 1 /*generates sigvtalrm */
230 #endif
231
232 #ifndef ITIMER_PROF
233 #define ITIMER_PROF 2 /*generates sigprof */
234 #endif
235
236 struct MLton_itimerval {
237 struct timeval it_interval;
238 struct timeval it_value;
239 };
240 #undef itimerval
241 #define itimerval MLton_itimerval
242
243 MLTON_WRAPPER int MLton_setitimer (int which,
244 const struct itimerval *value,
245 struct itimerval *ovalue);
246 #undef setitimer
247 #define setitimer MLton_setitimer
248
249 /* ------------------------------------------------- */
250 /* MLton.Rlimit */
251 /* ------------------------------------------------- */
252
253 #ifndef RLIMIT_CPU
254 #define RLIMIT_CPU 0 /* CPU time in seconds */
255 #endif
256
257 #ifndef RLIMIT_FSIZE
258 #define RLIMIT_FSIZE 1 /* Maximum filesize */
259 #endif
260
261 #ifndef RLIMIT_DATA
262 #define RLIMIT_DATA 2 /* max data size */
263 #endif
264
265 #ifndef RLIMIT_STACK
266 #define RLIMIT_STACK 3 /* max stack size */
267 #endif
268
269 #ifndef RLIMIT_CORE
270 #define RLIMIT_CORE 4 /* max core file size */
271 #endif
272
273 #ifndef RLIMIT_NOFILE
274 #define RLIMIT_NOFILE 5 /* max number of open files */
275 #endif
276
277 #ifndef RLIMIT_OFILE
278 #define RLIMIT_OFILE RLIMIT_NOFILE /* BSD name */
279 #endif
280
281 #ifndef RLIMIT_AS
282 #define RLIMIT_AS 6 /* address space (virt. memory) limit */
283 #endif
284
285 #define RLIMIT_NLIMITS 7 /* upper bound of RLIMIT_* defines */
286 #define RLIM_NLIMITS RLIMIT_NLIMITS
287
288 #ifndef RLIM_INFINITY
289 #define RLIM_INFINITY (0xffffffffUL)
290 #endif
291
292 #ifndef RLIM_SAVED_MAX
293 #define RLIM_SAVED_MAX RLIM_INFINITY
294 #endif
295
296 #ifndef RLIM_SAVED_CUR
297 #define RLIM_SAVED_CUR RLIM_INFINITY
298 #endif
299
300 typedef unsigned long MLton_rlim_t;
301 #undef rlim_t
302 #define rlim_t MLton_rlim_t
303
304 struct MLton_rlimit {
305 rlim_t rlim_cur;
306 rlim_t rlim_max;
307 };
308 #undef rlimit
309 #define rlimit MLton_rlimit
310
311 MLTON_WRAPPER int MLton_getrlimit (int resource, struct rlimit *rlim);
312 MLTON_WRAPPER int MLton_setrlimit (int resource, const struct rlimit *rlim);
313 #undef getrlimit
314 #undef setrlimit
315 #define getrlimit MLton_getrlimit
316 #define setrlimit MLton_setrlimit
317
318 /* ------------------------------------------------- */
319 /* MLton.Rusage */
320 /* ------------------------------------------------- */
321
322 #ifndef RUSAGE_SELF
323 #define RUSAGE_SELF 0 /* calling process */
324 #endif
325
326 #ifndef RUSAGE_CHILDREN
327 #define RUSAGE_CHILDREN -1 /* terminated child processes */
328 #endif
329
330 struct MLton_rusage {
331 struct timeval ru_utime;
332 struct timeval ru_stime;
333 };
334 #undef rusage
335 #define rusage MLton_rusage
336
337 MLTON_WRAPPER int MLton_getrusage (int who, struct rusage *usage);
338 #undef getrusage
339 #define getrusage MLton_getrusage
340
341 /* ------------------------------------------------- */
342 /* OS.IO */
343 /* ------------------------------------------------- */
344
345 struct MLton_pollfd {
346 short events;
347 int fd;
348 short revents;
349 };
350 #undef pollfd
351 #define pollfd MLton_pollfd
352
353 MLTON_WRAPPER int MLton_poll (struct pollfd *ufds, nfds_t nfds, int timeout);
354 #undef poll
355 #define poll MLton_poll
356
357 /* ------------------------------------------------- */
358 /* Posix.Error */
359 /* ------------------------------------------------- */
360
361 /* We cannot yet replace strerror at the time util.c is built */
362 #ifndef MLTON_UTIL
363 MLTON_WRAPPER char *MLton_strerror(int code);
364 #undef strerror
365 #define strerror MLton_strerror
366 #endif
367
368 /* If MinGW doesn't (currently) define an error status we need, but winsock
369 * does, then default to using the winsock status. They will not conflict.
370 */
371
372 #ifndef EINTR
373 #define EINTR WSAEINTR
374 #endif
375
376 #ifndef EBADF
377 #define EBADF WSAEBADF
378 #endif
379
380 #ifndef EACCES
381 #define EACCES WSAEACCES
382 #endif
383
384 #ifndef EFAULT
385 #define EFAULT WSAEFAULT
386 #endif
387
388 #ifndef EINVAL
389 #define EINVAL WSAEINVAL
390 #endif
391
392 #ifndef EMFILE
393 #define EMFILE WSAEMFILE
394 #endif
395
396 #ifndef EAGAIN
397 #define EAGAIN WSAEWOULDBLOCK
398 #endif
399
400 #ifndef EWOULDBLOCK
401 #define EWOULDBLOCK EAGAIN
402 #endif
403
404 #ifndef EINPROGRESS
405 #define EINPROGRESS WSAEINPROGRESS
406 #endif
407
408 #ifndef EALREADY
409 #define EALREADY WSAEALREADY
410 #endif
411
412 #ifndef ENOTSOCK
413 #define ENOTSOCK WSAENOTSOCK
414 #endif
415
416 #ifndef EDESTADDRREQ
417 #define EDESTADDRREQ WSAEDESTADDRREQ
418 #endif
419
420 #ifndef EMSGSIZE
421 #define EMSGSIZE WSAEMSGSIZE
422 #endif
423
424 #ifndef EPROTOTYPE
425 #define EPROTOTYPE WSAEPROTOTYPE
426 #endif
427
428 #ifndef ENOPROTOOPT
429 #define ENOPROTOOPT WSAENOPROTOOPT
430 #endif
431
432 #ifndef EPROTONOSUPPORT
433 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
434 #endif
435
436 #ifndef ESOCKTNOSUPPORT
437 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
438 #endif
439
440 #ifndef EOPNOTSUPP
441 #define EOPNOTSUPP WSAEOPNOTSUPP
442 #endif
443
444 #ifndef EPFNOSUPPORT
445 #define EPFNOSUPPORT WSAEPFNOSUPPORT
446 #endif
447
448 #ifndef EAFNOSUPPORT
449 #define EAFNOSUPPORT WSAEAFNOSUPPORT
450 #endif
451
452 #ifndef EADDRINUSE
453 #define EADDRINUSE WSAEADDRINUSE
454 #endif
455
456 #ifndef EADDRNOTAVAIL
457 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
458 #endif
459
460 #ifndef ENETDOWN
461 #define ENETDOWN WSAENETDOWN
462 #endif
463
464 #ifndef ENETUNREACH
465 #define ENETUNREACH WSAENETUNREACH
466 #endif
467
468 #ifndef ENETRESET
469 #define ENETRESET WSAENETRESET
470 #endif
471
472 #ifndef ECONNABORTED
473 #define ECONNABORTED WSAECONNABORTED
474 #endif
475
476 #ifndef ECONNRESET
477 #define ECONNRESET WSAECONNRESET
478 #endif
479
480 #ifndef ENOBUFS
481 #define ENOBUFS WSAENOBUFS
482 #endif
483
484 #ifndef EISCONN
485 #define EISCONN WSAEISCONN
486 #endif
487
488 #ifndef ENOTCONN
489 #define ENOTCONN WSAENOTCONN
490 #endif
491
492 #ifndef ESHUTDOWN
493 #define ESHUTDOWN WSAESHUTDOWN
494 #endif
495
496 #ifndef ETIMEDOUT
497 #define ETIMEDOUT WSAETIMEDOUT
498 #endif
499
500 #ifndef ECONNREFUSED
501 #define ECONNREFUSED WSAECONNREFUSED
502 #endif
503
504 #ifndef ELOOP
505 #define ELOOP WSAELOOP
506 #endif
507
508 #ifndef ENAMETOOLONG
509 #define ENAMETOOLONG WSAENAMETOOLONG
510 #endif
511
512 #ifndef EHOSTDOWN
513 #define EHOSTDOWN WSAEHOSTDOWN
514 #endif
515
516 #ifndef EHOSTUNREACH
517 #define EHOSTUNREACH WSAEHOSTUNREACH
518 #endif
519
520 #ifndef ENOTEMPTY
521 #define ENOTEMPTY WSAENOTEMPTY
522 #endif
523
524 #ifndef EDQUOT
525 #define EDQUOT WSAEDQUOT
526 #endif
527
528 #ifndef ESTALE
529 #define ESTALE WSAESTALE
530 #endif
531
532 #ifndef ERMOTE
533 #define EREMOTE WSAEREMOTE
534 #endif
535
536 /* Questionable fall backs: */
537
538 #ifndef EUSERS
539 #define EUSERS WSAEUSERS
540 #endif
541
542 #ifndef ECANCELED
543 #define ECANCELED WSAECANCELLED
544 #endif
545
546 #ifndef EBADMSG
547 #define EBADMSG 77
548 #endif
549
550 /* ------------------------------------------------- */
551 /* Posix.FileSys */
552 /* ------------------------------------------------- */
553
554 #ifndef S_IRGRP
555 #define S_IRGRP 0000040
556 #endif
557
558 #ifndef S_IROTH
559 #define S_IROTH 0000004
560 #endif
561
562 #ifndef S_IRWXG
563 #define S_IRWXG 0000070
564 #endif
565
566 #ifndef S_IRWXO
567 #define S_IRWXO 0000007
568 #endif
569
570 #ifndef S_ISGID
571 #define S_ISGID 0002000
572 #endif
573
574 #ifndef S_ISUID
575 #define S_ISUID 0004000
576 #endif
577
578 #ifndef S_IWGRP
579 #define S_IWGRP 0000020
580 #endif
581
582 #ifndef S_IWOTH
583 #define S_IWOTH 0000002
584 #endif
585
586 #ifndef S_IXGRP
587 #define S_IXGRP 0000010
588 #endif
589
590 #ifndef S_IXOTH
591 #define S_IXOTH 0000001
592 #endif
593
594 // Do not exist in a windows filesystem
595 #ifndef S_IFLNK
596 #define S_IFLNK 0
597 #endif
598
599 #ifndef S_IFSOCK
600 #define S_IFSOCK 0
601 #endif
602
603 #ifndef S_ISVTX
604 #define S_ISVTX 0
605 #endif
606
607 #ifndef O_NOCTTY
608 #define O_NOCTTY 0x8000
609 #endif
610
611 #ifndef O_NONBLOCK
612 #define O_NONBLOCK 0x4000
613 #endif
614
615 // Synchronized writes? Safety of any kind? ... and windows?! hell no!
616 #ifndef O_SYNC
617 #define O_SYNC 0
618 #endif
619
620 // Use m to silence unused warnings
621 #undef S_ISLNK
622 #undef S_ISSOCK
623 #define S_ISLNK(m) (m?FALSE:FALSE)
624 #define S_ISSOCK(m) (m?FALSE:FALSE)
625
626 #ifndef O_ACCMODE
627 #define O_ACCMODE O_RDONLY|O_WRONLY|O_RDWR
628 #endif
629
630 MLTON_WRAPPER int MLton_chown (const char *path, uid_t owner, gid_t group);
631 MLTON_WRAPPER int MLton_fchmod (int filedes, mode_t mode);
632 MLTON_WRAPPER int MLton_fchdir (int filedes);
633 MLTON_WRAPPER int MLton_fchown (int fd, uid_t owner, gid_t group);
634 MLTON_WRAPPER long MLton_fpathconf (int filedes, int name);
635 MLTON_WRAPPER int MLton_link (const char *oldpath, const char *newpath);
636 MLTON_WRAPPER int MLton_lstat (const char *file_name, struct stat *buf);
637 MLTON_WRAPPER int MLton_mkfifo (const char *pathname, mode_t mode);
638 MLTON_WRAPPER long MLton_pathconf (const char *path, int name);
639 MLTON_WRAPPER int MLton_readlink (const char *path, char *buf, size_t bufsiz);
640 MLTON_WRAPPER int MLton_symlink (const char *oldpath, const char *newpath);
641 MLTON_WRAPPER int MLton_truncate (const char *path, off_t len);
642
643 #undef chown
644 #undef fchmod
645 #undef fchdir
646 #undef fchown
647 #undef fpathconf
648 #undef link
649 #undef lstat
650 #undef mkfifo
651 #undef pathconf
652 #undef readlink
653 #undef symlink
654 #undef truncate
655
656 #define chown MLton_chown
657 #define fchmod MLton_fchmod
658 #define fchdir MLton_fchdir
659 #define fchown MLton_fchown
660 #define fpathconf MLton_fpathconf
661 #define link MLton_link
662 #define lstat MLton_lstat
663 #define mkfifo MLton_mkfifo
664 #define pathconf MLton_pathconf
665 #define readlink MLton_readlink
666 #define symlink MLton_symlink
667 #define truncate MLton_truncate
668
669 #undef mkdir
670 #define mkdir(f, m) mkdir(f); chmod(f, m)
671
672 /* ------------------------------------------------- */
673 /* Posix.IO */
674 /* ------------------------------------------------- */
675
676 struct MLton_flock {
677 off_t l_len;
678 pid_t l_pid;
679 off_t l_start;
680 short l_type;
681 short l_whence;
682 };
683 #undef flock
684 #define flock MLton_flock
685
686 MLTON_WRAPPER int MLton_fcntl (int fd, int cmd, ...);
687 MLTON_WRAPPER int MLton_fsync (int fd);
688 MLTON_WRAPPER int MLton_pipe (int filedes[2]);
689
690 #undef fcntl
691 #undef fsync
692 #undef pipe
693
694 #define fcntl MLton_fcntl
695 #define fsync MLton_fsync
696 #define pipe MLton_pipe
697
698 /* ------------------------------------------------- */
699 /* Posix.ProcEnv */
700 /* ------------------------------------------------- */
701
702 #ifndef _SC_ARG_MAX
703 #define _SC_ARG_MAX 0
704 #endif
705
706 #ifndef _SC_CHILD_MAX
707 #define _SC_CHILD_MAX 1
708 #endif
709
710 #ifndef _SC_CLK_TCK
711 #define _SC_CLK_TCK 2
712 #endif
713
714 #ifndef _SC_JOB_CONTROL
715 #define _SC_JOB_CONTROL 5
716 #endif
717
718 #ifndef _SC_NGROUPS_MAX
719 #define _SC_NGROUPS_MAX 3
720 #endif
721
722 #ifndef _SC_OPEN_MAX
723 #define _SC_OPEN_MAX 4
724 #endif
725
726 #ifndef _SC_SAVED_IDS
727 #define _SC_SAVED_IDS 6
728 #endif
729
730 #ifndef _SC_VERSION
731 #define _SC_VERSION 7
732 #endif
733
734 struct MLton_tms {
735 int tms_utime;
736 int tms_stime;
737 int tms_cutime;
738 int tms_cstime;
739 };
740
741 struct MLton_utsname {
742 char machine[20];
743 char nodename[256];
744 char release[20];
745 char sysname[30];
746 char version[20];
747 };
748
749 #undef tms
750 #undef utsname
751
752 #define tms MLton_tms
753 #define utsname MLton_utsname
754
755 MLTON_WRAPPER char *MLton_getlogin (void);
756 MLTON_WRAPPER char *MLton_ctermid (char *s);
757 MLTON_WRAPPER gid_t MLton_getegid (void);
758 MLTON_WRAPPER uid_t MLton_geteuid (void);
759 MLTON_WRAPPER gid_t MLton_getgid (void);
760 MLTON_WRAPPER int MLton_getgroups (int size, gid_t list[]);
761 MLTON_WRAPPER pid_t MLton_getpgid(pid_t pid);
762 MLTON_WRAPPER pid_t MLton_getpgrp(void);
763 MLTON_WRAPPER pid_t MLton_getppid (void);
764 MLTON_WRAPPER uid_t MLton_getuid (void);
765 MLTON_WRAPPER int MLton_setenv (const char *name, const char *value, int overwrite);
766 MLTON_WRAPPER int MLton_setgid (gid_t gid);
767 MLTON_WRAPPER int MLton_setgroups (size_t size, const gid_t *list);
768 MLTON_WRAPPER int MLton_setpgid (pid_t pid, pid_t pgid);
769 MLTON_WRAPPER pid_t MLton_setsid (void);
770 MLTON_WRAPPER int MLton_setuid (uid_t uid);
771 MLTON_WRAPPER long MLton_sysconf (int name);
772 MLTON_WRAPPER clock_t MLton_times (struct tms *buf);
773 MLTON_WRAPPER char *MLton_ttyname (int desc);
774 MLTON_WRAPPER int MLton_uname (struct utsname *buf);
775
776 #undef getlogin
777 #undef ctermid
778 #undef getegid
779 #undef geteuid
780 #undef getgid
781 #undef getgroups
782 #undef getpgid
783 #undef getpgrp
784 #undef getppid
785 #undef getuid
786 #undef setenv
787 #undef setgid
788 #undef setgroups
789 #undef setpgid
790 #undef setsid
791 #undef setuid
792 #undef sysconf
793 #undef times
794 #undef ttyname
795 #undef uname
796
797 #define getlogin MLton_getlogin
798 #define ctermid MLton_ctermid
799 #define getegid MLton_getegid
800 #define geteuid MLton_geteuid
801 #define getgid MLton_getgid
802 #define getgroups MLton_getgroups
803 #define getpgid MLton_getpgid
804 #define getpgrp MLton_getpgrp
805 #define getppid MLton_getppid
806 #define getuid MLton_getuid
807 #define setenv MLton_setenv
808 #define setgid MLton_setgid
809 #define setgroups MLton_setgroups
810 #define setpgid MLton_setpgid
811 #define setsid MLton_setsid
812 #define setuid MLton_setuid
813 #define sysconf MLton_sysconf
814 #define times MLton_times
815 #define ttyname MLton_ttyname
816 #define uname MLton_uname
817
818
819 /* ------------------------------------------------- */
820 /* Posix.Process */
821 /* ------------------------------------------------- */
822
823 #define EXECVE(path, args, env) \
824 execve (path, (const char* const*)args, (const char* const*)env)
825 #define EXECVP(file, args) execvp (file, (const char* const*) args)
826 #define SPAWN_MODE _P_NOWAIT
827
828 /* Windows exit status comes from:
829 * 1. ExitProcess (used by return from main and exit)
830 * 2. TerminateProcess (used by a remote process to 'kill')
831 *
832 * Windows does NOT differentiate between these two cases.
833 * The waitpid API expects us to be able to tell the difference,
834 * so we will emulate this difference by setting high 31st bit
835 * whenever we 'kill' a process.
836 */
837
838 #ifndef WNOHANG
839 #define WNOHANG 1
840 #endif
841
842 #ifndef WUNTRACED
843 #define WUNTRACED 2
844 #endif
845
846 #define SIGNALLED_BIT 0x80000000UL
847
848 #ifndef WIFEXITED
849 #define WIFEXITED(w) (((w) & SIGNALLED_BIT) == 0)
850 #endif
851
852 #ifndef WIFSIGNALED
853 #define WIFSIGNALED(w) (((w) & SIGNALLED_BIT) != 0)
854 #endif
855
856 #ifndef WIFSTOPPED
857 #define WIFSTOPPED(w) 0
858 #endif
859
860 #ifndef WEXITSTATUS
861 #define WEXITSTATUS(w) ((w) & 0xff)
862 #endif
863
864 #ifndef WTERMSIG
865 #define WTERMSIG(w) ((w) & 0xff)
866 #endif
867
868 #ifndef WSTOPSIG
869 #define WSTOPSIG WEXITSTATUS
870 #endif
871
872 /* Sometimes defined by mingw */
873 #if !defined(TIMESPEC_DEFINED) && !defined(_TIMESPEC_DEFINED)
874 struct timespec {
875 time_t tv_sec;
876 long tv_nsec;
877 };
878 #endif
879
880 MLTON_WRAPPER int MLton_alarm(int);
881 MLTON_WRAPPER int MLton_fork(void); /* mingw demands this return int */
882 MLTON_WRAPPER int MLton_kill (pid_t pid, int sig);
883 MLTON_WRAPPER int MLton_pause (void);
884 MLTON_WRAPPER int MLton_nanosleep (const struct timespec *req, struct timespec *rem);
885 MLTON_WRAPPER unsigned int MLton_sleep (unsigned int seconds);
886 MLTON_WRAPPER pid_t MLton_wait (int *status);
887 MLTON_WRAPPER pid_t MLton_waitpid (pid_t pid, int *status, int options);
888
889 #undef alarm
890 #undef fork
891 #undef kill
892 #undef pause
893 #undef nanosleep
894 #undef sleep
895 #undef wait
896 #undef waitpid
897
898 #define alarm MLton_alarm
899 #define fork MLton_fork
900 #define kill MLton_kill
901 #define pause MLton_pause
902 #define nanosleep MLton_nanosleep
903 #define sleep MLton_sleep
904 #define wait MLton_wait
905 #define waitpid MLton_waitpid
906
907 /* ------------------------------------------------- */
908 /* Posix.Signal */
909 /* ------------------------------------------------- */
910
911 /* Sometimes mingw defines some of these. Some not. Some always. */
912
913 #ifndef SIG_BLOCK
914 #define SIG_BLOCK 1
915 #endif
916
917 #ifndef SIG_SETMASK
918 #define SIG_SETMASK 0
919 #endif
920
921 #ifndef SIG_UNBLOCK
922 #define SIG_UNBLOCK 2
923 #endif
924
925 #ifndef SIGHUP
926 #define SIGHUP 1
927 #endif
928
929 /* SIGINT = 2 */
930
931 #ifndef SIGQUIT
932 #define SIGQUIT 3
933 #endif
934
935 /* SIGILL = 4 */
936 /* SIGTRAP = 5 (unused) */
937 /* SIGIOT = 6 (unused) */
938 /* SIGABRT = 6 (unused) */
939 /* SIGEMT = 7 (unused) */
940 /* SIGFPE = 8 */
941
942 #ifndef SIGKILL
943 #define SIGKILL 9
944 #endif
945
946 #ifndef SIGBUS
947 #define SIGBUS 10
948 #endif
949
950 /* SIGSEGV = 11 */
951 /* SIGSYS = 12 (unused) */
952
953 #ifndef SIGPIPE
954 #define SIGPIPE 13
955 #endif
956
957 #ifndef SIGALRM
958 #define SIGALRM 14
959 #endif
960
961 /* SIGTERM = 15 */
962 /* SIGBREAK = 21 */
963 /* SIGABRT2 = 22 */
964
965 /* These signals are fake. They do not exist on windows. */
966
967 #ifndef SIGSTOP
968 #define SIGSTOP 16
969 #endif
970
971 #ifndef SIGTSTP
972 #define SIGTSTP 18
973 #endif
974
975 #ifndef SIGCHLD
976 #define SIGCHLD 23
977 #endif
978
979 #ifndef SIGTTIN
980 #define SIGTTIN 24
981 #endif
982
983 #ifndef SIGTTOU
984 #define SIGTTOU 25
985 #endif
986
987 #ifndef SIGCONT
988 #define SIGCONT 26
989 #endif
990
991 #ifndef SIGUSR1
992 #define SIGUSR1 27
993 #endif
994
995 #ifndef SIGUSR2
996 #define SIGUSR2 28
997 #endif
998
999 #ifndef SIGVTALRM
1000 #define SIGVTALRM 29 /* virtual time alarm */
1001 #endif
1002
1003 #ifndef SIGPROF
1004 #define SIGPROF 30 /* profiling time alarm */
1005 #endif
1006
1007 /* We have extended the number of signals ... */
1008 #ifdef NSIG
1009 #undef NSIG
1010 #endif
1011 #define NSIG 32
1012
1013 typedef __p_sig_fn_t MLton__sig_func_ptr;
1014 typedef int MLton_sigset_t;
1015
1016 #undef _sig_func_ptr
1017 #undef sigset_t
1018
1019 #define _sig_func_ptr MLton__sig_func_ptr
1020 #define sigset_t MLton_sigset_t
1021
1022 struct MLton_sigaction {
1023 int sa_flags;
1024 sigset_t sa_mask;
1025 _sig_func_ptr sa_handler;
1026 };
1027
1028 #undef sigaction
1029 #define sigaction MLton_sigaction
1030
1031 #ifndef SIGTOMASK
1032 #define SIGTOMASK(sn) (1 << ((sn)-1))
1033 #endif
1034
1035 MLTON_WRAPPER int MLton_sigaction (int signum,
1036 const struct sigaction *act,
1037 struct sigaction *oldact);
1038 MLTON_WRAPPER int MLton_sigaddset (sigset_t *set, int signum);
1039 MLTON_WRAPPER int MLton_sigdelset (sigset_t *set, int signum);
1040 MLTON_WRAPPER int MLton_sigemptyset (sigset_t *set);
1041 MLTON_WRAPPER int MLton_sigfillset (sigset_t *set);
1042 MLTON_WRAPPER int MLton_sigismember (const sigset_t *set, int signum);
1043 MLTON_WRAPPER int MLton_sigpending (sigset_t *set);
1044 MLTON_WRAPPER int MLton_sigprocmask (int how, const sigset_t *set, sigset_t *oldset);
1045 MLTON_WRAPPER int MLton_sigsuspend (const sigset_t *mask);
1046
1047 #undef sigaction
1048 #undef sigaddset
1049 #undef sigdelset
1050 #undef sigemptyset
1051 #undef sigfillset
1052 #undef sigismember
1053 #undef sigpending
1054 #undef sigprocmask
1055 #undef sigsuspend
1056
1057 #define sigaction MLton_sigaction
1058 #define sigaddset MLton_sigaddset
1059 #define sigdelset MLton_sigdelset
1060 #define sigemptyset MLton_sigemptyset
1061 #define sigfillset MLton_sigfillset
1062 #define sigismember MLton_sigismember
1063 #define sigpending MLton_sigpending
1064 #define sigprocmask MLton_sigprocmask
1065 #define sigsuspend MLton_sigsuspend
1066
1067 /* ------------------------------------------------- */
1068 /* Posix.SysDB.Passwd */
1069 /* ------------------------------------------------- */
1070
1071 struct MLton_group {
1072 gid_t gr_gid;
1073 char **gr_mem;
1074 char *gr_name;
1075 char *gr_passwd;
1076 };
1077
1078 struct MLton_passwd {
1079 char *pw_dir;
1080 gid_t pw_gid;
1081 char *pw_name;
1082 char *pw_shell;
1083 uid_t pw_uid;
1084 };
1085
1086 #undef group
1087 #undef passwd
1088 #define group MLton_group
1089 #define passwd MLton_passwd
1090
1091 MLTON_WRAPPER struct group *MLton_getgrgid (gid_t gid);
1092 MLTON_WRAPPER struct group *MLton_getgrnam (const char *name);
1093 MLTON_WRAPPER struct passwd *MLton_getpwnam (const char *name);
1094 MLTON_WRAPPER struct passwd *MLton_getpwuid (uid_t uid);
1095
1096 #undef getgrgid
1097 #undef getgrnam
1098 #undef getpwnam
1099 #undef getpwuid
1100
1101 #define getgrgid MLton_getgrgid
1102 #define getgrnam MLton_getgrnam
1103 #define getpwnam MLton_getpwnam
1104 #define getpwuid MLton_getpwuid
1105
1106 /* ------------------------------------------------- */
1107 /* Posix.TTY */
1108 /* ------------------------------------------------- */
1109
1110 #ifndef B0
1111 #define B0 0x00000
1112 #endif
1113
1114 #ifndef B50
1115 #define B50 0x00001
1116 #endif
1117
1118 #ifndef B75
1119 #define B75 0x00002
1120 #endif
1121
1122 #ifndef B110
1123 #define B110 0x00003
1124 #endif
1125
1126 #ifndef B134
1127 #define B134 0x00004
1128 #endif
1129
1130 #ifndef B150
1131 #define B150 0x00005
1132 #endif
1133
1134 #ifndef B200
1135 #define B200 0x00006
1136 #endif
1137
1138 #ifndef B300
1139 #define B300 0x00007
1140 #endif
1141
1142 #ifndef B600
1143 #define B600 0x00008
1144 #endif
1145
1146 #ifndef B1200
1147 #define B1200 0x00009
1148 #endif
1149
1150 #ifndef B1800
1151 #define B1800 0x0000a
1152 #endif
1153
1154 #ifndef B2400
1155 #define B2400 0x0000b
1156 #endif
1157
1158 #ifndef B4800
1159 #define B4800 0x0000c
1160 #endif
1161
1162 #ifndef B9600
1163 #define B9600 0x0000d
1164 #endif
1165
1166 #ifndef B19200
1167 #define B19200 0x0000e
1168 #endif
1169
1170 #ifndef B38400
1171 #define B38400 0x0000f
1172 #endif
1173
1174 #ifndef VEOL
1175 #define VEOL 2
1176 #endif
1177
1178 #ifndef VEOL2
1179 #define VEOL2 3
1180 #endif
1181
1182 #ifndef VEOF
1183 #define VEOF 4
1184 #endif
1185
1186 #ifndef VERASE
1187 #define VERASE 5
1188 #endif
1189
1190 #ifndef VINTER
1191 #define VINTR 6
1192 #endif
1193
1194 #ifndef VKILL
1195 #define VKILL 7
1196 #endif
1197
1198 #ifndef VLNEXT
1199 #define VLNEXT 8
1200 #endif
1201
1202 #ifndef VMIN
1203 #define VMIN 9
1204 #endif
1205
1206 #ifndef VQUIT
1207 #define VQUIT 10
1208 #endif
1209
1210 #ifndef VREPRINT
1211 #define VREPRINT 11
1212 #endif
1213
1214 #ifndef VSTART
1215 #define VSTART 12
1216 #endif
1217
1218 #ifndef VSTOP
1219 #define VSTOP 13
1220 #endif
1221
1222 #ifndef VSUSP
1223 #define VSUSP 14
1224 #endif
1225
1226 #ifndef VSWTC
1227 #define VSWTC 15
1228 #endif
1229
1230 #ifndef VTIME
1231 #define VTIME 16
1232 #endif
1233
1234 #ifndef VWERASE
1235 #define VWERASE 17
1236 #endif
1237
1238 #ifndef NCCS
1239 #define NCCS 18
1240 #endif
1241
1242 #ifndef IGNBRK
1243 #define IGNBRK 0x00001
1244 #endif
1245
1246 #ifndef BRKINT
1247 #define BRKINT 0x00002
1248 #endif
1249
1250 #ifndef IGNPAR
1251 #define IGNPAR 0x00004
1252 #endif
1253
1254 #ifndef IMAXBEL
1255 #define IMAXBEL 0x00008
1256 #endif
1257
1258 #ifndef INPCK
1259 #define INPCK 0x00010
1260 #endif
1261
1262 #ifndef ISTRIP
1263 #define ISTRIP 0x00020
1264 #endif
1265
1266 #ifndef INLCR
1267 #define INLCR 0x00040
1268 #endif
1269
1270 #ifndef IGNCR
1271 #define IGNCR 0x00080
1272 #endif
1273
1274 #ifndef ICRNL
1275 #define ICRNL 0x00100
1276 #endif
1277
1278 #ifndef IXON
1279 #define IXON 0x00400
1280 #endif
1281
1282 #ifndef IXOFF
1283 #define IXOFF 0x01000
1284 #endif
1285
1286 #ifndef IUCLC
1287 #define IUCLC 0x04000
1288 #endif
1289
1290 #ifndef IXANY
1291 #define IXANY 0x08000
1292 #endif
1293
1294 #ifndef PARMRK
1295 #define PARMRK 0x10000
1296 #endif
1297
1298 #ifndef OPOST
1299 #define OPOST 0x00001
1300 #endif
1301
1302 #ifndef CSIZE
1303 #define CSIZE 0x00030
1304 #endif
1305
1306 #ifndef CS5
1307 #define CS5 0x00000
1308 #endif
1309
1310 #ifndef CS6
1311 #define CS6 0x00010
1312 #endif
1313
1314 #ifndef CS7
1315 #define CS7 0x00020
1316 #endif
1317
1318 #ifndef CS8
1319 #define CS8 0x00030
1320 #endif
1321
1322 #ifndef CSTOPB
1323 #define CSTOPB 0x00040
1324 #endif
1325
1326 #ifndef CREAD
1327 #define CREAD 0x00080
1328 #endif
1329
1330 #ifndef PARENB
1331 #define PARENB 0x00100
1332 #endif
1333
1334 #ifndef PARODD
1335 #define PARODD 0x00200
1336 #endif
1337
1338 #ifndef HPUCL
1339 #define HUPCL 0x00400
1340 #endif
1341
1342 #ifndef CLOCAL
1343 #define CLOCAL 0x00800
1344 #endif
1345
1346 #ifndef CBAUDEX
1347 #define CBAUDEX 0x0100f
1348 #endif
1349
1350 #ifndef B57600
1351 #define B57600 0x01001
1352 #endif
1353
1354 #ifndef B115200
1355 #define B115200 0x01002
1356 #endif
1357
1358 #ifndef B128000
1359 #define B128000 0x01003
1360 #endif
1361
1362 #ifndef B230400
1363 #define B230400 0x01004
1364 #endif
1365
1366 #ifndef B256000
1367 #define B256000 0x01005
1368 #endif
1369
1370 #ifndef CRTSXOFF
1371 #define CRTSXOFF 0x04000
1372 #endif
1373
1374 #ifndef CRTSCTS
1375 #define CRTSCTS 0x08000
1376 #endif
1377
1378 #ifndef ISIG
1379 #define ISIG 0x0001
1380 #endif
1381
1382 #ifndef ICANON
1383 #define ICANON 0x0002
1384 #endif
1385
1386 #ifndef ECHO
1387 #define ECHO 0x0004
1388 #endif
1389
1390 #ifndef ECHOE
1391 #define ECHOE 0x0008
1392 #endif
1393
1394 #ifndef ECHOK
1395 #define ECHOK 0x0010
1396 #endif
1397
1398 #ifndef ECHONL
1399 #define ECHONL 0x0020
1400 #endif
1401
1402 #ifndef NOFLSH
1403 #define NOFLSH 0x0040
1404 #endif
1405
1406 #ifndef TOSTOP
1407 #define TOSTOP 0x0080
1408 #endif
1409
1410 #ifndef IEXTEN
1411 #define IEXTEN 0x0100
1412 #endif
1413
1414 #ifndef FLUSHO
1415 #define FLUSHO 0x0200
1416 #endif
1417
1418 #ifndef ECHOKE
1419 #define ECHOKE 0x0400
1420 #endif
1421
1422 #ifndef ECHOCTL
1423 #define ECHOCTL 0x0800
1424 #endif
1425
1426 #ifndef TCOOFF
1427 #define TCOOFF 0
1428 #endif
1429
1430 #ifndef TCOON
1431 #define TCOON 1
1432 #endif
1433
1434 #ifndef TCIOFF
1435 #define TCIOFF 2
1436 #endif
1437
1438 #ifndef TCION
1439 #define TCION 3
1440 #endif
1441
1442 #ifndef TCIFLUSH
1443 #define TCIFLUSH 0
1444 #endif
1445
1446 #ifndef TCOFLUSH
1447 #define TCOFLUSH 1
1448 #endif
1449
1450 #ifndef TCIOFLUSH
1451 #define TCIOFLUSH 2
1452 #endif
1453
1454 #ifndef TCFLSH
1455 #define TCFLSH 3
1456 #endif
1457
1458 #ifndef TCSAFLUSH
1459 #define TCSAFLUSH 1
1460 #endif
1461
1462 #ifndef TCSANOW
1463 #define TCSANOW 2
1464 #endif
1465
1466 #ifndef TCSADRAIN
1467 #define TCSADRAIN 3
1468 #endif
1469
1470 #ifndef TCSADFLUSH
1471 #define TCSADFLUSH 4
1472 #endif
1473
1474 typedef unsigned char MLton_cc_t;
1475 typedef unsigned int MLton_speed_t;
1476 typedef unsigned int MLton_tcflag_t;
1477
1478 #undef cc_t
1479 #undef speed_t
1480 #undef tcflag_t
1481
1482 #define cc_t MLton_cc_t
1483 #define speed_t MLton_speed_t
1484 #define tcflag_t MLton_tcflag_t
1485
1486 struct MLton_termios {
1487 cc_t c_cc[NCCS];
1488 tcflag_t c_cflag;
1489 tcflag_t c_iflag;
1490 tcflag_t c_lflag;
1491 tcflag_t c_oflag;
1492 };
1493 #undef termios
1494 #define termios MLton_termios
1495
1496 MLTON_WRAPPER speed_t MLton_cfgetispeed (struct termios *termios_p);
1497 MLTON_WRAPPER speed_t MLton_cfgetospeed (struct termios *termios_p);
1498 MLTON_WRAPPER int MLton_cfsetispeed (struct termios *termios_p, speed_t speed);
1499 MLTON_WRAPPER int MLton_cfsetospeed (struct termios *termios_p, speed_t speed);
1500 MLTON_WRAPPER int MLton_tcdrain (int fd);
1501 MLTON_WRAPPER int MLton_tcflow (int fd, int action);
1502 MLTON_WRAPPER int MLton_tcflush (int fd, int queue_selector);
1503 MLTON_WRAPPER int MLton_tcgetattr (int fd, struct termios *termios_p);
1504 MLTON_WRAPPER pid_t MLton_tcgetpgrp (int fd);
1505 MLTON_WRAPPER int MLton_tcsendbreak (int fd, int duration);
1506 MLTON_WRAPPER int MLton_tcsetattr (int fd, int optional_actions, struct termios *termios_p);
1507 MLTON_WRAPPER int MLton_tcsetpgrp (int fd, pid_t pgrpid);
1508
1509 #undef cfgetispeed
1510 #undef cfgetospeed
1511 #undef cfsetispeed
1512 #undef cfsetospeed
1513 #undef tcdrain
1514 #undef tcflow
1515 #undef tcflush
1516 #undef tcgetattr
1517 #undef tcgetpgrp
1518 #undef tcsendbreak
1519 #undef tcsetattr
1520 #undef tcsetpgrp
1521
1522 #define cfgetispeed MLton_cfgetispeed
1523 #define cfgetospeed MLton_cfgetospeed
1524 #define cfsetispeed MLton_cfsetispeed
1525 #define cfsetospeed MLton_cfsetospeed
1526 #define tcdrain MLton_tcdrain
1527 #define tcflow MLton_tcflow
1528 #define tcflush MLton_tcflush
1529 #define tcgetattr MLton_tcgetattr
1530 #define tcgetpgrp MLton_tcgetpgrp
1531 #define tcsendbreak MLton_tcsendbreak
1532 #define tcsetattr MLton_tcsetattr
1533 #define tcsetpgrp MLton_tcsetpgrp
1534
1535 /* ------------------------------------------------- */
1536 /* Socket */
1537 /* ------------------------------------------------- */
1538
1539 // Unimplemented on windows:
1540 #ifndef MSG_WAITALL
1541 #define MSG_WAITALL 0x8
1542 #endif
1543
1544 #ifndef MSG_DONTWAIT
1545 #define MSG_DONTWAIT 0x1000000
1546 #endif
1547
1548 #ifndef MSG_EOR
1549 #define MSG_EOR 0
1550 #endif
1551
1552 #ifndef MSG_CTRUNC
1553 #define MSG_CTRUNC 0
1554 #endif
1555
1556 #ifndef MSG_TRUNC
1557 #define MSG_TRUNC MSG_PARTIAL
1558 #endif
1559
1560 #ifndef UNIX_PATH_MAX
1561 #define UNIX_PATH_MAX 108
1562 #endif
1563
1564 typedef unsigned short MLton_sa_family_t;
1565 #undef sa_family_t
1566 #define sa_family_t MLton_sa_family_t
1567
1568 struct MLton_sockaddr_un {
1569 sa_family_t sun_family;
1570 char sun_path[UNIX_PATH_MAX];
1571 };
1572 #undef sockaddr_un
1573 #define sockaddr_un MLton_sockaddr_un
1574
1575 MLTON_WRAPPER int MLton_ioctl (int d, int request, ...);
1576 MLTON_WRAPPER int MLton_socketpair (int d, int type, int protocol, int sv[2]);
1577
1578 #undef ioctl
1579 #undef socketpair
1580
1581 #define ioctl MLton_ioctl
1582 #define socketpair MLton_socketpair
1583
1584 /* ------------------------------------------------- */
1585 /* Syslog */
1586 /* ------------------------------------------------- */
1587
1588 #ifndef LOG_EMERG
1589 #define LOG_EMERG 7
1590 #endif
1591
1592 #ifndef LOG_ALERT
1593 #define LOG_ALERT 6
1594 #endif
1595
1596 #ifndef LOG_CRIT
1597 #define LOG_CRIT 5
1598 #endif
1599
1600 #ifndef LOG_ERR
1601 #define LOG_ERR 4
1602 #endif
1603
1604 #ifndef LOG_WARNING
1605 #define LOG_WARNING 3
1606 #endif
1607
1608 #ifndef LOG_NOTICE
1609 #define LOG_NOTICE 2
1610 #endif
1611
1612 #ifndef LOG_INFO
1613 #define LOG_INFO 1
1614 #endif
1615
1616 #ifndef LOG_DEBUG
1617 #define LOG_DEBUG 0
1618 #endif
1619
1620 #ifndef LOG_PID
1621 #define LOG_PID 0x01 /* include PID in output */
1622 #endif
1623
1624 #ifndef LOG_CONS
1625 #define LOG_CONS 0x02 /* dump to console (meaningless for windows?) */
1626 #endif
1627
1628 #ifndef LOG_ODELAY
1629 #define LOG_ODELAY 0x04 /* delay open; meaningless---always open */
1630 #endif
1631
1632 #ifndef LOG_NDELAY
1633 #define LOG_NDELAY 0x08 /* don't delay; meaningless */
1634 #endif
1635
1636 #ifndef LOG_NOWAIT
1637 #define LOG_NOWAIT 0x10 /* ignored and obsolete anyways */
1638 #endif
1639
1640 #ifndef LOG_PERROR
1641 #define LOG_PERROR 0x20 /* print to standard error, honoured */
1642 #endif
1643
1644 #ifndef LOG_AUTH
1645 #define LOG_AUTH 1
1646 #endif
1647
1648 #ifndef LOG_CRON
1649 #define LOG_CRON 2
1650 #endif
1651
1652 #ifndef LOG_DAEMON
1653 #define LOG_DAEMON 3
1654 #endif
1655
1656 #ifndef LOG_KERN
1657 #define LOG_KERN 4
1658 #endif
1659
1660 #ifndef LOG_LOCAL0
1661 #define LOG_LOCAL0 5
1662 #endif
1663
1664 #ifndef LOG_LOCAL1
1665 #define LOG_LOCAL1 6
1666 #endif
1667
1668 #ifndef LOG_LOCAL2
1669 #define LOG_LOCAL2 7
1670 #endif
1671
1672 #ifndef LOG_LOCAL3
1673 #define LOG_LOCAL3 8
1674 #endif
1675
1676 #ifndef LOG_LOCAL4
1677 #define LOG_LOCAL4 9
1678 #endif
1679
1680 #ifndef LOG_LOCAL5
1681 #define LOG_LOCAL5 10
1682 #endif
1683
1684 #ifndef LOG_LOCAL6
1685 #define LOG_LOCAL6 11
1686 #endif
1687
1688 #ifndef LOG_LOCAL7
1689 #define LOG_LOCAL7 12
1690 #endif
1691
1692 #ifndef LOG_LPR
1693 #define LOG_LPR 13
1694 #endif
1695
1696 #ifndef LOG_MAIL
1697 #define LOG_MAIL 14
1698 #endif
1699
1700 #ifndef LOG_NEWS
1701 #define LOG_NEWS 15
1702 #endif
1703
1704 #ifndef LOG_SYSLOG
1705 #define LOG_SYSLOG 16
1706 #endif
1707
1708 #ifndef LOG_USER
1709 #define LOG_USER 17
1710 #endif
1711
1712 #ifndef LOG_UUCP
1713 #define LOG_UUCP 18
1714 #endif
1715
1716 MLTON_WRAPPER void MLton_openlog(const char* ident, int logopt, int facility);
1717 MLTON_WRAPPER void MLton_closelog(void);
1718 MLTON_WRAPPER void MLton_syslog(int priority, const char* fmt, const char* msg);
1719
1720 #undef openlog
1721 #undef closelog
1722 #undef syslog
1723
1724 #define openlog MLton_openlog
1725 #define closelog MLton_closelog
1726 #define syslog MLton_syslog