## mythryl-callable-c-library-interface.api
#
# Compiled by:
#
src/lib/std/src/standard-core.sublib# This api is implemented in:
#
#
src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkgapi Mythryl_Callable_C_Library_Interface {
#
exception CFUN_NOT_FOUND String;
find_c_function: { lib_name: String, fun_name: String } -> (X -> Y);
#
# Fetches a Mythryl-callable C function by giving the
# library name and function name, which get looked up
# in the table defined in
#
# src/c/lib/mythryl-callable-c-libraries-list.h
#
# We raise the exception CFUN_NOT_FOUND if the function is unknown.
#
# A typical call looks like
#
# my tmp_name: Void -> String
# =
# ci::find_c_function { lib_name => "posix_os", fun_name => "tmpname" };
#
# where the type declaration is needed to assign a
# Mythryl-level type to the C function.
#
# The example is taken from
src/lib/std/src/posix/winix-file.pkg # The matching C code is in src/c/lib/posix-os/
# The following fn differs from the above one in that
# it is designed to support replacing the returned fn
# by an equivalent one, and to that end:
#
# 1) Returns a refcell holding the fn, rather than the bare fn.
# 2) Returns a fn which will update the contents of the refcell.
# (And also do internal bookkeeping.)
#
find_c_function'
:
{ lib_name: String, fun_name: String }
->
( Ref (X -> Y), # Refcell holding bare fn.
#
( { lib_name: String, # To update the refcell, the caller supplies a fn f which
fun_name: String, # will be given the original value of the refcell, of type (X -> Y)
io_call: (X -> Y) # and will return a new value for the refcell, also of type (X -> Y)
} # and then will use f to do the update.
-> #
(X -> Y) # The point of supplying the original value is of course that in general
) # caller will incorporate it in the new value -- the syscall still
-> Void # has to be performed at some point.
);
find_c_function''
:
{ lib_name: String, fun_name: String }
->
( X -> Y, # Bare fn.
#
Ref (X -> Y), # Refcell holding bare fn.
#
( { lib_name: String, # To update the refcell, the caller supplies a fn f which
fun_name: String, # will be given the original value of the refcell, of type (X -> Y)
io_call: (X -> Y) # and will return a new value for the refcell, also of type (X -> Y)
} # and then will use f to do the update.
-> #
(X -> Y) # The point of supplying the original value is of course that in general
) # caller will incorporate it in the new value -- the syscall still
-> Void # has to be performed at some point.
);
find_c_function'''
:
{ lib_name: String, fun_name: String }
->
( X -> Y, # Bare fn.
#
Ref (X -> Y), # Refcell holding bare fn.
#
( { lib_name: String, # To update the refcell, the caller supplies a fn f which
fun_name: String, # will be given the original value of the refcell, of type (X -> Y)
io_call: (X -> Y) # and will return a new value for the refcell, also of type (X -> Y)
} # and then will use f to do the update.
-> #
(X -> Y) # The point of supplying the original value is of course that in general
) # caller will incorporate it in the new value -- the syscall still
-> Void, # has to be performed at some point.
X -> Z, # Bare fn.
#
Ref (X -> Z), # Refcell holding bare mailop.
#
( { lib_name: String, # To update the refcell, the caller supplies a fn f which
fun_name: String, # will be given the original value of refcell -- not mailop_refcell, of type (X -> Y)
io_call: (X -> Y) # and will return a new value for the refcell, also of type (X -> Y)
} # and then will use f to do the update.
-> #
(X -> Z) # The point of supplying the original value is of course that in general
) # caller will incorporate it in the new value -- the syscall still
-> Void # has to be performed at some point.
);
restore_redirected_syscalls_to_direct_form # Restore all redirected syscalls to direct form (i.e., original setting).
:
Void -> Void;
# Utilities for working with system constants
#
System_Constant = { id: Int, name: String };
exception SYSTEM_CONSTANT_NOT_FOUND String;
find_system_constant: (String, List(System_Constant)) -> Null_Or(System_Constant); # Returns NULL if not found.
bind_system_constant: (String, List(System_Constant)) -> System_Constant; # Raises SYSTEM_CONSTANT_NOT_FOUND if not found.
# Cfunction;
# find_cfun: (String, String) -> Cfunction;
#
# I've commented the above two out because they
# are nowhere used and they are clearly low-level
# magic which should not be exported to higher
# levels of the system without excellent reason.
#
# I have not deleted them because they may be needed
# by Matthias Blume's call-C-fns-directly stuff, which is
# currently neither working nor in the unit test framework.
#
# -- CrT 2012-04-18
};
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.