1 /* Many of the functions used in mingw.c are Win2000+ */
3 #define _WIN32_WINNT 0x0500
18 #include <sys/timeb.h>
19 #include <sys/types.h>
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
41 #define MLton_Platform_OS_host "mingw"
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.
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
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
74 MLTON_WRAPPER
int MLton_getpagesize (void);
75 MLTON_WRAPPER
int MLton_mkstemp (char *template);
80 #define getpagesize MLton_getpagesize
81 #define mkstemp MLton_mkstemp
95 #ifndef _PC_CHOWN_RESTRICTED
96 #define _PC_CHOWN_RESTRICTED 6
100 #define _PC_LINK_MAX 0
103 #ifndef _PC_MAX_CANON
104 #define _PC_MAX_CANON 1
107 #ifndef _PC_MAX_INPUT
108 #define _PC_MAX_INPUT 2
112 #define _PC_NAME_MAX 3
116 #define _PC_NO_TRUNC 7
120 #define _PC_PATH_MAX 4
124 #define _PC_PIPE_BUF 5
128 #define _PC_VDISABLE 8
188 #define SHUT_RD SD_RECEIVE
192 #define SHUT_WR SD_SEND
196 #define SHUT_RDWR SD_BOTH
199 /* ------------------------------------------------- */
201 /* ------------------------------------------------- */
203 /* MinGW provides gettimeofday in -lmingwex, which we don't link.
204 * In order to avoid a name conflict, we use a different name.
206 struct MLton_timezone
{
210 #define timezone MLton_timezone
212 MLTON_WRAPPER
int MLton_gettimeofday (struct timeval
*tv
, struct timezone
*tz
);
214 #define gettimeofday MLton_gettimeofday
216 /* ------------------------------------------------- */
218 /* ------------------------------------------------- */
221 #define ITIMER_REAL 0 /*generates sigalrm */
224 #ifndef ITIMER_VIRTUAL
225 #define ITIMER_VIRTUAL 1 /*generates sigvtalrm */
229 #define ITIMER_VIRT 1 /*generates sigvtalrm */
233 #define ITIMER_PROF 2 /*generates sigprof */
236 struct MLton_itimerval
{
237 struct timeval it_interval
;
238 struct timeval it_value
;
241 #define itimerval MLton_itimerval
243 MLTON_WRAPPER
int MLton_setitimer (int which
,
244 const struct itimerval
*value
,
245 struct itimerval
*ovalue
);
247 #define setitimer MLton_setitimer
249 /* ------------------------------------------------- */
251 /* ------------------------------------------------- */
254 #define RLIMIT_CPU 0 /* CPU time in seconds */
258 #define RLIMIT_FSIZE 1 /* Maximum filesize */
262 #define RLIMIT_DATA 2 /* max data size */
266 #define RLIMIT_STACK 3 /* max stack size */
270 #define RLIMIT_CORE 4 /* max core file size */
273 #ifndef RLIMIT_NOFILE
274 #define RLIMIT_NOFILE 5 /* max number of open files */
278 #define RLIMIT_OFILE RLIMIT_NOFILE /* BSD name */
282 #define RLIMIT_AS 6 /* address space (virt. memory) limit */
285 #define RLIMIT_NLIMITS 7 /* upper bound of RLIMIT_* defines */
286 #define RLIM_NLIMITS RLIMIT_NLIMITS
288 #ifndef RLIM_INFINITY
289 #define RLIM_INFINITY (0xffffffffUL)
292 #ifndef RLIM_SAVED_MAX
293 #define RLIM_SAVED_MAX RLIM_INFINITY
296 #ifndef RLIM_SAVED_CUR
297 #define RLIM_SAVED_CUR RLIM_INFINITY
300 typedef unsigned long MLton_rlim_t
;
302 #define rlim_t MLton_rlim_t
304 struct MLton_rlimit
{
309 #define rlimit MLton_rlimit
311 MLTON_WRAPPER
int MLton_getrlimit (int resource
, struct rlimit
*rlim
);
312 MLTON_WRAPPER
int MLton_setrlimit (int resource
, const struct rlimit
*rlim
);
315 #define getrlimit MLton_getrlimit
316 #define setrlimit MLton_setrlimit
318 /* ------------------------------------------------- */
320 /* ------------------------------------------------- */
323 #define RUSAGE_SELF 0 /* calling process */
326 #ifndef RUSAGE_CHILDREN
327 #define RUSAGE_CHILDREN -1 /* terminated child processes */
330 struct MLton_rusage
{
331 struct timeval ru_utime
;
332 struct timeval ru_stime
;
335 #define rusage MLton_rusage
337 MLTON_WRAPPER
int MLton_getrusage (int who
, struct rusage
*usage
);
339 #define getrusage MLton_getrusage
341 /* ------------------------------------------------- */
343 /* ------------------------------------------------- */
345 struct MLton_pollfd
{
351 #define pollfd MLton_pollfd
353 MLTON_WRAPPER
int MLton_poll (struct pollfd
*ufds
, nfds_t nfds
, int timeout
);
355 #define poll MLton_poll
357 /* ------------------------------------------------- */
359 /* ------------------------------------------------- */
361 /* We cannot yet replace strerror at the time util.c is built */
363 MLTON_WRAPPER
char *MLton_strerror(int code
);
365 #define strerror MLton_strerror
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.
373 #define EINTR WSAEINTR
377 #define EBADF WSAEBADF
381 #define EACCES WSAEACCES
385 #define EFAULT WSAEFAULT
389 #define EINVAL WSAEINVAL
393 #define EMFILE WSAEMFILE
397 #define EAGAIN WSAEWOULDBLOCK
401 #define EWOULDBLOCK EAGAIN
405 #define EINPROGRESS WSAEINPROGRESS
409 #define EALREADY WSAEALREADY
413 #define ENOTSOCK WSAENOTSOCK
417 #define EDESTADDRREQ WSAEDESTADDRREQ
421 #define EMSGSIZE WSAEMSGSIZE
425 #define EPROTOTYPE WSAEPROTOTYPE
429 #define ENOPROTOOPT WSAENOPROTOOPT
432 #ifndef EPROTONOSUPPORT
433 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
436 #ifndef ESOCKTNOSUPPORT
437 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
441 #define EOPNOTSUPP WSAEOPNOTSUPP
445 #define EPFNOSUPPORT WSAEPFNOSUPPORT
449 #define EAFNOSUPPORT WSAEAFNOSUPPORT
453 #define EADDRINUSE WSAEADDRINUSE
456 #ifndef EADDRNOTAVAIL
457 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
461 #define ENETDOWN WSAENETDOWN
465 #define ENETUNREACH WSAENETUNREACH
469 #define ENETRESET WSAENETRESET
473 #define ECONNABORTED WSAECONNABORTED
477 #define ECONNRESET WSAECONNRESET
481 #define ENOBUFS WSAENOBUFS
485 #define EISCONN WSAEISCONN
489 #define ENOTCONN WSAENOTCONN
493 #define ESHUTDOWN WSAESHUTDOWN
497 #define ETIMEDOUT WSAETIMEDOUT
501 #define ECONNREFUSED WSAECONNREFUSED
505 #define ELOOP WSAELOOP
509 #define ENAMETOOLONG WSAENAMETOOLONG
513 #define EHOSTDOWN WSAEHOSTDOWN
517 #define EHOSTUNREACH WSAEHOSTUNREACH
521 #define ENOTEMPTY WSAENOTEMPTY
525 #define EDQUOT WSAEDQUOT
529 #define ESTALE WSAESTALE
533 #define EREMOTE WSAEREMOTE
536 /* Questionable fall backs: */
539 #define EUSERS WSAEUSERS
543 #define ECANCELED WSAECANCELLED
550 /* ------------------------------------------------- */
552 /* ------------------------------------------------- */
555 #define S_IRGRP 0000040
559 #define S_IROTH 0000004
563 #define S_IRWXG 0000070
567 #define S_IRWXO 0000007
571 #define S_ISGID 0002000
575 #define S_ISUID 0004000
579 #define S_IWGRP 0000020
583 #define S_IWOTH 0000002
587 #define S_IXGRP 0000010
591 #define S_IXOTH 0000001
594 // Do not exist in a windows filesystem
608 #define O_NOCTTY 0x8000
612 #define O_NONBLOCK 0x4000
615 // Synchronized writes? Safety of any kind? ... and windows?! hell no!
620 // Use m to silence unused warnings
623 #define S_ISLNK(m) (m?FALSE:FALSE)
624 #define S_ISSOCK(m) (m?FALSE:FALSE)
627 #define O_ACCMODE O_RDONLY|O_WRONLY|O_RDWR
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
);
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
670 #define mkdir(f, m) mkdir(f); chmod(f, m)
672 /* ------------------------------------------------- */
674 /* ------------------------------------------------- */
684 #define flock MLton_flock
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]);
694 #define fcntl MLton_fcntl
695 #define fsync MLton_fsync
696 #define pipe MLton_pipe
698 /* ------------------------------------------------- */
700 /* ------------------------------------------------- */
703 #define _SC_ARG_MAX 0
706 #ifndef _SC_CHILD_MAX
707 #define _SC_CHILD_MAX 1
711 #define _SC_CLK_TCK 2
714 #ifndef _SC_JOB_CONTROL
715 #define _SC_JOB_CONTROL 5
718 #ifndef _SC_NGROUPS_MAX
719 #define _SC_NGROUPS_MAX 3
723 #define _SC_OPEN_MAX 4
726 #ifndef _SC_SAVED_IDS
727 #define _SC_SAVED_IDS 6
731 #define _SC_VERSION 7
741 struct MLton_utsname
{
752 #define tms MLton_tms
753 #define utsname MLton_utsname
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
);
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
819 /* ------------------------------------------------- */
821 /* ------------------------------------------------- */
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
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')
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.
846 #define SIGNALLED_BIT 0x80000000UL
849 #define WIFEXITED(w) (((w) & SIGNALLED_BIT) == 0)
853 #define WIFSIGNALED(w) (((w) & SIGNALLED_BIT) != 0)
857 #define WIFSTOPPED(w) 0
861 #define WEXITSTATUS(w) ((w) & 0xff)
865 #define WTERMSIG(w) ((w) & 0xff)
869 #define WSTOPSIG WEXITSTATUS
872 /* Sometimes defined by mingw */
873 #if !defined(TIMESPEC_DEFINED) && !defined(_TIMESPEC_DEFINED)
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
);
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
907 /* ------------------------------------------------- */
909 /* ------------------------------------------------- */
911 /* Sometimes mingw defines some of these. Some not. Some always. */
918 #define SIG_SETMASK 0
922 #define SIG_UNBLOCK 2
936 /* SIGTRAP = 5 (unused) */
937 /* SIGIOT = 6 (unused) */
938 /* SIGABRT = 6 (unused) */
939 /* SIGEMT = 7 (unused) */
951 /* SIGSYS = 12 (unused) */
965 /* These signals are fake. They do not exist on windows. */
1000 #define SIGVTALRM 29 /* virtual time alarm */
1004 #define SIGPROF 30 /* profiling time alarm */
1007 /* We have extended the number of signals ... */
1013 typedef __p_sig_fn_t MLton__sig_func_ptr
;
1014 typedef int MLton_sigset_t
;
1016 #undef _sig_func_ptr
1019 #define _sig_func_ptr MLton__sig_func_ptr
1020 #define sigset_t MLton_sigset_t
1022 struct MLton_sigaction
{
1025 _sig_func_ptr sa_handler
;
1029 #define sigaction MLton_sigaction
1032 #define SIGTOMASK(sn) (1 << ((sn)-1))
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
);
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
1067 /* ------------------------------------------------- */
1068 /* Posix.SysDB.Passwd */
1069 /* ------------------------------------------------- */
1071 struct MLton_group
{
1078 struct MLton_passwd
{
1088 #define group MLton_group
1089 #define passwd MLton_passwd
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
);
1101 #define getgrgid MLton_getgrgid
1102 #define getgrnam MLton_getgrnam
1103 #define getpwnam MLton_getpwnam
1104 #define getpwuid MLton_getpwuid
1106 /* ------------------------------------------------- */
1108 /* ------------------------------------------------- */
1123 #define B110 0x00003
1127 #define B134 0x00004
1131 #define B150 0x00005
1135 #define B200 0x00006
1139 #define B300 0x00007
1143 #define B600 0x00008
1147 #define B1200 0x00009
1151 #define B1800 0x0000a
1155 #define B2400 0x0000b
1159 #define B4800 0x0000c
1163 #define B9600 0x0000d
1167 #define B19200 0x0000e
1171 #define B38400 0x0000f
1243 #define IGNBRK 0x00001
1247 #define BRKINT 0x00002
1251 #define IGNPAR 0x00004
1255 #define IMAXBEL 0x00008
1259 #define INPCK 0x00010
1263 #define ISTRIP 0x00020
1267 #define INLCR 0x00040
1271 #define IGNCR 0x00080
1275 #define ICRNL 0x00100
1279 #define IXON 0x00400
1283 #define IXOFF 0x01000
1287 #define IUCLC 0x04000
1291 #define IXANY 0x08000
1295 #define PARMRK 0x10000
1299 #define OPOST 0x00001
1303 #define CSIZE 0x00030
1323 #define CSTOPB 0x00040
1327 #define CREAD 0x00080
1331 #define PARENB 0x00100
1335 #define PARODD 0x00200
1339 #define HUPCL 0x00400
1343 #define CLOCAL 0x00800
1347 #define CBAUDEX 0x0100f
1351 #define B57600 0x01001
1355 #define B115200 0x01002
1359 #define B128000 0x01003
1363 #define B230400 0x01004
1367 #define B256000 0x01005
1371 #define CRTSXOFF 0x04000
1375 #define CRTSCTS 0x08000
1383 #define ICANON 0x0002
1391 #define ECHOE 0x0008
1395 #define ECHOK 0x0010
1399 #define ECHONL 0x0020
1403 #define NOFLSH 0x0040
1407 #define TOSTOP 0x0080
1411 #define IEXTEN 0x0100
1415 #define FLUSHO 0x0200
1419 #define ECHOKE 0x0400
1423 #define ECHOCTL 0x0800
1471 #define TCSADFLUSH 4
1474 typedef unsigned char MLton_cc_t
;
1475 typedef unsigned int MLton_speed_t
;
1476 typedef unsigned int MLton_tcflag_t
;
1482 #define cc_t MLton_cc_t
1483 #define speed_t MLton_speed_t
1484 #define tcflag_t MLton_tcflag_t
1486 struct MLton_termios
{
1494 #define termios MLton_termios
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
);
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
1535 /* ------------------------------------------------- */
1537 /* ------------------------------------------------- */
1539 // Unimplemented on windows:
1541 #define MSG_WAITALL 0x8
1544 #ifndef MSG_DONTWAIT
1545 #define MSG_DONTWAIT 0x1000000
1553 #define MSG_CTRUNC 0
1557 #define MSG_TRUNC MSG_PARTIAL
1560 #ifndef UNIX_PATH_MAX
1561 #define UNIX_PATH_MAX 108
1564 typedef unsigned short MLton_sa_family_t
;
1566 #define sa_family_t MLton_sa_family_t
1568 struct MLton_sockaddr_un
{
1569 sa_family_t sun_family
;
1570 char sun_path
[UNIX_PATH_MAX
];
1573 #define sockaddr_un MLton_sockaddr_un
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]);
1581 #define ioctl MLton_ioctl
1582 #define socketpair MLton_socketpair
1584 /* ------------------------------------------------- */
1586 /* ------------------------------------------------- */
1605 #define LOG_WARNING 3
1609 #define LOG_NOTICE 2
1621 #define LOG_PID 0x01 /* include PID in output */
1625 #define LOG_CONS 0x02 /* dump to console (meaningless for windows?) */
1629 #define LOG_ODELAY 0x04 /* delay open; meaningless---always open */
1633 #define LOG_NDELAY 0x08 /* don't delay; meaningless */
1637 #define LOG_NOWAIT 0x10 /* ignored and obsolete anyways */
1641 #define LOG_PERROR 0x20 /* print to standard error, honoured */
1653 #define LOG_DAEMON 3
1661 #define LOG_LOCAL0 5
1665 #define LOG_LOCAL1 6
1669 #define LOG_LOCAL2 7
1673 #define LOG_LOCAL3 8
1677 #define LOG_LOCAL4 9
1681 #define LOG_LOCAL5 10
1685 #define LOG_LOCAL6 11
1689 #define LOG_LOCAL7 12
1705 #define LOG_SYSLOG 16
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
);
1724 #define openlog MLton_openlog
1725 #define closelog MLton_closelog
1726 #define syslog MLton_syslog