| 1 |
(* Copyright (C) 2004-2007 Henry Cejtin, Matthew Fluet, Suresh |
| 2 |
* Jagannathan, and Stephen Weeks. |
| 3 |
* |
| 4 |
* MLton is released under a HPND-style license. |
| 5 |
* See the file MLton-LICENSE for details. |
| 6 |
*) |
| 7 |
|
| 8 |
(* Stub out functions that are not implemented on MinGW. *) |
| 9 |
local |
| 10 |
structure Error = PosixError |
| 11 |
val stub: string * ('a -> 'b) -> ('a -> 'b) = |
| 12 |
fn (msg, f) => |
| 13 |
if let open Primitive.MLton.Platform.OS in MinGW = host end |
| 14 |
then fn _ => (if true |
| 15 |
then () |
| 16 |
else (PrimitiveFFI.Stdio.print msg |
| 17 |
; PrimitiveFFI.Stdio.print "\n") |
| 18 |
; Error.raiseSysWithMsg (Error.nosys, msg)) |
| 19 |
else f |
| 20 |
in |
| 21 |
structure PrimitiveFFI = |
| 22 |
struct |
| 23 |
open PrimitiveFFI |
| 24 |
|
| 25 |
structure OS = |
| 26 |
struct |
| 27 |
open OS |
| 28 |
|
| 29 |
structure IO = |
| 30 |
struct |
| 31 |
open IO |
| 32 |
|
| 33 |
val poll = stub ("poll", poll) |
| 34 |
end |
| 35 |
end |
| 36 |
|
| 37 |
structure Posix = |
| 38 |
struct |
| 39 |
open Posix |
| 40 |
|
| 41 |
structure FileSys = |
| 42 |
struct |
| 43 |
open FileSys |
| 44 |
|
| 45 |
val chown = stub ("chown", chown) |
| 46 |
val fchown = stub ("fchown", fchown) |
| 47 |
val fpathconf = stub ("fpathconf", fpathconf) |
| 48 |
val link = stub ("link", link) |
| 49 |
val mkfifo = stub ("mkfifo", mkfifo) |
| 50 |
val pathconf = stub ("pathconf", pathconf) |
| 51 |
val readlink = stub ("readlink", readlink) |
| 52 |
val symlink = stub ("symlink", symlink) |
| 53 |
end |
| 54 |
|
| 55 |
structure IO = |
| 56 |
struct |
| 57 |
open IO |
| 58 |
|
| 59 |
val fcntl2 = stub ("fcntl2", fcntl2) |
| 60 |
val fcntl3 = stub ("fcntl3", fcntl3) |
| 61 |
end |
| 62 |
|
| 63 |
structure ProcEnv = |
| 64 |
struct |
| 65 |
open ProcEnv |
| 66 |
|
| 67 |
val ctermid = stub ("ctermid", ctermid) |
| 68 |
val getegid = stub ("getegid", getegid) |
| 69 |
val geteuid = stub ("geteuid", geteuid) |
| 70 |
val getgid = stub ("getgid", getgid) |
| 71 |
val getgroups = stub ("getgroups", getgroups) |
| 72 |
val getlogin = stub ("getlogin", getlogin) |
| 73 |
val getpgrp = stub ("getpgrp", getpgrp) |
| 74 |
val getppid = stub ("getppid", getppid) |
| 75 |
val getuid = stub ("getuid", getuid) |
| 76 |
val setgid = stub ("setgid", setgid) |
| 77 |
val setgroups = stub ("stegroups", setgroups) |
| 78 |
val setpgid = stub ("setpgid", setpgid) |
| 79 |
val setsid = stub ("setsid", setsid) |
| 80 |
val setuid = stub ("setuid", setuid) |
| 81 |
val sysconf = stub ("sysconf", sysconf) |
| 82 |
val times = stub ("times", times) |
| 83 |
val ttyname = stub ("ttyname", ttyname) |
| 84 |
end |
| 85 |
|
| 86 |
structure Process = |
| 87 |
struct |
| 88 |
open Process |
| 89 |
|
| 90 |
val exece = stub ("exece", exece) |
| 91 |
val execp = stub ("execp", execp) |
| 92 |
val fork = stub ("fork", fork) |
| 93 |
val pause = stub ("pause", pause) |
| 94 |
val waitpid = fn (args as (pid, _, _)) => |
| 95 |
if C_PId.<= (pid, 0) |
| 96 |
then stub ("waitpid", waitpid) args |
| 97 |
else waitpid args |
| 98 |
end |
| 99 |
|
| 100 |
structure SysDB = |
| 101 |
struct |
| 102 |
open SysDB |
| 103 |
|
| 104 |
val getgrgid = stub ("getgrgid", getgrgid) |
| 105 |
val getgrnam = stub ("getgrnam", getgrnam) |
| 106 |
val getpwuid = stub ("getpwuid", getpwuid) |
| 107 |
end |
| 108 |
|
| 109 |
structure TTY = |
| 110 |
struct |
| 111 |
open TTY |
| 112 |
|
| 113 |
structure TC = |
| 114 |
struct |
| 115 |
open TC |
| 116 |
|
| 117 |
val drain = stub ("drain", drain) |
| 118 |
val flow = stub ("flow", flow) |
| 119 |
val flush = stub ("flush", flush) |
| 120 |
val getattr = stub ("getattr", getattr) |
| 121 |
val getpgrp = stub ("getpgrp", getpgrp) |
| 122 |
val sendbreak = stub ("sendbreak", sendbreak) |
| 123 |
val setattr = stub ("setattr", setattr) |
| 124 |
val setpgrp = stub ("setpgrp", setpgrp) |
| 125 |
end |
| 126 |
end |
| 127 |
end |
| 128 |
|
| 129 |
structure Socket = |
| 130 |
struct |
| 131 |
open Socket |
| 132 |
|
| 133 |
structure UnixSock = |
| 134 |
struct |
| 135 |
open UnixSock |
| 136 |
|
| 137 |
val toAddr = stub ("toAddr", toAddr) |
| 138 |
val fromAddr = stub ("fromAddr", fromAddr) |
| 139 |
end |
| 140 |
end |
| 141 |
end |
| 142 |
end |