UnixTypes.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:02:04 pm PST
Carl Hauser, November 22, 1988 5:22:21 pm PST
Michael Plass, August 12, 1991 5:21 pm PDT
Types and structures from <sys/types.h> and from whole cloth.
bitsPerUnitMustBeEight:
CARD[8..8] ~
BITS[
UNIT];
CHARPtr:
TYPE ~
POINTER
TO Basics.RawChars ¬
NIL;
there is no guarantee that the chars pointed to will be word aligned
INTPtr: TYPE ~ POINTER TO INT;
Flag:
TYPE ~
MACHINE
DEPENDENT {false(0), true(1)};
UID: TYPE ~ INT16;
GID: TYPE ~ INT16;
PIDPtr: TYPE ~ POINTER TO PID;
PID: TYPE ~ INT;
PGRPPtr: TYPE ~ POINTER TO PGRP;
PGRP: TYPE ~ INT;
Time: TYPE ~ INT32;
Dev: TYPE ~ INT16;
Offset: TYPE ~ INT32;
INum: TYPE ~ CARD32;
RES: TYPE ~ SysCallResult;
SysCallResult:
TYPE ~
MACHINE
DEPENDENT {
success(0),
failure(CARD32.LAST)
};
GIDsPtr: TYPE ~ POINTER TO GIDs;
GIDs:
TYPE ~
RECORD [
gids: PACKED SEQUENCE COMPUTED CARD OF GID
];
Enumerations and structures from <sys/file.h> and its included header files.
FD: TYPE ~ FileDescriptor;
FileDescriptor:
TYPE ~
MACHINE
DEPENDENT {
pseudostdin(0),
pseudostdout(1),
pseudostderr(2),
stdtrc(LOOPHOLE[-4]),
stdout(LOOPHOLE[-3]),
stdin(LOOPHOLE[-2]),
error(CARD32.LAST)
};
FileFlags:
TYPE ~
MACHINE
DEPENDENT
RECORD [
fill0: [0..3777777B] ¬ 0,
excl: Flag ¬ false, -- error if already created
trunc: Flag ¬ false, -- truncate to zero length
creat: Flag ¬ false, -- create if nonexistant [sic]
fill1: [0..3] ¬ 0,
async: Flag ¬ false, -- signal pgrp when data ready
fill2: [0..3] ¬ 0,
append: Flag ¬ false, -- append on each write
ndelay: Flag ¬ false, -- non-blocking reads
access: MACHINE DEPENDENT {RDONLY(0), WRONLY(1), RDWR(2), (3)}
];
flags argument for open.
LockOp:
TYPE ~
MACHINE
DEPENDENT
RECORD [
fill: [0..0fffffffH] ¬ 0,
un: Flag ¬ false, -- unlock
nb: Flag ¬ false, -- don't block when locking
ex: Flag ¬ false, -- exclusive lock
sh: Flag ¬ false -- shared lock
];
op argument for FLock.
Whence:
TYPE ~
MACHINE
DEPENDENT {
set(0), -- absolute offset
incr(1), -- relative to current offset
xtnd(2), -- relative to end of file
(CARD32.LAST)
};
whence argument to lseek.
Types to access the Unix shared memory features: <sys/ipc.h> and <sys/shm.h>
IpcPerm:
TYPE =
MACHINE
DEPENDENT
RECORD [
--common IPC access structure
uid: UID, -- (owner's) user id
gid: GID, -- (owner's) group id
cuid: UID, -- creator's user id
cgid: GID, -- creator's group id
mode: CARD16, -- access modes; r/w permission; (set op sets only low 9 bits)
seq: CARD16, -- slot usage sequence number
key: CARD -- key
];
ShmIdDs:
TYPE =
MACHINE
DEPENDENT
RECORD [
--shared memory descriptor structure
ipcPerm: IpcPerm, -- operation permission struct
segsz: INT, -- size of segment in bytes
lpid: UID, -- process ID of last shmop
cpid: UID, -- process ID of creator
nAttch: CARD16, -- number of current attaches
unused1: CARD16, -- depending on C compiler's padding algorithm !
aTime: Time, -- last shmat time
dTime: Time, -- last shmdt time
cTime: Time, -- last change time
amp: POINTER -- segment anon¬map pointer
];
SharedMemoryIdentifier:
TYPE =
RECORD [val:
CARD];
errorSharedMemoryIdentifier: SharedMemoryIdentifier = [CARD.LAST];
SharedMemoryKey:
TYPE =
RECORD [val:
CARD];
ipcPRIVATE: SharedMemoryKey = [0]; --private key to create new SharedMemoryIdentifier
ShmGetFlags:
TYPE =
RECORD [val:
CARD];
--low order 9 bits for permission stuff
ipcALLOC: ShmGetFlags = [0100000B]; -- entry currently allocated
ipcCREAT: ShmGetFlags = [0001000B]; -- create entry if key doesn't exist
ipcEXCL: ShmGetFlags = [0002000B]; -- fail if key exists
allPerms: ShmGetFlags = [0000777B]; -- (not in found ipc.h)
IPCCtlCmd:
TYPE =
RECORD [val:
CARD];
ipcRMID: IPCCtlCmd = [0]; -- remove identifier
ipcSET: IPCCtlCmd = [1]; -- set options
ipcSTAT: IPCCtlCmd = [2]; -- get options
ShmAtFlags:
TYPE =
RECORD [
CARD];
shmNoFlags: ShmAtFlags = [000000];
shmRDOnly: ShmAtFlags = [010000]; -- attach read-only (else read-write)
shmRnd: ShmAtFlags = [020000]; -- round attach address to SHMBA
Constants from <sys/signal.h>
Signal:
TYPE ~
MACHINE
DEPENDENT {
SIGHUP(1), -- hangup
SIGINT(2), -- interrupt
SIGQUIT(3), -- quit
SIGILL(4), -- illegal instruction (not reset when caught)
SIGTRAP(5), -- trace trap (not reset when caught)
SIGABRT(6), -- used by abort
SIGEMT(7), -- EMT instruction
SIGFPE(8), -- floating point exception
SIGKILL(9), -- kill (cannot be caught or ignored)
SIGBUS(10), -- bus error
SIGSEGV(11), -- segmentation violation
SIGSYS(12), -- bad argument to system call
SIGPIPE(13), -- write on a pipe with no one to read it
SIGALRM(14), -- alarm clock
SIGTERM(15), -- software termination signal from kill
SIGURG(16), -- urgent condition on IO channel
SIGSTOP(17), -- sendable stop signal not from tty
SIGTSTP(18), -- stop signal from tty
SIGCONT(19), -- continue a stopped process
SIGCHLD(20), -- to parent on child stop or exit
SIGTTIN(21), -- to readers pgrp upon background tty read
SIGTTOU(22), -- like TTIN for output if (tp->t¬local<OSTOP)
SIGIO(23), -- input/output possible signal
SIGXCPU(24), -- exceeded CPU time limit
SIGXFSZ(25), -- exceeded file size limit
SIGVTALRM(26), -- virtual time alarm
SIGPROF(27), -- profiling time alarm
SIGWINCH(28), -- window changed
SIGLOST(29), -- resource lost (eg, record-lock lost)
SIGUSR1(30), -- user defined signal 1
SIGUSR2(31) -- user defined signal 2
};
Types describing sockets
SocketType:
TYPE ~
MACHINE
DEPENDENT {
stream(1), -- stream socket
dgram(2), -- datagram socket
raw(3), -- raw-protocol interface
rdm(4), -- reliably-delivered message
seqPacket(5), -- sequenced packet stream
(CARD16.LAST)
};
AddressFamily:
TYPE ~
MACHINE
DEPENDENT {
unspec(0), -- unspecified
unix(1), -- local to host (pipes, portals)
inet(2), -- internetwork: UDP, TCP, etc.
impLink(3), -- arpanet imp addresses
pup(4), -- pup protocols: e.g. BSP
chaos(5), -- mit CHAOS protocols
ns(6), -- XEROX NS protocols
nbs(7), -- nbs protocols
ecma(8), -- european computer manufacturers
datakit(9), -- datakit protocols
ccitt(10), -- CCITT protocols, X.25 etc.
sna(11), -- IBM SNA
decNet(12), -- DECnet
dli(13), -- Direct data link interface
lat(14), -- LAT
hyLink(15), -- NSC Hyperchannel
appleTalk(16), -- Apple Talk
nit(17), -- Network Interface Tap
ieee802(18), -- IEEE 802.2, also ISO 8802
osi(19), -- umbrella for all families used by OSI (e.g. protosw lookup)
x25(20), -- CCITT X.25 in particular
osinet(21), -- AFI = 47, IDI = 4
gosip(22), -- U.S. Government OSI
(CARD16.LAST)
};
SockAddrPtr: TYPE ~ POINTER TO SockAddr;
SockAddr:
TYPE ~
WORD16
MACHINE
DEPENDENT
RECORD [
family(0): AddressFamily,
data(1): PACKED ARRAY[0..14) OF CHAR -- up to 14 bytes of direct address
];
ProtocolFamily:
TYPE ~
MACHINE
DEPENDENT {
-- same as address families for now
unspec(0), -- unspecified
unix(1), -- local to host (pipes, portals)
inet(2), -- internetwork: UDP, TCP, etc.
impLink(3), -- arpanet imp addresses
pup(4), -- pup protocols: e.g. BSP
chaos(5), -- mit CHAOS protocols
ns(6), -- XEROX NS protocols
nbs(7), -- nbs protocols
ecma(8), -- european computer manufacturers
datakit(9), -- datakit protocols
ccitt(10), -- CCITT protocols, X.25 etc.
sna(11), -- IBM SNA
decNet(12), -- DECnet
dli(13), -- Direct data link interface
lat(14), -- LAT
hyLink(15), -- NSC Hyperchannel
appleTalk(16), -- Apple Talk
nit(17), -- Network Interface Tap
ieee802(18), -- IEEE 802.2, also ISO 8802
osi(19), -- umbrella for all families used by OSI (e.g. protosw lookup)
x25(20), -- CCITT X.25 in particular
osinet(21), -- AFI = 47, IDI = 4
gosip(22), -- U.S. Government OSI
(CARD16.LAST)
};
MsgFlags:
TYPE ~
MACHINE
DEPENDENT
RECORD [
spare: [0..01fffffffH] ¬ 0,
dontRoute: Flag ¬ false, -- send without using routing tables
peek: Flag ¬ false, -- peek at incoming message
oob: Flag ¬ false -- process out-of-band data
];
SDHow:
TYPE ~
MACHINE
DEPENDENT {
noRecv(0), -- disable receives on the socket
noSend(1), -- disable sends on the socket
noSendOrRecv(2) -- disable both sends and receives
};
Structures and flags from <sys/stat.h>.
Fmt:
TYPE ~
MACHINE
DEPENDENT {
fifo(01B), -- fifo special
chr(02B), -- character special
dir(04B), -- directory
blk(06B), -- block special
reg(10B), -- regular file
lnk(12B), -- symbolic link
sock(14B), -- socket
(17B)
};
Permission:
TYPE ~
MACHINE
DEPENDENT
RECORD [
read: Flag,
write: Flag,
exec: Flag
];
Mode:
TYPE ~
MACHINE
DEPENDENT
RECORD [
fmt: Fmt ¬ LOOPHOLE[0], -- type of file
suid: Flag ¬ false, -- set user id on execution
sgid: Flag ¬ false, -- set group id on execution
svtx: Flag ¬ false, -- save swapped text even after use
owner: Permission ¬ [false, false, false],
group: Permission ¬ [false, false, false],
others: Permission ¬ [false, false, false]
];
StatPtr: TYPE ~ POINTER TO Stat;
Stat:
TYPE ~
MACHINE
DEPENDENT
RECORD [
dev: Dev, -- device inode resides on
pad0: INT16,
ino: INum, -- this inode's number
mode: Mode, -- protection
nlink: INT16, -- number of hard links to the file
uid: UID, -- user ID of owner
gid: GID, -- group ID of owner
rdev: Dev, -- the device type, for inode that is device
pad1: INT16,
size: CARD32, -- total size of file, in bytes
atime: Time, -- file last access time
spare1: INT32,
mtime: Time, -- file last modify time
spare2: INT32,
ctime: Time, -- file last status change time
spare3: INT32,
blksize: CARD32, -- optimal blocksize for file system i/o ops
blocks: CARD32, -- actual number of blocks allocated
spare4: ARRAY [0..2) OF INT32
];
Structure filled in by fstat.
Structures for GetRUsage
Who:
TYPE ~
INT;
children: Who = -1;
self: Who = 0;
RUsage:
TYPE ~
RECORD [
utime: TimeVal, -- user time used
stime: TimeVal, -- system time used
maxrss: INT, -- max resident set size
ixrss: INT, -- integral shared memory size
idrss: INT, -- integral unshared data
isrss: INT, -- integral unshared stack
minflt: INT, -- page reclaims
majflt: INT, -- page faults
nswap: INT, -- swaps
inblock: INT, -- block input operations
oublock: INT, -- block output operations
msgsnd: INT, -- messages sent
msgrcv: INT, -- messages received
nsignals: INT, -- signals received
nvcsw: INT, -- voluntary context switches
nivcsw: INT -- involuntary
];
Structure declarations from <sys/vfs.h>.
FileSystemID:
TYPE ~
MACHINE
DEPENDENT
RECORD [
val: ARRAY [0..2) OF CARD32
];
StatFSPtr: TYPE ~ POINTER TO StatFS;
StatFS:
TYPE ~
MACHINE
DEPENDENT
RECORD [
type: CARD32, -- type of info, zero for now
bsize: CARD32, -- fundamental file system block size
blocks: CARD32, -- total blocks in file system
bfree: CARD32, -- free blocks in file system
bavail: CARD32, -- free blocks available to non-superuser
files: CARD32, -- total file nodes in file system
ffree: CARD32, -- free file nodes in file system
fsid: FileSystemID, -- file system id
spare: ARRAY [0..7) OF CARD32
];
}.