Skip to main content

Module runtime

Module runtime 

Source
Expand description

Rust-native R C API runtime.

These functions deref raw SEXP pointers from C code โ€” this is inherently unsafe but required for C API compatibility. We suppress the clippy lint at module level since every function in this module works with raw pointers.

Implements the R C API functions (Rf_allocVector, Rf_protect, etc.) as extern "C" Rust functions that are compiled into the miniR binary. Package .so files resolve these symbols at load time.

setjmp/longjmp-based functions (Rf_error, _minir_call_protected) are in csrc/native_trampoline.c (compiled via build.rs) because longjmp is not safely callable from Rust.

Structsยง

AllocNode ๐Ÿ”’
Linked list node for tracking allocations.
ExtPtrData ๐Ÿ”’
InterpreterCallbacks
Callback function pointers set by the Rust interpreter before each .Call.
RCallMethodDef
Rcomplex
RuntimeState ๐Ÿ”’
Thread-local allocation state for the current .Call invocation. This is in the binary (shared by all packages), not per-.so.
SendPtr
Wrapper for raw pointers that is Send (safe because we only access from single-threaded contexts).

Constantsยง

STATE ๐Ÿ”’

Staticsยง

CCALLABLE ๐Ÿ”’
NIL_REC ๐Ÿ”’
REGISTERED_CALLS
Registered .Call methods โ€” shared across all packages in this runtime.
REGISTERED_C_METHODS
Registered .C methods โ€” shared across all packages in this runtime.
R_BaseEnv
R_BaseNamespace
R_BlankString
R_BraceSymbol
R_Bracket2Symbol
R_BracketSymbol
R_ClassSymbol
R_DimNamesSymbol
R_DimSymbol
R_DollarSymbol
R_DotsSymbol
R_DoubleColonSymbol
R_EmptyEnv
R_GlobalEnv
R_InputHandlers
R_Interactive
R_LevelsSymbol
R_MissingArg
R_NaInt
R_NaInt โ€” addressable NA_INTEGER constant for C code that takes &NA_INTEGER.
R_NaReal
R_NaReal โ€” addressable NA_REAL constant for C code that takes &NA_REAL.
R_NaString
R_NameSymbol
R_NamesSymbol
R_NamespaceRegistry
R_NilValue
R_NilValue โ€” exported to C code.
R_PolledEvents
R_RowNamesSymbol
R_Srcref
R_TripleColonSymbol
R_UnboundValue
R_interrupts_pending
R_interrupts_suspended
R_wait_usec
SYM_CLASS ๐Ÿ”’
SYM_DIM ๐Ÿ”’
SYM_DIMNAMES ๐Ÿ”’
SYM_DOTS ๐Ÿ”’
SYM_LEVELS ๐Ÿ”’
SYM_NAMES ๐Ÿ”’
SYM_ROWNAMES ๐Ÿ”’
_minir_current_dll_info

Functionsยง

BODY
CLOENV
ENCLOS
FORMALS
GetRNGstate
MARK_NOT_MUTABLE
PRCODE
PRENV
PREXPR
PRVALUE
PutRNGstate
R_ActiveBindingFunction
R_BindingIsActive
R_BindingIsLocked
R_CheckStack
R_CheckStack2
R_CheckUserInterrupt
R_ClearExternalPtr
R_ClosureBody
R_ClosureEnv
R_ClosureExpr
R_ClosureFormals
R_ContinueUnwind
R_EnvironmentIsLocked
R_ExecWithCleanup
R_ExpandFileName
R_ExternalPtrAddr
R_ExternalPtrAddrFn
R_ExternalPtrProtected
R_ExternalPtrTag
R_FindNamespace
R_FlushConsole
R_GetCCallable
R_GetConnection
R_IsNamespaceEnv
R_IsPackageEnv
R_LockBinding
R_MakeActiveBinding
R_MakeExternalPtr
R_MakeExternalPtrFn
R_MakeUnwindCont
R_MakeWeakRef
R_MakeWeakRefC
R_NamespaceEnvSpec
R_NewEnv
R_OrderVector1
R_PackageEnvName
R_ParentEnv
R_ParseVector
R_PreserveObject
R_PromiseExpr
R_ProtectWithIndex
R_RegisterCCallable
R_RegisterCFinalizer
R_RegisterCFinalizerEx
R_ReleaseObject
R_Reprotect
R_Serialize
R_SetExternalPtrAddr
R_SetExternalPtrProtected
R_SetExternalPtrTag
R_ToplevelExec
R_UnwindProtect
R_WeakRefKey
R_WeakRefValue
R_alloc
R_atof
R_check_class_etc
R_chk_calloc
R_chk_free
R_chk_realloc
R_compute_identical
R_do_MAKE_CLASS
R_do_new_object
R_do_slot
R_do_slot_assign
R_envHasNoSpecialSymbols
R_existsVarInFrame
R_finite
R_forceAndCall
R_forceSymbols
R_getClassDef
R_has_slot
R_isort
R_lsInternal3
R_new_custom_connection
R_qsort
R_qsort_I
R_qsort_int
R_qsort_int_I
R_registerRoutines
R_removeVarFromFrame
R_rsort
R_tryEval
R_tryEvalSilent
R_useDynamicSymbols
Rf_GetOption1
Rf_GetOptionWidth
Rf_ScalarComplex
Rf_ScalarInteger
Rf_ScalarLogical
Rf_ScalarRaw
Rf_ScalarReal
Rf_ScalarString
Rf_StringBlank
Rf_allocArray
Rf_allocList
Rf_allocMatrix
Rf_allocS4Object
Rf_allocSExp
Rf_allocVector
Rf_any_duplicated
Rf_any_duplicated3
Rf_asCharacterFactor
Rf_asInteger
Rf_asLogical
Rf_asReal
Rf_beta
Rf_choose
Rf_classgets
Rf_coerceVector
Rf_cons
Rf_copyMostAttrib
Rf_countContexts
Rf_defineVar
Rf_digamma
Rf_dimgets
Rf_dimnamesgets
Rf_dpsifn
Rf_duplicate
Rf_duplicated
Rf_eval
Rf_findFun
Rf_findVar
Rf_findVarInFrame
Rf_findVarInFrame3
Rf_fprec
Rf_fround
Rf_ftrunc
Rf_gammafn
Rf_getAttrib
Rf_getCharCE
Rf_inherits
Rf_install
Rf_installChar
Rf_installTrChar
Rf_isEnvironment
Rf_isFrame
Rf_isFunction
Rf_isInteger
Rf_isLanguage
Rf_isLogical
Rf_isMatrix
Rf_isNull
Rf_isNumeric
Rf_isObject
Rf_isPrimitive
Rf_isReal
Rf_isS4
Rf_isString
Rf_isSymbol
Rf_isVector
Rf_isVectorAtomic
Rf_isVectorList
Rf_lang1
Rf_lang2
Rf_lang3
Rf_lang4
Rf_lang5
Rf_lang6
Rf_lbeta
Rf_lchoose
Rf_lcons
Rf_length
Rf_lengthgets
Rf_lengthgets โ€” resize a vector (copy into a new allocation).
Rf_lgamma1p
Rf_lgammafn
Rf_lgammafn_sign
Rf_log1pmx
Rf_logspace_add
Rf_logspace_sub
Rf_match
Rf_mkChar
Rf_mkCharCE
Rf_mkCharLen
Rf_mkCharLenCE
Rf_mkNamed
Rf_mkString
Rf_namesgets
Rf_nchar
Rf_ncols
Rf_nrows
Rf_nthcdr
Rf_onintr
Rf_pentagamma
Rf_protect
Rf_psigamma
Rf_reEnc
Rf_setAttrib
Rf_shallow_duplicate
Rf_sign
Rf_str2type
Rf_tetragamma
Rf_translateChar
Rf_trigamma
Rf_type2char
Rf_type2str
Rf_ucstoutf8
Rf_unprotect
Rf_xlength
Rf_xlengthgets
SET_BODY
SET_CLOENV
SET_ENCLOS
SET_FORMALS
SET_FRAME
SET_HASHTAB
SET_PRCODE
SET_PRENV
SET_PRVALUE
S_alloc
S_realloc
addInputHandler
beta
calloc ๐Ÿ”’ โš 
chol_
choose
clear_callbacks
Clear interpreter callbacks after .Call returns.
dbinom
dgemm_
dgemv_
dnorm
dpois
dpotrf_
dpotri_
dqrdc2_
dqrsl_
dsyrk_
dtrsl_
dtrsm_
exp_rand
find_registered_c_method
Look up a registered .C method by name. Returns the function pointer or null.
find_registered_call
Look up a registered .Call method by name. Returns the function pointer or null.
free ๐Ÿ”’ โš 
free_allocs
Free all tracked allocations (called by Rust after .Call). Persistent SEXPs (external pointers, flags=1) are kept alive.
gammafn
get_stashed_rvalue ๐Ÿ”’
Retrieve a stashed RValue by index. Used by Rf_eval.
iPsort
init_global_envs
Initialize the global R_BaseEnv, R_GlobalEnv, R_EmptyEnv SEXPs from interpreter envs. Called once from the package loader before the first .Call.
init_globals
Initialize global sentinels. Called once at interpreter startup.
langsxp_to_text ๐Ÿ”’
Decompile a pairlist-style LANGSXP into R source text.
lbeta
lchoose
lgammafn
log1pexp
nmmin
norm_rand
optif9
pgamma
pnorm
ps__define_errno
ps__list_apps
qchisq
qgamma
qnorm
rPsort
rbinom
realloc ๐Ÿ”’ โš 
register_call_methods ๐Ÿ”’
registered_c_method_names
Get all registered .C method names.
registered_call_names
Get all registered .Call method names.
removeInputHandler
revsort
rexp
rlang_ccallable_sexp_stub ๐Ÿ”’
Stub for rlang CCallable functions that return SEXP.
rlang_ccallable_str_stub ๐Ÿ”’
Stub for rlang CCallable functions that return const char*.
rnorm
rpois
rs_
rsort_with_index
runif
set_callbacks
Set interpreter callbacks for the current .Call invocation.
sexp_to_text_repr ๐Ÿ”’
Convert a SEXP value to its text representation for decompilation.
stash_rvalue ๐Ÿ”’
Stash an RValue and return its index. Used by R_ParseVector.
sym_eq ๐Ÿ”’
track ๐Ÿ”’
unif_rand
vmmin

Type Aliasesยง

CbResult ๐Ÿ”’
Result type for interpreter callbacks.
RCMethodDef ๐Ÿ”’
R_CMethodDef has the same layout as R_CallMethodDef (name, fun, numArgs).