UnixSysCallExtensionsImpl.mesa
Copyright Ó 1988, 1991, 1992 by Xerox Corporation. All rights reserved.
Christian Jacobi, January 24, 1991 5:30 pm PST
Peter B. Kessler, January 16, 1990 1:20:35 pm PST
Demers, November 11, 1988 1:13:10 pm PST
Carl Hauser, December 8, 1988 12:56:07 pm PST
Michael Plass, January 29, 1992 2:54 pm PST
DIRECTORY
UnixSysCallExtensions,
UnixTypes
;
UnixSysCallExtensionsImpl: CEDAR PROGRAM
EXPORTS UnixSysCallExtensions
~ { OPEN UnixTypes;
Non-Unix-like I/O
FDKind: TYPE ~ UnixSysCallExtensions.FDKind;
Open4: PUBLIC PROC [path: CHARPtr, flags: FileFlags, mode: Mode, kind: FDKind] RETURNS [FD]
~ {
Open4Inner: PROC [path: CHARPtr, flags: FileFlags, mode: Mode, kind: FDKind] RETURNS [FD]
~ TRUSTED MACHINE CODE {
"XR←Open4"
};
RETURN[ Open4Inner[path, flags, mode, kind] ];
};
GetDescriptorKind: PUBLIC PROC [d: FD] RETURNS [FDKind]
~ {
GetDescriptorKindInner: PROC [d: FD] RETURNS [FDKind]
~ TRUSTED MACHINE CODE {
"XR←GetDescriptorKind"
};
RETURN[ GetDescriptorKindInner[d] ];
};
GetDTableSize1: PUBLIC PROC [kind: FDKind] RETURNS [INT]
~ {
GetDTableSize1Inner: PROC [kind: FDKind] RETURNS [INT]
~ TRUSTED MACHINE CODE {
"XR←GetDTableSize1"
};
RETURN[ GetDTableSize1Inner[kind] ];
};
ExpandPath: PUBLIC PROC [path: CHARPtr] RETURNS [CHARPtr] ~ {
ExpandPathInner: PROC [path: CHARPtr] RETURNS [CHARPtr]
~ TRUSTED MACHINE CODE {
"XR𡤎xpandPath"
};
RETURN[ ExpandPathInner[path] ];
};
GetNumberOfFreeFDs: PUBLIC PROC [kind: FDKind] RETURNS [INT] ~ {
GetNumberOfFreeFDsInner: PROC [kind: FDKind] RETURNS [INT]
~ TRUSTED MACHINE CODE {
"XR←GetNumberOfFreeFDs"
};
RETURN[ GetNumberOfFreeFDsInner[kind] ];
};
NonBlocking I/O
BlockingMode: TYPE ~ UnixSysCallExtensions.BlockingMode;
SetGetBlocking: PUBLIC PROC [s: FD, blocking: BlockingMode] RETURNS [RES]
~ {
SetGetBlockingInner: PROC [s: FD, blocking: BlockingMode] RETURNS [RES]
~ TRUSTED MACHINE CODE {
"XR←SetGetBlocking"
};
RETURN[ SetGetBlockingInner[s, blocking] ];
};
GetGetBlocking: PUBLIC PROC [s: FD] RETURNS [BlockingMode]
~ {
GetGetBlockingInner: PROC [s: FD] RETURNS [BlockingMode]
~ TRUSTED MACHINE CODE {
"XR←GetGetBlocking"
};
RETURN[ GetGetBlockingInner[s] ];
};
SetPutBlocking: PUBLIC PROC [s: FD, blocking: BlockingMode] RETURNS [RES]
~ {
SetPutBlockingInner: PROC [s: FD, blocking: BlockingMode] RETURNS [RES]
~ TRUSTED MACHINE CODE {
"XR←SetPutBlocking"
};
RETURN[ SetPutBlockingInner[s, blocking] ];
};
GetPutBlocking: PUBLIC PROC [s: FD] RETURNS [BlockingMode]
~ {
GetPutBlockingInner: PROC [s: FD] RETURNS [BlockingMode]
~ TRUSTED MACHINE CODE {
"XR←GetPutBlocking"
};
RETURN[ GetPutBlockingInner[s] ];
};
Timeouts
SetGetTimeout: PUBLIC PROC [s: FD, timeoutMsec: CARD] RETURNS [RES]
~ {
SetGetTimeoutInner: PROC [s: FD, timeoutMsec: CARD] RETURNS [RES]
~ TRUSTED MACHINE CODE {
"XR←SetGetTimeout"
};
RETURN[ SetGetTimeoutInner[s, timeoutMsec] ];
};
GetGetTimeout: PUBLIC PROC [s: FD] RETURNS [CARD]
~ {
GetGetTimeoutInner: PROC [s: FD] RETURNS [CARD]
~ TRUSTED MACHINE CODE {
"XR←GetGetTimeout"
};
RETURN[ GetGetTimeoutInner[s] ];
};
SetPutTimeout: PUBLIC PROC [s: FD, timeoutMsec: CARD] RETURNS [RES]
~ {
SetPutTimeoutInner: PROC [s: FD, timeoutMsec: CARD] RETURNS [RES]
~ TRUSTED MACHINE CODE {
"XR←SetPutTimeout"
};
RETURN[ SetPutTimeoutInner[s, timeoutMsec] ];
};
GetPutTimeout: PUBLIC PROC [s: FD] RETURNS [CARD]
~ {
GetPutTimeoutInner: PROC [s: FD] RETURNS [CARD]
~ TRUSTED MACHINE CODE {
"XR←GetPutTimeout"
};
RETURN[ GetPutTimeoutInner[s] ];
};
Unix command access
Spawn: PUBLIC PROC [cmd, stdin, stdout, stderr: CHARPtr] RETURNS [INT]
~ {
SpawnInner: PROC [cmd, stdin, stdout, stderr: CHARPtr] RETURNS [INT]
~ TRUSTED MACHINE CODE {
"XR←Spawn"
};
RETURN[ SpawnInner[cmd, stdin, stdout, stderr] ];
};
CDSpawn: PUBLIC PROCEDURE [cmd, wd, stdin, stdout, stderr: UnixTypes.CHARPtr]
RETURNS [INT] ~ {
CDSpawnInner: PROCEDURE [cmd, wd, stdin, stdout, stderr: UnixTypes.CHARPtr]
RETURNS [INT] ~ TRUSTED MACHINE CODE {
"XR�Spawn"
};
RETURN[ CDSpawnInner[cmd, wd, stdin, stdout, stderr] ];
};
PPOpen: PUBLIC PROC [cmd: CHARPtr] RETURNS [FD] ~ {
PPOpenInner: PROC [cmd: CHARPtr] RETURNS [FD] ~ TRUSTED MACHINE CODE {
"XR←PPOpen"
};
RETURN [PPOpenInner[cmd]]
};
RExec2: PUBLIC PROC [host: SockAddrPtr, port: CARD, user: CHARPtr, passwd: CHARPtr, cmd: CHARPtr, errbuf: CHARPtr, errbufbytes: INT ¬ 0] RETURNS [FD] ~ {
RExec2Inner: PROC [host: SockAddrPtr, port: CARD, user: CHARPtr, passwd: CHARPtr, cmd: CHARPtr, errbuf: CHARPtr, errbufbytes: INT] RETURNS [FD] ~ TRUSTED MACHINE CODE {
"XR←RExec2"
};
RETURN [RExec2Inner[host, port, user, passwd, cmd, errbuf, errbufbytes]]
};
Virtual memory allocation
VMReserve: PUBLIC PROC [nbytes: CARD] RETURNS [address: RawVM] ~ {
vmreserve: PROC [nbytes: CARD] RETURNS [address: RawVM] ~ TRUSTED MACHINE CODE {
"<xr/ThreadsSharedMem.h>.XR←VMReserve"
};
RETURN [vmreserve[nbytes]]
};
UNTHREADEDShmCtl: PUBLIC UNSAFE PROC [shmId: SharedMemoryIdentifier, cmd: IPCCtlCmd, buf: POINTER TO ShmIdDs] RETURNS [RES] = UNCHECKED {
Shared memory control operations, version NOT to be called from a regular Cedar/Mesa thread.
unthreadedshmctl: PUBLIC UNSAFE PROC [shmId: SharedMemoryIdentifier, cmd: IPCCtlCmd, buf: POINTER TO ShmIdDs] RETURNS [RES] = MACHINE CODE {
"*#include <sys/types.h>\n";
"#include <sys/ipc.h>\n";
"#include <sys/shm.h>\n";
".shmctl"
};
RETURN [unthreadedshmctl[shmId, cmd, buf]]
};
RegisterUNTHREADEDTerminationCleanupProc: PUBLIC UNSAFE PROC [cleanup: PROC [REF], data: REF ¬ NIL] RETURNS [RES] = UNCHECKED {
Register a cleanup proc to be called automatically just before PCR terminates. The cleanup proc is called from a Unix process rather than a thread -- it should do native Unix system calls and avoid thread operations such as entering monitors.
registerunthreadedterminationcleanupproc: UNSAFE PROC [cleanup: PROC [REF], data: REF] RETURNS [RES] = MACHINE CODE {
"<xr/ThreadsTermination.h>.XR←RegisterTerminationCleanupProc"
};
RETURN [registerunthreadedterminationcleanupproc[cleanup, data]];
};
}.