## winix-io--premicrothread.api
#
# A sub-api of api Winix__Premicrothread:
#
#
src/lib/std/src/winix/winix--premicrothread.api# Compiled by:
#
src/lib/std/src/standard-core.sublibstipulate
package i1w = one_word_int_guts; # one_word_int_guts is from
src/lib/std/src/one-word-int-guts.pkg package wty = winix_types; # winix_types is from
src/lib/std/src/posix/winix-types.pkgherein
# This api is implemented in:
#
#
src/lib/std/src/posix/winix-io--premicrothread.pkg #
api Winix_Io__Premicrothread {
#
eqtype Iod; # "Iod" == "I/O descriptor".
# An Iod is an abstract descriptor for an OS entity that supports I/O
# (e::g., file, tty device, socket, ...).
# On posix, in practice it is an Int encoding a host-OS fd.
Iod_Kind = FILE # On posix defined by psx::stat::is_file
| DIRECTORY
# On posix defined by psx::stat::is_directory
| SYMLINK
# On posix defined by psx::stat::is_symlink
| CHAR_DEVICE
# On posix defined by psx::stat::is_char_dev
| BLOCK_DEVICE
# On posix defined by psx::stat::is_block_dev
| PIPE
# On posix defined by psx::stat::is_pipe
| SOCKET
# On posix defined by psx::stat::is_socket
| OTHER
# Future-proofing.
;
hash: Iod -> Unt; # Return a hash value for the I/O descriptor.
compare: (Iod, Iod) -> Order; # Compare two I/O descriptors
iod_to_iodkind: Iod -> wty::Iod_Kind; # Return the kind of I/O descriptor: FILE
|DIR|SYMLINK|TTY|PIPE|SOCKET|DEVICE|OTHER.
# Existing code uses this only to check for TTY, mostly to select line-buffering vs block buffering.
Ioplea
=
{ io_descriptor: Iod,
readable: Bool,
writable: Bool,
oobdable: Bool # Out-Of-Band-Data available on socket or PTY.
};
# Public representation of a polling operation on
# an I/O descriptor.
Ioplea_Result = Ioplea; # A synonym to clarify declarations.
exception BAD_WAIT_REQUEST;
# Block on a set of I/O descriptors until
# an I/O opportunity arises or until
# specified timeout expires.
#
# See also the 'wait_for_io_opportunity' operation in:
src/lib/std/src/socket/socket--premicrothread.api #
wait_for_io_opportunity
:
{ wait_requests: List( Ioplea ),
timeout: Null_Or( time::Time ) # Timeout: NULL means wait forever, (THE time::zero_time) means do not block.
}
->
List( Ioplea_Result );
wait_for_io_opportunity__without_syscall_redirection # Use this in secondary hostthreads like
src/lib/std/src/hostthread/io-wait-hostthread.pkg :
{ wait_requests: List( Ioplea ),
timeout: Null_Or( time::Time )
}
->
List( Ioplea_Result );
#######################################################################
# Below stuff is intended only for one-time use during
# booting, to switch from direct to indirect syscalls: # For background see Note[1] in
src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg poll__syscall: (((List((Int,Unt)),Null_Or((i1w::Int,Int)))) -> List((Int,Unt)));
set__poll__ref: ( { lib_name: String, fun_name: String, io_call: (((List((Int,Unt)),Null_Or((i1w::Int,Int)))) -> List((Int,Unt))) } -> (((List((Int,Unt)),Null_Or((i1w::Int,Int)))) -> List((Int,Unt)))) -> Void;
}; # api Winix_Io__Premicrothread
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.