UnixSysCalls.mesa
Copyright Ó 1988, 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Christian Jacobi, January 24, 1991 5:30 pm PST
Demers, November 9, 1988 5:41:50 pm PST
Carl Hauser, February 16, 1989 1:46:38 pm PST
Michael Plass, August 13, 1991 12:57 pm PDT
Unix(tm) system calls for PCedar.
Commented-out names are unimplemented for good reason, and not to be used, except: "????" means we should implement some version of this eventually.
DIRECTORY
UnixTypes USING [AccModTimes, AddressFamily, CHARPtr, FD, FileFlags, FileTimesPtr, GetResult, GID, GIDs, GIDsPtr, INTPtr, IOVec, IOVecPtr, IPCCtlCmd, MMapFlags, Mode, MsgFlags, MSyncFlags, PGRP, PID, PollFD, Protections, ProtocolFamily, RawVM, RES, RSFlags, RUsage, SDHow, SharedMemoryIdentifier, SharedMemoryKey, ShmAtFlags, ShmGetFlags, ShmIdDs, shmNoFlags, Signal, SockAddr, SockAddrPtr, SocketType, Stat, StatFS, StatFSPtr, StatPtr, StrBuf, StrBufPtr, TimeVal, TimeValPtr, TimeZone, TimeZonePtr, UID, Whence, Who];
UnixSysCalls:
CEDAR
DEFINITIONS
~ { OPEN UnixTypes;
Accept:
UNSAFE
PROC [s:
FD, addr: SockAddrPtr, addrLen: INTPtr]
RETURNS [
FD];
Access:
PROC [path: CHARPtr, mode: Mode]
RETURNS [
RES];
Acct
AdjTime
Audit
AuditOn
Bind:
PROC [s:
FD, name: SockAddrPtr, nameLen:
INT]
RETURNS [
RES];
Brk
SBrk
ChMod: PROC [path: CHARPtr, mode: Mode] RETURNS [RES];
FChMod:
PROC [fd:
FD, mode: Mode]
RETURNS [
RES];
Chown
FChown
Close:
PROC [fd:
FD]
RETURNS [
RES];
Connect:
PROC [s:
FD, name: SockAddrPtr, nameLen:
INT]
RETURNS [
RES];
Dup2 ????
ExecVE
FCntl: PROC [fd: FD, cmd: INT, arg: INT] RETURNS [RES];
FCntl4:
PROC [fd:
FD, cmd:
INT, arg:
INT, doInIOP:
BOOL]
RETURNS [
RES];
Caller controls whether fcntl is done in vp or iop. The Unix-style entry FCntl always does the fcntl call in the vp, which in some cases is inappropriate.
Fork
but see UnixSysCallExtensions.Spawn
FSync:
PROC [fd:
FD]
RETURNS [
RES];
GetAUID
SetAUID
GetDEnts: UNSAFE PROC [fd: FD, buf: CHARPtr, nBytes: INT] RETURNS [INT];
GetDomainName:
UNSAFE
PROC [name: CHARPtr, nameLen:
INT]
RETURNS [
RES];
GetDTableSize:
PROC
RETURNS [
INT];
GetGID: PROC RETURNS [GID];
GetEGID:
PROC
RETURNS [
GID];
GetGroups:
UNSAFE
PROC [gidSetLen:
INT, gidSet: GIDsPtr]
RETURNS [nGroups:
INT];
GetHostID:
PROC
RETURNS [
INT];
GetHostName:
UNSAFE
PROC [name: CHARPtr, nameLen:
INT]
RETURNS [
RES];
SetHostName
GetITimer
SetITimer
GetMsg:
UNSAFE
PROC [fd:
FD, ctlPtr, dataPtr: StrBufPtr, flags:
POINTER
TO RSFlags]
RETURNS [GetResult];
GetPageSize:
PROC
RETURNS [
INT];
GetPeerName:
UNSAFE
PROC [s:
FD, name: SockAddrPtr, nameLen: INTPtr]
RETURNS [
RES];
GetPID: PROC RETURNS [INT];
GetPPID:
PROC
RETURNS [
INT];
GetPriority
SetPriority
GetRLimit
GetRUsage:
UNSAFE
PROC [who: Who, rusage:
POINTER
TO RUsage]
RETURNS [
RES];
GetSockName:
UNSAFE
PROC [s:
FD, name: SockAddrPtr, nameLen: INTPtr]
RETURNS [
RES];
GetSockOpt: UNSAFE PROC [s: FD, level: INT, optName: INT, optVal: CHARPtr, optLen: INTPtr] RETURNS [RES];
SetSockOpt:
PROC [s:
FD, level:
INT, optName:
INT, optVal: CHARPtr, optLen:
INT]
RETURNS [
RES];
GetTimeOfDay:
UNSAFE
PROC [tp: TimeValPtr, tzp: TimeZonePtr]
RETURNS [
RES];
GetUID: PROC RETURNS[UID];
GetEUID:
PROC
RETURNS[
UID];
IOCtl:
UNSAFE
PROC [d:
FD, request:
INT, argp: CHARPtr]
RETURNS [
RES];
... only a subset of the full Unix capability. See impl.
IOCtl4:
UNSAFE
PROC [d:
FD, request:
INT, argp: CHARPtr, doInIOP:
BOOL]
RETURNS [
RES];
Caller controls whether ioctl is done in vp or iop.
The Unix-style entry IOCtl always does the ioctl call in the vp, which in some cases is inappropriate.
Kill: PROC [pid: PID, sig: Signal] RETURNS [RES];
KillPG:
PROC [pgrp:
PGRP, sig: Signal]
RETURNS [
RES];
Link:
PROC [name1, name2: CHARPtr]
RETURNS [
RES];
Listen:
PROC [s:
FD, backlog:
INT]
RETURNS [
RES];
LSeek:
PROC [d:
FD, offset:
INT, whence: Whence]
RETURNS [
INT];
MInCore:
UNSAFE
PROC [addr: CHARPtr, len:
INT, vec: CHARPtr]
RETURNS [
RES];
MkDir:
PROC [path: CHARPtr, mode: Mode]
RETURNS [
RES];
MkNod:
PROC [path: CHARPtr, mode: Mode, dev:
INT]
RETURNS [
RES];
MMap:
UNSAFE
PROC [addr: RawVM, nbytes:
CARD, prot: Protections, flags: MMapFlags, d:
FD, offset:
CARD]
RETURNS [
RES];
Restrictions: MUST HAVE flags.shared AND flags.fixed
addr must be page-aligned and must lie beyond heap segment limit.
Use UnixSysCallExtensions.VMReserve to reserve suitable VM
MUnmap:
UNSAFE
PROC [addr: RawVM, nbytes:
CARD]
RETURNS [
RES];
addr must be page-aligned.
munmapped region must lie beyond heap segment limit AND MUST BE MAPPED.
Return 0 on success.
Panic on failure. DANGER!
MProtect:
UNSAFE
PROC [addr: RawVM, nbytes:
CARD, prot: Protections]
RETURNS [
RES];
Use only in address ranges obtained with UnixSysCallExtensions.VMReserve.
MSync:
UNSAFE
PROC [addr: RawVM, nbytes:
CARD, flags: MSyncFlags]
RETURNS [
RES];
MsgCtl
MsgGet
NFSSvc
Open:
PROC [path: CHARPtr, flags: FileFlags, mode: Mode]
RETURNS [
FD];
Pipe
Poll:
UNSAFE
PROC [fds:
POINTER
TO PollFD, nfds:
CARD, timeout:
INT]
RETURNS [selected:
INT];
Restricted form of the Unix Poll system call. The restrictions are:
nfds must be 1
the file descriptor specified in fds[0] must be valid (not -1)
Profil: UNSAFE PROC[buf: CHARPtr, bufSize: INT, offset: INT, scale: INT] RETURNS [RES];
PTrace
PutMsg:
PROC [fd:
FD, ctlPtr, dataPtr: StrBufPtr, flags: RSFlags]
RETURNS [
RES];
Read: UNSAFE PROC [d: FD, buf: CHARPtr, nBytes: INT] RETURNS [INT];
ReadV:
UNSAFE
PROC [d:
FD, iov: IOVecPtr, iovCnt:
INT]
RETURNS [
INT];
ReadLink:
UNSAFE
PROC [path: CHARPtr, buf: CHARPtr, bufSize:
INT]
RETURNS [
INT];
Recv: UNSAFE PROC [fd: FD, buf: CHARPtr, len: INT, flags: MsgFlags] RETURNS [INT];
RecvFrom:
UNSAFE
PROC [fd:
FD, buf: CHARPtr, len:
INT, flags: MsgFlags, from: SockAddrPtr, fromLen: INTPtr]
RETURNS [
INT];
Rename:
PROC [from, to: CHARPtr]
RETURNS [
RES];
RmDir:
PROC [path: CHARPtr]
RETURNS [
RES];
Select
SemCtl
SemGet
Send: PROC [s: FD, msg: CHARPtr, len: INT, flags: MsgFlags] RETURNS [INT];
SendTo:
PROC [s:
FD, msg: CHARPtr, len:
INT, flags: MsgFlags, to: SockAddrPtr, toLen:
INT]
RETURNS [
INT];
GetPGrp:
PROC [pid:
PID]
RETURNS [
PGRP];
SetREGID
SetREUID
ShmGet:
PROC [key: SharedMemoryKey, size:
INT, shmflg: ShmGetFlags]
RETURNS [shmId: SharedMemoryIdentifier];
Returns shared memory identifier or errorSharedMemoryIdentifier.
Heavy clients of this should use the termination cleanup aids in UnixSysCallExtensions to clean up on termination of the world.
ShmCtl:
PROC [shmId: SharedMemoryIdentifier, cmd: IPCCtlCmd, buf:
POINTER
TO ShmIdDs]
RETURNS [
RES];
Shared memory control operations.
ShmAt:
UNSAFE PROC [id: SharedMemoryIdentifier, addr: RawVM, flags: ShmAtFlags ¬ shmNoFlags]
RETURNS [
INT];
Attaches shared memory segment.
Returns address of memory segment or -1 on failure.
WARNING:
You should explicitly allocate the memory with UnixSysCallExtensions.VMReserve.
A 0 addr would confuse the garbage collector.
ShmDt:
UNSAFE PROC [addr: RawVM]
RETURNS [
RES];
Unmaps shared memory segment at addr from calling processes address space.
But segment and contents are retained.
Shutdown:
PROC [s:
FD, how: SDHow]
RETURNS [
RES];
SigBlock
SigPause
SigSetMask
SigStack
Socket:
PROC [af: AddressFamily, type: SocketType, protocol: ProtocolFamily]
RETURNS [
FD];
Stat: UNSAFE PROC [path: CHARPtr, buf: StatPtr] RETURNS [RES];
LStat: UNSAFE PROC [path: CHARPtr, buf: StatPtr] RETURNS [RES];
FStat:
UNSAFE
PROC [fd:
FD, buf: StatPtr]
RETURNS [
RES];
StatFS: UNSAFE PROC [path: CHARPtr, buf: StatFSPtr] RETURNS [RES];
FStatFS:
UNSAFE
PROC [fd:
FD, buf: StatFSPtr]
RETURNS [
RES];
SymLink:
PROC [name1, name2: CHARPtr]
RETURNS [
RES];
Sync:
PROC
RETURNS [
RES];
Truncate: PROC [path: CHARPtr, length: CARD] RETURNS [RES];
FTruncate:
PROC [fd:
FD, length:
CARD]
RETURNS [
RES];
UMask
Unlink:
PROC [path: CHARPtr]
RETURNS [
RES];
UTimes:
PROC [file: CHARPtr, tvp: FileTimesPtr]
RETURNS [
RES];
VAdvise
VFork
Wait
Wait3
Write: PROC [d: FD, buf: CHARPtr, nBytes: INT] RETURNS [INT];
WriteV:
PROC [d:
FD, iov: IOVecPtr, iovCnt:
INT]
RETURNS [
INT];
}.