Skip to main content

miniextendr_api/
sys.rs

1//! Raw FFI bindings to R headers.
2//!
3//! This module mirrors R's C API closely and is intentionally thin. **You
4//! almost never call these directly from user code** — prefer the
5//! higher-level wrappers: `SEXP` (in [`crate::sexp`]), [`SexpExt`] (in
6//! [`crate::sexp_ext`]), the type vocabulary in [`crate::sexp_types`], plus
7//! [`IntoR`], [`TryFromSexp`], [`with_r_thread`], [`with_r_unwind_protect`],
8//! and the `#[miniextendr]` proc-macro. The items here exist so those
9//! wrappers can be written; treat them as the framework's escape hatch.
10//!
11//! [`SexpExt`]: crate::sexp_ext::SexpExt
12//! [`IntoR`]: crate::IntoR
13//! [`TryFromSexp`]: crate::TryFromSexp
14//! [`with_r_thread`]: crate::worker::with_r_thread
15//! [`with_r_unwind_protect`]: crate::unwind_protect::with_r_unwind_protect
16//!
17//! # Checked vs `*_unchecked` variants
18//!
19//! Most non-variadic R API entry points come in two forms thanks to the
20//! [`#[r_ffi_checked]`](miniextendr_macros::r_ffi_checked) proc-macro applied
21//! to the `unsafe extern "C-unwind"` blocks below:
22//!
23//! - **Checked** (default — e.g. `Rf_allocVector`, `Rf_protect`, `INTEGER`):
24//!   runs directly on R's main thread, routes through
25//!   [`crate::worker::with_r_thread`] from an active miniextendr worker
26//!   context, and panics for arbitrary off-main callers. **Use these by
27//!   default.**
28//! - **`*_unchecked`** (e.g. `Rf_allocVector_unchecked`): bypass the assertion
29//!   and the worker round-trip. Calling one off the R main thread is
30//!   undefined behaviour. They exist for three known-safe contexts:
31//!     1. Inside ALTREP callbacks — R is already calling us on the main thread.
32//!     2. Inside a [`crate::unwind_protect::with_r_unwind_protect`] body —
33//!        the guard has already established main-thread context.
34//!     3. Inside a [`crate::worker::with_r_thread`] body — the check would be
35//!        redundant.
36//!
37//! The build-time lint **MXL301** enforces this: any `*_unchecked` call
38//! outside those contexts is a compile-time error.
39//!
40//! # Don't raise R errors directly
41//!
42//! `Rf_error`, `Rf_errorcall`, and their `_unchecked` siblings longjmp,
43//! which **skips Rust destructors** and leaks resources. The lint **MXL300**
44//! forbids them in user code. Use `panic!()` instead; the framework converts
45//! the panic into a structured R condition with `rust_*` class layering via
46//! the tagged-SEXP transport (see [`crate::error_value`]).
47//!
48//! # Cross references
49//!
50//! - [`crate::ffi_guard`] — guard taxonomy and worker-thread invariants.
51//! - [`crate::thread`] / [`crate::worker`] — worker / main-thread split.
52//! - [`crate::altrep_traits`] / [`crate::altrep_bridge`] — guard modes
53//!   inside ALTREP callbacks.
54//! - [`crate::error_value`] / [`mod@crate::condition`] — panic → R condition
55//!   transport.
56
57/// Raw ALTREP C API method type aliases.
58pub mod altrep;
59
60// `extern "C-unwind"` signatures below reference the type vocabulary by
61// bare name. Bring it into scope as a private `use` (NOT `pub use`) — the
62// vocab's canonical home is the crate root (`crate::SEXP`, etc.) and
63// `crate::sexp_types` for the niche helpers. Adding these to the public
64// API of `sys::` would re-create the bridge.
65use crate::sexp::SEXP;
66use crate::sexp_types::{R_CFinalizer_t, R_xlen_t, Rboolean, Rbyte, Rcomplex, SEXPTYPE, cetype_t};
67
68// region: Connections types (gated behind `connections` feature)
69// WARNING: R's connection API is explicitly marked as UNSTABLE.
70
71/// Opaque R connection implementation (from R_ext/Connections.h).
72///
73/// This is an opaque type representing R's internal connection structure.
74/// The actual structure is explicitly unstable and may change between R versions.
75#[cfg(feature = "connections")]
76#[repr(C)]
77#[allow(non_camel_case_types)]
78pub struct Rconnection_impl(::std::os::raw::c_void);
79
80/// Pointer to an R connection handle.
81///
82/// This is the typed equivalent of R's `Rconnection` type, which is a pointer
83/// to the opaque `Rconn` struct. Using this instead of `*mut c_void` provides
84/// type safety for connection APIs.
85#[cfg(feature = "connections")]
86#[allow(non_camel_case_types)]
87pub type Rconnection = *mut Rconnection_impl;
88
89/// R connections API version from R's `R_ext/Connections.h` at compile time.
90///
91/// This is a compile-time constant baked into the Rust FFI bindings when they
92/// were generated against a particular R version's headers. It does **not**
93/// dynamically probe the running R session.
94///
95/// From R_ext/Connections.h: "you *must* check the version and proceed only
96/// if it matches what you expect. We explicitly reserve the right to change
97/// the connection implementation without a compatibility layer."
98///
99/// Before using any connection APIs, check that this equals the expected version (1).
100#[cfg(feature = "connections")]
101#[allow(non_upper_case_globals)]
102pub const R_CONNECTIONS_VERSION: ::std::os::raw::c_int = 1;
103
104// endregion
105
106use miniextendr_macros::r_ffi_checked;
107
108// Unchecked variadic functions (internal use only, no thread check)
109#[allow(clashing_extern_declarations)]
110#[allow(varargs_without_pattern)]
111unsafe extern "C-unwind" {
112    /// Unchecked variadic `Rf_error`; call checked wrapper when possible.
113    #[link_name = "Rf_error"]
114    pub fn Rf_error_unchecked(arg1: *const ::std::os::raw::c_char, ...) -> !;
115    /// Unchecked variadic `Rf_errorcall`; call checked wrapper when possible.
116    #[link_name = "Rf_errorcall"]
117    pub fn Rf_errorcall_unchecked(arg1: SEXP, arg2: *const ::std::os::raw::c_char, ...) -> !;
118    /// Unchecked variadic `Rf_warning`; call checked wrapper when possible.
119    #[link_name = "Rf_warning"]
120    pub fn Rf_warning_unchecked(arg1: *const ::std::os::raw::c_char, ...);
121    /// Unchecked variadic `Rprintf`; call checked wrapper when possible.
122    #[link_name = "Rprintf"]
123    pub fn Rprintf_unchecked(arg1: *const ::std::os::raw::c_char, ...);
124    /// Unchecked variadic `REprintf`; call checked wrapper when possible.
125    #[link_name = "REprintf"]
126    pub fn REprintf_unchecked(arg1: *const ::std::os::raw::c_char, ...);
127}
128
129// Error message access (non-API, declared in Rinternals.h but flagged by R CMD check)
130#[cfg(feature = "nonapi")]
131unsafe extern "C-unwind" {
132    /// Get the current R error message buffer.
133    ///
134    /// Returns a pointer to R's internal error message buffer.
135    /// Used by Rserve and other embedding applications.
136    ///
137    /// # Safety
138    ///
139    /// - The returned pointer is only valid until the next R error
140    /// - Must not be modified
141    /// - Should be copied if needed beyond the immediate scope
142    ///
143    /// # Feature Gate
144    ///
145    /// This is a non-API function and requires the `nonapi` feature.
146    #[allow(non_snake_case, dead_code)] // used by worker.rs under worker-thread feature
147    pub(crate) fn R_curErrorBuf() -> *const ::std::os::raw::c_char;
148}
149
150// Console hooks (non-API; declared in Rinterface.h)
151#[cfg(feature = "nonapi")]
152unsafe extern "C-unwind" {
153    #[expect(dead_code, reason = "declared for future use")]
154    pub(crate) static ptr_R_WriteConsoleEx: Option<
155        unsafe extern "C-unwind" fn(
156            *const ::std::os::raw::c_char,
157            ::std::os::raw::c_int,
158            ::std::os::raw::c_int,
159        ),
160    >;
161}
162
163/// Checked wrapper for `Rf_error` - panics if called from non-main thread.
164/// Common usage: `Rf_error(c"%s".as_ptr(), message.as_ptr())`
165///
166/// # Safety
167///
168/// - Must be called from the R main thread
169/// - `fmt` and `arg1` must be valid null-terminated C strings
170#[inline(always)]
171#[allow(non_snake_case)]
172pub unsafe fn Rf_error(
173    fmt: *const ::std::os::raw::c_char,
174    arg1: *const ::std::os::raw::c_char,
175) -> ! {
176    if !crate::worker::is_r_main_thread() {
177        {
    ::core::panicking::panic_fmt(format_args!("Rf_error called from non-main thread"));
};panic!("Rf_error called from non-main thread");
178    }
179    unsafe { Rf_error_unchecked(fmt, arg1) }
180}
181
182/// Checked wrapper for `Rf_errorcall` - panics if called from non-main thread.
183///
184/// # Safety
185///
186/// - Must be called from the R main thread
187/// - `call` must be a valid SEXP or R_NilValue
188/// - `fmt` and `arg1` must be valid null-terminated C strings
189#[inline(always)]
190#[allow(non_snake_case)]
191pub unsafe fn Rf_errorcall(
192    call: SEXP,
193    fmt: *const ::std::os::raw::c_char,
194    arg1: *const ::std::os::raw::c_char,
195) -> ! {
196    if !crate::worker::is_r_main_thread() {
197        {
    ::core::panicking::panic_fmt(format_args!("Rf_errorcall called from non-main thread"));
};panic!("Rf_errorcall called from non-main thread");
198    }
199    unsafe { Rf_errorcall_unchecked(call, fmt, arg1) }
200}
201
202/// Checked wrapper for `Rf_warning` - panics if called from non-main thread.
203///
204/// # Safety
205///
206/// - Must be called from the R main thread
207/// - `fmt` and `arg1` must be valid null-terminated C strings
208#[inline(always)]
209#[allow(non_snake_case)]
210pub unsafe fn Rf_warning(fmt: *const ::std::os::raw::c_char, arg1: *const ::std::os::raw::c_char) {
211    if !crate::worker::is_r_main_thread() {
212        {
    ::core::panicking::panic_fmt(format_args!("Rf_warning called from non-main thread"));
};panic!("Rf_warning called from non-main thread");
213    }
214    unsafe { Rf_warning_unchecked(fmt, arg1) }
215}
216
217/// Checked wrapper for `Rprintf` - panics if called from non-main thread.
218///
219/// # Safety
220///
221/// - Must be called from the R main thread
222/// - `fmt` and `arg1` must be valid null-terminated C strings
223#[inline(always)]
224#[allow(non_snake_case)]
225pub unsafe fn Rprintf(fmt: *const ::std::os::raw::c_char, arg1: *const ::std::os::raw::c_char) {
226    if !crate::worker::is_r_main_thread() {
227        {
    ::core::panicking::panic_fmt(format_args!("Rprintf called from non-main thread"));
};panic!("Rprintf called from non-main thread");
228    }
229    unsafe { Rprintf_unchecked(fmt, arg1) }
230}
231
232/// Print to R's stderr (via R_ShowMessage or error console).
233///
234/// # Safety
235///
236/// - Must be called from the R main thread
237/// - `fmt` and `arg1` must be valid null-terminated C strings
238#[inline(always)]
239#[allow(non_snake_case)]
240pub unsafe fn REprintf(fmt: *const ::std::os::raw::c_char, arg1: *const ::std::os::raw::c_char) {
241    if !crate::worker::is_r_main_thread() {
242        {
    ::core::panicking::panic_fmt(format_args!("REprintf called from non-main thread"));
};panic!("REprintf called from non-main thread");
243    }
244    unsafe { REprintf_unchecked(fmt, arg1) }
245}
246
247// Imported R symbols and functions with runtime thread checks enabled.
248#[allow(missing_docs)]
249#[allow(missing_docs)]
#[allow(clashing_extern_declarations)]
unsafe extern "C-unwind" {
    #[doc = " The canonical R `NULL` value."]
    pub static R_NilValue: SEXP;
    #[doc(alias = "NA_STRING")]
    #[doc = " Missing string singleton — encapsulated by SEXP::na_string()"]
    pub static R_NaString: SEXP;
    #[doc = " Empty string CHARSXP — encapsulated by SEXP::blank_string()"]
    pub static R_BlankString: SEXP;
    #[doc = " Symbol for `names` attribute."]
    pub static R_NamesSymbol: SEXP;
    pub static R_DimSymbol: SEXP;
    pub static R_DimNamesSymbol: SEXP;
    pub static R_ClassSymbol: SEXP;
    pub static R_RowNamesSymbol: SEXP;
    pub static R_LevelsSymbol: SEXP;
    pub static R_TspSymbol: SEXP;
    #[doc = " Global environment (`.GlobalEnv`)."]
    pub static R_GlobalEnv: SEXP;
    #[doc = " Base package namespace environment."]
    pub static R_BaseEnv: SEXP;
    #[doc = " Empty root environment."]
    pub static R_EmptyEnv: SEXP;
    #[doc =
    " Base package namespace — encapsulated by SEXP::base_namespace()"]
    pub static R_BaseNamespace: SEXP;
    #[doc = " The \"missing argument\" sentinel value."]
    #[doc = ""]
    #[doc =
    " When an R function is called without providing a value for a formal"]
    #[doc =
    " argument, R passes `R_MissingArg` as a placeholder. This is different"]
    #[doc =
    " from `R_NilValue` (NULL) - a missing argument means \"not provided\","]
    #[doc = " while NULL is an explicit value."]
    #[doc = ""]
    #[doc = " In R: `f <- function(x) missing(x); f()` returns `TRUE`."]
    #[doc = " Encapsulated by SEXP::missing_arg()"]
    pub static R_MissingArg: SEXP;
    #[doc =
    " Sentinel returned by `R_getVarEx` (via its `ifnotfound` argument) when"]
    #[doc = " the symbol has no binding in the searched frame(s)."]
    pub static R_UnboundValue: SEXP;
    #[doc = "Unchecked FFI binding for `R_FlushConsole`."]
    #[doc = "Generated from source location line 296, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_FlushConsole"]
    pub(crate) fn R_FlushConsole_unchecked();
    #[doc(alias = "mkChar")]
    #[doc = "Unchecked FFI binding for `Rf_mkChar`."]
    #[doc = "Generated from source location line 312, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_mkChar"]
    pub fn Rf_mkChar_unchecked(s: *const ::std::os::raw::c_char)
    -> SEXP;
    #[doc(alias = "mkCharLen")]
    #[doc = "Unchecked FFI binding for `Rf_mkCharLen`."]
    #[doc = "Generated from source location line 314, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_mkCharLen"]
    pub fn Rf_mkCharLen_unchecked(s: *const ::std::os::raw::c_char, len: i32)
    -> SEXP;
    #[doc(alias = "mkCharLenCE")]
    #[doc = "Unchecked FFI binding for `Rf_mkCharLenCE`."]
    #[doc = "Generated from source location line 316, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_mkCharLenCE"]
    pub fn Rf_mkCharLenCE_unchecked(x: *const ::std::os::raw::c_char,
    len: ::std::os::raw::c_int, ce: cetype_t)
    -> SEXP;
    #[doc(alias = "xlength")]
    #[doc(alias = "XLENGTH")]
    #[doc = "Unchecked FFI binding for `Rf_xlength`."]
    #[doc = "Generated from source location line 323, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_xlength"]
    pub fn Rf_xlength_unchecked(x: SEXP)
    -> R_xlen_t;
    #[doc(alias = "translateCharUTF8")]
    #[doc = "Unchecked FFI binding for `Rf_translateCharUTF8`."]
    #[doc = "Generated from source location line 325, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_translateCharUTF8"]
    pub fn Rf_translateCharUTF8_unchecked(x: SEXP)
    -> *const ::std::os::raw::c_char;
    #[doc(alias = "getCharCE")]
    #[doc = "Unchecked FFI binding for `Rf_getCharCE`."]
    #[doc = "Generated from source location line 327, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_getCharCE"]
    pub fn Rf_getCharCE_unchecked(x: SEXP)
    -> cetype_t;
    #[doc(alias = "charIsASCII")]
    #[doc = "Unchecked FFI binding for `Rf_charIsASCII`."]
    #[doc = "Generated from source location line 329, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_charIsASCII"]
    pub fn Rf_charIsASCII_unchecked(x: SEXP)
    -> Rboolean;
    #[doc(alias = "charIsUTF8")]
    #[doc = "Unchecked FFI binding for `Rf_charIsUTF8`."]
    #[doc = "Generated from source location line 331, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_charIsUTF8"]
    pub fn Rf_charIsUTF8_unchecked(x: SEXP)
    -> Rboolean;
    #[doc(alias = "charIsLatin1")]
    #[doc = "Unchecked FFI binding for `Rf_charIsLatin1`."]
    #[doc = "Generated from source location line 333, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_charIsLatin1"]
    pub fn Rf_charIsLatin1_unchecked(x: SEXP)
    -> Rboolean;
    #[doc = "Unchecked FFI binding for `R_MakeUnwindCont`."]
    #[doc = "Generated from source location line 336, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_MakeUnwindCont"]
    pub(crate) fn R_MakeUnwindCont_unchecked()
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_ContinueUnwind`."]
    #[doc = "Generated from source location line 337, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ContinueUnwind"]
    pub(crate) fn R_ContinueUnwind_unchecked(cont: SEXP)
    -> !;
    #[doc = "Unchecked FFI binding for `R_UnwindProtect`."]
    #[doc = "Generated from source location line 338, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_UnwindProtect"]
    pub(crate) fn R_UnwindProtect_unchecked(fun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)
            -> SEXP>, fun_data: *mut ::std::os::raw::c_void,
    cleanfun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void,
            Rboolean)>, cleanfun_data: *mut ::std::os::raw::c_void,
    cont: SEXP)
    -> SEXP;
    #[doc =
    " Version of `R_UnwindProtect` that accepts `extern \"C-unwind\"` function pointers"]
    #[link_name = "R_UnwindProtect"]
    pub(crate) fn R_UnwindProtect_C_unwind(fun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)
            -> SEXP>, fun_data: *mut ::std::os::raw::c_void,
    cleanfun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void,
            Rboolean)>, cleanfun_data: *mut ::std::os::raw::c_void,
    cont: SEXP)
    -> SEXP;
    #[doc = " External pointer interface"]
    #[doc = "Unchecked FFI binding for `R_MakeExternalPtr`."]
    #[doc = "Generated from source location line 367, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_MakeExternalPtr"]
    pub(crate) fn R_MakeExternalPtr_unchecked(p: *mut ::std::os::raw::c_void,
    tag: SEXP, prot: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_ExternalPtrAddr`."]
    #[doc = "Generated from source location line 368, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ExternalPtrAddr"]
    pub fn R_ExternalPtrAddr_unchecked(s: SEXP)
    -> *mut ::std::os::raw::c_void;
    #[doc = "Unchecked FFI binding for `R_ExternalPtrTag`."]
    #[doc = "Generated from source location line 369, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ExternalPtrTag"]
    pub(crate) fn R_ExternalPtrTag_unchecked(s: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_ExternalPtrProtected`."]
    #[doc = "Generated from source location line 370, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ExternalPtrProtected"]
    pub(crate) fn R_ExternalPtrProtected_unchecked(s: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_ClearExternalPtr`."]
    #[doc = "Generated from source location line 371, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ClearExternalPtr"]
    pub(crate) fn R_ClearExternalPtr_unchecked(s: SEXP);
    #[doc = "Unchecked FFI binding for `R_SetExternalPtrAddr`."]
    #[doc = "Generated from source location line 372, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_SetExternalPtrAddr"]
    pub(crate) fn R_SetExternalPtrAddr_unchecked(s: SEXP,
    p: *mut ::std::os::raw::c_void);
    #[doc = "Unchecked FFI binding for `R_SetExternalPtrTag`."]
    #[doc = "Generated from source location line 373, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_SetExternalPtrTag"]
    pub(crate) fn R_SetExternalPtrTag_unchecked(s: SEXP, tag: SEXP);
    #[doc = "Unchecked FFI binding for `R_SetExternalPtrProtected`."]
    #[doc = "Generated from source location line 374, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_SetExternalPtrProtected"]
    pub(crate) fn R_SetExternalPtrProtected_unchecked(s: SEXP, p: SEXP);
    #[doc = " Added in R 3.4.0"]
    #[doc = "Unchecked FFI binding for `R_MakeExternalPtrFn`."]
    #[doc = "Generated from source location line 376, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_MakeExternalPtrFn"]
    pub fn R_MakeExternalPtrFn_unchecked(p: DL_FUNC, tag: SEXP, prot: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_ExternalPtrAddrFn`."]
    #[doc = "Generated from source location line 377, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ExternalPtrAddrFn"]
    pub fn R_ExternalPtrAddrFn_unchecked(s: SEXP)
    -> DL_FUNC;
    #[doc = "Unchecked FFI binding for `R_RegisterFinalizer`."]
    #[doc = "Generated from source location line 378, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_RegisterFinalizer"]
    pub fn R_RegisterFinalizer_unchecked(s: SEXP, fun: SEXP);
    #[doc = "Unchecked FFI binding for `R_RegisterCFinalizer`."]
    #[doc = "Generated from source location line 379, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_RegisterCFinalizer"]
    pub(crate) fn R_RegisterCFinalizer_unchecked(s: SEXP,
    fun: R_CFinalizer_t);
    #[doc = "Unchecked FFI binding for `R_RegisterFinalizerEx`."]
    #[doc = "Generated from source location line 380, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_RegisterFinalizerEx"]
    pub fn R_RegisterFinalizerEx_unchecked(s: SEXP, fun: SEXP,
    onexit: Rboolean);
    #[doc = "Unchecked FFI binding for `R_RegisterCFinalizerEx`."]
    #[doc = "Generated from source location line 381, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_RegisterCFinalizerEx"]
    pub(crate) fn R_RegisterCFinalizerEx_unchecked(s: SEXP,
    fun: R_CFinalizer_t, onexit: Rboolean);
    #[doc = " Register a C-callable function for cross-package access."]
    #[doc = "Unchecked FFI binding for `R_RegisterCCallable`."]
    #[doc = "Generated from source location line 386, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_RegisterCCallable"]
    pub(crate) fn R_RegisterCCallable_unchecked(package:
        *const ::std::os::raw::c_char, name: *const ::std::os::raw::c_char,
    fptr: DL_FUNC);
    #[doc = " Get a C-callable function from another package."]
    #[doc = "Unchecked FFI binding for `R_GetCCallable`."]
    #[doc = "Generated from source location line 392, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_GetCCallable"]
    pub(crate) fn R_GetCCallable_unchecked(package:
        *const ::std::os::raw::c_char, name: *const ::std::os::raw::c_char)
    -> DL_FUNC;
    #[doc = " Add a SEXP to the protect stack, preventing GC collection."]
    #[doc = ""]
    #[doc =
    " **Cost: O(1)** — single array write (`R_PPStack[top++] = s`). No allocation."]
    #[doc = ""]
    #[doc =
    " Must be balanced by a corresponding `Rf_unprotect`. The protect stack is"]
    #[doc =
    " LIFO — nested scopes are safe, but interleaved usage from different scopes"]
    #[doc = " will cause incorrect unprotection."]
    #[doc(alias = "PROTECT")]
    #[doc(alias = "protect")]
    #[doc = "Unchecked FFI binding for `Rf_protect`."]
    #[doc = "Generated from source location line 440, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_protect"]
    pub fn Rf_protect_unchecked(s: SEXP)
    -> SEXP;
    #[doc = " Pop the top `l` entries from the protect stack."]
    #[doc = ""]
    #[doc =
    " **Cost: O(1)** — single integer subtract (`R_PPStackTop -= l`). No allocation."]
    #[doc = ""]
    #[doc =
    " The popped SEXPs become eligible for GC. Must match the number of"]
    #[doc = " `Rf_protect` calls in the current scope (LIFO order)."]
    #[doc(alias = "UNPROTECT")]
    #[doc(alias = "unprotect")]
    #[doc = "Unchecked FFI binding for `Rf_unprotect`."]
    #[doc = "Generated from source location line 450, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_unprotect"]
    pub fn Rf_unprotect_unchecked(l: ::std::os::raw::c_int);
    #[doc = " Remove a specific SEXP from anywhere in the protect stack."]
    #[doc = ""]
    #[doc =
    " **Cost: O(k)** — scans backwards from top (k = distance from top), then"]
    #[doc =
    " shifts remaining entries down. No allocation. R source comment:"]
    #[doc = " *\"should be among the top few items\"*."]
    #[doc = ""]
    #[doc =
    " Unlike `Rf_unprotect`, this is order-independent — it finds and removes"]
    #[doc =
    " the specific pointer regardless of stack position. Useful when LIFO"]
    #[doc =
    " discipline cannot be maintained, but more expensive than `Rf_unprotect`."]
    #[doc(alias = "UNPROTECT_PTR")]
    #[doc = "Unchecked FFI binding for `Rf_unprotect_ptr`."]
    #[doc = "Generated from source location line 462, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_unprotect_ptr"]
    pub fn Rf_unprotect_ptr_unchecked(s: SEXP);
    #[doc =
    " Add a SEXP to the global precious list, preventing GC indefinitely."]
    #[doc = ""]
    #[doc =
    " **Cost: O(1) but allocates a CONSXP cell** — creates GC pressure on every"]
    #[doc =
    " call. The precious list is a global linked list (`R_PreciousList`)."]
    #[doc = ""]
    #[doc =
    " Use only for long-lived objects (e.g., ExternalPtr stored across R calls)."]
    #[doc =
    " For temporary protection within a function, prefer `Rf_protect`."]
    #[doc = "Unchecked FFI binding for `R_PreserveObject`."]
    #[doc = "Generated from source location line 471, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_PreserveObject"]
    pub fn R_PreserveObject_unchecked(object: SEXP);
    #[doc = " Remove a SEXP from the global precious list, allowing GC."]
    #[doc = ""]
    #[doc =
    " **Cost: O(n)** — linear scan of the entire precious list to find and unlink"]
    #[doc =
    " the cons cell. With `R_HASH_PRECIOUS` env var, O(bucket_size) average"]
    #[doc = " via a 1069-bucket hash table, but this is off by default."]
    #[doc = "Unchecked FFI binding for `R_ReleaseObject`."]
    #[doc = "Generated from source location line 478, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ReleaseObject"]
    pub fn R_ReleaseObject_unchecked(object: SEXP);
    #[doc(alias = "allocVector")]
    #[doc = "Unchecked FFI binding for `Rf_allocVector`."]
    #[doc = "Generated from source location line 483, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_allocVector"]
    pub fn Rf_allocVector_unchecked(sexptype: SEXPTYPE, length: R_xlen_t)
    -> SEXP;
    #[doc(alias = "allocMatrix")]
    #[doc = "Unchecked FFI binding for `Rf_allocMatrix`."]
    #[doc = "Generated from source location line 485, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_allocMatrix"]
    pub fn Rf_allocMatrix_unchecked(sexptype: SEXPTYPE,
    nrow: ::std::os::raw::c_int, ncol: ::std::os::raw::c_int)
    -> SEXP;
    #[doc(alias = "allocArray")]
    #[doc = "Unchecked FFI binding for `Rf_allocArray`."]
    #[doc = "Generated from source location line 491, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_allocArray"]
    pub fn Rf_allocArray_unchecked(sexptype: SEXPTYPE, dims: SEXP)
    -> SEXP;
    #[doc(alias = "alloc3DArray")]
    #[doc = "Unchecked FFI binding for `Rf_alloc3DArray`."]
    #[doc = "Generated from source location line 493, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_alloc3DArray"]
    pub fn Rf_alloc3DArray_unchecked(sexptype: SEXPTYPE,
    nrow: ::std::os::raw::c_int, ncol: ::std::os::raw::c_int,
    nface: ::std::os::raw::c_int)
    -> SEXP;
    #[doc(alias = "allocList")]
    #[doc = "Unchecked FFI binding for `Rf_allocList`."]
    #[doc = "Generated from source location line 503, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_allocList"]
    pub(crate) fn Rf_allocList_unchecked(n: ::std::os::raw::c_int)
    -> SEXP;
    #[doc = " Allocate a language object. Requires R >= 4.4.1; the portable"]
    #[doc =
    " [`crate::gc_protect::ProtectScope::alloc_lang`] also supports R 4.4.0."]
    #[doc(alias = "allocLang")]
    #[doc = "Unchecked FFI binding for `Rf_allocLang`."]
    #[doc = "Generated from source location line 507, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_allocLang"]
    pub fn Rf_allocLang_unchecked(n: ::std::os::raw::c_int)
    -> SEXP;
    #[doc(alias = "allocS4Object")]
    #[doc = "Unchecked FFI binding for `Rf_allocS4Object`."]
    #[doc = "Generated from source location line 509, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_allocS4Object"]
    pub fn Rf_allocS4Object_unchecked()
    -> SEXP;
    #[doc = "Unchecked FFI binding for `Rf_cons`."]
    #[doc = "Generated from source location line 512, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_cons"]
    pub fn Rf_cons_unchecked(car: SEXP, cdr: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `Rf_lcons`."]
    #[doc = "Generated from source location line 513, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_lcons"]
    pub fn Rf_lcons_unchecked(car: SEXP, cdr: SEXP)
    -> SEXP;
    #[doc(alias = "setAttrib")]
    #[doc = "Unchecked FFI binding for `Rf_setAttrib`."]
    #[doc = "Generated from source location line 517, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_setAttrib"]
    pub fn Rf_setAttrib_unchecked(vec: SEXP, name: SEXP, val: SEXP)
    -> SEXP;
    #[doc(alias = "ScalarComplex")]
    #[doc = "Unchecked FFI binding for `Rf_ScalarComplex`."]
    #[doc = "Generated from source location line 521, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_ScalarComplex"]
    pub fn Rf_ScalarComplex_unchecked(x: Rcomplex)
    -> SEXP;
    #[doc(alias = "ScalarInteger")]
    #[doc = "Unchecked FFI binding for `Rf_ScalarInteger`."]
    #[doc = "Generated from source location line 523, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_ScalarInteger"]
    pub fn Rf_ScalarInteger_unchecked(x: ::std::os::raw::c_int)
    -> SEXP;
    #[doc(alias = "ScalarLogical")]
    #[doc = "Unchecked FFI binding for `Rf_ScalarLogical`."]
    #[doc = "Generated from source location line 525, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_ScalarLogical"]
    pub fn Rf_ScalarLogical_unchecked(x: ::std::os::raw::c_int)
    -> SEXP;
    #[doc(alias = "ScalarRaw")]
    #[doc = "Unchecked FFI binding for `Rf_ScalarRaw`."]
    #[doc = "Generated from source location line 527, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_ScalarRaw"]
    pub fn Rf_ScalarRaw_unchecked(x: Rbyte)
    -> SEXP;
    #[doc(alias = "ScalarReal")]
    #[doc = "Unchecked FFI binding for `Rf_ScalarReal`."]
    #[doc = "Generated from source location line 529, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_ScalarReal"]
    pub fn Rf_ScalarReal_unchecked(x: f64)
    -> SEXP;
    #[doc(alias = "ScalarString")]
    #[doc = "Unchecked FFI binding for `Rf_ScalarString`."]
    #[doc = "Generated from source location line 531, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_ScalarString"]
    pub fn Rf_ScalarString_unchecked(x: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `DATAPTR_RO`."]
    #[doc = "Generated from source location line 538, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "DATAPTR_RO"]
    pub fn DATAPTR_RO_unchecked(x: SEXP)
    -> *const ::std::os::raw::c_void;
    #[doc = "Unchecked FFI binding for `DATAPTR_OR_NULL`."]
    #[doc = "Generated from source location line 539, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "DATAPTR_OR_NULL"]
    pub fn DATAPTR_OR_NULL_unchecked(x: SEXP)
    -> *const ::std::os::raw::c_void;
    #[doc = "Unchecked FFI binding for `CAR`."]
    #[doc = "Generated from source location line 567, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CAR"]
    pub fn CAR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CDR`."]
    #[doc = "Generated from source location line 568, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CDR"]
    pub fn CDR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CAAR`."]
    #[doc = "Generated from source location line 569, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CAAR"]
    pub fn CAAR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CDAR`."]
    #[doc = "Generated from source location line 570, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CDAR"]
    pub fn CDAR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CADR`."]
    #[doc = "Generated from source location line 571, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CADR"]
    pub fn CADR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CDDR`."]
    #[doc = "Generated from source location line 572, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CDDR"]
    pub fn CDDR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CADDR`."]
    #[doc = "Generated from source location line 573, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CADDR"]
    pub fn CADDR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CADDDR`."]
    #[doc = "Generated from source location line 574, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CADDDR"]
    pub fn CADDDR_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `CAD4R`."]
    #[doc = "Generated from source location line 575, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "CAD4R"]
    pub fn CAD4R_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `TAG`."]
    #[doc = "Generated from source location line 576, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "TAG"]
    pub fn TAG_unchecked(e: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `SET_TAG`."]
    #[doc = "Generated from source location line 577, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_TAG"]
    pub fn SET_TAG_unchecked(x: SEXP, y: SEXP);
    #[doc = "Unchecked FFI binding for `SETCAR`."]
    #[doc = "Generated from source location line 578, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SETCAR"]
    pub fn SETCAR_unchecked(x: SEXP, y: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `SETCDR`."]
    #[doc = "Generated from source location line 579, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SETCDR"]
    pub fn SETCDR_unchecked(x: SEXP, y: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `SETCADR`."]
    #[doc = "Generated from source location line 580, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SETCADR"]
    pub fn SETCADR_unchecked(x: SEXP, y: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `SETCADDR`."]
    #[doc = "Generated from source location line 581, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SETCADDR"]
    pub fn SETCADDR_unchecked(x: SEXP, y: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `SETCADDDR`."]
    #[doc = "Generated from source location line 582, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SETCADDDR"]
    pub fn SETCADDDR_unchecked(x: SEXP, y: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `SETCAD4R`."]
    #[doc = "Generated from source location line 583, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SETCAD4R"]
    pub fn SETCAD4R_unchecked(e: SEXP, y: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `LOGICAL_OR_NULL`."]
    #[doc = "Generated from source location line 584, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "LOGICAL_OR_NULL"]
    pub fn LOGICAL_OR_NULL_unchecked(x: SEXP)
    -> *const ::std::os::raw::c_int;
    #[doc = "Unchecked FFI binding for `INTEGER_OR_NULL`."]
    #[doc = "Generated from source location line 585, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "INTEGER_OR_NULL"]
    pub fn INTEGER_OR_NULL_unchecked(x: SEXP)
    -> *const ::std::os::raw::c_int;
    #[doc = "Unchecked FFI binding for `REAL_OR_NULL`."]
    #[doc = "Generated from source location line 586, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "REAL_OR_NULL"]
    pub fn REAL_OR_NULL_unchecked(x: SEXP)
    -> *const f64;
    #[doc = "Unchecked FFI binding for `COMPLEX_OR_NULL`."]
    #[doc = "Generated from source location line 587, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "COMPLEX_OR_NULL"]
    pub fn COMPLEX_OR_NULL_unchecked(x: SEXP)
    -> *const Rcomplex;
    #[doc = "Unchecked FFI binding for `RAW_OR_NULL`."]
    #[doc = "Generated from source location line 588, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "RAW_OR_NULL"]
    pub fn RAW_OR_NULL_unchecked(x: SEXP)
    -> *const Rbyte;
    #[doc = "Unchecked FFI binding for `INTEGER_ELT`."]
    #[doc = "Generated from source location line 591, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "INTEGER_ELT"]
    pub fn INTEGER_ELT_unchecked(x: SEXP, i: R_xlen_t)
    -> ::std::os::raw::c_int;
    #[doc = "Unchecked FFI binding for `REAL_ELT`."]
    #[doc = "Generated from source location line 592, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "REAL_ELT"]
    pub fn REAL_ELT_unchecked(x: SEXP, i: R_xlen_t)
    -> f64;
    #[doc = "Unchecked FFI binding for `LOGICAL_ELT`."]
    #[doc = "Generated from source location line 593, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "LOGICAL_ELT"]
    pub fn LOGICAL_ELT_unchecked(x: SEXP, i: R_xlen_t)
    -> ::std::os::raw::c_int;
    #[doc = "Unchecked FFI binding for `COMPLEX_ELT`."]
    #[doc = "Generated from source location line 594, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "COMPLEX_ELT"]
    pub fn COMPLEX_ELT_unchecked(x: SEXP, i: R_xlen_t)
    -> Rcomplex;
    #[doc = "Unchecked FFI binding for `RAW_ELT`."]
    #[doc = "Generated from source location line 595, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "RAW_ELT"]
    pub fn RAW_ELT_unchecked(x: SEXP, i: R_xlen_t)
    -> Rbyte;
    #[doc = "Unchecked FFI binding for `VECTOR_ELT`."]
    #[doc = "Generated from source location line 596, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "VECTOR_ELT"]
    pub fn VECTOR_ELT_unchecked(x: SEXP, i: R_xlen_t)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `STRING_ELT`."]
    #[doc = "Generated from source location line 597, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "STRING_ELT"]
    pub fn STRING_ELT_unchecked(x: SEXP, i: R_xlen_t)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `SET_STRING_ELT`."]
    #[doc = "Generated from source location line 598, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_STRING_ELT"]
    pub fn SET_STRING_ELT_unchecked(x: SEXP, i: R_xlen_t, v: SEXP);
    #[doc = "Unchecked FFI binding for `SET_LOGICAL_ELT`."]
    #[doc = "Generated from source location line 599, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_LOGICAL_ELT"]
    pub fn SET_LOGICAL_ELT_unchecked(x: SEXP, i: R_xlen_t,
    v: ::std::os::raw::c_int);
    #[doc = "Unchecked FFI binding for `SET_INTEGER_ELT`."]
    #[doc = "Generated from source location line 600, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_INTEGER_ELT"]
    pub fn SET_INTEGER_ELT_unchecked(x: SEXP, i: R_xlen_t,
    v: ::std::os::raw::c_int);
    #[doc = "Unchecked FFI binding for `SET_REAL_ELT`."]
    #[doc = "Generated from source location line 601, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_REAL_ELT"]
    pub fn SET_REAL_ELT_unchecked(x: SEXP, i: R_xlen_t, v: f64);
    #[doc = "Unchecked FFI binding for `SET_COMPLEX_ELT`."]
    #[doc = "Generated from source location line 602, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_COMPLEX_ELT"]
    pub fn SET_COMPLEX_ELT_unchecked(x: SEXP, i: R_xlen_t, v: Rcomplex);
    #[doc = "Unchecked FFI binding for `SET_RAW_ELT`."]
    #[doc = "Generated from source location line 603, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_RAW_ELT"]
    pub fn SET_RAW_ELT_unchecked(x: SEXP, i: R_xlen_t, v: Rbyte);
    #[doc = "Unchecked FFI binding for `SET_VECTOR_ELT`."]
    #[doc = "Generated from source location line 604, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "SET_VECTOR_ELT"]
    pub fn SET_VECTOR_ELT_unchecked(x: SEXP, i: R_xlen_t, v: SEXP)
    -> SEXP;
    #[doc = " Get the length of a SEXP as `int` (for short vectors < 2^31)."]
    #[doc = ""]
    #[doc = " For long vectors, use `Rf_xlength()` instead."]
    #[doc = " Returns 0 for R_NilValue."]
    #[doc = "Unchecked FFI binding for `LENGTH`."]
    #[doc = "Generated from source location line 614, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "LENGTH"]
    pub fn LENGTH_unchecked(x: SEXP)
    -> ::std::os::raw::c_int;
    #[doc =
    " Get the length of a SEXP as `R_xlen_t` (supports long vectors)."]
    #[doc = ""]
    #[doc = " ALTREP-aware: will call ALTREP Length method if needed."]
    #[doc = "Unchecked FFI binding for `XLENGTH`."]
    #[doc = "Generated from source location line 619, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "XLENGTH"]
    pub fn XLENGTH_unchecked(x: SEXP)
    -> R_xlen_t;
    #[doc =
    " Non-zero if `x` has any attributes (`ATTRIB(x) != R_NilValue`)."]
    #[doc = ""]
    #[doc =
    " The API replacement for testing `ATTRIB`. R 4.5.0 added it: R 4.4\'s"]
    #[doc =
    " libR does not export it, so a package that references it fails to"]
    #[doc =
    " load there, and it is declared only when building against R >= 4.5"]
    #[doc =
    " (`r_4_5`, #1905). `SexpExt::has_attributes` works on R 4.4 as well."]
    #[doc = " Unlike `attributes()`, it ignores the tag names of a pairlist."]
    #[doc(alias = "NO_ATTRIB")]
    #[doc = "Unchecked FFI binding for `ANY_ATTRIB`."]
    #[doc = "Generated from source location line 630, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "ANY_ATTRIB"]
    pub fn ANY_ATTRIB_unchecked(x: SEXP)
    -> ::std::os::raw::c_int;
    #[doc = "Unchecked FFI binding for `ALTREP_CLASS`."]
    #[doc = "Generated from source location line 688, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "ALTREP_CLASS"]
    pub(crate) fn ALTREP_CLASS_unchecked(x: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_altrep_data1`."]
    #[doc = "Generated from source location line 689, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_altrep_data1"]
    pub fn R_altrep_data1_unchecked(x: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_altrep_data2`."]
    #[doc = "Generated from source location line 690, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_altrep_data2"]
    pub fn R_altrep_data2_unchecked(x: SEXP)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_set_altrep_data1`."]
    #[doc = "Generated from source location line 691, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_set_altrep_data1"]
    pub fn R_set_altrep_data1_unchecked(x: SEXP, v: SEXP);
    #[doc = "Unchecked FFI binding for `R_set_altrep_data2`."]
    #[doc = "Generated from source location line 692, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_set_altrep_data2"]
    pub fn R_set_altrep_data2_unchecked(x: SEXP, v: SEXP);
    #[doc =
    " Check if a SEXP is an ALTREP object (returns non-zero if true)."]
    #[doc = ""]
    #[doc = " Use `SexpExt::is_altrep()` instead of calling this directly."]
    #[doc = "Unchecked FFI binding for `ALTREP`."]
    #[doc = "Generated from source location line 697, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "ALTREP"]
    pub fn ALTREP_unchecked(x: SEXP)
    -> ::std::os::raw::c_int;
    #[doc = " Get mutable pointer to logical vector data."]
    #[doc = ""]
    #[doc = " For ALTREP vectors, this may force materialization."]
    #[doc = " Get mutable pointer to logical vector data."]
    #[doc = ""]
    #[doc = " For ALTREP vectors, this may force materialization."]
    #[doc =
    " Prefer `SexpExt::set_logical_elt()` / `SexpExt::logical_elt()`."]
    #[doc = "Unchecked FFI binding for `LOGICAL`."]
    #[doc = "Generated from source location line 712, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "LOGICAL"]
    pub(crate) fn LOGICAL_unchecked(x: SEXP)
    -> *mut ::std::os::raw::c_int;
    #[doc = " Get mutable pointer to integer vector data."]
    #[doc = ""]
    #[doc = " For ALTREP vectors, this may force materialization."]
    #[doc =
    " Prefer `SexpExt::set_integer_elt()` / `SexpExt::integer_elt()`."]
    #[doc = "Unchecked FFI binding for `INTEGER`."]
    #[doc = "Generated from source location line 718, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "INTEGER"]
    pub(crate) fn INTEGER_unchecked(x: SEXP)
    -> *mut ::std::os::raw::c_int;
    #[doc = " Get mutable pointer to real vector data."]
    #[doc = ""]
    #[doc = " For ALTREP vectors, this may force materialization."]
    #[doc = " Prefer `SexpExt::set_real_elt()` / `SexpExt::real_elt()`."]
    #[doc = "Unchecked FFI binding for `REAL`."]
    #[doc = "Generated from source location line 724, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "REAL"]
    pub(crate) fn REAL_unchecked(x: SEXP)
    -> *mut f64;
    #[doc = " Get mutable pointer to complex vector data."]
    #[doc = ""]
    #[doc = " For ALTREP vectors, this may force materialization."]
    #[doc =
    " Prefer `SexpExt::set_complex_elt()` / `SexpExt::complex_elt()`."]
    #[doc = "Unchecked FFI binding for `COMPLEX`."]
    #[doc = "Generated from source location line 730, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "COMPLEX"]
    pub(crate) fn COMPLEX_unchecked(x: SEXP)
    -> *mut Rcomplex;
    #[doc = " Get mutable pointer to raw vector data."]
    #[doc = ""]
    #[doc = " For ALTREP vectors, this may force materialization."]
    #[doc = " Prefer `SexpExt::set_raw_elt()` / `SexpExt::raw_elt()`."]
    #[doc = "Unchecked FFI binding for `RAW`."]
    #[doc = "Generated from source location line 736, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "RAW"]
    pub(crate) fn RAW_unchecked(x: SEXP)
    -> *mut Rbyte;
    #[doc = "Unchecked FFI binding for `R_CheckUserInterrupt`."]
    #[doc = "Generated from source location line 743, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_CheckUserInterrupt"]
    pub fn R_CheckUserInterrupt_unchecked();
    #[doc = "Unchecked FFI binding for `TYPEOF`."]
    #[doc = "Generated from source location line 749, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "TYPEOF"]
    pub fn TYPEOF_unchecked(x: SEXP)
    -> SEXPTYPE;
    #[doc(alias = "install")]
    #[doc = "Unchecked FFI binding for `Rf_install`."]
    #[doc = "Generated from source location line 755, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_install"]
    pub fn Rf_install_unchecked(name: *const ::std::os::raw::c_char)
    -> SEXP;
    #[doc = " Get the print name (CHARSXP) of a symbol (SYMSXP)"]
    #[doc = "Unchecked FFI binding for `PRINTNAME`."]
    #[doc = "Generated from source location line 757, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "PRINTNAME"]
    pub fn PRINTNAME_unchecked(x: SEXP)
    -> SEXP;
    #[doc =
    " Get the C string pointer from a CHARSXP — encapsulated by SexpExt::r_char()"]
    #[doc(alias = "CHAR")]
    #[doc = "Unchecked FFI binding for `R_CHAR`."]
    #[doc = "Generated from source location line 760, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_CHAR"]
    pub fn R_CHAR_unchecked(x: SEXP)
    -> *const ::std::os::raw::c_char;
    #[doc =
    " Read an attribute from an object by symbol (e.g. `R_NamesSymbol`)."]
    #[doc = ""]
    #[doc = " Returns `R_NilValue` if the attribute is not set."]
    #[doc(alias = "getAttrib")]
    #[doc = "Unchecked FFI binding for `Rf_getAttrib`."]
    #[doc = "Generated from source location line 768, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_getAttrib"]
    pub fn Rf_getAttrib_unchecked(vec: SEXP, name: SEXP)
    -> SEXP;
    #[doc = " Set the `names` attribute; returns the updated object."]
    #[doc(alias = "namesgets")]
    #[doc = "Unchecked FFI binding for `Rf_namesgets`."]
    #[doc = "Generated from source location line 771, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_namesgets"]
    pub fn Rf_namesgets_unchecked(vec: SEXP, val: SEXP)
    -> SEXP;
    #[doc = " Set the `dim` attribute; returns the updated object."]
    #[doc(alias = "dimgets")]
    #[doc = "Unchecked FFI binding for `Rf_dimgets`."]
    #[doc = "Generated from source location line 774, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_dimgets"]
    pub fn Rf_dimgets_unchecked(vec: SEXP, val: SEXP)
    -> SEXP;
    #[doc(alias = "duplicate")]
    #[doc = "Unchecked FFI binding for `Rf_duplicate`."]
    #[doc = "Generated from source location line 778, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_duplicate"]
    pub fn Rf_duplicate_unchecked(s: SEXP)
    -> SEXP;
    #[doc(alias = "shallow_duplicate")]
    #[doc = "Unchecked FFI binding for `Rf_shallow_duplicate`."]
    #[doc = "Generated from source location line 780, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_shallow_duplicate"]
    pub fn Rf_shallow_duplicate_unchecked(s: SEXP)
    -> SEXP;
    #[doc = " Check if two R objects are identical (deep semantic equality)."]
    #[doc = ""]
    #[doc = " This is the C implementation of R\'s `identical()` function."]
    #[doc = ""]
    #[doc = " # Flags"]
    #[doc = ""]
    #[doc =
    " Use the `IDENT_*` constants below. Flags are inverted: set bit = disable that check."]
    #[doc = ""]
    #[doc =
    " **Default from R**: `IDENT_USE_CLOENV` (16) - ignore closure environments"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " `TRUE` if identical, `FALSE` otherwise."]
    #[doc = ""]
    #[doc = " # Performance"]
    #[doc = ""]
    #[doc = " Fast-path: Returns `TRUE` immediately if pointers are equal."]
    #[doc = "Unchecked FFI binding for `R_compute_identical`."]
    #[doc = "Generated from source location line 800, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_compute_identical"]
    pub fn R_compute_identical_unchecked(x: SEXP, y: SEXP,
    flags: ::std::os::raw::c_int)
    -> Rboolean;
}
#[doc =
"Checked wrapper for `R_FlushConsole`. Calls `R_FlushConsole_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 296, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_FlushConsole() {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_FlushConsole_unchecked()
                        })
                });
    result.0
}
#[doc(alias = "mkChar")]
#[doc =
"Checked wrapper for `Rf_mkChar`. Calls `Rf_mkChar_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 312, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_mkChar(s: *const ::std::os::raw::c_char) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_mkChar_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "mkCharLen")]
#[doc =
"Checked wrapper for `Rf_mkCharLen`. Calls `Rf_mkCharLen_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 314, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_mkCharLen(s: *const ::std::os::raw::c_char, len: i32)
    -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_mkCharLen_unchecked(s, len)
                        })
                });
    result.0
}
#[doc(alias = "mkCharLenCE")]
#[doc =
"Checked wrapper for `Rf_mkCharLenCE`. Calls `Rf_mkCharLenCE_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 316, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_mkCharLenCE(x: *const ::std::os::raw::c_char,
    len: ::std::os::raw::c_int, ce: cetype_t) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_mkCharLenCE_unchecked(x, len, ce)
                        })
                });
    result.0
}
#[doc(alias = "xlength")]
#[doc(alias = "XLENGTH")]
#[doc =
"Checked wrapper for `Rf_xlength`. Calls `Rf_xlength_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 323, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_xlength(x: SEXP) -> R_xlen_t {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_xlength_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "translateCharUTF8")]
#[doc =
"Checked wrapper for `Rf_translateCharUTF8`. Calls `Rf_translateCharUTF8_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 325, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_translateCharUTF8(x: SEXP) -> *const ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_translateCharUTF8_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "getCharCE")]
#[doc =
"Checked wrapper for `Rf_getCharCE`. Calls `Rf_getCharCE_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 327, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_getCharCE(x: SEXP) -> cetype_t {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_getCharCE_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "charIsASCII")]
#[doc =
"Checked wrapper for `Rf_charIsASCII`. Calls `Rf_charIsASCII_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 329, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_charIsASCII(x: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_charIsASCII_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "charIsUTF8")]
#[doc =
"Checked wrapper for `Rf_charIsUTF8`. Calls `Rf_charIsUTF8_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 331, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_charIsUTF8(x: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_charIsUTF8_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "charIsLatin1")]
#[doc =
"Checked wrapper for `Rf_charIsLatin1`. Calls `Rf_charIsLatin1_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 333, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_charIsLatin1(x: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_charIsLatin1_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_MakeUnwindCont`. Calls `R_MakeUnwindCont_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 336, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_MakeUnwindCont() -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_MakeUnwindCont_unchecked()
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_ContinueUnwind`. Calls `R_ContinueUnwind_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 337, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_ContinueUnwind(cont: SEXP) -> ! {
    ::miniextendr_api::worker::with_r_thread(move ||
            unsafe { R_ContinueUnwind_unchecked(cont) })
}
#[doc =
"Checked wrapper for `R_UnwindProtect`. Calls `R_UnwindProtect_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 338, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_UnwindProtect(fun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)
            -> SEXP>, fun_data: *mut ::std::os::raw::c_void,
    cleanfun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void,
            Rboolean)>, cleanfun_data: *mut ::std::os::raw::c_void,
    cont: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_UnwindProtect_unchecked(fun, fun_data, cleanfun,
                                cleanfun_data, cont)
                        })
                });
    result.0
}
#[doc = " External pointer interface"]
#[doc =
"Checked wrapper for `R_MakeExternalPtr`. Calls `R_MakeExternalPtr_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 367, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_MakeExternalPtr(p: *mut ::std::os::raw::c_void,
    tag: SEXP, prot: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_MakeExternalPtr_unchecked(p, tag, prot)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_ExternalPtrAddr`. Calls `R_ExternalPtrAddr_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 368, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_ExternalPtrAddr(s: SEXP) -> *mut ::std::os::raw::c_void {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ExternalPtrAddr_unchecked(s)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_ExternalPtrTag`. Calls `R_ExternalPtrTag_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 369, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_ExternalPtrTag(s: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ExternalPtrTag_unchecked(s)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_ExternalPtrProtected`. Calls `R_ExternalPtrProtected_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 370, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_ExternalPtrProtected(s: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ExternalPtrProtected_unchecked(s)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_ClearExternalPtr`. Calls `R_ClearExternalPtr_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 371, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_ClearExternalPtr(s: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ClearExternalPtr_unchecked(s)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_SetExternalPtrAddr`. Calls `R_SetExternalPtrAddr_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 372, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_SetExternalPtrAddr(s: SEXP,
    p: *mut ::std::os::raw::c_void) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_SetExternalPtrAddr_unchecked(s, p)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_SetExternalPtrTag`. Calls `R_SetExternalPtrTag_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 373, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_SetExternalPtrTag(s: SEXP, tag: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_SetExternalPtrTag_unchecked(s, tag)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_SetExternalPtrProtected`. Calls `R_SetExternalPtrProtected_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 374, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_SetExternalPtrProtected(s: SEXP, p: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_SetExternalPtrProtected_unchecked(s, p)
                        })
                });
    result.0
}
#[doc = " Added in R 3.4.0"]
#[doc =
"Checked wrapper for `R_MakeExternalPtrFn`. Calls `R_MakeExternalPtrFn_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 376, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_MakeExternalPtrFn(p: DL_FUNC, tag: SEXP, prot: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_MakeExternalPtrFn_unchecked(p, tag, prot)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_ExternalPtrAddrFn`. Calls `R_ExternalPtrAddrFn_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 377, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_ExternalPtrAddrFn(s: SEXP) -> DL_FUNC {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ExternalPtrAddrFn_unchecked(s)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_RegisterFinalizer`. Calls `R_RegisterFinalizer_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 378, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_RegisterFinalizer(s: SEXP, fun: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_RegisterFinalizer_unchecked(s, fun)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_RegisterCFinalizer`. Calls `R_RegisterCFinalizer_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 379, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_RegisterCFinalizer(s: SEXP, fun: R_CFinalizer_t) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_RegisterCFinalizer_unchecked(s, fun)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_RegisterFinalizerEx`. Calls `R_RegisterFinalizerEx_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 380, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_RegisterFinalizerEx(s: SEXP, fun: SEXP, onexit: Rboolean) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_RegisterFinalizerEx_unchecked(s, fun, onexit)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_RegisterCFinalizerEx`. Calls `R_RegisterCFinalizerEx_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 381, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_RegisterCFinalizerEx(s: SEXP, fun: R_CFinalizer_t,
    onexit: Rboolean) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_RegisterCFinalizerEx_unchecked(s, fun, onexit)
                        })
                });
    result.0
}
#[doc = " Register a C-callable function for cross-package access."]
#[doc =
"Checked wrapper for `R_RegisterCCallable`. Calls `R_RegisterCCallable_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 386, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_RegisterCCallable(package:
        *const ::std::os::raw::c_char, name: *const ::std::os::raw::c_char,
    fptr: DL_FUNC) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_RegisterCCallable_unchecked(package, name, fptr)
                        })
                });
    result.0
}
#[doc = " Get a C-callable function from another package."]
#[doc =
"Checked wrapper for `R_GetCCallable`. Calls `R_GetCCallable_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 392, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_GetCCallable(package: *const ::std::os::raw::c_char,
    name: *const ::std::os::raw::c_char) -> DL_FUNC {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_GetCCallable_unchecked(package, name)
                        })
                });
    result.0
}
#[doc = " Add a SEXP to the protect stack, preventing GC collection."]
#[doc = ""]
#[doc =
" **Cost: O(1)** — single array write (`R_PPStack[top++] = s`). No allocation."]
#[doc = ""]
#[doc =
" Must be balanced by a corresponding `Rf_unprotect`. The protect stack is"]
#[doc =
" LIFO — nested scopes are safe, but interleaved usage from different scopes"]
#[doc = " will cause incorrect unprotection."]
#[doc(alias = "PROTECT")]
#[doc(alias = "protect")]
#[doc =
"Checked wrapper for `Rf_protect`. Calls `Rf_protect_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 440, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_protect(s: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_protect_unchecked(s)
                        })
                });
    result.0
}
#[doc = " Pop the top `l` entries from the protect stack."]
#[doc = ""]
#[doc =
" **Cost: O(1)** — single integer subtract (`R_PPStackTop -= l`). No allocation."]
#[doc = ""]
#[doc = " The popped SEXPs become eligible for GC. Must match the number of"]
#[doc = " `Rf_protect` calls in the current scope (LIFO order)."]
#[doc(alias = "UNPROTECT")]
#[doc(alias = "unprotect")]
#[doc =
"Checked wrapper for `Rf_unprotect`. Calls `Rf_unprotect_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 450, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_unprotect(l: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_unprotect_unchecked(l)
                        })
                });
    result.0
}
#[doc = " Remove a specific SEXP from anywhere in the protect stack."]
#[doc = ""]
#[doc =
" **Cost: O(k)** — scans backwards from top (k = distance from top), then"]
#[doc = " shifts remaining entries down. No allocation. R source comment:"]
#[doc = " *\"should be among the top few items\"*."]
#[doc = ""]
#[doc =
" Unlike `Rf_unprotect`, this is order-independent — it finds and removes"]
#[doc =
" the specific pointer regardless of stack position. Useful when LIFO"]
#[doc =
" discipline cannot be maintained, but more expensive than `Rf_unprotect`."]
#[doc(alias = "UNPROTECT_PTR")]
#[doc =
"Checked wrapper for `Rf_unprotect_ptr`. Calls `Rf_unprotect_ptr_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 462, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_unprotect_ptr(s: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_unprotect_ptr_unchecked(s)
                        })
                });
    result.0
}
#[doc =
" Add a SEXP to the global precious list, preventing GC indefinitely."]
#[doc = ""]
#[doc =
" **Cost: O(1) but allocates a CONSXP cell** — creates GC pressure on every"]
#[doc =
" call. The precious list is a global linked list (`R_PreciousList`)."]
#[doc = ""]
#[doc =
" Use only for long-lived objects (e.g., ExternalPtr stored across R calls)."]
#[doc = " For temporary protection within a function, prefer `Rf_protect`."]
#[doc =
"Checked wrapper for `R_PreserveObject`. Calls `R_PreserveObject_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 471, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_PreserveObject(object: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_PreserveObject_unchecked(object)
                        })
                });
    result.0
}
#[doc = " Remove a SEXP from the global precious list, allowing GC."]
#[doc = ""]
#[doc =
" **Cost: O(n)** — linear scan of the entire precious list to find and unlink"]
#[doc =
" the cons cell. With `R_HASH_PRECIOUS` env var, O(bucket_size) average"]
#[doc = " via a 1069-bucket hash table, but this is off by default."]
#[doc =
"Checked wrapper for `R_ReleaseObject`. Calls `R_ReleaseObject_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 478, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_ReleaseObject(object: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ReleaseObject_unchecked(object)
                        })
                });
    result.0
}
#[doc(alias = "allocVector")]
#[doc =
"Checked wrapper for `Rf_allocVector`. Calls `Rf_allocVector_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 483, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_allocVector(sexptype: SEXPTYPE, length: R_xlen_t) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_allocVector_unchecked(sexptype, length)
                        })
                });
    result.0
}
#[doc(alias = "allocMatrix")]
#[doc =
"Checked wrapper for `Rf_allocMatrix`. Calls `Rf_allocMatrix_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 485, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_allocMatrix(sexptype: SEXPTYPE, nrow: ::std::os::raw::c_int,
    ncol: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_allocMatrix_unchecked(sexptype, nrow, ncol)
                        })
                });
    result.0
}
#[doc(alias = "allocArray")]
#[doc =
"Checked wrapper for `Rf_allocArray`. Calls `Rf_allocArray_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 491, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_allocArray(sexptype: SEXPTYPE, dims: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_allocArray_unchecked(sexptype, dims)
                        })
                });
    result.0
}
#[doc(alias = "alloc3DArray")]
#[doc =
"Checked wrapper for `Rf_alloc3DArray`. Calls `Rf_alloc3DArray_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 493, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_alloc3DArray(sexptype: SEXPTYPE, nrow: ::std::os::raw::c_int,
    ncol: ::std::os::raw::c_int, nface: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_alloc3DArray_unchecked(sexptype, nrow, ncol, nface)
                        })
                });
    result.0
}
#[doc(alias = "allocList")]
#[doc =
"Checked wrapper for `Rf_allocList`. Calls `Rf_allocList_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 503, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn Rf_allocList(n: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_allocList_unchecked(n)
                        })
                });
    result.0
}
#[doc = " Allocate a language object. Requires R >= 4.4.1; the portable"]
#[doc =
" [`crate::gc_protect::ProtectScope::alloc_lang`] also supports R 4.4.0."]
#[doc(alias = "allocLang")]
#[doc =
"Checked wrapper for `Rf_allocLang`. Calls `Rf_allocLang_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 507, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_allocLang(n: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_allocLang_unchecked(n)
                        })
                });
    result.0
}
#[doc(alias = "allocS4Object")]
#[doc =
"Checked wrapper for `Rf_allocS4Object`. Calls `Rf_allocS4Object_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 509, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_allocS4Object() -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_allocS4Object_unchecked()
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `Rf_cons`. Calls `Rf_cons_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 512, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_cons(car: SEXP, cdr: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_cons_unchecked(car, cdr)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `Rf_lcons`. Calls `Rf_lcons_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 513, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_lcons(car: SEXP, cdr: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_lcons_unchecked(car, cdr)
                        })
                });
    result.0
}
#[doc(alias = "setAttrib")]
#[doc =
"Checked wrapper for `Rf_setAttrib`. Calls `Rf_setAttrib_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 517, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_setAttrib(vec: SEXP, name: SEXP, val: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_setAttrib_unchecked(vec, name, val)
                        })
                });
    result.0
}
#[doc(alias = "ScalarComplex")]
#[doc =
"Checked wrapper for `Rf_ScalarComplex`. Calls `Rf_ScalarComplex_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 521, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_ScalarComplex(x: Rcomplex) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_ScalarComplex_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "ScalarInteger")]
#[doc =
"Checked wrapper for `Rf_ScalarInteger`. Calls `Rf_ScalarInteger_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 523, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_ScalarInteger(x: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_ScalarInteger_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "ScalarLogical")]
#[doc =
"Checked wrapper for `Rf_ScalarLogical`. Calls `Rf_ScalarLogical_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 525, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_ScalarLogical(x: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_ScalarLogical_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "ScalarRaw")]
#[doc =
"Checked wrapper for `Rf_ScalarRaw`. Calls `Rf_ScalarRaw_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 527, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_ScalarRaw(x: Rbyte) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_ScalarRaw_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "ScalarReal")]
#[doc =
"Checked wrapper for `Rf_ScalarReal`. Calls `Rf_ScalarReal_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 529, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_ScalarReal(x: f64) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_ScalarReal_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "ScalarString")]
#[doc =
"Checked wrapper for `Rf_ScalarString`. Calls `Rf_ScalarString_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 531, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_ScalarString(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_ScalarString_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `DATAPTR_RO`. Calls `DATAPTR_RO_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 538, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn DATAPTR_RO(x: SEXP) -> *const ::std::os::raw::c_void {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            DATAPTR_RO_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `DATAPTR_OR_NULL`. Calls `DATAPTR_OR_NULL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 539, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn DATAPTR_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_void {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            DATAPTR_OR_NULL_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CAR`. Calls `CAR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 567, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CAR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CAR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CDR`. Calls `CDR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 568, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CDR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CDR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CAAR`. Calls `CAAR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 569, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CAAR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CAAR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CDAR`. Calls `CDAR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 570, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CDAR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CDAR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CADR`. Calls `CADR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 571, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CADR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CADR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CDDR`. Calls `CDDR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 572, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CDDR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CDDR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CADDR`. Calls `CADDR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 573, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CADDR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CADDR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CADDDR`. Calls `CADDDR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 574, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CADDDR(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CADDDR_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `CAD4R`. Calls `CAD4R_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 575, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn CAD4R(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            CAD4R_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `TAG`. Calls `TAG_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 576, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn TAG(e: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            TAG_unchecked(e)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_TAG`. Calls `SET_TAG_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 577, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_TAG(x: SEXP, y: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_TAG_unchecked(x, y)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SETCAR`. Calls `SETCAR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 578, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SETCAR(x: SEXP, y: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SETCAR_unchecked(x, y)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SETCDR`. Calls `SETCDR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 579, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SETCDR(x: SEXP, y: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SETCDR_unchecked(x, y)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SETCADR`. Calls `SETCADR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 580, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SETCADR(x: SEXP, y: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SETCADR_unchecked(x, y)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SETCADDR`. Calls `SETCADDR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 581, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SETCADDR(x: SEXP, y: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SETCADDR_unchecked(x, y)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SETCADDDR`. Calls `SETCADDDR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 582, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SETCADDDR(x: SEXP, y: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SETCADDDR_unchecked(x, y)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SETCAD4R`. Calls `SETCAD4R_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 583, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SETCAD4R(e: SEXP, y: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SETCAD4R_unchecked(e, y)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `LOGICAL_OR_NULL`. Calls `LOGICAL_OR_NULL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 584, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn LOGICAL_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            LOGICAL_OR_NULL_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `INTEGER_OR_NULL`. Calls `INTEGER_OR_NULL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 585, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn INTEGER_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            INTEGER_OR_NULL_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `REAL_OR_NULL`. Calls `REAL_OR_NULL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 586, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn REAL_OR_NULL(x: SEXP) -> *const f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            REAL_OR_NULL_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `COMPLEX_OR_NULL`. Calls `COMPLEX_OR_NULL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 587, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn COMPLEX_OR_NULL(x: SEXP) -> *const Rcomplex {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            COMPLEX_OR_NULL_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `RAW_OR_NULL`. Calls `RAW_OR_NULL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 588, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn RAW_OR_NULL(x: SEXP) -> *const Rbyte {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            RAW_OR_NULL_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `INTEGER_ELT`. Calls `INTEGER_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 591, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn INTEGER_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            INTEGER_ELT_unchecked(x, i)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `REAL_ELT`. Calls `REAL_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 592, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn REAL_ELT(x: SEXP, i: R_xlen_t) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            REAL_ELT_unchecked(x, i)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `LOGICAL_ELT`. Calls `LOGICAL_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 593, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn LOGICAL_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            LOGICAL_ELT_unchecked(x, i)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `COMPLEX_ELT`. Calls `COMPLEX_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 594, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn COMPLEX_ELT(x: SEXP, i: R_xlen_t) -> Rcomplex {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            COMPLEX_ELT_unchecked(x, i)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `RAW_ELT`. Calls `RAW_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 595, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn RAW_ELT(x: SEXP, i: R_xlen_t) -> Rbyte {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            RAW_ELT_unchecked(x, i)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `VECTOR_ELT`. Calls `VECTOR_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 596, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn VECTOR_ELT(x: SEXP, i: R_xlen_t) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            VECTOR_ELT_unchecked(x, i)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `STRING_ELT`. Calls `STRING_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 597, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn STRING_ELT(x: SEXP, i: R_xlen_t) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            STRING_ELT_unchecked(x, i)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_STRING_ELT`. Calls `SET_STRING_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 598, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_STRING_ELT(x: SEXP, i: R_xlen_t, v: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_STRING_ELT_unchecked(x, i, v)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_LOGICAL_ELT`. Calls `SET_LOGICAL_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 599, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_LOGICAL_ELT(x: SEXP, i: R_xlen_t,
    v: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_LOGICAL_ELT_unchecked(x, i, v)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_INTEGER_ELT`. Calls `SET_INTEGER_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 600, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_INTEGER_ELT(x: SEXP, i: R_xlen_t,
    v: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_INTEGER_ELT_unchecked(x, i, v)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_REAL_ELT`. Calls `SET_REAL_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 601, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_REAL_ELT(x: SEXP, i: R_xlen_t, v: f64) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_REAL_ELT_unchecked(x, i, v)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_COMPLEX_ELT`. Calls `SET_COMPLEX_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 602, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_COMPLEX_ELT(x: SEXP, i: R_xlen_t, v: Rcomplex) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_COMPLEX_ELT_unchecked(x, i, v)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_RAW_ELT`. Calls `SET_RAW_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 603, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_RAW_ELT(x: SEXP, i: R_xlen_t, v: Rbyte) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_RAW_ELT_unchecked(x, i, v)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `SET_VECTOR_ELT`. Calls `SET_VECTOR_ELT_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 604, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn SET_VECTOR_ELT(x: SEXP, i: R_xlen_t, v: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            SET_VECTOR_ELT_unchecked(x, i, v)
                        })
                });
    result.0
}
#[doc = " Get the length of a SEXP as `int` (for short vectors < 2^31)."]
#[doc = ""]
#[doc = " For long vectors, use `Rf_xlength()` instead."]
#[doc = " Returns 0 for R_NilValue."]
#[doc =
"Checked wrapper for `LENGTH`. Calls `LENGTH_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 614, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn LENGTH(x: SEXP) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            LENGTH_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Get the length of a SEXP as `R_xlen_t` (supports long vectors)."]
#[doc = ""]
#[doc = " ALTREP-aware: will call ALTREP Length method if needed."]
#[doc =
"Checked wrapper for `XLENGTH`. Calls `XLENGTH_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 619, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn XLENGTH(x: SEXP) -> R_xlen_t {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            XLENGTH_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Non-zero if `x` has any attributes (`ATTRIB(x) != R_NilValue`)."]
#[doc = ""]
#[doc =
" The API replacement for testing `ATTRIB`. R 4.5.0 added it: R 4.4\'s"]
#[doc = " libR does not export it, so a package that references it fails to"]
#[doc = " load there, and it is declared only when building against R >= 4.5"]
#[doc =
" (`r_4_5`, #1905). `SexpExt::has_attributes` works on R 4.4 as well."]
#[doc = " Unlike `attributes()`, it ignores the tag names of a pairlist."]
#[doc(alias = "NO_ATTRIB")]
#[doc =
"Checked wrapper for `ANY_ATTRIB`. Calls `ANY_ATTRIB_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 630, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn ANY_ATTRIB(x: SEXP) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            ANY_ATTRIB_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `ALTREP_CLASS`. Calls `ALTREP_CLASS_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 688, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn ALTREP_CLASS(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            ALTREP_CLASS_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_altrep_data1`. Calls `R_altrep_data1_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 689, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_altrep_data1(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_altrep_data1_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_altrep_data2`. Calls `R_altrep_data2_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 690, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_altrep_data2(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_altrep_data2_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_set_altrep_data1`. Calls `R_set_altrep_data1_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 691, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_set_altrep_data1(x: SEXP, v: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_set_altrep_data1_unchecked(x, v)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_set_altrep_data2`. Calls `R_set_altrep_data2_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 692, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_set_altrep_data2(x: SEXP, v: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_set_altrep_data2_unchecked(x, v)
                        })
                });
    result.0
}
#[doc = " Check if a SEXP is an ALTREP object (returns non-zero if true)."]
#[doc = ""]
#[doc = " Use `SexpExt::is_altrep()` instead of calling this directly."]
#[doc =
"Checked wrapper for `ALTREP`. Calls `ALTREP_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 697, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn ALTREP(x: SEXP) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            ALTREP_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Get mutable pointer to logical vector data."]
#[doc = ""]
#[doc = " For ALTREP vectors, this may force materialization."]
#[doc = " Get mutable pointer to logical vector data."]
#[doc = ""]
#[doc = " For ALTREP vectors, this may force materialization."]
#[doc = " Prefer `SexpExt::set_logical_elt()` / `SexpExt::logical_elt()`."]
#[doc =
"Checked wrapper for `LOGICAL`. Calls `LOGICAL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 712, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn LOGICAL(x: SEXP) -> *mut ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            LOGICAL_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Get mutable pointer to integer vector data."]
#[doc = ""]
#[doc = " For ALTREP vectors, this may force materialization."]
#[doc = " Prefer `SexpExt::set_integer_elt()` / `SexpExt::integer_elt()`."]
#[doc =
"Checked wrapper for `INTEGER`. Calls `INTEGER_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 718, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn INTEGER(x: SEXP) -> *mut ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            INTEGER_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Get mutable pointer to real vector data."]
#[doc = ""]
#[doc = " For ALTREP vectors, this may force materialization."]
#[doc = " Prefer `SexpExt::set_real_elt()` / `SexpExt::real_elt()`."]
#[doc =
"Checked wrapper for `REAL`. Calls `REAL_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 724, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn REAL(x: SEXP) -> *mut f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            REAL_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Get mutable pointer to complex vector data."]
#[doc = ""]
#[doc = " For ALTREP vectors, this may force materialization."]
#[doc = " Prefer `SexpExt::set_complex_elt()` / `SexpExt::complex_elt()`."]
#[doc =
"Checked wrapper for `COMPLEX`. Calls `COMPLEX_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 730, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn COMPLEX(x: SEXP) -> *mut Rcomplex {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            COMPLEX_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Get mutable pointer to raw vector data."]
#[doc = ""]
#[doc = " For ALTREP vectors, this may force materialization."]
#[doc = " Prefer `SexpExt::set_raw_elt()` / `SexpExt::raw_elt()`."]
#[doc =
"Checked wrapper for `RAW`. Calls `RAW_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 736, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn RAW(x: SEXP) -> *mut Rbyte {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            RAW_unchecked(x)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_CheckUserInterrupt`. Calls `R_CheckUserInterrupt_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 743, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_CheckUserInterrupt() {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_CheckUserInterrupt_unchecked()
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `TYPEOF`. Calls `TYPEOF_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 749, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn TYPEOF(x: SEXP) -> SEXPTYPE {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            TYPEOF_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "install")]
#[doc =
"Checked wrapper for `Rf_install`. Calls `Rf_install_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 755, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_install(name: *const ::std::os::raw::c_char) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_install_unchecked(name)
                        })
                });
    result.0
}
#[doc = " Get the print name (CHARSXP) of a symbol (SYMSXP)"]
#[doc =
"Checked wrapper for `PRINTNAME`. Calls `PRINTNAME_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 757, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn PRINTNAME(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            PRINTNAME_unchecked(x)
                        })
                });
    result.0
}
#[doc =
" Get the C string pointer from a CHARSXP — encapsulated by SexpExt::r_char()"]
#[doc(alias = "CHAR")]
#[doc =
"Checked wrapper for `R_CHAR`. Calls `R_CHAR_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 760, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_CHAR(x: SEXP) -> *const ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_CHAR_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Read an attribute from an object by symbol (e.g. `R_NamesSymbol`)."]
#[doc = ""]
#[doc = " Returns `R_NilValue` if the attribute is not set."]
#[doc(alias = "getAttrib")]
#[doc =
"Checked wrapper for `Rf_getAttrib`. Calls `Rf_getAttrib_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 768, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_getAttrib(vec: SEXP, name: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_getAttrib_unchecked(vec, name)
                        })
                });
    result.0
}
#[doc = " Set the `names` attribute; returns the updated object."]
#[doc(alias = "namesgets")]
#[doc =
"Checked wrapper for `Rf_namesgets`. Calls `Rf_namesgets_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 771, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_namesgets(vec: SEXP, val: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_namesgets_unchecked(vec, val)
                        })
                });
    result.0
}
#[doc = " Set the `dim` attribute; returns the updated object."]
#[doc(alias = "dimgets")]
#[doc =
"Checked wrapper for `Rf_dimgets`. Calls `Rf_dimgets_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 774, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_dimgets(vec: SEXP, val: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_dimgets_unchecked(vec, val)
                        })
                });
    result.0
}
#[doc(alias = "duplicate")]
#[doc =
"Checked wrapper for `Rf_duplicate`. Calls `Rf_duplicate_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 778, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_duplicate(s: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_duplicate_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "shallow_duplicate")]
#[doc =
"Checked wrapper for `Rf_shallow_duplicate`. Calls `Rf_shallow_duplicate_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 780, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_shallow_duplicate(s: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_shallow_duplicate_unchecked(s)
                        })
                });
    result.0
}
#[doc = " Check if two R objects are identical (deep semantic equality)."]
#[doc = ""]
#[doc = " This is the C implementation of R\'s `identical()` function."]
#[doc = ""]
#[doc = " # Flags"]
#[doc = ""]
#[doc =
" Use the `IDENT_*` constants below. Flags are inverted: set bit = disable that check."]
#[doc = ""]
#[doc =
" **Default from R**: `IDENT_USE_CLOENV` (16) - ignore closure environments"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " `TRUE` if identical, `FALSE` otherwise."]
#[doc = ""]
#[doc = " # Performance"]
#[doc = ""]
#[doc = " Fast-path: Returns `TRUE` immediately if pointers are equal."]
#[doc =
"Checked wrapper for `R_compute_identical`. Calls `R_compute_identical_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 800, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_compute_identical(x: SEXP, y: SEXP,
    flags: ::std::os::raw::c_int) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_compute_identical_unchecked(x, y, flags)
                        })
                });
    result.0
}#[r_ffi_checked]
250#[allow(clashing_extern_declarations)]
251unsafe extern "C-unwind" {
252    /// The canonical R `NULL` value.
253    pub static R_NilValue: SEXP;
254
255    #[doc(alias = "NA_STRING")]
256    /// Missing string singleton — encapsulated by SEXP::na_string()
257    pub static R_NaString: SEXP;
258    /// Empty string CHARSXP — encapsulated by SEXP::blank_string()
259    pub static R_BlankString: SEXP;
260    /// Symbol for `names` attribute.
261    // Attribute symbols — encapsulated by SexpExt methods and SEXP::*_symbol()
262    pub static R_NamesSymbol: SEXP;
263    pub static R_DimSymbol: SEXP;
264    pub static R_DimNamesSymbol: SEXP;
265    pub static R_ClassSymbol: SEXP;
266    pub static R_RowNamesSymbol: SEXP;
267    pub static R_LevelsSymbol: SEXP;
268    pub static R_TspSymbol: SEXP;
269
270    /// Global environment (`.GlobalEnv`).
271    pub static R_GlobalEnv: SEXP;
272    /// Base package namespace environment.
273    pub static R_BaseEnv: SEXP;
274    /// Empty root environment.
275    pub static R_EmptyEnv: SEXP;
276    /// Base package namespace — encapsulated by SEXP::base_namespace()
277    pub static R_BaseNamespace: SEXP;
278
279    /// The "missing argument" sentinel value.
280    ///
281    /// When an R function is called without providing a value for a formal
282    /// argument, R passes `R_MissingArg` as a placeholder. This is different
283    /// from `R_NilValue` (NULL) - a missing argument means "not provided",
284    /// while NULL is an explicit value.
285    ///
286    /// In R: `f <- function(x) missing(x); f()` returns `TRUE`.
287    /// Encapsulated by SEXP::missing_arg()
288    pub static R_MissingArg: SEXP;
289
290    /// Sentinel returned by `R_getVarEx` (via its `ifnotfound` argument) when
291    /// the symbol has no binding in the searched frame(s).
292    pub static R_UnboundValue: SEXP;
293
294    // Issue #112 cat. 10: kept pub(crate) — single-caller utilities; wrapping adds no value
295    // Rinterface.h
296    pub(crate) fn R_FlushConsole();
297
298    // Special logical values (from internal Defn.h, not public API)
299    // These are gated behind `nonapi` feature as they may change across R versions.
300    #[cfg(feature = "nonapi")]
301    /// Non-API TRUE singleton.
302    pub static R_TrueValue: SEXP;
303    #[cfg(feature = "nonapi")]
304    /// Non-API FALSE singleton.
305    pub static R_FalseValue: SEXP;
306    #[cfg(feature = "nonapi")]
307    /// Non-API NA logical singleton.
308    pub static R_LogicalNAValue: SEXP;
309
310    // Rinternals.h
311    #[doc(alias = "mkChar")]
312    pub fn Rf_mkChar(s: *const ::std::os::raw::c_char) -> SEXP;
313    #[doc(alias = "mkCharLen")]
314    pub fn Rf_mkCharLen(s: *const ::std::os::raw::c_char, len: i32) -> SEXP;
315    #[doc(alias = "mkCharLenCE")]
316    pub fn Rf_mkCharLenCE(
317        x: *const ::std::os::raw::c_char,
318        len: ::std::os::raw::c_int,
319        ce: cetype_t,
320    ) -> SEXP;
321    #[doc(alias = "xlength")]
322    #[doc(alias = "XLENGTH")]
323    pub fn Rf_xlength(x: SEXP) -> R_xlen_t;
324    #[doc(alias = "translateCharUTF8")]
325    pub fn Rf_translateCharUTF8(x: SEXP) -> *const ::std::os::raw::c_char;
326    #[doc(alias = "getCharCE")]
327    pub fn Rf_getCharCE(x: SEXP) -> cetype_t;
328    #[doc(alias = "charIsASCII")]
329    pub fn Rf_charIsASCII(x: SEXP) -> Rboolean;
330    #[doc(alias = "charIsUTF8")]
331    pub fn Rf_charIsUTF8(x: SEXP) -> Rboolean;
332    #[doc(alias = "charIsLatin1")]
333    pub fn Rf_charIsLatin1(x: SEXP) -> Rboolean;
334
335    // Issue #112 cat. 3: kept pub(crate) — only called from unwind_protect.rs; users go through with_r_unwind_protect
336    pub(crate) fn R_MakeUnwindCont() -> SEXP;
337    pub(crate) fn R_ContinueUnwind(cont: SEXP) -> !;
338    pub(crate) fn R_UnwindProtect(
339        fun: ::std::option::Option<
340            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void) -> SEXP,
341        >,
342        fun_data: *mut ::std::os::raw::c_void,
343        cleanfun: ::std::option::Option<
344            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void, Rboolean),
345        >,
346        cleanfun_data: *mut ::std::os::raw::c_void,
347        cont: SEXP,
348    ) -> SEXP;
349
350    /// Version of `R_UnwindProtect` that accepts `extern "C-unwind"` function pointers
351    #[link_name = "R_UnwindProtect"]
352    pub(crate) fn R_UnwindProtect_C_unwind(
353        fun: ::std::option::Option<
354            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void) -> SEXP,
355        >,
356        fun_data: *mut ::std::os::raw::c_void,
357        cleanfun: ::std::option::Option<
358            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void, Rboolean),
359        >,
360        cleanfun_data: *mut ::std::os::raw::c_void,
361        cont: SEXP,
362    ) -> SEXP;
363
364    // Rinternals.h
365    // Issue #112 cat. 2: kept pub(crate) — ExternalPtr<T> encapsulates these for users; raw access needed within externalptr.rs
366    #[doc = " External pointer interface"]
367    pub(crate) fn R_MakeExternalPtr(p: *mut ::std::os::raw::c_void, tag: SEXP, prot: SEXP) -> SEXP;
368    pub fn R_ExternalPtrAddr(s: SEXP) -> *mut ::std::os::raw::c_void;
369    pub(crate) fn R_ExternalPtrTag(s: SEXP) -> SEXP;
370    pub(crate) fn R_ExternalPtrProtected(s: SEXP) -> SEXP;
371    pub(crate) fn R_ClearExternalPtr(s: SEXP);
372    pub(crate) fn R_SetExternalPtrAddr(s: SEXP, p: *mut ::std::os::raw::c_void);
373    pub(crate) fn R_SetExternalPtrTag(s: SEXP, tag: SEXP);
374    pub(crate) fn R_SetExternalPtrProtected(s: SEXP, p: SEXP);
375    #[doc = " Added in R 3.4.0"]
376    pub fn R_MakeExternalPtrFn(p: DL_FUNC, tag: SEXP, prot: SEXP) -> SEXP;
377    pub fn R_ExternalPtrAddrFn(s: SEXP) -> DL_FUNC;
378    pub fn R_RegisterFinalizer(s: SEXP, fun: SEXP);
379    pub(crate) fn R_RegisterCFinalizer(s: SEXP, fun: R_CFinalizer_t);
380    pub fn R_RegisterFinalizerEx(s: SEXP, fun: SEXP, onexit: Rboolean);
381    pub(crate) fn R_RegisterCFinalizerEx(s: SEXP, fun: R_CFinalizer_t, onexit: Rboolean);
382
383    // R_ext/Rdynload.h - C-callable interface
384    // Issue #112 cat. 10: kept pub(crate) — cross-package ABI helpers used from mx_abi.rs; wrapping adds no value
385    /// Register a C-callable function for cross-package access.
386    pub(crate) fn R_RegisterCCallable(
387        package: *const ::std::os::raw::c_char,
388        name: *const ::std::os::raw::c_char,
389        fptr: DL_FUNC,
390    );
391    /// Get a C-callable function from another package.
392    pub(crate) fn R_GetCCallable(
393        package: *const ::std::os::raw::c_char,
394        name: *const ::std::os::raw::c_char,
395    ) -> DL_FUNC;
396
397    // region: GC protection
398    //
399    // R has two GC protection mechanisms with very different cost profiles:
400    //
401    // ## Protect stack (`Rf_protect` / `Rf_unprotect`)
402    //
403    // A pre-allocated array (`R_PPStack`) with an integer index (`R_PPStackTop`).
404    // Protect pushes: `R_PPStack[R_PPStackTop++] = s`.
405    // Unprotect pops: `R_PPStackTop -= n`.
406    // **No heap allocation. No GC pressure. Essentially a single memory write.**
407    // Use this for temporary protection within a function.
408    // Requires LIFO discipline — nested scopes are fine, interleaved are not.
409    //
410    // ## Precious list (`R_PreserveObject` / `R_ReleaseObject`)
411    //
412    // A global linked list of CONSXP cells (`R_PreciousList`).
413    // Preserve: `CONS(object, R_PreciousList)` — **allocates a cons cell every call**.
414    // Release: linear scan of the entire list to find and unlink the object — **O(n)**.
415    // (Optional `R_HASH_PRECIOUS` env var enables a 1069-bucket hash table, improving
416    // Release to O(bucket_size), but Preserve still allocates.)
417    // Use this only for long-lived objects that outlive any single protect scope.
418    //
419    // ## Cost summary
420    //
421    // | Operation            | Cost               | Allocates? |
422    // |----------------------|--------------------|------------|
423    // | `Rf_protect`         | array write        | no         |
424    // | `Rf_unprotect(n)`    | integer subtract   | no         |
425    // | `Rf_unprotect_ptr`   | scan + shift       | no         |
426    // | `R_PreserveObject`   | cons cell alloc    | **yes**    |
427    // | `R_ReleaseObject`    | linked list scan   | no (O(n))  |
428    // | `R_ProtectWithIndex` | array write + save | no         |
429    // | `R_Reprotect`        | array index write  | no         |
430
431    /// Add a SEXP to the protect stack, preventing GC collection.
432    ///
433    /// **Cost: O(1)** — single array write (`R_PPStack[top++] = s`). No allocation.
434    ///
435    /// Must be balanced by a corresponding `Rf_unprotect`. The protect stack is
436    /// LIFO — nested scopes are safe, but interleaved usage from different scopes
437    /// will cause incorrect unprotection.
438    #[doc(alias = "PROTECT")]
439    #[doc(alias = "protect")]
440    pub fn Rf_protect(s: SEXP) -> SEXP;
441
442    /// Pop the top `l` entries from the protect stack.
443    ///
444    /// **Cost: O(1)** — single integer subtract (`R_PPStackTop -= l`). No allocation.
445    ///
446    /// The popped SEXPs become eligible for GC. Must match the number of
447    /// `Rf_protect` calls in the current scope (LIFO order).
448    #[doc(alias = "UNPROTECT")]
449    #[doc(alias = "unprotect")]
450    pub fn Rf_unprotect(l: ::std::os::raw::c_int);
451
452    /// Remove a specific SEXP from anywhere in the protect stack.
453    ///
454    /// **Cost: O(k)** — scans backwards from top (k = distance from top), then
455    /// shifts remaining entries down. No allocation. R source comment:
456    /// *"should be among the top few items"*.
457    ///
458    /// Unlike `Rf_unprotect`, this is order-independent — it finds and removes
459    /// the specific pointer regardless of stack position. Useful when LIFO
460    /// discipline cannot be maintained, but more expensive than `Rf_unprotect`.
461    #[doc(alias = "UNPROTECT_PTR")]
462    pub fn Rf_unprotect_ptr(s: SEXP);
463
464    /// Add a SEXP to the global precious list, preventing GC indefinitely.
465    ///
466    /// **Cost: O(1) but allocates a CONSXP cell** — creates GC pressure on every
467    /// call. The precious list is a global linked list (`R_PreciousList`).
468    ///
469    /// Use only for long-lived objects (e.g., ExternalPtr stored across R calls).
470    /// For temporary protection within a function, prefer `Rf_protect`.
471    pub fn R_PreserveObject(object: SEXP);
472
473    /// Remove a SEXP from the global precious list, allowing GC.
474    ///
475    /// **Cost: O(n)** — linear scan of the entire precious list to find and unlink
476    /// the cons cell. With `R_HASH_PRECIOUS` env var, O(bucket_size) average
477    /// via a 1069-bucket hash table, but this is off by default.
478    pub fn R_ReleaseObject(object: SEXP);
479
480    // endregion
481    // Vector allocation functions
482    #[doc(alias = "allocVector")]
483    pub fn Rf_allocVector(sexptype: SEXPTYPE, length: R_xlen_t) -> SEXP;
484    #[doc(alias = "allocMatrix")]
485    pub fn Rf_allocMatrix(
486        sexptype: SEXPTYPE,
487        nrow: ::std::os::raw::c_int,
488        ncol: ::std::os::raw::c_int,
489    ) -> SEXP;
490    #[doc(alias = "allocArray")]
491    pub fn Rf_allocArray(sexptype: SEXPTYPE, dims: SEXP) -> SEXP;
492    #[doc(alias = "alloc3DArray")]
493    pub fn Rf_alloc3DArray(
494        sexptype: SEXPTYPE,
495        nrow: ::std::os::raw::c_int,
496        ncol: ::std::os::raw::c_int,
497        nface: ::std::os::raw::c_int,
498    ) -> SEXP;
499
500    // Pairlist allocation
501    // Issue #112 cat. 10: kept pub(crate) — 2 callers in expression.rs/dots.rs; wrapping adds no value
502    #[doc(alias = "allocList")]
503    pub(crate) fn Rf_allocList(n: ::std::os::raw::c_int) -> SEXP;
504    /// Allocate a language object. Requires R >= 4.4.1; the portable
505    /// [`crate::gc_protect::ProtectScope::alloc_lang`] also supports R 4.4.0.
506    #[doc(alias = "allocLang")]
507    pub fn Rf_allocLang(n: ::std::os::raw::c_int) -> SEXP;
508    #[doc(alias = "allocS4Object")]
509    pub fn Rf_allocS4Object() -> SEXP;
510
511    // Pairlist construction — encapsulated by PairListExt trait
512    pub fn Rf_cons(car: SEXP, cdr: SEXP) -> SEXP;
513    pub fn Rf_lcons(car: SEXP, cdr: SEXP) -> SEXP;
514
515    // Attribute manipulation — encapsulated by SexpExt methods
516    #[doc(alias = "setAttrib")]
517    pub fn Rf_setAttrib(vec: SEXP, name: SEXP, val: SEXP) -> SEXP;
518
519    // Rinternals.h — scalar constructors; encapsulated by SEXP::scalar_*() / scalar_*_unchecked()
520    #[doc(alias = "ScalarComplex")]
521    pub fn Rf_ScalarComplex(x: Rcomplex) -> SEXP;
522    #[doc(alias = "ScalarInteger")]
523    pub fn Rf_ScalarInteger(x: ::std::os::raw::c_int) -> SEXP;
524    #[doc(alias = "ScalarLogical")]
525    pub fn Rf_ScalarLogical(x: ::std::os::raw::c_int) -> SEXP;
526    #[doc(alias = "ScalarRaw")]
527    pub fn Rf_ScalarRaw(x: Rbyte) -> SEXP;
528    #[doc(alias = "ScalarReal")]
529    pub fn Rf_ScalarReal(x: f64) -> SEXP;
530    #[doc(alias = "ScalarString")]
531    pub fn Rf_ScalarString(x: SEXP) -> SEXP;
532
533    // Rinternals.h
534    /// Non-API function - use DATAPTR_RO or DATAPTR_OR_NULL instead.
535    /// Only available with `nonapi` feature.
536    #[cfg(feature = "nonapi")]
537    pub(crate) fn DATAPTR(x: SEXP) -> *mut ::std::os::raw::c_void;
538    pub fn DATAPTR_RO(x: SEXP) -> *const ::std::os::raw::c_void;
539    pub fn DATAPTR_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_void;
540
541    // region: Cons Cell (Pairlist) Accessors
542    //
543    // R's pairlists (LISTSXP) are cons cells like in Lisp/Scheme. Each node has:
544    // - CAR: The value/head element
545    // - CDR: The rest/tail of the list (another pairlist or R_NilValue)
546    // - TAG: An optional name (symbol) for named lists/arguments
547    //
548    // Example R pairlist: list(a = 1, b = 2, 3)
549    // - First node:  CAR=1,    TAG="a",  CDR=<next node>
550    // - Second node: CAR=2,    TAG="b",  CDR=<next node>
551    // - Third node:  CAR=3,    TAG=NULL, CDR=R_NilValue
552    //
553    // Pairlists are used for:
554    // - Function arguments (formal parameters and actual arguments)
555    // - Language objects (calls)
556    // - Dotted pairs in old-style lists
557    //
558    // The names CAR/CDR come from Lisp:
559    // - CAR = "Contents of Address part of Register"
560    // - CDR = "Contents of Decrement part of Register" (pronounced "could-er")
561    //
562    // Modern R mostly uses generic vectors (VECSXP) instead of pairlists,
563    // but pairlists are still used internally for function calls.
564
565    // Pairlist accessors — basic ops encapsulated by PairListExt trait,
566    // compound accessors (CAAR, CADR, etc.) module-private since no callers exist.
567    pub fn CAR(e: SEXP) -> SEXP;
568    pub fn CDR(e: SEXP) -> SEXP;
569    pub fn CAAR(e: SEXP) -> SEXP;
570    pub fn CDAR(e: SEXP) -> SEXP;
571    pub fn CADR(e: SEXP) -> SEXP;
572    pub fn CDDR(e: SEXP) -> SEXP;
573    pub fn CADDR(e: SEXP) -> SEXP;
574    pub fn CADDDR(e: SEXP) -> SEXP;
575    pub fn CAD4R(e: SEXP) -> SEXP;
576    pub fn TAG(e: SEXP) -> SEXP;
577    pub fn SET_TAG(x: SEXP, y: SEXP);
578    pub fn SETCAR(x: SEXP, y: SEXP) -> SEXP;
579    pub fn SETCDR(x: SEXP, y: SEXP) -> SEXP;
580    pub fn SETCADR(x: SEXP, y: SEXP) -> SEXP;
581    pub fn SETCADDR(x: SEXP, y: SEXP) -> SEXP;
582    pub fn SETCADDDR(x: SEXP, y: SEXP) -> SEXP;
583    pub fn SETCAD4R(e: SEXP, y: SEXP) -> SEXP;
584    pub fn LOGICAL_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_int;
585    pub fn INTEGER_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_int;
586    pub fn REAL_OR_NULL(x: SEXP) -> *const f64;
587    pub fn COMPLEX_OR_NULL(x: SEXP) -> *const Rcomplex;
588    pub fn RAW_OR_NULL(x: SEXP) -> *const Rbyte;
589
590    // Element-wise accessors (ALTREP-aware) — encapsulated by SexpExt methods
591    pub fn INTEGER_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int;
592    pub fn REAL_ELT(x: SEXP, i: R_xlen_t) -> f64;
593    pub fn LOGICAL_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int;
594    pub fn COMPLEX_ELT(x: SEXP, i: R_xlen_t) -> Rcomplex;
595    pub fn RAW_ELT(x: SEXP, i: R_xlen_t) -> Rbyte;
596    pub fn VECTOR_ELT(x: SEXP, i: R_xlen_t) -> SEXP;
597    pub fn STRING_ELT(x: SEXP, i: R_xlen_t) -> SEXP;
598    pub fn SET_STRING_ELT(x: SEXP, i: R_xlen_t, v: SEXP);
599    pub fn SET_LOGICAL_ELT(x: SEXP, i: R_xlen_t, v: ::std::os::raw::c_int);
600    pub fn SET_INTEGER_ELT(x: SEXP, i: R_xlen_t, v: ::std::os::raw::c_int);
601    pub fn SET_REAL_ELT(x: SEXP, i: R_xlen_t, v: f64);
602    pub fn SET_COMPLEX_ELT(x: SEXP, i: R_xlen_t, v: Rcomplex);
603    pub fn SET_RAW_ELT(x: SEXP, i: R_xlen_t, v: Rbyte);
604    pub fn SET_VECTOR_ELT(x: SEXP, i: R_xlen_t, v: SEXP) -> SEXP;
605
606    // endregion
607
608    // region: SEXP metadata accessors
609
610    /// Get the length of a SEXP as `int` (for short vectors < 2^31).
611    ///
612    /// For long vectors, use `Rf_xlength()` instead.
613    /// Returns 0 for R_NilValue.
614    pub fn LENGTH(x: SEXP) -> ::std::os::raw::c_int;
615
616    /// Get the length of a SEXP as `R_xlen_t` (supports long vectors).
617    ///
618    /// ALTREP-aware: will call ALTREP Length method if needed.
619    pub fn XLENGTH(x: SEXP) -> R_xlen_t;
620
621    /// Non-zero if `x` has any attributes (`ATTRIB(x) != R_NilValue`).
622    ///
623    /// The API replacement for testing `ATTRIB`. R 4.5.0 added it: R 4.4's
624    /// libR does not export it, so a package that references it fails to
625    /// load there, and it is declared only when building against R >= 4.5
626    /// (`r_4_5`, #1905). `SexpExt::has_attributes` works on R 4.4 as well.
627    /// Unlike `attributes()`, it ignores the tag names of a pairlist.
628    #[cfg(r_4_5)]
629    #[doc(alias = "NO_ATTRIB")]
630    pub fn ANY_ATTRIB(x: SEXP) -> ::std::os::raw::c_int;
631
632    // Non-API attribute / header-bit accessors. `R CMD check` (R >= 4.6)
633    // reports each as a non-API entry point, so they need the `nonapi`
634    // feature. The API routes are `SexpExt::has_attributes`,
635    // `SexpExt::get_attr` / `SexpExt::set_attr`, `SexpExt::is_object`,
636    // `SexpExt::is_identical` and `DUPLICATE_ATTRIB` / `SHALLOW_DUPLICATE_ATTRIB`.
637
638    /// Get the attributes pairlist of a SEXP. Non-API (`nonapi` feature).
639    ///
640    /// Returns R_NilValue if no attributes. To ask whether there are any
641    /// attributes, use `SexpExt::has_attributes`; to read one, use
642    /// `SexpExt::get_attr`.
643    #[cfg(feature = "nonapi")]
644    pub fn ATTRIB(x: SEXP) -> SEXP;
645
646    /// Set the attributes pairlist of a SEXP. Non-API (`nonapi` feature).
647    ///
648    /// Prefer `SexpExt::set_attr` (one attribute) or `DUPLICATE_ATTRIB` /
649    /// `SHALLOW_DUPLICATE_ATTRIB` (copy all of them), which keep the object
650    /// bit consistent with the `class` attribute.
651    ///
652    /// # Safety
653    ///
654    /// `v` must be a pairlist or R_NilValue
655    #[cfg(feature = "nonapi")]
656    pub fn SET_ATTRIB(x: SEXP, v: SEXP);
657
658    /// Check if SEXP has the "object" bit set (has a class). Non-API
659    /// (`nonapi` feature); use `SexpExt::is_object` (`Rf_isObject`).
660    ///
661    /// Returns non-zero if object has a class attribute.
662    #[cfg(feature = "nonapi")]
663    pub fn OBJECT(x: SEXP) -> ::std::os::raw::c_int;
664
665    /// Set the "object" bit. Non-API (`nonapi` feature); setting a `class`
666    /// attribute with `SexpExt::set_class` sets it.
667    #[cfg(feature = "nonapi")]
668    pub fn SET_OBJECT(x: SEXP, v: ::std::os::raw::c_int);
669
670    /// Get the `gp` header bits. Non-API (`nonapi` feature).
671    ///
672    /// Not a factor's levels: those are the `levels` attribute
673    /// (`SexpExt::get_levels`).
674    #[cfg(feature = "nonapi")]
675    pub fn LEVELS(x: SEXP) -> ::std::os::raw::c_int;
676
677    /// Set the `gp` header bits. Non-API (`nonapi` feature).
678    ///
679    /// Returns the value that was set.
680    #[cfg(feature = "nonapi")]
681    pub fn SETLEVELS(x: SEXP, v: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
682
683    // endregion
684
685    // region: ALTREP support — data2 encapsulated by AltrepSexpExt; data1 via standalone helpers
686
687    // Issue #112 cat. 6: pub(crate) — no AltrepSexpExt method yet; available for future callers
688    pub(crate) fn ALTREP_CLASS(x: SEXP) -> SEXP;
689    pub fn R_altrep_data1(x: SEXP) -> SEXP;
690    pub fn R_altrep_data2(x: SEXP) -> SEXP;
691    pub fn R_set_altrep_data1(x: SEXP, v: SEXP);
692    pub fn R_set_altrep_data2(x: SEXP, v: SEXP);
693
694    /// Check if a SEXP is an ALTREP object (returns non-zero if true).
695    ///
696    /// Use `SexpExt::is_altrep()` instead of calling this directly.
697    pub fn ALTREP(x: SEXP) -> ::std::os::raw::c_int;
698
699    // endregion
700
701    // region: Vector data accessors (mutable pointers)
702    // Issue #112 cat. 5: kept pub(crate) — raw pointer access needed in RNativeType impls and scattered callers;
703    //   partial migration to SexpExt::as_mut_slice() tracked in follow-up issue
704
705    /// Get mutable pointer to logical vector data.
706    ///
707    /// For ALTREP vectors, this may force materialization.
708    /// Get mutable pointer to logical vector data.
709    ///
710    /// For ALTREP vectors, this may force materialization.
711    /// Prefer `SexpExt::set_logical_elt()` / `SexpExt::logical_elt()`.
712    pub(crate) fn LOGICAL(x: SEXP) -> *mut ::std::os::raw::c_int;
713
714    /// Get mutable pointer to integer vector data.
715    ///
716    /// For ALTREP vectors, this may force materialization.
717    /// Prefer `SexpExt::set_integer_elt()` / `SexpExt::integer_elt()`.
718    pub(crate) fn INTEGER(x: SEXP) -> *mut ::std::os::raw::c_int;
719
720    /// Get mutable pointer to real vector data.
721    ///
722    /// For ALTREP vectors, this may force materialization.
723    /// Prefer `SexpExt::set_real_elt()` / `SexpExt::real_elt()`.
724    pub(crate) fn REAL(x: SEXP) -> *mut f64;
725
726    /// Get mutable pointer to complex vector data.
727    ///
728    /// For ALTREP vectors, this may force materialization.
729    /// Prefer `SexpExt::set_complex_elt()` / `SexpExt::complex_elt()`.
730    pub(crate) fn COMPLEX(x: SEXP) -> *mut Rcomplex;
731
732    /// Get mutable pointer to raw vector data.
733    ///
734    /// For ALTREP vectors, this may force materialization.
735    /// Prefer `SexpExt::set_raw_elt()` / `SexpExt::raw_elt()`.
736    pub(crate) fn RAW(x: SEXP) -> *mut Rbyte;
737
738    // endregion
739
740    // region: User interrupt and utilities
741
742    // utils.h
743    pub fn R_CheckUserInterrupt();
744
745    // endregion
746
747    // region: Type checking — encapsulated by SexpExt::type_of()
748
749    pub fn TYPEOF(x: SEXP) -> SEXPTYPE;
750
751    // endregion
752
753    // Symbol creation and access
754    #[doc(alias = "install")]
755    pub fn Rf_install(name: *const ::std::os::raw::c_char) -> SEXP;
756    /// Get the print name (CHARSXP) of a symbol (SYMSXP)
757    pub fn PRINTNAME(x: SEXP) -> SEXP;
758    /// Get the C string pointer from a CHARSXP — encapsulated by SexpExt::r_char()
759    #[doc(alias = "CHAR")]
760    pub fn R_CHAR(x: SEXP) -> *const ::std::os::raw::c_char;
761
762    // Attribute access
763    // Attribute accessors — encapsulated by SexpExt methods
764    /// Read an attribute from an object by symbol (e.g. `R_NamesSymbol`).
765    ///
766    /// Returns `R_NilValue` if the attribute is not set.
767    #[doc(alias = "getAttrib")]
768    pub fn Rf_getAttrib(vec: SEXP, name: SEXP) -> SEXP;
769    /// Set the `names` attribute; returns the updated object.
770    #[doc(alias = "namesgets")]
771    pub fn Rf_namesgets(vec: SEXP, val: SEXP) -> SEXP;
772    /// Set the `dim` attribute; returns the updated object.
773    #[doc(alias = "dimgets")]
774    pub fn Rf_dimgets(vec: SEXP, val: SEXP) -> SEXP;
775
776    // Duplication
777    #[doc(alias = "duplicate")]
778    pub fn Rf_duplicate(s: SEXP) -> SEXP;
779    #[doc(alias = "shallow_duplicate")]
780    pub fn Rf_shallow_duplicate(s: SEXP) -> SEXP;
781
782    // Object comparison
783    /// Check if two R objects are identical (deep semantic equality).
784    ///
785    /// This is the C implementation of R's `identical()` function.
786    ///
787    /// # Flags
788    ///
789    /// Use the `IDENT_*` constants below. Flags are inverted: set bit = disable that check.
790    ///
791    /// **Default from R**: `IDENT_USE_CLOENV` (16) - ignore closure environments
792    ///
793    /// # Returns
794    ///
795    /// `TRUE` if identical, `FALSE` otherwise.
796    ///
797    /// # Performance
798    ///
799    /// Fast-path: Returns `TRUE` immediately if pointers are equal.
800    pub fn R_compute_identical(x: SEXP, y: SEXP, flags: ::std::os::raw::c_int) -> Rboolean;
801}
802
803/// Flags for `R_compute_identical` (bitmask, inverted logic: set bit = disable check).
804pub const IDENT_NUM_AS_BITS: ::std::os::raw::c_int = 1;
805/// Treat all NAs as identical (ignore NA payload differences).
806pub const IDENT_NA_AS_BITS: ::std::os::raw::c_int = 2;
807/// Compare attributes in order (not as a set).
808pub const IDENT_ATTR_BY_ORDER: ::std::os::raw::c_int = 4;
809/// Include bytecode in comparison.
810pub const IDENT_USE_BYTECODE: ::std::os::raw::c_int = 8;
811/// Include closure environments in comparison.
812pub const IDENT_USE_CLOENV: ::std::os::raw::c_int = 16;
813/// Include source references in comparison.
814pub const IDENT_USE_SRCREF: ::std::os::raw::c_int = 32;
815/// Compare external pointers as references (not by address).
816pub const IDENT_EXTPTR_AS_REF: ::std::os::raw::c_int = 64;
817
818// Additional checked R API declarations used by conversion and reflection code.
819#[allow(missing_docs)]
820#[allow(missing_docs)]
unsafe extern "C-unwind" {
    #[doc(alias = "asLogical")]
    #[doc = "Unchecked FFI binding for `Rf_asLogical`."]
    #[doc = "Generated from source location line 824, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_asLogical"]
    pub fn Rf_asLogical_unchecked(x: SEXP)
    -> ::std::os::raw::c_int;
    #[doc(alias = "asInteger")]
    #[doc = "Unchecked FFI binding for `Rf_asInteger`."]
    #[doc = "Generated from source location line 826, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_asInteger"]
    pub fn Rf_asInteger_unchecked(x: SEXP)
    -> ::std::os::raw::c_int;
    #[doc(alias = "asReal")]
    #[doc = "Unchecked FFI binding for `Rf_asReal`."]
    #[doc = "Generated from source location line 828, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_asReal"]
    pub fn Rf_asReal_unchecked(x: SEXP)
    -> f64;
    #[doc(alias = "asChar")]
    #[doc = "Unchecked FFI binding for `Rf_asChar`."]
    #[doc = "Generated from source location line 830, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_asChar"]
    pub fn Rf_asChar_unchecked(x: SEXP)
    -> SEXP;
    #[doc(alias = "coerceVector")]
    #[doc = "Unchecked FFI binding for `Rf_coerceVector`."]
    #[doc = "Generated from source location line 832, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_coerceVector"]
    pub fn Rf_coerceVector_unchecked(v: SEXP, sexptype: SEXPTYPE)
    -> SEXP;
    #[doc(alias = "nrows")]
    #[doc = "Unchecked FFI binding for `Rf_nrows`."]
    #[doc = "Generated from source location line 836, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_nrows"]
    pub fn Rf_nrows_unchecked(x: SEXP)
    -> ::std::os::raw::c_int;
    #[doc(alias = "ncols")]
    #[doc = "Unchecked FFI binding for `Rf_ncols`."]
    #[doc = "Generated from source location line 838, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_ncols"]
    pub fn Rf_ncols_unchecked(x: SEXP)
    -> ::std::os::raw::c_int;
    #[doc(alias = "inherits")]
    #[doc = "Unchecked FFI binding for `Rf_inherits`."]
    #[doc = "Generated from source location line 842, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_inherits"]
    pub fn Rf_inherits_unchecked(x: SEXP,
    klass: *const ::std::os::raw::c_char)
    -> Rboolean;
    #[doc(alias = "isNull")]
    #[doc = "Unchecked FFI binding for `Rf_isNull`."]
    #[doc = "Generated from source location line 846, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isNull"]
    pub fn Rf_isNull_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isSymbol")]
    #[doc = "Unchecked FFI binding for `Rf_isSymbol`."]
    #[doc = "Generated from source location line 848, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isSymbol"]
    pub fn Rf_isSymbol_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isLogical")]
    #[doc = "Unchecked FFI binding for `Rf_isLogical`."]
    #[doc = "Generated from source location line 850, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isLogical"]
    pub fn Rf_isLogical_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isReal")]
    #[doc = "Unchecked FFI binding for `Rf_isReal`."]
    #[doc = "Generated from source location line 852, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isReal"]
    pub fn Rf_isReal_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isComplex")]
    #[doc = "Unchecked FFI binding for `Rf_isComplex`."]
    #[doc = "Generated from source location line 854, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isComplex"]
    pub fn Rf_isComplex_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isExpression")]
    #[doc = "Unchecked FFI binding for `Rf_isExpression`."]
    #[doc = "Generated from source location line 856, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isExpression"]
    pub fn Rf_isExpression_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isEnvironment")]
    #[doc = "Unchecked FFI binding for `Rf_isEnvironment`."]
    #[doc = "Generated from source location line 858, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isEnvironment"]
    pub fn Rf_isEnvironment_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isString")]
    #[doc = "Unchecked FFI binding for `Rf_isString`."]
    #[doc = "Generated from source location line 860, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isString"]
    pub fn Rf_isString_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isArray")]
    #[doc = "Unchecked FFI binding for `Rf_isArray`."]
    #[doc = "Generated from source location line 864, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isArray"]
    pub fn Rf_isArray_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isMatrix")]
    #[doc = "Unchecked FFI binding for `Rf_isMatrix`."]
    #[doc = "Generated from source location line 866, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isMatrix"]
    pub fn Rf_isMatrix_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isList")]
    #[doc = "Unchecked FFI binding for `Rf_isList`."]
    #[doc = "Generated from source location line 868, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isList"]
    pub fn Rf_isList_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isNewList")]
    #[doc = "Unchecked FFI binding for `Rf_isNewList`."]
    #[doc = "Generated from source location line 870, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isNewList"]
    pub fn Rf_isNewList_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isPairList")]
    #[doc = "Unchecked FFI binding for `Rf_isPairList`."]
    #[doc = "Generated from source location line 872, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isPairList"]
    pub fn Rf_isPairList_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isFunction")]
    #[doc = "Unchecked FFI binding for `Rf_isFunction`."]
    #[doc = "Generated from source location line 874, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isFunction"]
    pub fn Rf_isFunction_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isPrimitive")]
    #[doc = "Unchecked FFI binding for `Rf_isPrimitive`."]
    #[doc = "Generated from source location line 876, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isPrimitive"]
    pub fn Rf_isPrimitive_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isLanguage")]
    #[doc = "Unchecked FFI binding for `Rf_isLanguage`."]
    #[doc = "Generated from source location line 878, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isLanguage"]
    pub fn Rf_isLanguage_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isDataFrame")]
    #[doc = "Unchecked FFI binding for `Rf_isDataFrame`."]
    #[doc = "Generated from source location line 880, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isDataFrame"]
    pub fn Rf_isDataFrame_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isFactor")]
    #[doc = "Unchecked FFI binding for `Rf_isFactor`."]
    #[doc = "Generated from source location line 882, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isFactor"]
    pub fn Rf_isFactor_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isInteger")]
    #[doc = "Unchecked FFI binding for `Rf_isInteger`."]
    #[doc = "Generated from source location line 884, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isInteger"]
    pub fn Rf_isInteger_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "isObject")]
    #[doc = "Unchecked FFI binding for `Rf_isObject`."]
    #[doc = "Generated from source location line 886, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isObject"]
    pub fn Rf_isObject_unchecked(s: SEXP)
    -> Rboolean;
    #[doc(alias = "elt")]
    #[doc = "Unchecked FFI binding for `Rf_elt`."]
    #[doc = "Generated from source location line 890, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_elt"]
    pub fn Rf_elt_unchecked(list: SEXP, i: ::std::os::raw::c_int)
    -> SEXP;
    #[doc(alias = "lastElt")]
    #[doc = "Unchecked FFI binding for `Rf_lastElt`."]
    #[doc = "Generated from source location line 892, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_lastElt"]
    pub fn Rf_lastElt_unchecked(list: SEXP)
    -> SEXP;
    #[doc(alias = "nthcdr")]
    #[doc = "Unchecked FFI binding for `Rf_nthcdr`."]
    #[doc = "Generated from source location line 894, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_nthcdr"]
    pub fn Rf_nthcdr_unchecked(list: SEXP, n: ::std::os::raw::c_int)
    -> SEXP;
    #[doc(alias = "listAppend")]
    #[doc = "Unchecked FFI binding for `Rf_listAppend`."]
    #[doc = "Generated from source location line 896, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_listAppend"]
    pub fn Rf_listAppend_unchecked(s: SEXP, t: SEXP)
    -> SEXP;
    #[doc = " Set the class attribute of a vector."]
    #[doc = ""]
    #[doc = " Equivalent to R\'s `class(vec) <- klass` syntax."]
    #[doc = " The \"gets\" suffix indicates this is a setter function."]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " Returns the modified vector (like all \"*gets\" functions)."]
    #[doc(alias = "classgets")]
    #[doc = "Unchecked FFI binding for `Rf_classgets`."]
    #[doc = "Generated from source location line 912, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_classgets"]
    pub fn Rf_classgets_unchecked(vec: SEXP, klass: SEXP)
    -> SEXP;
    #[doc = " Set the dimnames attribute of an array/matrix."]
    #[doc = ""]
    #[doc = " Equivalent to R\'s `dimnames(vec) <- val` syntax."]
    #[doc = " The \"gets\" suffix indicates this is a setter function."]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " Returns the modified vector."]
    #[doc(alias = "dimnamesgets")]
    #[doc = "Unchecked FFI binding for `Rf_dimnamesgets`."]
    #[doc = "Generated from source location line 923, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_dimnamesgets"]
    pub fn Rf_dimnamesgets_unchecked(vec: SEXP, val: SEXP)
    -> SEXP;
    #[doc(alias = "GetRowNames")]
    #[doc = "Unchecked FFI binding for `Rf_GetRowNames`."]
    #[doc = "Generated from source location line 926, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_GetRowNames"]
    pub(crate) fn Rf_GetRowNames_unchecked(dimnames: SEXP)
    -> SEXP;
    #[doc(alias = "GetColNames")]
    #[doc = "Unchecked FFI binding for `Rf_GetColNames`."]
    #[doc = "Generated from source location line 928, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_GetColNames"]
    pub(crate) fn Rf_GetColNames_unchecked(dimnames: SEXP)
    -> SEXP;
    #[doc =
    " Single-frame (`inherits = FALSE`) or inherited variable lookup with an"]
    #[doc = " `ifnotfound` default — the API-blessed replacement for"]
    #[doc =
    " `Rf_findVarInFrame`. R 4.5.0 added it, so it is declared only when"]
    #[doc =
    " building against R >= 4.5 (`r_4_5`, #1905); for R 4.4, evaluate"]
    #[doc = " `base::get0()` instead."]
    #[doc = " **Longjmps** if `rho` is not an environment or"]
    #[doc = " the binding is `R_MissingArg`; forces promises."]
    #[doc(alias = "getVarEx")]
    #[doc = "Unchecked FFI binding for `R_getVarEx`."]
    #[doc = "Generated from source location line 940, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_getVarEx"]
    pub fn R_getVarEx_unchecked(sym: SEXP, rho: SEXP, inherits: Rboolean,
    ifnotfound: SEXP)
    -> SEXP;
    #[doc(alias = "defineVar")]
    #[doc = "Unchecked FFI binding for `Rf_defineVar`."]
    #[doc = "Generated from source location line 942, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_defineVar"]
    pub fn Rf_defineVar_unchecked(symbol: SEXP, value: SEXP, rho: SEXP);
    #[doc(alias = "setVar")]
    #[doc = "Unchecked FFI binding for `Rf_setVar`."]
    #[doc = "Generated from source location line 944, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_setVar"]
    pub fn Rf_setVar_unchecked(symbol: SEXP, value: SEXP, rho: SEXP);
    #[doc(alias = "findFun")]
    #[doc = "Unchecked FFI binding for `Rf_findFun`."]
    #[doc = "Generated from source location line 946, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_findFun"]
    pub fn Rf_findFun_unchecked(symbol: SEXP, rho: SEXP)
    -> SEXP;
    #[doc =
    " Find a registered namespace by name. **Longjmps on error** — prefer"]
    #[doc = " `REnv::package_namespace()` which wraps this safely."]
    #[doc(alias = "FindNamespace")]
    #[doc = "Unchecked FFI binding for `R_FindNamespace`."]
    #[doc = "Generated from source location line 951, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_FindNamespace"]
    pub fn R_FindNamespace_unchecked(info: SEXP)
    -> SEXP;
    #[doc =
    " Return the current execution environment (innermost closure on call"]
    #[doc = " stack, or `R_GlobalEnv` if none)."]
    #[doc(alias = "GetCurrentEnv")]
    #[doc = "Unchecked FFI binding for `R_GetCurrentEnv`."]
    #[doc = "Generated from source location line 957, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_GetCurrentEnv"]
    pub(crate) fn R_GetCurrentEnv_unchecked()
    -> SEXP;
    #[doc(alias = "eval")]
    #[doc = "Unchecked FFI binding for `Rf_eval`."]
    #[doc = "Generated from source location line 961, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_eval"]
    pub fn Rf_eval_unchecked(expr: SEXP, rho: SEXP)
    -> SEXP;
    #[doc(alias = "applyClosure")]
    #[doc = "Unchecked FFI binding for `Rf_applyClosure`."]
    #[doc = "Generated from source location line 963, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_applyClosure"]
    pub fn Rf_applyClosure_unchecked(call: SEXP, op: SEXP, args: SEXP,
    rho: SEXP, suppliedvars: SEXP, check: Rboolean)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_tryEval`."]
    #[doc = "Generated from source location line 971, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_tryEval"]
    pub fn R_tryEval_unchecked(expr: SEXP, env: SEXP,
    error_occurred: *mut ::std::os::raw::c_int)
    -> SEXP;
    #[doc =
    " Run `fun(data)` in a new top-level context: the caller\'s condition"]
    #[doc =
    " handlers and restarts are hidden from it, and any jump out of it"]
    #[doc =
    " (an unhandled error, an interrupt, an `abort` restart) stops here."]
    #[doc = " `TRUE` when `fun` returned, `FALSE` after such a jump."]
    #[doc(alias = "ToplevelExec")]
    #[doc = "Unchecked FFI binding for `R_ToplevelExec`."]
    #[doc = "Generated from source location line 981, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ToplevelExec"]
    pub(crate) fn R_ToplevelExec_unchecked(fun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)>,
    data: *mut ::std::os::raw::c_void)
    -> Rboolean;
    #[doc =
    " Call `body(bdata)` with an exiting handler for conditions of class"]
    #[doc =
    " `error`: on such a condition, `handler(cond, hdata)` runs after the"]
    #[doc =
    " unwind and its value is returned. Built on R\'s `tryCatch()`, so the"]
    #[doc = " caller\'s handlers stay visible to `body` (wrap it in"]
    #[doc = " [`R_ToplevelExec`] to hide them)."]
    #[doc(alias = "tryCatchError")]
    #[doc = "Unchecked FFI binding for `R_tryCatchError`."]
    #[doc = "Generated from source location line 991, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_tryCatchError"]
    pub(crate) fn R_tryCatchError_unchecked(body:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)
            -> SEXP>, bdata: *mut ::std::os::raw::c_void,
    handler:
        ::std::option::Option<unsafe extern "C-unwind" fn(SEXP,
            *mut ::std::os::raw::c_void) -> SEXP>,
    hdata: *mut ::std::os::raw::c_void)
    -> SEXP;
    #[doc = "Unchecked FFI binding for `R_forceAndCall`."]
    #[doc = "Generated from source location line 1001, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_forceAndCall"]
    pub fn R_forceAndCall_unchecked(e: SEXP, n: ::std::os::raw::c_int,
    rho: SEXP)
    -> SEXP;
    #[doc =
    " Parse R source text into an EXPRSXP (a list of parsed expressions)."]
    #[doc = ""]
    #[doc =
    " `text` is a STRSXP holding the source, `n` is the number of expressions"]
    #[doc =
    " to parse (`-1` for all), `status` receives the [`ParseStatus`] outcome,"]
    #[doc =
    " and `srcfile` is a srcref/`R_NilValue`. Allocates; protect the result."]
    #[doc = ""]
    #[doc =
    " Prefer the safe [`crate::expression::r_eval_str`] wrapper, which does the"]
    #[doc =
    " STRSXP construction, status check, and protection bookkeeping for you."]
    #[doc(alias = "ParseVector")]
    #[doc = "Unchecked FFI binding for `R_ParseVector`."]
    #[doc = "Generated from source location line 1012, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ParseVector"]
    pub fn R_ParseVector_unchecked(text: SEXP, n: ::std::os::raw::c_int,
    status: *mut ParseStatus, srcfile: SEXP)
    -> SEXP;
}
#[doc(alias = "asLogical")]
#[doc =
"Checked wrapper for `Rf_asLogical`. Calls `Rf_asLogical_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 824, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_asLogical(x: SEXP) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_asLogical_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "asInteger")]
#[doc =
"Checked wrapper for `Rf_asInteger`. Calls `Rf_asInteger_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 826, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_asInteger(x: SEXP) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_asInteger_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "asReal")]
#[doc =
"Checked wrapper for `Rf_asReal`. Calls `Rf_asReal_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 828, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_asReal(x: SEXP) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_asReal_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "asChar")]
#[doc =
"Checked wrapper for `Rf_asChar`. Calls `Rf_asChar_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 830, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_asChar(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_asChar_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "coerceVector")]
#[doc =
"Checked wrapper for `Rf_coerceVector`. Calls `Rf_coerceVector_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 832, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_coerceVector(v: SEXP, sexptype: SEXPTYPE) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_coerceVector_unchecked(v, sexptype)
                        })
                });
    result.0
}
#[doc(alias = "nrows")]
#[doc =
"Checked wrapper for `Rf_nrows`. Calls `Rf_nrows_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 836, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_nrows(x: SEXP) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_nrows_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "ncols")]
#[doc =
"Checked wrapper for `Rf_ncols`. Calls `Rf_ncols_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 838, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_ncols(x: SEXP) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_ncols_unchecked(x)
                        })
                });
    result.0
}
#[doc(alias = "inherits")]
#[doc =
"Checked wrapper for `Rf_inherits`. Calls `Rf_inherits_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 842, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_inherits(x: SEXP, klass: *const ::std::os::raw::c_char)
    -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_inherits_unchecked(x, klass)
                        })
                });
    result.0
}
#[doc(alias = "isNull")]
#[doc =
"Checked wrapper for `Rf_isNull`. Calls `Rf_isNull_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 846, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isNull(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isNull_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isSymbol")]
#[doc =
"Checked wrapper for `Rf_isSymbol`. Calls `Rf_isSymbol_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 848, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isSymbol(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isSymbol_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isLogical")]
#[doc =
"Checked wrapper for `Rf_isLogical`. Calls `Rf_isLogical_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 850, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isLogical(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isLogical_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isReal")]
#[doc =
"Checked wrapper for `Rf_isReal`. Calls `Rf_isReal_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 852, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isReal(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isReal_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isComplex")]
#[doc =
"Checked wrapper for `Rf_isComplex`. Calls `Rf_isComplex_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 854, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isComplex(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isComplex_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isExpression")]
#[doc =
"Checked wrapper for `Rf_isExpression`. Calls `Rf_isExpression_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 856, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isExpression(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isExpression_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isEnvironment")]
#[doc =
"Checked wrapper for `Rf_isEnvironment`. Calls `Rf_isEnvironment_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 858, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isEnvironment(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isEnvironment_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isString")]
#[doc =
"Checked wrapper for `Rf_isString`. Calls `Rf_isString_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 860, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isString(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isString_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isArray")]
#[doc =
"Checked wrapper for `Rf_isArray`. Calls `Rf_isArray_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 864, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isArray(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isArray_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isMatrix")]
#[doc =
"Checked wrapper for `Rf_isMatrix`. Calls `Rf_isMatrix_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 866, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isMatrix(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isMatrix_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isList")]
#[doc =
"Checked wrapper for `Rf_isList`. Calls `Rf_isList_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 868, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isList(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isList_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isNewList")]
#[doc =
"Checked wrapper for `Rf_isNewList`. Calls `Rf_isNewList_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 870, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isNewList(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isNewList_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isPairList")]
#[doc =
"Checked wrapper for `Rf_isPairList`. Calls `Rf_isPairList_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 872, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isPairList(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isPairList_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isFunction")]
#[doc =
"Checked wrapper for `Rf_isFunction`. Calls `Rf_isFunction_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 874, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isFunction(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isFunction_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isPrimitive")]
#[doc =
"Checked wrapper for `Rf_isPrimitive`. Calls `Rf_isPrimitive_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 876, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isPrimitive(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isPrimitive_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isLanguage")]
#[doc =
"Checked wrapper for `Rf_isLanguage`. Calls `Rf_isLanguage_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 878, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isLanguage(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isLanguage_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isDataFrame")]
#[doc =
"Checked wrapper for `Rf_isDataFrame`. Calls `Rf_isDataFrame_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 880, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isDataFrame(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isDataFrame_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isFactor")]
#[doc =
"Checked wrapper for `Rf_isFactor`. Calls `Rf_isFactor_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 882, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isFactor(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isFactor_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isInteger")]
#[doc =
"Checked wrapper for `Rf_isInteger`. Calls `Rf_isInteger_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 884, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isInteger(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isInteger_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "isObject")]
#[doc =
"Checked wrapper for `Rf_isObject`. Calls `Rf_isObject_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 886, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isObject(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isObject_unchecked(s)
                        })
                });
    result.0
}
#[doc(alias = "elt")]
#[doc =
"Checked wrapper for `Rf_elt`. Calls `Rf_elt_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 890, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_elt(list: SEXP, i: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_elt_unchecked(list, i)
                        })
                });
    result.0
}
#[doc(alias = "lastElt")]
#[doc =
"Checked wrapper for `Rf_lastElt`. Calls `Rf_lastElt_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 892, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_lastElt(list: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_lastElt_unchecked(list)
                        })
                });
    result.0
}
#[doc(alias = "nthcdr")]
#[doc =
"Checked wrapper for `Rf_nthcdr`. Calls `Rf_nthcdr_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 894, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_nthcdr(list: SEXP, n: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_nthcdr_unchecked(list, n)
                        })
                });
    result.0
}
#[doc(alias = "listAppend")]
#[doc =
"Checked wrapper for `Rf_listAppend`. Calls `Rf_listAppend_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 896, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_listAppend(s: SEXP, t: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_listAppend_unchecked(s, t)
                        })
                });
    result.0
}
#[doc = " Set the class attribute of a vector."]
#[doc = ""]
#[doc = " Equivalent to R\'s `class(vec) <- klass` syntax."]
#[doc = " The \"gets\" suffix indicates this is a setter function."]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Returns the modified vector (like all \"*gets\" functions)."]
#[doc(alias = "classgets")]
#[doc =
"Checked wrapper for `Rf_classgets`. Calls `Rf_classgets_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 912, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_classgets(vec: SEXP, klass: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_classgets_unchecked(vec, klass)
                        })
                });
    result.0
}
#[doc = " Set the dimnames attribute of an array/matrix."]
#[doc = ""]
#[doc = " Equivalent to R\'s `dimnames(vec) <- val` syntax."]
#[doc = " The \"gets\" suffix indicates this is a setter function."]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Returns the modified vector."]
#[doc(alias = "dimnamesgets")]
#[doc =
"Checked wrapper for `Rf_dimnamesgets`. Calls `Rf_dimnamesgets_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 923, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_dimnamesgets(vec: SEXP, val: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_dimnamesgets_unchecked(vec, val)
                        })
                });
    result.0
}
#[doc(alias = "GetRowNames")]
#[doc =
"Checked wrapper for `Rf_GetRowNames`. Calls `Rf_GetRowNames_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 926, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn Rf_GetRowNames(dimnames: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_GetRowNames_unchecked(dimnames)
                        })
                });
    result.0
}
#[doc(alias = "GetColNames")]
#[doc =
"Checked wrapper for `Rf_GetColNames`. Calls `Rf_GetColNames_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 928, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn Rf_GetColNames(dimnames: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_GetColNames_unchecked(dimnames)
                        })
                });
    result.0
}
#[doc =
" Single-frame (`inherits = FALSE`) or inherited variable lookup with an"]
#[doc = " `ifnotfound` default — the API-blessed replacement for"]
#[doc = " `Rf_findVarInFrame`. R 4.5.0 added it, so it is declared only when"]
#[doc = " building against R >= 4.5 (`r_4_5`, #1905); for R 4.4, evaluate"]
#[doc = " `base::get0()` instead."]
#[doc = " **Longjmps** if `rho` is not an environment or"]
#[doc = " the binding is `R_MissingArg`; forces promises."]
#[doc(alias = "getVarEx")]
#[doc =
"Checked wrapper for `R_getVarEx`. Calls `R_getVarEx_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 940, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_getVarEx(sym: SEXP, rho: SEXP, inherits: Rboolean,
    ifnotfound: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_getVarEx_unchecked(sym, rho, inherits, ifnotfound)
                        })
                });
    result.0
}
#[doc(alias = "defineVar")]
#[doc =
"Checked wrapper for `Rf_defineVar`. Calls `Rf_defineVar_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 942, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_defineVar(symbol: SEXP, value: SEXP, rho: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_defineVar_unchecked(symbol, value, rho)
                        })
                });
    result.0
}
#[doc(alias = "setVar")]
#[doc =
"Checked wrapper for `Rf_setVar`. Calls `Rf_setVar_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 944, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_setVar(symbol: SEXP, value: SEXP, rho: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_setVar_unchecked(symbol, value, rho)
                        })
                });
    result.0
}
#[doc(alias = "findFun")]
#[doc =
"Checked wrapper for `Rf_findFun`. Calls `Rf_findFun_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 946, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_findFun(symbol: SEXP, rho: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_findFun_unchecked(symbol, rho)
                        })
                });
    result.0
}
#[doc =
" Find a registered namespace by name. **Longjmps on error** — prefer"]
#[doc = " `REnv::package_namespace()` which wraps this safely."]
#[doc(alias = "FindNamespace")]
#[doc =
"Checked wrapper for `R_FindNamespace`. Calls `R_FindNamespace_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 951, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_FindNamespace(info: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_FindNamespace_unchecked(info)
                        })
                });
    result.0
}
#[doc =
" Return the current execution environment (innermost closure on call"]
#[doc = " stack, or `R_GlobalEnv` if none)."]
#[doc(alias = "GetCurrentEnv")]
#[doc =
"Checked wrapper for `R_GetCurrentEnv`. Calls `R_GetCurrentEnv_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 957, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_GetCurrentEnv() -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_GetCurrentEnv_unchecked()
                        })
                });
    result.0
}
#[doc(alias = "eval")]
#[doc =
"Checked wrapper for `Rf_eval`. Calls `Rf_eval_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 961, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_eval(expr: SEXP, rho: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_eval_unchecked(expr, rho)
                        })
                });
    result.0
}
#[doc(alias = "applyClosure")]
#[doc =
"Checked wrapper for `Rf_applyClosure`. Calls `Rf_applyClosure_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 963, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_applyClosure(call: SEXP, op: SEXP, args: SEXP, rho: SEXP,
    suppliedvars: SEXP, check: Rboolean) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_applyClosure_unchecked(call, op, args, rho, suppliedvars,
                                check)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_tryEval`. Calls `R_tryEval_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 971, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_tryEval(expr: SEXP, env: SEXP,
    error_occurred: *mut ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_tryEval_unchecked(expr, env, error_occurred)
                        })
                });
    result.0
}
#[doc =
" Run `fun(data)` in a new top-level context: the caller\'s condition"]
#[doc = " handlers and restarts are hidden from it, and any jump out of it"]
#[doc = " (an unhandled error, an interrupt, an `abort` restart) stops here."]
#[doc = " `TRUE` when `fun` returned, `FALSE` after such a jump."]
#[doc(alias = "ToplevelExec")]
#[doc =
"Checked wrapper for `R_ToplevelExec`. Calls `R_ToplevelExec_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 981, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_ToplevelExec(fun:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)>,
    data: *mut ::std::os::raw::c_void) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ToplevelExec_unchecked(fun, data)
                        })
                });
    result.0
}
#[doc = " Call `body(bdata)` with an exiting handler for conditions of class"]
#[doc =
" `error`: on such a condition, `handler(cond, hdata)` runs after the"]
#[doc =
" unwind and its value is returned. Built on R\'s `tryCatch()`, so the"]
#[doc = " caller\'s handlers stay visible to `body` (wrap it in"]
#[doc = " [`R_ToplevelExec`] to hide them)."]
#[doc(alias = "tryCatchError")]
#[doc =
"Checked wrapper for `R_tryCatchError`. Calls `R_tryCatchError_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 991, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_tryCatchError(body:
        ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)
            -> SEXP>, bdata: *mut ::std::os::raw::c_void,
    handler:
        ::std::option::Option<unsafe extern "C-unwind" fn(SEXP,
            *mut ::std::os::raw::c_void) -> SEXP>,
    hdata: *mut ::std::os::raw::c_void) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_tryCatchError_unchecked(body, bdata, handler, hdata)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_forceAndCall`. Calls `R_forceAndCall_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1001, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_forceAndCall(e: SEXP, n: ::std::os::raw::c_int, rho: SEXP)
    -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_forceAndCall_unchecked(e, n, rho)
                        })
                });
    result.0
}
#[doc =
" Parse R source text into an EXPRSXP (a list of parsed expressions)."]
#[doc = ""]
#[doc =
" `text` is a STRSXP holding the source, `n` is the number of expressions"]
#[doc =
" to parse (`-1` for all), `status` receives the [`ParseStatus`] outcome,"]
#[doc =
" and `srcfile` is a srcref/`R_NilValue`. Allocates; protect the result."]
#[doc = ""]
#[doc =
" Prefer the safe [`crate::expression::r_eval_str`] wrapper, which does the"]
#[doc =
" STRSXP construction, status check, and protection bookkeeping for you."]
#[doc(alias = "ParseVector")]
#[doc =
"Checked wrapper for `R_ParseVector`. Calls `R_ParseVector_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1012, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_ParseVector(text: SEXP, n: ::std::os::raw::c_int,
    status: *mut ParseStatus, srcfile: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ParseVector_unchecked(text, n, status, srcfile)
                        })
                });
    result.0
}#[r_ffi_checked]
821unsafe extern "C-unwind" {
822    // Type coercion — encapsulated by SexpExt methods
823    #[doc(alias = "asLogical")]
824    pub fn Rf_asLogical(x: SEXP) -> ::std::os::raw::c_int;
825    #[doc(alias = "asInteger")]
826    pub fn Rf_asInteger(x: SEXP) -> ::std::os::raw::c_int;
827    #[doc(alias = "asReal")]
828    pub fn Rf_asReal(x: SEXP) -> f64;
829    #[doc(alias = "asChar")]
830    pub fn Rf_asChar(x: SEXP) -> SEXP;
831    #[doc(alias = "coerceVector")]
832    pub fn Rf_coerceVector(v: SEXP, sexptype: SEXPTYPE) -> SEXP;
833
834    // Matrix utilities — no callers outside ffi.rs
835    #[doc(alias = "nrows")]
836    pub fn Rf_nrows(x: SEXP) -> ::std::os::raw::c_int;
837    #[doc(alias = "ncols")]
838    pub fn Rf_ncols(x: SEXP) -> ::std::os::raw::c_int;
839
840    // Inheritance checking — encapsulated by SexpExt::inherits_class()
841    #[doc(alias = "inherits")]
842    pub fn Rf_inherits(x: SEXP, klass: *const ::std::os::raw::c_char) -> Rboolean;
843
844    // Type checking predicates — encapsulated by SexpExt type-check methods
845    #[doc(alias = "isNull")]
846    pub fn Rf_isNull(s: SEXP) -> Rboolean;
847    #[doc(alias = "isSymbol")]
848    pub fn Rf_isSymbol(s: SEXP) -> Rboolean;
849    #[doc(alias = "isLogical")]
850    pub fn Rf_isLogical(s: SEXP) -> Rboolean;
851    #[doc(alias = "isReal")]
852    pub fn Rf_isReal(s: SEXP) -> Rboolean;
853    #[doc(alias = "isComplex")]
854    pub fn Rf_isComplex(s: SEXP) -> Rboolean;
855    #[doc(alias = "isExpression")]
856    pub fn Rf_isExpression(s: SEXP) -> Rboolean;
857    #[doc(alias = "isEnvironment")]
858    pub fn Rf_isEnvironment(s: SEXP) -> Rboolean;
859    #[doc(alias = "isString")]
860    pub fn Rf_isString(s: SEXP) -> Rboolean;
861
862    // Composite type checking (from inline functions)
863    #[doc(alias = "isArray")]
864    pub fn Rf_isArray(s: SEXP) -> Rboolean;
865    #[doc(alias = "isMatrix")]
866    pub fn Rf_isMatrix(s: SEXP) -> Rboolean;
867    #[doc(alias = "isList")]
868    pub fn Rf_isList(s: SEXP) -> Rboolean;
869    #[doc(alias = "isNewList")]
870    pub fn Rf_isNewList(s: SEXP) -> Rboolean;
871    #[doc(alias = "isPairList")]
872    pub fn Rf_isPairList(s: SEXP) -> Rboolean;
873    #[doc(alias = "isFunction")]
874    pub fn Rf_isFunction(s: SEXP) -> Rboolean;
875    #[doc(alias = "isPrimitive")]
876    pub fn Rf_isPrimitive(s: SEXP) -> Rboolean;
877    #[doc(alias = "isLanguage")]
878    pub fn Rf_isLanguage(s: SEXP) -> Rboolean;
879    #[doc(alias = "isDataFrame")]
880    pub fn Rf_isDataFrame(s: SEXP) -> Rboolean;
881    #[doc(alias = "isFactor")]
882    pub fn Rf_isFactor(s: SEXP) -> Rboolean;
883    #[doc(alias = "isInteger")]
884    pub fn Rf_isInteger(s: SEXP) -> Rboolean;
885    #[doc(alias = "isObject")]
886    pub fn Rf_isObject(s: SEXP) -> Rboolean;
887
888    // Pairlist utilities
889    #[doc(alias = "elt")]
890    pub fn Rf_elt(list: SEXP, i: ::std::os::raw::c_int) -> SEXP;
891    #[doc(alias = "lastElt")]
892    pub fn Rf_lastElt(list: SEXP) -> SEXP;
893    #[doc(alias = "nthcdr")]
894    pub fn Rf_nthcdr(list: SEXP, n: ::std::os::raw::c_int) -> SEXP;
895    #[doc(alias = "listAppend")]
896    pub fn Rf_listAppend(s: SEXP, t: SEXP) -> SEXP;
897
898    // More attribute setters (using R's "gets" suffix convention)
899    //
900    // See "Attribute access" section above for explanation of the "gets" suffix.
901    // These are setter functions equivalent to R's `attr(x) <- value` syntax.
902
903    /// Set the class attribute of a vector.
904    ///
905    /// Equivalent to R's `class(vec) <- klass` syntax.
906    /// The "gets" suffix indicates this is a setter function.
907    ///
908    /// # Returns
909    ///
910    /// Returns the modified vector (like all "*gets" functions).
911    #[doc(alias = "classgets")]
912    pub fn Rf_classgets(vec: SEXP, klass: SEXP) -> SEXP;
913
914    /// Set the dimnames attribute of an array/matrix.
915    ///
916    /// Equivalent to R's `dimnames(vec) <- val` syntax.
917    /// The "gets" suffix indicates this is a setter function.
918    ///
919    /// # Returns
920    ///
921    /// Returns the modified vector.
922    #[doc(alias = "dimnamesgets")]
923    pub fn Rf_dimnamesgets(vec: SEXP, val: SEXP) -> SEXP;
924    // Issue #112 cat. 10: kept pub(crate) — 2 callers each in factor.rs/matrix helpers; wrapping adds no value
925    #[doc(alias = "GetRowNames")]
926    pub(crate) fn Rf_GetRowNames(dimnames: SEXP) -> SEXP;
927    #[doc(alias = "GetColNames")]
928    pub(crate) fn Rf_GetColNames(dimnames: SEXP) -> SEXP;
929
930    // Environment operations
931    /// Single-frame (`inherits = FALSE`) or inherited variable lookup with an
932    /// `ifnotfound` default — the API-blessed replacement for
933    /// `Rf_findVarInFrame`. R 4.5.0 added it, so it is declared only when
934    /// building against R >= 4.5 (`r_4_5`, #1905); for R 4.4, evaluate
935    /// `base::get0()` instead.
936    /// **Longjmps** if `rho` is not an environment or
937    /// the binding is `R_MissingArg`; forces promises.
938    #[cfg(r_4_5)]
939    #[doc(alias = "getVarEx")]
940    pub fn R_getVarEx(sym: SEXP, rho: SEXP, inherits: Rboolean, ifnotfound: SEXP) -> SEXP;
941    #[doc(alias = "defineVar")]
942    pub fn Rf_defineVar(symbol: SEXP, value: SEXP, rho: SEXP);
943    #[doc(alias = "setVar")]
944    pub fn Rf_setVar(symbol: SEXP, value: SEXP, rho: SEXP);
945    #[doc(alias = "findFun")]
946    pub fn Rf_findFun(symbol: SEXP, rho: SEXP) -> SEXP;
947
948    /// Find a registered namespace by name. **Longjmps on error** — prefer
949    /// `REnv::package_namespace()` which wraps this safely.
950    #[doc(alias = "FindNamespace")]
951    pub fn R_FindNamespace(info: SEXP) -> SEXP;
952
953    // Issue #112 cat. 9: kept pub(crate) — R_GetCurrentEnv used from s4_helpers.rs
954    /// Return the current execution environment (innermost closure on call
955    /// stack, or `R_GlobalEnv` if none).
956    #[doc(alias = "GetCurrentEnv")]
957    pub(crate) fn R_GetCurrentEnv() -> SEXP;
958
959    // Evaluation
960    #[doc(alias = "eval")]
961    pub fn Rf_eval(expr: SEXP, rho: SEXP) -> SEXP;
962    #[doc(alias = "applyClosure")]
963    pub fn Rf_applyClosure(
964        call: SEXP,
965        op: SEXP,
966        args: SEXP,
967        rho: SEXP,
968        suppliedvars: SEXP,
969        check: Rboolean,
970    ) -> SEXP;
971    pub fn R_tryEval(expr: SEXP, env: SEXP, error_occurred: *mut ::std::os::raw::c_int) -> SEXP;
972    // Kept pub(crate): the safe entries are `RCall::eval` / `r_eval_str`
973    // (expression.rs), which combine the two below, and
974    // `try_eval_with_handlers`, which runs `R_tryCatchError` alone inside its
975    // own `R_UnwindProtect`.
976    /// Run `fun(data)` in a new top-level context: the caller's condition
977    /// handlers and restarts are hidden from it, and any jump out of it
978    /// (an unhandled error, an interrupt, an `abort` restart) stops here.
979    /// `TRUE` when `fun` returned, `FALSE` after such a jump.
980    #[doc(alias = "ToplevelExec")]
981    pub(crate) fn R_ToplevelExec(
982        fun: ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)>,
983        data: *mut ::std::os::raw::c_void,
984    ) -> Rboolean;
985    /// Call `body(bdata)` with an exiting handler for conditions of class
986    /// `error`: on such a condition, `handler(cond, hdata)` runs after the
987    /// unwind and its value is returned. Built on R's `tryCatch()`, so the
988    /// caller's handlers stay visible to `body` (wrap it in
989    /// [`R_ToplevelExec`] to hide them).
990    #[doc(alias = "tryCatchError")]
991    pub(crate) fn R_tryCatchError(
992        body: ::std::option::Option<
993            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void) -> SEXP,
994        >,
995        bdata: *mut ::std::os::raw::c_void,
996        handler: ::std::option::Option<
997            unsafe extern "C-unwind" fn(SEXP, *mut ::std::os::raw::c_void) -> SEXP,
998        >,
999        hdata: *mut ::std::os::raw::c_void,
1000    ) -> SEXP;
1001    pub fn R_forceAndCall(e: SEXP, n: ::std::os::raw::c_int, rho: SEXP) -> SEXP;
1002
1003    /// Parse R source text into an EXPRSXP (a list of parsed expressions).
1004    ///
1005    /// `text` is a STRSXP holding the source, `n` is the number of expressions
1006    /// to parse (`-1` for all), `status` receives the [`ParseStatus`] outcome,
1007    /// and `srcfile` is a srcref/`R_NilValue`. Allocates; protect the result.
1008    ///
1009    /// Prefer the safe [`crate::expression::r_eval_str`] wrapper, which does the
1010    /// STRSXP construction, status check, and protection bookkeeping for you.
1011    #[doc(alias = "ParseVector")]
1012    pub fn R_ParseVector(
1013        text: SEXP,
1014        n: ::std::os::raw::c_int,
1015        status: *mut ParseStatus,
1016        srcfile: SEXP,
1017    ) -> SEXP;
1018}
1019
1020/// Outcome of [`R_ParseVector`] (from `R_ext/Parse.h`).
1021///
1022/// `PARSE_NULL` is never returned by `R_ParseVector`; the meaningful success
1023/// value is [`ParseStatus::PARSE_OK`]. The remaining variants indicate parse
1024/// failures (`PARSE_ERROR`), incomplete input (`PARSE_INCOMPLETE`), or
1025/// end-of-input (`PARSE_EOF`).
1026#[allow(non_camel_case_types)]
1027#[repr(i32)]
1028#[derive(#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::fmt::Debug for ParseStatus {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ParseStatus::PARSE_NULL => "PARSE_NULL",
                ParseStatus::PARSE_OK => "PARSE_OK",
                ParseStatus::PARSE_INCOMPLETE => "PARSE_INCOMPLETE",
                ParseStatus::PARSE_ERROR => "PARSE_ERROR",
                ParseStatus::PARSE_EOF => "PARSE_EOF",
            })
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
#[allow(non_camel_case_types)]
unsafe impl ::core::clone::TrivialClone for ParseStatus { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::clone::Clone for ParseStatus {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::Copy for ParseStatus { }Copy, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::StructuralPartialEq for ParseStatus { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::PartialEq for ParseStatus {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::Eq for ParseStatus { }Eq)]
1029pub enum ParseStatus {
1030    /// Never returned by `R_ParseVector`; the default-initialized sentinel.
1031    PARSE_NULL,
1032    /// Parse succeeded.
1033    PARSE_OK,
1034    /// Input ended mid-expression (e.g. an unbalanced delimiter).
1035    PARSE_INCOMPLETE,
1036    /// A syntax error was encountered.
1037    PARSE_ERROR,
1038    /// End of input reached with no further expressions.
1039    PARSE_EOF,
1040}
1041
1042// region: Connections API (R_ext/Connections.h)
1043//
1044// Gated behind `connections` feature because R's connection API is explicitly UNSTABLE.
1045// From R_ext/Connections.h:
1046//   "IMPORTANT: we do not expect future connection APIs to be
1047//    backward-compatible so if you use this, you *must* check the
1048//    version and proceeds only if it matches what you expect.
1049//
1050//    We explicitly reserve the right to change the connection
1051//    implementation without a compatibility layer."
1052//
1053// Use with caution and always check R_CONNECTIONS_VERSION.
1054// Issue #112 cat. 8: kept pub(crate) — feature-gated behind `connections`; behind Connection type for users
1055#[r_ffi_checked]
1056#[cfg(feature = "connections")]
1057unsafe extern "C-unwind" {
1058    /// Create a new custom connection.
1059    ///
1060    /// # WARNING
1061    ///
1062    /// This API is UNSTABLE. Check `R_CONNECTIONS_VERSION` before use.
1063    /// The connection implementation may change without notice.
1064    ///
1065    /// # Safety
1066    ///
1067    /// - `description`, `mode`, and `class_name` must be valid C strings
1068    /// - `ptr` must be a valid pointer to store the connection handle
1069    pub(crate) fn R_new_custom_connection(
1070        description: *const ::std::os::raw::c_char,
1071        mode: *const ::std::os::raw::c_char,
1072        class_name: *const ::std::os::raw::c_char,
1073        ptr: *mut Rconnection,
1074    ) -> SEXP;
1075
1076    /// Read from a connection.
1077    ///
1078    /// # WARNING
1079    ///
1080    /// This API is UNSTABLE and may change.
1081    ///
1082    /// # Safety
1083    ///
1084    /// - `con` must be a valid Rconnection handle
1085    /// - `buf` must be a valid buffer with at least `n` bytes
1086    pub(crate) fn R_ReadConnection(
1087        con: Rconnection,
1088        buf: *mut ::std::os::raw::c_void,
1089        n: usize,
1090    ) -> usize;
1091
1092    /// Write to a connection.
1093    ///
1094    /// # WARNING
1095    ///
1096    /// This API is UNSTABLE and may change.
1097    ///
1098    /// # Safety
1099    ///
1100    /// - `con` must be a valid Rconnection handle
1101    /// - `buf` must contain at least `n` valid bytes
1102    pub(crate) fn R_WriteConnection(
1103        con: Rconnection,
1104        buf: *const ::std::os::raw::c_void,
1105        n: usize,
1106    ) -> usize;
1107
1108    /// Get a connection from a SEXP.
1109    ///
1110    /// # WARNING
1111    ///
1112    /// This API is UNSTABLE and may change.
1113    /// Added in R 3.3.0.
1114    ///
1115    /// # Safety
1116    ///
1117    /// - `sConn` must be a valid connection SEXP
1118    pub(crate) fn R_GetConnection(sConn: SEXP) -> Rconnection;
1119}
1120// endregion: Connections API
1121
1122/// Check if a SEXP is an S4 object.
1123///
1124/// # Safety
1125///
1126/// - `arg1` must be a valid SEXP
1127#[allow(non_snake_case)]
1128pub unsafe fn Rf_isS4(arg1: SEXP) -> Rboolean {
1129    unsafe extern "C-unwind" {
1130        #[link_name = "Rf_isS4"]
1131        pub fn Rf_isS4_original(arg1: SEXP) -> u32;
1132    }
1133
1134    unsafe {
1135        if Rf_isS4_original(arg1) == 0 {
1136            Rboolean::FALSE
1137        } else {
1138            Rboolean::TRUE
1139        }
1140    }
1141}
1142
1143// region: registration!
1144
1145#[repr(C)]
1146#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DllInfo {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "DllInfo",
            &&self.0)
    }
}Debug)]
1147/// Opaque dynamic library descriptor from R.
1148pub struct DllInfo(::std::os::raw::c_void);
1149
1150/// Generic dynamic library function pointer.
1151///
1152/// R defines this as `void *(*)(void)` - a function taking no arguments and
1153/// returning `void*`. This is used for method registration and external pointer
1154/// functions. The actual function signatures vary; callers cast to the appropriate
1155/// concrete function type before calling.
1156///
1157/// We use `fn() -> *mut c_void` to match R's signature. The function pointer is
1158/// stored generically and cast to the appropriate type when called by R.
1159#[allow(non_camel_case_types)]
1160pub type DL_FUNC =
1161    ::std::option::Option<unsafe extern "C-unwind" fn() -> *mut ::std::os::raw::c_void>;
1162
1163/// Type descriptor for native primitive arguments in .C/.Fortran calls.
1164///
1165/// This is used in `R_CMethodDef` and `R_FortranMethodDef` to specify
1166/// argument types for type checking.
1167#[allow(non_camel_case_types)]
1168pub type R_NativePrimitiveArgType = ::std::os::raw::c_uint;
1169
1170/// Method definition for .C interface routines.
1171///
1172/// Used to register C functions callable via `.C()` from R.
1173#[repr(C)]
1174#[derive(#[automatically_derived]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
impl ::core::fmt::Debug for R_CMethodDef {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "R_CMethodDef",
            "name", &self.name, "fun", &self.fun, "numArgs", &self.numArgs,
            "types", &&self.types)
    }
}Debug, #[automatically_derived]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
impl ::core::marker::Copy for R_CMethodDef { }Copy, #[automatically_derived]
#[doc(hidden)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
unsafe impl ::core::clone::TrivialClone for R_CMethodDef { }
#[automatically_derived]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
impl ::core::clone::Clone for R_CMethodDef {
    #[inline]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<*const ::std::os::raw::c_char>;
        let _: ::core::clone::AssertParamIsClone<DL_FUNC>;
        let _: ::core::clone::AssertParamIsClone<::std::os::raw::c_int>;
        let _:
                ::core::clone::AssertParamIsClone<*const R_NativePrimitiveArgType>;
        *self
    }
}Clone)]
1175#[allow(non_camel_case_types)]
1176#[allow(non_snake_case)]
1177pub struct R_CMethodDef {
1178    /// Exported symbol name.
1179    pub name: *const ::std::os::raw::c_char,
1180    /// Function pointer implementing the routine.
1181    pub fun: DL_FUNC,
1182    /// Declared arity.
1183    pub numArgs: ::std::os::raw::c_int,
1184    /// Optional array of argument types for type checking. May be null.
1185    pub types: *const R_NativePrimitiveArgType,
1186}
1187
1188/// Method definition for .Fortran interface routines.
1189///
1190/// Structurally identical to `R_CMethodDef`.
1191#[allow(non_camel_case_types)]
1192pub type R_FortranMethodDef = R_CMethodDef;
1193
1194/// Method definition for .Call interface routines.
1195///
1196/// Used to register C functions callable via `.Call()` from R.
1197/// Unlike `.C()` routines, `.Call()` functions receive and return SEXP values directly.
1198#[repr(C)]
1199#[derive(#[automatically_derived]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
impl ::core::fmt::Debug for R_CallMethodDef {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "R_CallMethodDef", "name", &self.name, "fun", &self.fun,
            "numArgs", &&self.numArgs)
    }
}Debug, #[automatically_derived]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
impl ::core::marker::Copy for R_CallMethodDef { }Copy, #[automatically_derived]
#[doc(hidden)]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
unsafe impl ::core::clone::TrivialClone for R_CallMethodDef { }
#[automatically_derived]
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
impl ::core::clone::Clone for R_CallMethodDef {
    #[inline]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<*const ::std::os::raw::c_char>;
        let _: ::core::clone::AssertParamIsClone<DL_FUNC>;
        let _: ::core::clone::AssertParamIsClone<::std::os::raw::c_int>;
        *self
    }
}Clone)]
1200#[allow(non_camel_case_types)]
1201#[allow(non_snake_case)]
1202pub struct R_CallMethodDef {
1203    /// Exported symbol name.
1204    pub name: *const ::std::os::raw::c_char,
1205    /// Function pointer implementing the routine.
1206    pub fun: DL_FUNC,
1207    /// Declared arity.
1208    pub numArgs: ::std::os::raw::c_int,
1209}
1210
1211// SAFETY: `name` points to a static CStr literal, `fun` is a function pointer.
1212// Both are valid for program lifetime and safe to read from any thread.
1213unsafe impl Sync for R_CallMethodDef {}
1214unsafe impl Send for R_CallMethodDef {}
1215
1216/// Method definition for .External interface routines.
1217///
1218/// Structurally identical to `R_CallMethodDef`.
1219#[allow(non_camel_case_types)]
1220pub type R_ExternalMethodDef = R_CallMethodDef;
1221
1222// Checked routine registration API declarations.
1223// Issue #112 cat. 7: kept pub(crate) — only called from init.rs during package init; not worth a wrapper type
1224#[allow(missing_docs)]
1225#[allow(missing_docs)]
#[allow(clashing_extern_declarations)]
unsafe extern "C-unwind" {
    #[doc = "Unchecked FFI binding for `R_registerRoutines`."]
    #[doc = "Generated from source location line 1228, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_registerRoutines"]
    pub(crate) fn R_registerRoutines_unchecked(info: *mut DllInfo,
    croutines: *const R_CMethodDef, callRoutines: *const R_CallMethodDef,
    fortranRoutines: *const R_FortranMethodDef,
    externalRoutines: *const R_ExternalMethodDef)
    -> ::std::os::raw::c_int;
    #[doc = "Unchecked FFI binding for `R_useDynamicSymbols`."]
    #[doc = "Generated from source location line 1236, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_useDynamicSymbols"]
    pub(crate) fn R_useDynamicSymbols_unchecked(info: *mut DllInfo,
    value: Rboolean)
    -> Rboolean;
    #[doc = "Unchecked FFI binding for `R_forceSymbols`."]
    #[doc = "Generated from source location line 1237, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_forceSymbols"]
    pub(crate) fn R_forceSymbols_unchecked(info: *mut DllInfo,
    value: Rboolean)
    -> Rboolean;
}
#[doc =
"Checked wrapper for `R_registerRoutines`. Calls `R_registerRoutines_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1228, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_registerRoutines(info: *mut DllInfo,
    croutines: *const R_CMethodDef, callRoutines: *const R_CallMethodDef,
    fortranRoutines: *const R_FortranMethodDef,
    externalRoutines: *const R_ExternalMethodDef) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_registerRoutines_unchecked(info, croutines, callRoutines,
                                fortranRoutines, externalRoutines)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_useDynamicSymbols`. Calls `R_useDynamicSymbols_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1236, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_useDynamicSymbols(info: *mut DllInfo, value: Rboolean)
    -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_useDynamicSymbols_unchecked(info, value)
                        })
                });
    result.0
}
#[doc =
"Checked wrapper for `R_forceSymbols`. Calls `R_forceSymbols_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1237, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_forceSymbols(info: *mut DllInfo, value: Rboolean)
    -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_forceSymbols_unchecked(info, value)
                        })
                });
    result.0
}#[r_ffi_checked]
1226#[allow(clashing_extern_declarations)]
1227unsafe extern "C-unwind" {
1228    pub(crate) fn R_registerRoutines(
1229        info: *mut DllInfo,
1230        croutines: *const R_CMethodDef,
1231        callRoutines: *const R_CallMethodDef,
1232        fortranRoutines: *const R_FortranMethodDef,
1233        externalRoutines: *const R_ExternalMethodDef,
1234    ) -> ::std::os::raw::c_int;
1235
1236    pub(crate) fn R_useDynamicSymbols(info: *mut DllInfo, value: Rboolean) -> Rboolean;
1237    pub(crate) fn R_forceSymbols(info: *mut DllInfo, value: Rboolean) -> Rboolean;
1238}
1239
1240// endregion
1241
1242// region: Non-API encoding/locale state (Defn.h)
1243
1244/// Non-API encoding / locale helpers from R's `Defn.h`.
1245///
1246/// These are not part of the stable R API and may break across R versions.
1247///
1248/// Only symbols R's shared library actually **exports** may be declared here.
1249/// `Defn.h` marks most locale globals `extern0` (= `attribute_hidden`) —
1250/// referencing one of those (e.g. `known_to_be_utf8`, `latin1locale`,
1251/// `R_nativeEncoding`) compiles fine but aborts `dyn.load` of any binary that
1252/// carries the reference: data relocations resolve eagerly at load, whether or
1253/// not the code path ever runs. That made every `nonapi` build un-loadable
1254/// (caught by the feature-legs CI, audit A5). `utf8locale`, `mbcslocale`, and
1255/// `known_to_be_latin1` are plain `extern` and exported (verified against
1256/// R 4.6's libR).
1257#[cfg(feature = "nonapi")]
1258pub mod nonapi_encoding {
1259    use super::r_ffi_checked;
1260
1261    // Issue #112 cat. 10: kept pub(crate) — nonapi encoding helpers; single-caller utilities in encoding.rs
1262    #[r_ffi_checked]
1263    #[allow(clashing_extern_declarations)]
1264    unsafe extern "C-unwind" {
1265        // Locale flags (exported, non-hidden)
1266        pub(crate) static utf8locale: super::Rboolean;
1267        pub(crate) static mbcslocale: super::Rboolean;
1268        pub(crate) static known_to_be_latin1: super::Rboolean;
1269    }
1270}
1271
1272// endregion
1273
1274// region: Non-API stack checking variables (Rinterface.h)
1275
1276/// Non-API stack checking variables from `Rinterface.h`.
1277///
1278/// R uses these to detect stack overflow. On a different thread the values do
1279/// not describe the current stack, so a stack check can fail spuriously.
1280///
1281/// # Not a package thread-safety mechanism
1282///
1283/// Setting `R_CStackLimit` to `usize::MAX` disables only R's stack-address
1284/// check. It does not make the R API, GC, global state, or error signaling safe
1285/// on a secondary thread. R packages must keep R API calls on the main thread
1286/// and must not rewrite these globals for off-main calls. The higher-level
1287/// [`StackCheckGuard`](crate::thread::StackCheckGuard) has the same limitation;
1288/// removal or relocation of this surface is tracked in #1352.
1289#[cfg(feature = "nonapi")]
1290pub mod nonapi_stack {
1291    unsafe extern "C" {
1292        /// Top of the stack (set during `Rf_initialize_R` for main thread).
1293        ///
1294        /// On Unix, determined via `__libc_stack_end`, `KERN_USRSTACK`, or
1295        /// `thr_stksegment`. On Windows, via `VirtualQuery`.
1296        #[allow(non_upper_case_globals)]
1297        pub(crate) static R_CStackStart: usize;
1298
1299        /// Stack size limit. Set to `usize::MAX` to disable stack checking.
1300        ///
1301        /// From R source: `if(R_CStackStart == -1) R_CStackLimit = -1; /* never set */`
1302        #[allow(non_upper_case_globals)]
1303        pub static R_CStackLimit: usize;
1304
1305        /// Stack growth direction: 1 = grows up, -1 = grows down.
1306        ///
1307        /// Most systems (x86, ARM) grow down (-1).
1308        #[allow(non_upper_case_globals)]
1309        pub(crate) static R_CStackDir: ::std::os::raw::c_int;
1310    }
1311
1312    /// Write to `R_CStackLimit`.
1313    ///
1314    /// # Safety
1315    /// Must be called from R's main thread.
1316    #[inline]
1317    pub unsafe fn set_r_cstack_limit(value: usize) {
1318        unsafe {
1319            let ptr = (&raw const R_CStackLimit).cast_mut();
1320            ptr.write(value);
1321        }
1322    }
1323
1324    // Issue #112 cat. 10: kept pub(crate) — nonapi stack helpers; used from thread.rs; wrapping adds no value
1325    /// Read `R_CStackLimit`.
1326    #[inline]
1327    pub(crate) fn get_r_cstack_limit() -> usize {
1328        unsafe { R_CStackLimit }
1329    }
1330
1331    /// Read `R_CStackStart`.
1332    #[inline]
1333    pub(crate) fn get_r_cstack_start() -> usize {
1334        unsafe { R_CStackStart }
1335    }
1336
1337    /// Read `R_CStackDir`.
1338    #[inline]
1339    pub(crate) fn get_r_cstack_dir() -> ::std::os::raw::c_int {
1340        unsafe { R_CStackDir }
1341    }
1342}
1343
1344// endregion
1345
1346// region: Inline Helper Functions (Rust implementations of R's inline functions)
1347
1348/// Create a length-1 string vector from a C string.
1349///
1350/// Rust equivalent of R's inline `Rf_mkString(s)`, which is
1351/// shorthand for `ScalarString(mkChar(s))`.
1352///
1353/// # Safety
1354///
1355/// - `s` must be a valid null-terminated C string
1356/// - Must be called from R's main thread
1357/// - Result must be protected from GC
1358#[doc(alias = "mkString")]
1359#[allow(non_snake_case)]
1360#[inline]
1361pub unsafe fn Rf_mkString(s: *const ::std::os::raw::c_char) -> SEXP {
1362    unsafe {
1363        let charsxp = Rf_mkChar(s);
1364        let protected = Rf_protect(charsxp);
1365        let result = Rf_ScalarString(protected);
1366        Rf_unprotect(1);
1367        result
1368    }
1369}
1370
1371/// Build a pairlist with 1 element.
1372///
1373/// Rust equivalent of R's inline `Rf_list1(s)`.
1374///
1375/// # Safety
1376///
1377/// - `s` must be a valid SEXP
1378/// - Must be called from R's main thread
1379/// - Result must be protected from GC
1380#[doc(alias = "list1")]
1381#[allow(non_snake_case)]
1382#[inline]
1383pub unsafe fn Rf_list1(s: SEXP) -> SEXP {
1384    unsafe { Rf_cons(s, R_NilValue) }
1385}
1386
1387/// Build a pairlist with 2 elements.
1388///
1389/// Rust equivalent of R's inline `Rf_list2(s, t)`.
1390///
1391/// # Safety
1392///
1393/// - Both SEXPs must be valid
1394/// - Must be called from R's main thread
1395/// - Result must be protected from GC
1396#[doc(alias = "list2")]
1397#[allow(non_snake_case)]
1398#[inline]
1399pub unsafe fn Rf_list2(s: SEXP, t: SEXP) -> SEXP {
1400    unsafe { Rf_cons(s, Rf_cons(t, R_NilValue)) }
1401}
1402
1403/// Build a pairlist with 3 elements.
1404///
1405/// Rust equivalent of R's inline `Rf_list3(s, t, u)`.
1406///
1407/// # Safety
1408///
1409/// - All SEXPs must be valid
1410/// - Must be called from R's main thread
1411/// - Result must be protected from GC
1412#[doc(alias = "list3")]
1413#[allow(non_snake_case)]
1414#[inline]
1415pub unsafe fn Rf_list3(s: SEXP, t: SEXP, u: SEXP) -> SEXP {
1416    unsafe { Rf_cons(s, Rf_cons(t, Rf_cons(u, R_NilValue))) }
1417}
1418
1419/// Build a pairlist with 4 elements.
1420///
1421/// Rust equivalent of R's inline `Rf_list4(s, t, u, v)`.
1422///
1423/// # Safety
1424///
1425/// - All SEXPs must be valid
1426/// - Must be called from R's main thread
1427/// - Result must be protected from GC
1428#[doc(alias = "list4")]
1429#[allow(non_snake_case)]
1430#[inline]
1431pub unsafe fn Rf_list4(s: SEXP, t: SEXP, u: SEXP, v: SEXP) -> SEXP {
1432    unsafe { Rf_cons(s, Rf_cons(t, Rf_cons(u, Rf_cons(v, R_NilValue)))) }
1433}
1434
1435/// Build a language object (call) with 1 element (the function).
1436///
1437/// Rust equivalent of R's inline `Rf_lang1(s)`.
1438/// Creates a call like `f()` where `s` is the function.
1439///
1440/// # Safety
1441///
1442/// - `s` must be a valid SEXP (typically a symbol or closure)
1443/// - Must be called from R's main thread
1444/// - Result must be protected from GC
1445#[doc(alias = "lang1")]
1446#[allow(non_snake_case)]
1447#[inline]
1448pub unsafe fn Rf_lang1(s: SEXP) -> SEXP {
1449    unsafe { Rf_lcons(s, R_NilValue) }
1450}
1451
1452/// Build a language object (call) with function and 1 argument.
1453///
1454/// Rust equivalent of R's inline `Rf_lang2(s, t)`.
1455/// Creates a call like `f(arg)` where `s` is the function and `t` is the argument.
1456///
1457/// # Safety
1458///
1459/// - Both SEXPs must be valid
1460/// - Must be called from R's main thread
1461/// - Result must be protected from GC
1462#[doc(alias = "lang2")]
1463#[allow(non_snake_case)]
1464#[inline]
1465pub unsafe fn Rf_lang2(s: SEXP, t: SEXP) -> SEXP {
1466    unsafe { Rf_lcons(s, Rf_list1(t)) }
1467}
1468
1469/// Build a language object (call) with function and 2 arguments.
1470///
1471/// Rust equivalent of R's inline `Rf_lang3(s, t, u)`.
1472/// Creates a call like `f(arg1, arg2)`.
1473///
1474/// # Safety
1475///
1476/// - All SEXPs must be valid
1477/// - Must be called from R's main thread
1478/// - Result must be protected from GC
1479#[doc(alias = "lang3")]
1480#[allow(non_snake_case)]
1481#[inline]
1482pub unsafe fn Rf_lang3(s: SEXP, t: SEXP, u: SEXP) -> SEXP {
1483    unsafe { Rf_lcons(s, Rf_list2(t, u)) }
1484}
1485
1486/// Build a language object (call) with function and 3 arguments.
1487///
1488/// Rust equivalent of R's inline `Rf_lang4(s, t, u, v)`.
1489/// Creates a call like `f(arg1, arg2, arg3)`.
1490///
1491/// # Safety
1492///
1493/// - All SEXPs must be valid
1494/// - Must be called from R's main thread
1495/// - Result must be protected from GC
1496#[doc(alias = "lang4")]
1497#[allow(non_snake_case)]
1498#[inline]
1499pub unsafe fn Rf_lang4(s: SEXP, t: SEXP, u: SEXP, v: SEXP) -> SEXP {
1500    unsafe { Rf_lcons(s, Rf_list3(t, u, v)) }
1501}
1502
1503/// Build a language object (call) with function and 4 arguments.
1504///
1505/// Rust equivalent of R's inline `Rf_lang5(s, t, u, v, w)`.
1506/// Creates a call like `f(arg1, arg2, arg3, arg4)`.
1507///
1508/// # Safety
1509///
1510/// - All SEXPs must be valid
1511/// - Must be called from R's main thread
1512/// - Result must be protected from GC
1513#[doc(alias = "lang5")]
1514#[allow(non_snake_case)]
1515#[inline]
1516pub unsafe fn Rf_lang5(s: SEXP, t: SEXP, u: SEXP, v: SEXP, w: SEXP) -> SEXP {
1517    unsafe { Rf_lcons(s, Rf_list4(t, u, v, w)) }
1518}
1519
1520/// Build a language object (call) with function and 5 arguments.
1521///
1522/// Rust equivalent of R's inline `Rf_lang6(s, t, u, v, w, x)`.
1523/// Creates a call like `f(arg1, arg2, arg3, arg4, arg5)`.
1524///
1525/// # Safety
1526///
1527/// - All SEXPs must be valid
1528/// - Must be called from R's main thread
1529/// - Result must be protected from GC
1530#[doc(alias = "lang6")]
1531#[allow(non_snake_case)]
1532#[inline]
1533pub unsafe fn Rf_lang6(s: SEXP, t: SEXP, u: SEXP, v: SEXP, w: SEXP, x: SEXP) -> SEXP {
1534    unsafe {
1535        let protected = Rf_protect(s);
1536        let list = Rf_cons(t, Rf_list4(u, v, w, x));
1537        let result = Rf_lcons(protected, list);
1538        Rf_unprotect(1);
1539        result
1540    }
1541}
1542
1543// endregion
1544
1545// region: RNG functions (R_ext/Random.h)
1546
1547/// RNG type enum from R_ext/Random.h
1548#[repr(u32)]
1549#[non_exhaustive]
1550#[derive(#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::fmt::Debug for RNGtype {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RNGtype::WICHMANN_HILL => "WICHMANN_HILL",
                RNGtype::MARSAGLIA_MULTICARRY => "MARSAGLIA_MULTICARRY",
                RNGtype::SUPER_DUPER => "SUPER_DUPER",
                RNGtype::MERSENNE_TWISTER => "MERSENNE_TWISTER",
                RNGtype::KNUTH_TAOCP => "KNUTH_TAOCP",
                RNGtype::USER_UNIF => "USER_UNIF",
                RNGtype::KNUTH_TAOCP2 => "KNUTH_TAOCP2",
                RNGtype::LECUYER_CMRG => "LECUYER_CMRG",
            })
    }
}Debug, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::Copy for RNGtype { }Copy, #[automatically_derived]
#[doc(hidden)]
#[allow(non_camel_case_types)]
unsafe impl ::core::clone::TrivialClone for RNGtype { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::clone::Clone for RNGtype {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::hash::Hash for RNGtype {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::StructuralPartialEq for RNGtype { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::PartialEq for RNGtype {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::Eq for RNGtype { }Eq)]
1551#[allow(non_camel_case_types)]
1552pub enum RNGtype {
1553    /// Wichmann-Hill generator.
1554    WICHMANN_HILL = 0,
1555    /// Marsaglia-Multicarry generator.
1556    MARSAGLIA_MULTICARRY = 1,
1557    /// Super-Duper generator.
1558    SUPER_DUPER = 2,
1559    /// Mersenne Twister generator.
1560    MERSENNE_TWISTER = 3,
1561    /// Knuth TAOCP generator.
1562    KNUTH_TAOCP = 4,
1563    /// User-supplied uniform generator.
1564    USER_UNIF = 5,
1565    /// Knuth TAOCP 2002 variant.
1566    KNUTH_TAOCP2 = 6,
1567    /// L'Ecuyer-CMRG generator.
1568    LECUYER_CMRG = 7,
1569}
1570
1571/// Normal distribution generator type enum from R_ext/Random.h
1572#[repr(u32)]
1573#[non_exhaustive]
1574#[derive(#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::fmt::Debug for N01type {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                N01type::BUGGY_KINDERMAN_RAMAGE => "BUGGY_KINDERMAN_RAMAGE",
                N01type::AHRENS_DIETER => "AHRENS_DIETER",
                N01type::BOX_MULLER => "BOX_MULLER",
                N01type::USER_NORM => "USER_NORM",
                N01type::INVERSION => "INVERSION",
                N01type::KINDERMAN_RAMAGE => "KINDERMAN_RAMAGE",
            })
    }
}Debug, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::Copy for N01type { }Copy, #[automatically_derived]
#[doc(hidden)]
#[allow(non_camel_case_types)]
unsafe impl ::core::clone::TrivialClone for N01type { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::clone::Clone for N01type {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::hash::Hash for N01type {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::StructuralPartialEq for N01type { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::PartialEq for N01type {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::Eq for N01type { }Eq)]
1575#[allow(non_camel_case_types)]
1576pub enum N01type {
1577    /// Legacy buggy Kinderman-Ramage method.
1578    BUGGY_KINDERMAN_RAMAGE = 0,
1579    /// Ahrens-Dieter method.
1580    AHRENS_DIETER = 1,
1581    /// Box-Muller transform.
1582    BOX_MULLER = 2,
1583    /// User-supplied normal generator.
1584    USER_NORM = 3,
1585    /// Inversion method.
1586    INVERSION = 4,
1587    /// Fixed Kinderman-Ramage method.
1588    KINDERMAN_RAMAGE = 5,
1589}
1590
1591/// Discrete uniform sample method enum from R_ext/Random.h
1592#[repr(u32)]
1593#[non_exhaustive]
1594#[derive(#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::fmt::Debug for Sampletype {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Sampletype::ROUNDING => "ROUNDING",
                Sampletype::REJECTION => "REJECTION",
            })
    }
}Debug, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::Copy for Sampletype { }Copy, #[automatically_derived]
#[doc(hidden)]
#[allow(non_camel_case_types)]
unsafe impl ::core::clone::TrivialClone for Sampletype { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::clone::Clone for Sampletype {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::hash::Hash for Sampletype {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::marker::StructuralPartialEq for Sampletype { }
#[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::PartialEq for Sampletype {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
#[allow(non_camel_case_types)]
impl ::core::cmp::Eq for Sampletype { }Eq)]
1595#[allow(non_camel_case_types)]
1596pub enum Sampletype {
1597    /// Rounding method for integer sampling.
1598    ROUNDING = 0,
1599    /// Rejection sampling method.
1600    REJECTION = 1,
1601}
1602
1603unsafe extern "C-unwind" {
    #[doc = " Save the current RNG state from R\'s global state."]
    #[doc = ""]
    #[doc = " Must be called before using `unif_rand()`, `norm_rand()`, etc."]
    #[doc = " The state is restored with `PutRNGstate()`. The safe forms are"]
    #[doc =
    " [`RngGuard`](crate::rng::RngGuard), [`with_rng`](crate::rng::with_rng)"]
    #[doc = " and `#[miniextendr(rng)]`."]
    #[doc = ""]
    #[doc = " # Example"]
    #[doc = ""]
    #[doc = " ```ignore"]
    #[doc = " unsafe {"]
    #[doc = "     GetRNGstate();"]
    #[doc = "     let x = unif_rand();"]
    #[doc = "     let y = norm_rand();"]
    #[doc = "     PutRNGstate();"]
    #[doc = " }"]
    #[doc = " ```"]
    #[doc = "Unchecked FFI binding for `GetRNGstate`."]
    #[doc = "Generated from source location line 1622, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "GetRNGstate"]
    pub fn GetRNGstate_unchecked();
    #[doc = " Restore the RNG state to R\'s global state."]
    #[doc = ""]
    #[doc = " Must be called after using `unif_rand()`, `norm_rand()`, etc."]
    #[doc = " to ensure R\'s `.Random.seed` is updated."]
    #[doc = "Unchecked FFI binding for `PutRNGstate`."]
    #[doc = "Generated from source location line 1628, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "PutRNGstate"]
    pub fn PutRNGstate_unchecked();
    #[doc = " Generate a uniform random number in (0, 1)."]
    #[doc = ""]
    #[doc = " # Important"]
    #[doc = ""]
    #[doc =
    " Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
    #[doc =
    " form is [`RngGuard::unif_rand`](crate::rng::RngGuard::unif_rand)."]
    #[doc = "Unchecked FFI binding for `unif_rand`."]
    #[doc = "Generated from source location line 1636, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "unif_rand"]
    pub fn unif_rand_unchecked()
    -> f64;
    #[doc = " Generate a standard normal random number (mean 0, sd 1)."]
    #[doc = ""]
    #[doc = " # Important"]
    #[doc = ""]
    #[doc =
    " Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
    #[doc =
    " form is [`RngGuard::norm_rand`](crate::rng::RngGuard::norm_rand)."]
    #[doc = "Unchecked FFI binding for `norm_rand`."]
    #[doc = "Generated from source location line 1644, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "norm_rand"]
    pub fn norm_rand_unchecked()
    -> f64;
    #[doc = " Generate an exponential random number with rate 1."]
    #[doc = ""]
    #[doc = " # Important"]
    #[doc = ""]
    #[doc =
    " Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
    #[doc =
    " form is [`RngGuard::exp_rand`](crate::rng::RngGuard::exp_rand)."]
    #[doc = "Unchecked FFI binding for `exp_rand`."]
    #[doc = "Generated from source location line 1652, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "exp_rand"]
    pub fn exp_rand_unchecked()
    -> f64;
    #[doc = " Generate a uniform random index in [0, dn)."]
    #[doc = ""]
    #[doc = " Used for sampling without bias for large n."]
    #[doc = ""]
    #[doc = " # Important"]
    #[doc = ""]
    #[doc =
    " Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
    #[doc =
    " form is [`RngGuard::unif_index`](crate::rng::RngGuard::unif_index)."]
    #[doc = "Unchecked FFI binding for `R_unif_index`."]
    #[doc = "Generated from source location line 1662, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_unif_index"]
    pub fn R_unif_index_unchecked(dn: f64)
    -> f64;
    #[doc = " Get the current discrete uniform sample method."]
    #[doc = "Unchecked FFI binding for `R_sample_kind`."]
    #[doc = "Generated from source location line 1665, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_sample_kind"]
    pub fn R_sample_kind_unchecked()
    -> Sampletype;
}
#[doc = " Save the current RNG state from R\'s global state."]
#[doc = ""]
#[doc = " Must be called before using `unif_rand()`, `norm_rand()`, etc."]
#[doc = " The state is restored with `PutRNGstate()`. The safe forms are"]
#[doc =
" [`RngGuard`](crate::rng::RngGuard), [`with_rng`](crate::rng::with_rng)"]
#[doc = " and `#[miniextendr(rng)]`."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```ignore"]
#[doc = " unsafe {"]
#[doc = "     GetRNGstate();"]
#[doc = "     let x = unif_rand();"]
#[doc = "     let y = norm_rand();"]
#[doc = "     PutRNGstate();"]
#[doc = " }"]
#[doc = " ```"]
#[doc =
"Checked wrapper for `GetRNGstate`. Calls `GetRNGstate_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1622, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn GetRNGstate() {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            GetRNGstate_unchecked()
                        })
                });
    result.0
}
#[doc = " Restore the RNG state to R\'s global state."]
#[doc = ""]
#[doc = " Must be called after using `unif_rand()`, `norm_rand()`, etc."]
#[doc = " to ensure R\'s `.Random.seed` is updated."]
#[doc =
"Checked wrapper for `PutRNGstate`. Calls `PutRNGstate_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1628, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn PutRNGstate() {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            PutRNGstate_unchecked()
                        })
                });
    result.0
}
#[doc = " Generate a uniform random number in (0, 1)."]
#[doc = ""]
#[doc = " # Important"]
#[doc = ""]
#[doc =
" Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
#[doc = " form is [`RngGuard::unif_rand`](crate::rng::RngGuard::unif_rand)."]
#[doc =
"Checked wrapper for `unif_rand`. Calls `unif_rand_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1636, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn unif_rand() -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            unif_rand_unchecked()
                        })
                });
    result.0
}
#[doc = " Generate a standard normal random number (mean 0, sd 1)."]
#[doc = ""]
#[doc = " # Important"]
#[doc = ""]
#[doc =
" Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
#[doc = " form is [`RngGuard::norm_rand`](crate::rng::RngGuard::norm_rand)."]
#[doc =
"Checked wrapper for `norm_rand`. Calls `norm_rand_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1644, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn norm_rand() -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            norm_rand_unchecked()
                        })
                });
    result.0
}
#[doc = " Generate an exponential random number with rate 1."]
#[doc = ""]
#[doc = " # Important"]
#[doc = ""]
#[doc =
" Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
#[doc = " form is [`RngGuard::exp_rand`](crate::rng::RngGuard::exp_rand)."]
#[doc =
"Checked wrapper for `exp_rand`. Calls `exp_rand_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1652, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn exp_rand() -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            exp_rand_unchecked()
                        })
                });
    result.0
}
#[doc = " Generate a uniform random index in [0, dn)."]
#[doc = ""]
#[doc = " Used for sampling without bias for large n."]
#[doc = ""]
#[doc = " # Important"]
#[doc = ""]
#[doc =
" Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe"]
#[doc =
" form is [`RngGuard::unif_index`](crate::rng::RngGuard::unif_index)."]
#[doc =
"Checked wrapper for `R_unif_index`. Calls `R_unif_index_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1662, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_unif_index(dn: f64) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_unif_index_unchecked(dn)
                        })
                });
    result.0
}
#[doc = " Get the current discrete uniform sample method."]
#[doc =
"Checked wrapper for `R_sample_kind`. Calls `R_sample_kind_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1665, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_sample_kind() -> Sampletype {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_sample_kind_unchecked()
                        })
                });
    result.0
}#[r_ffi_checked]
1604unsafe extern "C-unwind" {
1605    /// Save the current RNG state from R's global state.
1606    ///
1607    /// Must be called before using `unif_rand()`, `norm_rand()`, etc.
1608    /// The state is restored with `PutRNGstate()`. The safe forms are
1609    /// [`RngGuard`](crate::rng::RngGuard), [`with_rng`](crate::rng::with_rng)
1610    /// and `#[miniextendr(rng)]`.
1611    ///
1612    /// # Example
1613    ///
1614    /// ```ignore
1615    /// unsafe {
1616    ///     GetRNGstate();
1617    ///     let x = unif_rand();
1618    ///     let y = norm_rand();
1619    ///     PutRNGstate();
1620    /// }
1621    /// ```
1622    pub fn GetRNGstate();
1623
1624    /// Restore the RNG state to R's global state.
1625    ///
1626    /// Must be called after using `unif_rand()`, `norm_rand()`, etc.
1627    /// to ensure R's `.Random.seed` is updated.
1628    pub fn PutRNGstate();
1629
1630    /// Generate a uniform random number in (0, 1).
1631    ///
1632    /// # Important
1633    ///
1634    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1635    /// form is [`RngGuard::unif_rand`](crate::rng::RngGuard::unif_rand).
1636    pub fn unif_rand() -> f64;
1637
1638    /// Generate a standard normal random number (mean 0, sd 1).
1639    ///
1640    /// # Important
1641    ///
1642    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1643    /// form is [`RngGuard::norm_rand`](crate::rng::RngGuard::norm_rand).
1644    pub fn norm_rand() -> f64;
1645
1646    /// Generate an exponential random number with rate 1.
1647    ///
1648    /// # Important
1649    ///
1650    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1651    /// form is [`RngGuard::exp_rand`](crate::rng::RngGuard::exp_rand).
1652    pub fn exp_rand() -> f64;
1653
1654    /// Generate a uniform random index in [0, dn).
1655    ///
1656    /// Used for sampling without bias for large n.
1657    ///
1658    /// # Important
1659    ///
1660    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1661    /// form is [`RngGuard::unif_index`](crate::rng::RngGuard::unif_index).
1662    pub fn R_unif_index(dn: f64) -> f64;
1663
1664    /// Get the current discrete uniform sample method.
1665    pub fn R_sample_kind() -> Sampletype;
1666}
1667
1668// endregion
1669
1670// region: Rmath distribution functions (Rmath.h)
1671//
1672// Unless `MATHLIB_STANDALONE` is defined, `Rmath.h` remaps the short names
1673// (`dnorm` -> `dnorm4` -> `Rf_dnorm4`, `pnorm` -> `pnorm5` -> `Rf_pnorm5`,
1674// `qnorm` -> `qnorm5` -> `Rf_qnorm5`, `qchisq` -> `Rf_qchisq`); these are the
1675// symbols libR exports, with these prototypes, from the R 4.4 floor on.
1676// `tools:::funAPI()` lists all four as `api` (R 4.6 and R-devel 4.7) and none
1677// is in `tools:::nonAPI` (R 4.4 to 4.7), so they need no feature gate.
1678//
1679// These are the scalar C routines, not the vectorised `stats::` functions:
1680// arguments are passed through unchanged (the `lower_tail` / `log_p` flags
1681// select R's own tail and log-scale code paths), and NA, NaN and infinite
1682// inputs come back as R's C code computes them.
1683
1684unsafe extern "C-unwind" {
    #[doc =
    " Normal density: `dnorm(x, mean = mu, sd = sigma, log = give_log)`."]
    #[doc = ""]
    #[doc =
    " `Rf_dnorm4` from `Rmath.h` (the `dnorm` and `dnorm4` macros resolve"]
    #[doc = " to it). A non-zero `give_log` returns the log density."]
    #[doc = ""]
    #[doc = " # R conditions"]
    #[doc = ""]
    #[doc =
    " An invalid `sigma` (negative) returns `NaN` without a warning: nmath"]
    #[doc =
    " does not report domain errors, and the \"NaNs produced\" warning that"]
    #[doc =
    " `stats::dnorm` gives comes from R\'s vectorised wrapper. nmath reports"]
    #[doc = " other problems (precision loss, non-convergence) through R\'s"]
    #[doc =
    " `warning()`, and under `options(warn = 2)` a warning becomes an R"]
    #[doc =
    " error, which longjmps. Call this where such a longjmp is caught: a"]
    #[doc = " `#[miniextendr]` function body, or"]
    #[doc =
    " [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
    #[doc =
    " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_dnorm4`."]
    #[doc = "Generated from source location line 1703, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_dnorm4"]
    pub fn Rf_dnorm4_unchecked(x: f64, mu: f64, sigma: f64,
    give_log: ::std::os::raw::c_int)
    -> f64;
    #[doc = " Normal distribution function:"]
    #[doc =
    " `pnorm(x, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`."]
    #[doc = ""]
    #[doc =
    " `Rf_pnorm5` from `Rmath.h` (the `pnorm` and `pnorm5` macros resolve"]
    #[doc =
    " to it). `lower_tail = 0` computes the upper tail `P[X > x]` directly"]
    #[doc =
    " (accurate far into the tail, unlike `1 - P[X <= x]`); a non-zero"]
    #[doc = " `log_p` returns the log probability."]
    #[doc = ""]
    #[doc = " # R conditions"]
    #[doc = ""]
    #[doc =
    " An invalid `sigma` (negative) returns `NaN` without a warning (nmath"]
    #[doc =
    " does not report domain errors). nmath reports other problems through"]
    #[doc =
    " R\'s `warning()`, and under `options(warn = 2)` a warning becomes an R"]
    #[doc =
    " error, which longjmps. Call this where such a longjmp is caught: a"]
    #[doc = " `#[miniextendr]` function body, or"]
    #[doc =
    " [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
    #[doc =
    " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_pnorm5`."]
    #[doc = "Generated from source location line 1723, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_pnorm5"]
    pub fn Rf_pnorm5_unchecked(x: f64, mu: f64, sigma: f64,
    lower_tail: ::std::os::raw::c_int, log_p: ::std::os::raw::c_int)
    -> f64;
    #[doc = " Normal quantile function:"]
    #[doc =
    " `qnorm(p, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`."]
    #[doc = ""]
    #[doc =
    " `Rf_qnorm5` from `Rmath.h` (the `qnorm` and `qnorm5` macros resolve"]
    #[doc =
    " to it). With a non-zero `log_p`, `p` is a log probability; with"]
    #[doc =
    " `lower_tail = 0`, `p` is an upper-tail probability. `p = 0` and"]
    #[doc =
    " `p = 1` (or `-Inf` / `0` on the log scale) return `-Inf` / `Inf` as"]
    #[doc = " the tail requires."]
    #[doc = ""]
    #[doc = " # R conditions"]
    #[doc = ""]
    #[doc =
    " A `p` outside `[0, 1]` (outside `[-Inf, 0]` on the log scale) or a"]
    #[doc =
    " negative `sigma` returns `NaN` without a warning (nmath does not"]
    #[doc =
    " report domain errors). nmath reports other problems through R\'s"]
    #[doc =
    " `warning()`, and under `options(warn = 2)` a warning becomes an R"]
    #[doc =
    " error, which longjmps. Call this where such a longjmp is caught: a"]
    #[doc = " `#[miniextendr]` function body, or"]
    #[doc =
    " [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
    #[doc =
    " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_qnorm5`."]
    #[doc = "Generated from source location line 1751, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_qnorm5"]
    pub fn Rf_qnorm5_unchecked(p: f64, mu: f64, sigma: f64,
    lower_tail: ::std::os::raw::c_int, log_p: ::std::os::raw::c_int)
    -> f64;
    #[doc = " Chi-squared quantile function:"]
    #[doc =
    " `qchisq(p, df, lower.tail = lower_tail, log.p = log_p)` (central only;"]
    #[doc = " `stats::qchisq` with `ncp` calls a different routine)."]
    #[doc = ""]
    #[doc =
    " `Rf_qchisq` from `Rmath.h` (the `qchisq` macro resolves to it). It is"]
    #[doc =
    " R\'s gamma quantile with shape `df / 2` and scale `2`. The flags have"]
    #[doc = " the same meaning as for [`Rf_qnorm5`]."]
    #[doc = ""]
    #[doc = " # R conditions"]
    #[doc = ""]
    #[doc =
    " A `p` outside the probability range or a negative `df` returns `NaN`"]
    #[doc =
    " without a warning (nmath does not report domain errors). The gamma"]
    #[doc =
    " quantile iterates, and nmath reports non-convergence or precision"]
    #[doc =
    " loss in it (and in the gamma distribution function it calls) through"]
    #[doc =
    " R\'s `warning()`; under `options(warn = 2)` that warning becomes an R"]
    #[doc =
    " error, which longjmps. Call this where such a longjmp is caught: a"]
    #[doc = " `#[miniextendr]` function body, or"]
    #[doc =
    " [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
    #[doc =
    " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_qchisq`."]
    #[doc = "Generated from source location line 1779, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_qchisq"]
    pub fn Rf_qchisq_unchecked(p: f64, df: f64,
    lower_tail: ::std::os::raw::c_int, log_p: ::std::os::raw::c_int)
    -> f64;
}
#[doc = " Normal density: `dnorm(x, mean = mu, sd = sigma, log = give_log)`."]
#[doc = ""]
#[doc =
" `Rf_dnorm4` from `Rmath.h` (the `dnorm` and `dnorm4` macros resolve"]
#[doc = " to it). A non-zero `give_log` returns the log density."]
#[doc = ""]
#[doc = " # R conditions"]
#[doc = ""]
#[doc =
" An invalid `sigma` (negative) returns `NaN` without a warning: nmath"]
#[doc =
" does not report domain errors, and the \"NaNs produced\" warning that"]
#[doc =
" `stats::dnorm` gives comes from R\'s vectorised wrapper. nmath reports"]
#[doc = " other problems (precision loss, non-convergence) through R\'s"]
#[doc = " `warning()`, and under `options(warn = 2)` a warning becomes an R"]
#[doc = " error, which longjmps. Call this where such a longjmp is caught: a"]
#[doc = " `#[miniextendr]` function body, or"]
#[doc =
" [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
#[doc = " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_dnorm4`. Calls `Rf_dnorm4_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1703, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_dnorm4(x: f64, mu: f64, sigma: f64,
    give_log: ::std::os::raw::c_int) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_dnorm4_unchecked(x, mu, sigma, give_log)
                        })
                });
    result.0
}
#[doc = " Normal distribution function:"]
#[doc =
" `pnorm(x, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`."]
#[doc = ""]
#[doc =
" `Rf_pnorm5` from `Rmath.h` (the `pnorm` and `pnorm5` macros resolve"]
#[doc =
" to it). `lower_tail = 0` computes the upper tail `P[X > x]` directly"]
#[doc = " (accurate far into the tail, unlike `1 - P[X <= x]`); a non-zero"]
#[doc = " `log_p` returns the log probability."]
#[doc = ""]
#[doc = " # R conditions"]
#[doc = ""]
#[doc =
" An invalid `sigma` (negative) returns `NaN` without a warning (nmath"]
#[doc =
" does not report domain errors). nmath reports other problems through"]
#[doc =
" R\'s `warning()`, and under `options(warn = 2)` a warning becomes an R"]
#[doc = " error, which longjmps. Call this where such a longjmp is caught: a"]
#[doc = " `#[miniextendr]` function body, or"]
#[doc =
" [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
#[doc = " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_pnorm5`. Calls `Rf_pnorm5_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1723, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_pnorm5(x: f64, mu: f64, sigma: f64,
    lower_tail: ::std::os::raw::c_int, log_p: ::std::os::raw::c_int) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_pnorm5_unchecked(x, mu, sigma, lower_tail, log_p)
                        })
                });
    result.0
}
#[doc = " Normal quantile function:"]
#[doc =
" `qnorm(p, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`."]
#[doc = ""]
#[doc =
" `Rf_qnorm5` from `Rmath.h` (the `qnorm` and `qnorm5` macros resolve"]
#[doc = " to it). With a non-zero `log_p`, `p` is a log probability; with"]
#[doc = " `lower_tail = 0`, `p` is an upper-tail probability. `p = 0` and"]
#[doc =
" `p = 1` (or `-Inf` / `0` on the log scale) return `-Inf` / `Inf` as"]
#[doc = " the tail requires."]
#[doc = ""]
#[doc = " # R conditions"]
#[doc = ""]
#[doc = " A `p` outside `[0, 1]` (outside `[-Inf, 0]` on the log scale) or a"]
#[doc = " negative `sigma` returns `NaN` without a warning (nmath does not"]
#[doc = " report domain errors). nmath reports other problems through R\'s"]
#[doc = " `warning()`, and under `options(warn = 2)` a warning becomes an R"]
#[doc = " error, which longjmps. Call this where such a longjmp is caught: a"]
#[doc = " `#[miniextendr]` function body, or"]
#[doc =
" [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
#[doc = " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_qnorm5`. Calls `Rf_qnorm5_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1751, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_qnorm5(p: f64, mu: f64, sigma: f64,
    lower_tail: ::std::os::raw::c_int, log_p: ::std::os::raw::c_int) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_qnorm5_unchecked(p, mu, sigma, lower_tail, log_p)
                        })
                });
    result.0
}
#[doc = " Chi-squared quantile function:"]
#[doc =
" `qchisq(p, df, lower.tail = lower_tail, log.p = log_p)` (central only;"]
#[doc = " `stats::qchisq` with `ncp` calls a different routine)."]
#[doc = ""]
#[doc =
" `Rf_qchisq` from `Rmath.h` (the `qchisq` macro resolves to it). It is"]
#[doc =
" R\'s gamma quantile with shape `df / 2` and scale `2`. The flags have"]
#[doc = " the same meaning as for [`Rf_qnorm5`]."]
#[doc = ""]
#[doc = " # R conditions"]
#[doc = ""]
#[doc =
" A `p` outside the probability range or a negative `df` returns `NaN`"]
#[doc = " without a warning (nmath does not report domain errors). The gamma"]
#[doc = " quantile iterates, and nmath reports non-convergence or precision"]
#[doc =
" loss in it (and in the gamma distribution function it calls) through"]
#[doc =
" R\'s `warning()`; under `options(warn = 2)` that warning becomes an R"]
#[doc = " error, which longjmps. Call this where such a longjmp is caught: a"]
#[doc = " `#[miniextendr]` function body, or"]
#[doc =
" [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
#[doc = " `#[r_ffi_checked]` gives thread routing and checking only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_qchisq`. Calls `Rf_qchisq_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1779, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_qchisq(p: f64, df: f64, lower_tail: ::std::os::raw::c_int,
    log_p: ::std::os::raw::c_int) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_qchisq_unchecked(p, df, lower_tail, log_p)
                        })
                });
    result.0
}#[r_ffi_checked]
1685unsafe extern "C-unwind" {
1686    /// Normal density: `dnorm(x, mean = mu, sd = sigma, log = give_log)`.
1687    ///
1688    /// `Rf_dnorm4` from `Rmath.h` (the `dnorm` and `dnorm4` macros resolve
1689    /// to it). A non-zero `give_log` returns the log density.
1690    ///
1691    /// # R conditions
1692    ///
1693    /// An invalid `sigma` (negative) returns `NaN` without a warning: nmath
1694    /// does not report domain errors, and the "NaNs produced" warning that
1695    /// `stats::dnorm` gives comes from R's vectorised wrapper. nmath reports
1696    /// other problems (precision loss, non-convergence) through R's
1697    /// `warning()`, and under `options(warn = 2)` a warning becomes an R
1698    /// error, which longjmps. Call this where such a longjmp is caught: a
1699    /// `#[miniextendr]` function body, or
1700    /// [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1701    /// `#[r_ffi_checked]` gives thread routing and checking only, not an
1702    /// unwind guard.
1703    pub fn Rf_dnorm4(x: f64, mu: f64, sigma: f64, give_log: ::std::os::raw::c_int) -> f64;
1704
1705    /// Normal distribution function:
1706    /// `pnorm(x, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`.
1707    ///
1708    /// `Rf_pnorm5` from `Rmath.h` (the `pnorm` and `pnorm5` macros resolve
1709    /// to it). `lower_tail = 0` computes the upper tail `P[X > x]` directly
1710    /// (accurate far into the tail, unlike `1 - P[X <= x]`); a non-zero
1711    /// `log_p` returns the log probability.
1712    ///
1713    /// # R conditions
1714    ///
1715    /// An invalid `sigma` (negative) returns `NaN` without a warning (nmath
1716    /// does not report domain errors). nmath reports other problems through
1717    /// R's `warning()`, and under `options(warn = 2)` a warning becomes an R
1718    /// error, which longjmps. Call this where such a longjmp is caught: a
1719    /// `#[miniextendr]` function body, or
1720    /// [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1721    /// `#[r_ffi_checked]` gives thread routing and checking only, not an
1722    /// unwind guard.
1723    pub fn Rf_pnorm5(
1724        x: f64,
1725        mu: f64,
1726        sigma: f64,
1727        lower_tail: ::std::os::raw::c_int,
1728        log_p: ::std::os::raw::c_int,
1729    ) -> f64;
1730
1731    /// Normal quantile function:
1732    /// `qnorm(p, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`.
1733    ///
1734    /// `Rf_qnorm5` from `Rmath.h` (the `qnorm` and `qnorm5` macros resolve
1735    /// to it). With a non-zero `log_p`, `p` is a log probability; with
1736    /// `lower_tail = 0`, `p` is an upper-tail probability. `p = 0` and
1737    /// `p = 1` (or `-Inf` / `0` on the log scale) return `-Inf` / `Inf` as
1738    /// the tail requires.
1739    ///
1740    /// # R conditions
1741    ///
1742    /// A `p` outside `[0, 1]` (outside `[-Inf, 0]` on the log scale) or a
1743    /// negative `sigma` returns `NaN` without a warning (nmath does not
1744    /// report domain errors). nmath reports other problems through R's
1745    /// `warning()`, and under `options(warn = 2)` a warning becomes an R
1746    /// error, which longjmps. Call this where such a longjmp is caught: a
1747    /// `#[miniextendr]` function body, or
1748    /// [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1749    /// `#[r_ffi_checked]` gives thread routing and checking only, not an
1750    /// unwind guard.
1751    pub fn Rf_qnorm5(
1752        p: f64,
1753        mu: f64,
1754        sigma: f64,
1755        lower_tail: ::std::os::raw::c_int,
1756        log_p: ::std::os::raw::c_int,
1757    ) -> f64;
1758
1759    /// Chi-squared quantile function:
1760    /// `qchisq(p, df, lower.tail = lower_tail, log.p = log_p)` (central only;
1761    /// `stats::qchisq` with `ncp` calls a different routine).
1762    ///
1763    /// `Rf_qchisq` from `Rmath.h` (the `qchisq` macro resolves to it). It is
1764    /// R's gamma quantile with shape `df / 2` and scale `2`. The flags have
1765    /// the same meaning as for [`Rf_qnorm5`].
1766    ///
1767    /// # R conditions
1768    ///
1769    /// A `p` outside the probability range or a negative `df` returns `NaN`
1770    /// without a warning (nmath does not report domain errors). The gamma
1771    /// quantile iterates, and nmath reports non-convergence or precision
1772    /// loss in it (and in the gamma distribution function it calls) through
1773    /// R's `warning()`; under `options(warn = 2)` that warning becomes an R
1774    /// error, which longjmps. Call this where such a longjmp is caught: a
1775    /// `#[miniextendr]` function body, or
1776    /// [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1777    /// `#[r_ffi_checked]` gives thread routing and checking only, not an
1778    /// unwind guard.
1779    pub fn Rf_qchisq(
1780        p: f64,
1781        df: f64,
1782        lower_tail: ::std::os::raw::c_int,
1783        log_p: ::std::os::raw::c_int,
1784    ) -> f64;
1785}
1786
1787// endregion
1788
1789// region: Optimisation (R_ext/Applic.h)
1790//
1791// `R_ext/Applic.h` lists `lbfgsb` under "Entry points in the R API" (no `Rf_`
1792// prefix), libR exports it with this prototype from the R 4.4 floor on,
1793// `tools:::funAPI()` lists it as `api` (R 4.6 and R-devel 4.7), and it is not
1794// in `tools:::nonAPI` (R 4.4 to 4.7), so it needs no feature gate. Only the
1795// raw ABI is declared here; there is no safe adapter.
1796
1797/// Objective callback type for R's optimisers: `optimfn` in `R_ext/Applic.h`,
1798/// `typedef double optimfn(int n, double *par, void *ex)`.
1799///
1800/// Called with the parameter count, a pointer to `n` parameter values, and
1801/// the `ex` pointer given to the optimiser; returns the objective value.
1802/// [`lbfgsb`] requires a finite value: it raises an R error otherwise.
1803///
1804/// A Rust panic must not unwind out of the callback through R's C frames:
1805/// catch it inside the callback (`std::panic::catch_unwind`), store the
1806/// payload in the `ex` state, return a finite value, and resume the panic
1807/// after the optimiser returns.
1808#[allow(non_camel_case_types)]
1809pub type optimfn = unsafe extern "C-unwind" fn(
1810    n: ::std::os::raw::c_int,
1811    par: *mut f64,
1812    ex: *mut ::std::os::raw::c_void,
1813) -> f64;
1814
1815/// Gradient callback type for R's optimisers: `optimgr` in `R_ext/Applic.h`,
1816/// `typedef void optimgr(int n, double *par, double *gr, void *ex)`.
1817///
1818/// Called with the parameter count, a pointer to `n` parameter values, a
1819/// pointer to `n` gradient slots to fill, and the `ex` pointer given to the
1820/// optimiser. The panic rule of [`optimfn`] applies: catch it inside, store
1821/// the payload in `ex`, fill the slots (zeros will do), resume afterwards.
1822#[allow(non_camel_case_types)]
1823pub type optimgr = unsafe extern "C-unwind" fn(
1824    n: ::std::os::raw::c_int,
1825    par: *mut f64,
1826    gr: *mut f64,
1827    ex: *mut ::std::os::raw::c_void,
1828);
1829
1830unsafe extern "C-unwind" {
    #[doc = " Bound-constrained limited-memory BFGS minimiser: `lbfgsb` in"]
    #[doc =
    " `R_ext/Applic.h`, the routine behind `optim(method = \"L-BFGS-B\")`."]
    #[doc = ""]
    #[doc = " # Arguments"]
    #[doc = ""]
    #[doc =
    " - `n`: number of parameters. With `n = 0` it calls `fn_(0, u, ex)`"]
    #[doc =
    "   once and returns `fail = 0`, `fncount = 1`, `grcount = 0` and the"]
    #[doc = "   message `\"NOTHING TO DO\"`."]
    #[doc =
    " - `m`: number of correction pairs kept (`optim`\'s `lmm`, default 5)."]
    #[doc = " - `x`: `n` starting values; overwritten with the solution."]
    #[doc =
    " - `l`, `u`: `n` lower and upper bounds, read where `nbd` says so."]
    #[doc =
    " - `nbd`: `n` bound codes: `0` unbounded, `1` lower bound only, `2`"]
    #[doc =
    "   both bounds, `3` upper bound only. Code `2` with `l[i] == u[i]`"]
    #[doc = "   fixes parameter `i`."]
    #[doc =
    " - `fmin`: receives the last objective value computed, the one at the"]
    #[doc =
    "   returned `x` on convergence. It is not meaningful when the input"]
    #[doc = "   checks fail (`fail = 52` before any evaluation)."]
    #[doc =
    " - `fn_`, `gr`: objective and gradient callbacks. Both are required"]
    #[doc = "   (R calls them unconditionally)."]
    #[doc =
    " - `fail`: receives `0` (converged), `1` (`maxit` reached; the message"]
    #[doc =
    "   is then `\"NEW_X\"`), `51` (a `\"WARNING: ...\"` from the line search)"]
    #[doc =
    "   or `52` (an `\"ERROR: ...\"`, such as an invalid `nbd` code or"]
    #[doc = "   `l[i] > u[i]` under code `2`)."]
    #[doc = " - `ex`: passed unchanged to both callbacks."]
    #[doc =
    " - `factr`: relative-reduction tolerance in units of machine epsilon"]
    #[doc = "   (`optim`\'s default `1e7`)."]
    #[doc =
    " - `pgtol`: projected-gradient tolerance (with `optim`\'s default `0`"]
    #[doc = "   only an exactly zero projected gradient stops on it)."]
    #[doc =
    " - `fncount`, `grcount`: receive the evaluation counts (R stores the"]
    #[doc = "   same count in both, except with `n = 0`: see `n` above)."]
    #[doc = " - `maxit`: iteration limit."]
    #[doc =
    " - `msg`: caller-owned buffer of at least 60 bytes (C `char msg[60]`);"]
    #[doc = "   receives a NUL-terminated status such as"]
    #[doc = "   `\"CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH\"`."]
    #[doc =
    " - `trace`: `0` is silent; `1` to `6` print progress through `Rprintf`."]
    #[doc =
    " - `nreport`: progress interval in iterations. It must be at least `1`"]
    #[doc = "   even when `trace = 0`."]
    #[doc = ""]
    #[doc =
    " The routine keeps a limited-memory approximation of the inverse"]
    #[doc =
    " Hessian internally and does not return it. That approximation is a"]
    #[doc =
    " search device, not an inferential covariance: compute the Hessian at"]
    #[doc = " the optimum (as `stats::optimHess` does) for standard errors."]
    #[doc = ""]
    #[doc = " # Safety"]
    #[doc = ""]
    #[doc =
    " - `x`, `l`, `u` and `nbd` must be valid for `n` elements, `msg` must"]
    #[doc =
    "   be writable for 60 bytes, and the other out-pointers must be valid."]
    #[doc =
    "   `ex` must stay valid for the whole call: the callbacks receive it"]
    #[doc = "   on every evaluation."]
    #[doc = " - `lbfgsb` raises R errors itself (an R longjmp): when"]
    #[doc =
    "   `nreport <= 0`, and when the objective returns a non-finite value"]
    #[doc =
    "   (\"L-BFGS-B needs finite values of \'fn\'\"). Call it where such a"]
    #[doc = "   longjmp is caught: a `#[miniextendr]` function body, or"]
    #[doc =
    "   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
    #[doc =
    "   `#[r_ffi_checked]` gives thread routing and checking only, not an"]
    #[doc = "   unwind guard."]
    #[doc =
    " - The callbacks must not let a Rust panic unwind through `lbfgsb`\'s"]
    #[doc = "   frames (see [`optimfn`])."]
    #[doc =
    " - The workspace comes from `R_alloc` / `S_alloc`, R\'s transient"]
    #[doc =
    "   allocation stack. R reclaims it when the enclosing `.Call` returns;"]
    #[doc =
    "   outside `.Call`, bracket the call with [`vmaxget`] / [`vmaxset`]."]
    #[allow(clippy::too_many_arguments)]
    #[doc = "Unchecked FFI binding for `lbfgsb`."]
    #[doc = "Generated from source location line 1894, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "lbfgsb"]
    pub fn lbfgsb_unchecked(n: ::std::os::raw::c_int,
    m: ::std::os::raw::c_int, x: *mut f64, l: *mut f64, u: *mut f64,
    nbd: *mut ::std::os::raw::c_int, fmin: *mut f64, fn_: optimfn,
    gr: optimgr, fail: *mut ::std::os::raw::c_int,
    ex: *mut ::std::os::raw::c_void, factr: f64, pgtol: f64,
    fncount: *mut ::std::os::raw::c_int, grcount: *mut ::std::os::raw::c_int,
    maxit: ::std::os::raw::c_int, msg: *mut ::std::os::raw::c_char,
    trace: ::std::os::raw::c_int, nreport: ::std::os::raw::c_int);
}
#[doc = " Bound-constrained limited-memory BFGS minimiser: `lbfgsb` in"]
#[doc =
" `R_ext/Applic.h`, the routine behind `optim(method = \"L-BFGS-B\")`."]
#[doc = ""]
#[doc = " # Arguments"]
#[doc = ""]
#[doc = " - `n`: number of parameters. With `n = 0` it calls `fn_(0, u, ex)`"]
#[doc =
"   once and returns `fail = 0`, `fncount = 1`, `grcount = 0` and the"]
#[doc = "   message `\"NOTHING TO DO\"`."]
#[doc =
" - `m`: number of correction pairs kept (`optim`\'s `lmm`, default 5)."]
#[doc = " - `x`: `n` starting values; overwritten with the solution."]
#[doc = " - `l`, `u`: `n` lower and upper bounds, read where `nbd` says so."]
#[doc = " - `nbd`: `n` bound codes: `0` unbounded, `1` lower bound only, `2`"]
#[doc = "   both bounds, `3` upper bound only. Code `2` with `l[i] == u[i]`"]
#[doc = "   fixes parameter `i`."]
#[doc =
" - `fmin`: receives the last objective value computed, the one at the"]
#[doc = "   returned `x` on convergence. It is not meaningful when the input"]
#[doc = "   checks fail (`fail = 52` before any evaluation)."]
#[doc = " - `fn_`, `gr`: objective and gradient callbacks. Both are required"]
#[doc = "   (R calls them unconditionally)."]
#[doc =
" - `fail`: receives `0` (converged), `1` (`maxit` reached; the message"]
#[doc =
"   is then `\"NEW_X\"`), `51` (a `\"WARNING: ...\"` from the line search)"]
#[doc = "   or `52` (an `\"ERROR: ...\"`, such as an invalid `nbd` code or"]
#[doc = "   `l[i] > u[i]` under code `2`)."]
#[doc = " - `ex`: passed unchanged to both callbacks."]
#[doc =
" - `factr`: relative-reduction tolerance in units of machine epsilon"]
#[doc = "   (`optim`\'s default `1e7`)."]
#[doc =
" - `pgtol`: projected-gradient tolerance (with `optim`\'s default `0`"]
#[doc = "   only an exactly zero projected gradient stops on it)."]
#[doc =
" - `fncount`, `grcount`: receive the evaluation counts (R stores the"]
#[doc = "   same count in both, except with `n = 0`: see `n` above)."]
#[doc = " - `maxit`: iteration limit."]
#[doc =
" - `msg`: caller-owned buffer of at least 60 bytes (C `char msg[60]`);"]
#[doc = "   receives a NUL-terminated status such as"]
#[doc = "   `\"CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH\"`."]
#[doc =
" - `trace`: `0` is silent; `1` to `6` print progress through `Rprintf`."]
#[doc =
" - `nreport`: progress interval in iterations. It must be at least `1`"]
#[doc = "   even when `trace = 0`."]
#[doc = ""]
#[doc = " The routine keeps a limited-memory approximation of the inverse"]
#[doc = " Hessian internally and does not return it. That approximation is a"]
#[doc =
" search device, not an inferential covariance: compute the Hessian at"]
#[doc = " the optimum (as `stats::optimHess` does) for standard errors."]
#[doc = ""]
#[doc = " # Safety"]
#[doc = ""]
#[doc =
" - `x`, `l`, `u` and `nbd` must be valid for `n` elements, `msg` must"]
#[doc =
"   be writable for 60 bytes, and the other out-pointers must be valid."]
#[doc =
"   `ex` must stay valid for the whole call: the callbacks receive it"]
#[doc = "   on every evaluation."]
#[doc = " - `lbfgsb` raises R errors itself (an R longjmp): when"]
#[doc =
"   `nreport <= 0`, and when the objective returns a non-finite value"]
#[doc =
"   (\"L-BFGS-B needs finite values of \'fn\'\"). Call it where such a"]
#[doc = "   longjmp is caught: a `#[miniextendr]` function body, or"]
#[doc =
"   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect)."]
#[doc =
"   `#[r_ffi_checked]` gives thread routing and checking only, not an"]
#[doc = "   unwind guard."]
#[doc =
" - The callbacks must not let a Rust panic unwind through `lbfgsb`\'s"]
#[doc = "   frames (see [`optimfn`])."]
#[doc = " - The workspace comes from `R_alloc` / `S_alloc`, R\'s transient"]
#[doc =
"   allocation stack. R reclaims it when the enclosing `.Call` returns;"]
#[doc =
"   outside `.Call`, bracket the call with [`vmaxget`] / [`vmaxset`]."]
#[allow(clippy::too_many_arguments)]
#[doc =
"Checked wrapper for `lbfgsb`. Calls `lbfgsb_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 1894, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn lbfgsb(n: ::std::os::raw::c_int, m: ::std::os::raw::c_int,
    x: *mut f64, l: *mut f64, u: *mut f64, nbd: *mut ::std::os::raw::c_int,
    fmin: *mut f64, fn_: optimfn, gr: optimgr,
    fail: *mut ::std::os::raw::c_int, ex: *mut ::std::os::raw::c_void,
    factr: f64, pgtol: f64, fncount: *mut ::std::os::raw::c_int,
    grcount: *mut ::std::os::raw::c_int, maxit: ::std::os::raw::c_int,
    msg: *mut ::std::os::raw::c_char, trace: ::std::os::raw::c_int,
    nreport: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            lbfgsb_unchecked(n, m, x, l, u, nbd, fmin, fn_, gr, fail,
                                ex, factr, pgtol, fncount, grcount, maxit, msg, trace,
                                nreport)
                        })
                });
    result.0
}#[r_ffi_checked]
1831unsafe extern "C-unwind" {
1832    /// Bound-constrained limited-memory BFGS minimiser: `lbfgsb` in
1833    /// `R_ext/Applic.h`, the routine behind `optim(method = "L-BFGS-B")`.
1834    ///
1835    /// # Arguments
1836    ///
1837    /// - `n`: number of parameters. With `n = 0` it calls `fn_(0, u, ex)`
1838    ///   once and returns `fail = 0`, `fncount = 1`, `grcount = 0` and the
1839    ///   message `"NOTHING TO DO"`.
1840    /// - `m`: number of correction pairs kept (`optim`'s `lmm`, default 5).
1841    /// - `x`: `n` starting values; overwritten with the solution.
1842    /// - `l`, `u`: `n` lower and upper bounds, read where `nbd` says so.
1843    /// - `nbd`: `n` bound codes: `0` unbounded, `1` lower bound only, `2`
1844    ///   both bounds, `3` upper bound only. Code `2` with `l[i] == u[i]`
1845    ///   fixes parameter `i`.
1846    /// - `fmin`: receives the last objective value computed, the one at the
1847    ///   returned `x` on convergence. It is not meaningful when the input
1848    ///   checks fail (`fail = 52` before any evaluation).
1849    /// - `fn_`, `gr`: objective and gradient callbacks. Both are required
1850    ///   (R calls them unconditionally).
1851    /// - `fail`: receives `0` (converged), `1` (`maxit` reached; the message
1852    ///   is then `"NEW_X"`), `51` (a `"WARNING: ..."` from the line search)
1853    ///   or `52` (an `"ERROR: ..."`, such as an invalid `nbd` code or
1854    ///   `l[i] > u[i]` under code `2`).
1855    /// - `ex`: passed unchanged to both callbacks.
1856    /// - `factr`: relative-reduction tolerance in units of machine epsilon
1857    ///   (`optim`'s default `1e7`).
1858    /// - `pgtol`: projected-gradient tolerance (with `optim`'s default `0`
1859    ///   only an exactly zero projected gradient stops on it).
1860    /// - `fncount`, `grcount`: receive the evaluation counts (R stores the
1861    ///   same count in both, except with `n = 0`: see `n` above).
1862    /// - `maxit`: iteration limit.
1863    /// - `msg`: caller-owned buffer of at least 60 bytes (C `char msg[60]`);
1864    ///   receives a NUL-terminated status such as
1865    ///   `"CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"`.
1866    /// - `trace`: `0` is silent; `1` to `6` print progress through `Rprintf`.
1867    /// - `nreport`: progress interval in iterations. It must be at least `1`
1868    ///   even when `trace = 0`.
1869    ///
1870    /// The routine keeps a limited-memory approximation of the inverse
1871    /// Hessian internally and does not return it. That approximation is a
1872    /// search device, not an inferential covariance: compute the Hessian at
1873    /// the optimum (as `stats::optimHess` does) for standard errors.
1874    ///
1875    /// # Safety
1876    ///
1877    /// - `x`, `l`, `u` and `nbd` must be valid for `n` elements, `msg` must
1878    ///   be writable for 60 bytes, and the other out-pointers must be valid.
1879    ///   `ex` must stay valid for the whole call: the callbacks receive it
1880    ///   on every evaluation.
1881    /// - `lbfgsb` raises R errors itself (an R longjmp): when
1882    ///   `nreport <= 0`, and when the objective returns a non-finite value
1883    ///   ("L-BFGS-B needs finite values of 'fn'"). Call it where such a
1884    ///   longjmp is caught: a `#[miniextendr]` function body, or
1885    ///   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1886    ///   `#[r_ffi_checked]` gives thread routing and checking only, not an
1887    ///   unwind guard.
1888    /// - The callbacks must not let a Rust panic unwind through `lbfgsb`'s
1889    ///   frames (see [`optimfn`]).
1890    /// - The workspace comes from `R_alloc` / `S_alloc`, R's transient
1891    ///   allocation stack. R reclaims it when the enclosing `.Call` returns;
1892    ///   outside `.Call`, bracket the call with [`vmaxget`] / [`vmaxset`].
1893    #[allow(clippy::too_many_arguments)]
1894    pub fn lbfgsb(
1895        n: ::std::os::raw::c_int,
1896        m: ::std::os::raw::c_int,
1897        x: *mut f64,
1898        l: *mut f64,
1899        u: *mut f64,
1900        nbd: *mut ::std::os::raw::c_int,
1901        fmin: *mut f64,
1902        fn_: optimfn,
1903        gr: optimgr,
1904        fail: *mut ::std::os::raw::c_int,
1905        ex: *mut ::std::os::raw::c_void,
1906        factr: f64,
1907        pgtol: f64,
1908        fncount: *mut ::std::os::raw::c_int,
1909        grcount: *mut ::std::os::raw::c_int,
1910        maxit: ::std::os::raw::c_int,
1911        msg: *mut ::std::os::raw::c_char,
1912        trace: ::std::os::raw::c_int,
1913        nreport: ::std::os::raw::c_int,
1914    );
1915}
1916
1917// endregion
1918
1919// region: BLAS and LAPACK (R_ext/BLAS.h, R_ext/Lapack.h), `blas-lapack` feature
1920//
1921// The BLAS and LAPACK that R itself was built with (`libRblas` / `libRlapack`
1922// or an external library chosen at R's configure time). `tools:::funAPI()`
1923// lists `dgemm_` (`R_ext/BLAS.h`) and `dgesv_` (`R_ext/Lapack.h`) as `api` in
1924// R 4.6.1 and R-devel 4.7.0, neither is in `tools:::nonAPI` (R 4.4 to 4.7),
1925// and R's BLAS/LAPACK export both from the R 4.4 floor on. The `blas-lapack`
1926// feature gates them only because they live in libraries a package must link
1927// itself: `PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)`.
1928//
1929// The ABI is Fortran's, as `R_ext/RS.h` and `R_ext/BLAS.h` spell it:
1930//
1931// - Symbol: `F77_NAME(dgemm)` is `dgemm_`. `Rconfig.h` defines
1932//   `HAVE_F77_UNDERSCORE` on every current R platform (macOS, Linux, Windows
1933//   and webR).
1934// - Every declared argument is a pointer, scalars included.
1935// - Each CHARACTER argument adds a hidden length, passed by value after all
1936//   the declared arguments, in the order of the character arguments (`FCLEN`
1937//   in the prototypes, `FCONE` = `(FC_LEN_T)1` at call sites). See
1938//   [`FC_LEN_T`].
1939// - INTEGER is `BLAS_INT` / `La_INT`, which the headers define as `int`
1940//   unless `ILP64` is defined. R never defines it, and R's configure requires
1941//   a 32-bit Fortran INTEGER equal to C `int`. There is no ILP64 variant
1942//   here: the assertion below refuses a target where `c_int` is not 32-bit.
1943//
1944// R replaces the BLAS/LAPACK invalid-argument handler `xerbla` with one that
1945// raises an R error ("BLAS/LAPACK routine 'DGEMM ' gave error code ...", in
1946// `src/main/print.c`), so an invalid argument longjmps out of the routine
1947// instead of returning. The safe adapters in [`crate::linalg`] validate every
1948// argument before calling.
1949
1950/// Type of the hidden CHARACTER-length arguments of R's Fortran BLAS/LAPACK:
1951/// `FC_LEN_T` in R's `Rconfig.h`.
1952///
1953/// gfortran (since version 8) and LLVM flang pass the length of each
1954/// CHARACTER argument as an extra by-value argument after the declared
1955/// ones. R's configure probes the Fortran compiler and defines `FC_LEN_T` as
1956/// `size_t`, and since R 4.3.0 `R_ext/BLAS.h` and `R_ext/Lapack.h` declare
1957/// one `FC_LEN_T` per character argument by default (`USE_FC_LEN_T`).
1958/// `usize` is `size_t` on every target R runs on: the macOS, Linux and
1959/// Windows `Rconfig.h` define
1960/// `FC_LEN_T size_t`, and so does webR's, where `size_t` is 32 bits (its
1961/// `libRblas.so` exports `dgemm_` with 15 `i32` parameters: 13 declared
1962/// arguments and two lengths).
1963///
1964/// Omitting the lengths, as the `blas-sys` / `lapack-sys` crates do, is
1965/// undefined behaviour with these compilers and a link-time signature
1966/// mismatch on webR. Pass `1` for each single-character flag, as `FCONE`
1967/// does.
1968#[allow(non_camel_case_types)]
1969#[cfg(feature = "blas-lapack")]
1970pub type FC_LEN_T = usize;
1971
1972// R's BLAS/LAPACK INTEGER is C `int` (32-bit); see the region comment.
1973#[cfg(feature = "blas-lapack")]
1974const _: () = assert!(
1975    ::std::mem::size_of::<::std::os::raw::c_int>() == 4,
1976    "R's BLAS/LAPACK use a 32-bit INTEGER (C int); ILP64 is not supported"
1977);
1978
1979#[cfg(feature = "blas-lapack")]
1980#[r_ffi_checked]
1981unsafe extern "C-unwind" {
1982    /// General matrix product: `C := alpha * op(A) * op(B) + beta * C`,
1983    /// `F77_NAME(dgemm)` from `R_ext/BLAS.h` (the routine behind R's `%*%`).
1984    ///
1985    /// All matrices are column-major. `op(X)` is `X` when its flag is
1986    /// `b'N'` (or `b'n'`) and `X'` when it is `b'T'` / `b'C'`.
1987    ///
1988    /// # Arguments
1989    ///
1990    /// - `transa`, `transb`: pointers to one ASCII flag character each.
1991    /// - `m`, `n`, `k`: `op(A)` is `m x k`, `op(B)` is `k x n`, `C` is
1992    ///   `m x n`.
1993    /// - `alpha`, `beta`: scalars. With `*beta == 0.0`, `C` need not be
1994    ///   initialised (NaNs in it are not propagated).
1995    /// - `a`, `lda`: `A` is `lda x ka` with `ka = k` for `'N'` and `ka = m`
1996    ///   for `'T'`; `lda >= max(1, rows of A)` (`m` for `'N'`, `k` for
1997    ///   `'T'`).
1998    /// - `b`, `ldb`: `B` is `ldb x kb` with `kb = n` for `'N'` and `kb = k`
1999    ///   for `'T'`; `ldb >= max(1, rows of B)` (`k` for `'N'`, `n` for
2000    ///   `'T'`).
2001    /// - `c`, `ldc`: `C` is `ldc x n`, `ldc >= max(1, m)`; overwritten with
2002    ///   the result.
2003    /// - `transa_len`, `transb_len`: the hidden lengths of `transa` and
2004    ///   `transb` ([`FC_LEN_T`]); pass `1` each.
2005    ///
2006    /// Non-finite inputs are not guaranteed to propagate: a BLAS may skip a
2007    /// term whose multiplier is zero, so `0 * Inf` or `0 * NaN` can vanish.
2008    /// R's `%*%` checks for NA/NaN first and uses its own loop in that case
2009    /// (`options(matprod = "default")`).
2010    ///
2011    /// # Safety
2012    ///
2013    /// - Every pointer must be valid for the reads (and, for `c`, writes)
2014    ///   the dimensions imply, `c` must not overlap `a` or `b`, and nothing
2015    ///   may mutate `a` or `b` during the call.
2016    /// - An invalid argument (a flag other than N/T/C, a negative dimension,
2017    ///   a leading dimension that is too small) makes R's `xerbla` raise an
2018    ///   R error, which longjmps over the Rust frames. Validate the
2019    ///   arguments first, as [`crate::linalg::matrix_product`] does, or call
2020    ///   it where such a longjmp is caught: a `#[miniextendr]` function
2021    ///   body, or
2022    ///   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
2023    ///   `#[r_ffi_checked]` gives thread routing and checking only, not an
2024    ///   unwind guard.
2025    /// - Call it from R's main thread (the checked variant routes there from
2026    ///   a worker) in a process where R is initialised: `xerbla` is R's.
2027    ///   A standalone binary must start R first (`miniextendr-engine`).
2028    #[allow(clippy::too_many_arguments)]
2029    pub fn dgemm_(
2030        transa: *const ::std::os::raw::c_char,
2031        transb: *const ::std::os::raw::c_char,
2032        m: *const ::std::os::raw::c_int,
2033        n: *const ::std::os::raw::c_int,
2034        k: *const ::std::os::raw::c_int,
2035        alpha: *const f64,
2036        a: *const f64,
2037        lda: *const ::std::os::raw::c_int,
2038        b: *const f64,
2039        ldb: *const ::std::os::raw::c_int,
2040        beta: *const f64,
2041        c: *mut f64,
2042        ldc: *const ::std::os::raw::c_int,
2043        transa_len: FC_LEN_T,
2044        transb_len: FC_LEN_T,
2045    );
2046
2047    /// Solve `A X = B` for a general square `A` by LU factorisation with
2048    /// partial pivoting: `F77_NAME(dgesv)` from `R_ext/Lapack.h` (the
2049    /// routine behind `base::solve()`).
2050    ///
2051    /// All matrices are column-major. DGESV has no character arguments, so
2052    /// no hidden lengths.
2053    ///
2054    /// # Arguments
2055    ///
2056    /// - `n`: order of `A` (rows of `B`).
2057    /// - `nrhs`: number of right-hand sides (columns of `B`).
2058    /// - `a`, `lda`: `A`, `lda x n` with `lda >= max(1, n)`. Overwritten with
2059    ///   the factors `L` (unit diagonal not stored) and `U` of `A = P L U`.
2060    /// - `ipiv`: `n` pivot indices (1-based): row `i` was interchanged with
2061    ///   row `ipiv[i - 1]`.
2062    /// - `b`, `ldb`: `B`, `ldb x nrhs` with `ldb >= max(1, n)`. Overwritten
2063    ///   with the solution `X` when `*info == 0`.
2064    /// - `info`: receives `0` on success, or `i > 0` when `U(i, i)` is
2065    ///   exactly zero: `A` is singular, the factorisation is complete but `X`
2066    ///   was not computed. A negative value would report an invalid
2067    ///   argument, but under R `xerbla` raises an R error instead (see
2068    ///   Safety).
2069    ///
2070    /// Only an exactly zero pivot is reported: a nearly singular `A` returns
2071    /// `info = 0` and an inaccurate `X`. `base::solve()` additionally
2072    /// estimates the reciprocal condition number (`dgecon`) and errors below
2073    /// `tol`; DGESV does not.
2074    ///
2075    /// # Safety
2076    ///
2077    /// - `a` must be valid for `lda * n` reads and writes, `b` for
2078    ///   `ldb * nrhs`, `ipiv` for `n` writes, and none of them may overlap.
2079    /// - An invalid argument (a negative `n` or `nrhs`, `lda` or `ldb` below
2080    ///   `max(1, n)`) makes R's `xerbla` raise an R error, which longjmps
2081    ///   over the Rust frames. Validate the arguments first, as
2082    ///   [`crate::linalg::solve`] does, or call it where such a longjmp is
2083    ///   caught: a `#[miniextendr]` function body, or
2084    ///   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
2085    ///   `#[r_ffi_checked]` gives thread routing and checking only, not an
2086    ///   unwind guard.
2087    /// - Call it from R's main thread (the checked variant routes there from
2088    ///   a worker) in a process where R is initialised: `xerbla` is R's.
2089    ///   A standalone binary must start R first (`miniextendr-engine`).
2090    #[allow(clippy::too_many_arguments)]
2091    pub fn dgesv_(
2092        n: *const ::std::os::raw::c_int,
2093        nrhs: *const ::std::os::raw::c_int,
2094        a: *mut f64,
2095        lda: *const ::std::os::raw::c_int,
2096        ipiv: *mut ::std::os::raw::c_int,
2097        b: *mut f64,
2098        ldb: *const ::std::os::raw::c_int,
2099        info: *mut ::std::os::raw::c_int,
2100    );
2101}
2102
2103// endregion
2104
2105// region: Memory allocation (R_ext/Memory.h)
2106
2107unsafe extern "C-unwind" {
    #[doc = " Get the current R memory stack watermark."]
    #[doc = ""]
    #[doc = " Use with `vmaxset()` to restore memory stack state."]
    #[doc =
    " Memory allocated with `R_alloc()` between `vmaxget()` and `vmaxset()`"]
    #[doc = " will be freed when `vmaxset()` is called."]
    #[doc = ""]
    #[doc = " # Example"]
    #[doc = ""]
    #[doc = " ```ignore"]
    #[doc = " unsafe {"]
    #[doc = "     let watermark = vmaxget();"]
    #[doc = "     let buf = R_alloc(100, 1);"]
    #[doc = "     // ... use buf ..."]
    #[doc = "     vmaxset(watermark); // frees buf"]
    #[doc = " }"]
    #[doc = " ```"]
    #[doc = "Unchecked FFI binding for `vmaxget`."]
    #[doc = "Generated from source location line 2125, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "vmaxget"]
    pub fn vmaxget_unchecked()
    -> *mut ::std::os::raw::c_void;
    #[doc =
    " Set the R memory stack watermark, freeing memory allocated since the mark."]
    #[doc = ""]
    #[doc = " # Safety"]
    #[doc = ""]
    #[doc =
    " `ovmax` must be a value returned by `vmaxget()` called earlier in the"]
    #[doc = " same R evaluation context."]
    #[doc = "Unchecked FFI binding for `vmaxset`."]
    #[doc = "Generated from source location line 2133, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "vmaxset"]
    pub fn vmaxset_unchecked(ovmax: *const ::std::os::raw::c_void);
    #[doc = " Run the R garbage collector."]
    #[doc = ""]
    #[doc = " Forces a full garbage collection cycle."]
    #[doc = "Unchecked FFI binding for `R_gc`."]
    #[doc = "Generated from source location line 2138, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_gc"]
    pub fn R_gc_unchecked();
    #[doc = " Check if the garbage collector is currently running."]
    #[doc = ""]
    #[doc = " Returns non-zero if GC is in progress."]
    #[doc = "Unchecked FFI binding for `R_gc_running`."]
    #[doc = "Generated from source location line 2143, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_gc_running"]
    pub fn R_gc_running_unchecked()
    -> ::std::os::raw::c_int;
    #[doc = " Allocate memory on R\'s memory stack."]
    #[doc = ""]
    #[doc =
    " This memory is automatically freed when the calling R function returns,"]
    #[doc = " or can be freed earlier with `vmaxset()`."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `nelem`: Number of elements to allocate"]
    #[doc = " - `eltsize`: Size of each element in bytes"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc =
    " Pointer to allocated memory (as `char*` for compatibility with S)."]
    #[doc = "Unchecked FFI binding for `R_alloc`."]
    #[doc = "Generated from source location line 2158, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_alloc"]
    pub fn R_alloc_unchecked(nelem: usize, eltsize: ::std::os::raw::c_int)
    -> *mut ::std::os::raw::c_char;
    #[doc = " Allocate an array of long doubles on R\'s memory stack."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `nelem`: Number of long double elements to allocate"]
    #[doc = "Unchecked FFI binding for `R_allocLD`."]
    #[doc = "Generated from source location line 2165, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_allocLD"]
    pub fn R_allocLD_unchecked(nelem: usize)
    -> *mut f64;
    #[doc = " S compatibility: allocate zeroed memory on R\'s memory stack."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `nelem`: Number of elements"]
    #[doc = " - `eltsize`: Size of each element"]
    #[doc = "Unchecked FFI binding for `S_alloc`."]
    #[doc = "Generated from source location line 2173, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "S_alloc"]
    pub fn S_alloc_unchecked(nelem: ::std::os::raw::c_long,
    eltsize: ::std::os::raw::c_int)
    -> *mut ::std::os::raw::c_char;
    #[doc = " S compatibility: reallocate memory on R\'s memory stack."]
    #[doc = ""]
    #[doc = " # Safety"]
    #[doc = ""]
    #[doc = " `ptr` must have been allocated by `S_alloc`."]
    #[doc = "Unchecked FFI binding for `S_realloc`."]
    #[doc = "Generated from source location line 2183, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "S_realloc"]
    pub fn S_realloc_unchecked(ptr: *mut ::std::os::raw::c_char,
    newsize: ::std::os::raw::c_long, oldsize: ::std::os::raw::c_long,
    eltsize: ::std::os::raw::c_int)
    -> *mut ::std::os::raw::c_char;
    #[doc = " GC-aware malloc."]
    #[doc = ""]
    #[doc = " Triggers GC if allocation fails, then retries."]
    #[doc = " Memory must be freed with `free()`."]
    #[doc = "Unchecked FFI binding for `R_malloc_gc`."]
    #[doc = "Generated from source location line 2194, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_malloc_gc"]
    pub fn R_malloc_gc_unchecked(size: usize)
    -> *mut ::std::os::raw::c_void;
    #[doc = " GC-aware calloc."]
    #[doc = ""]
    #[doc = " Triggers GC if allocation fails, then retries."]
    #[doc = " Memory must be freed with `free()`."]
    #[doc = "Unchecked FFI binding for `R_calloc_gc`."]
    #[doc = "Generated from source location line 2200, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_calloc_gc"]
    pub fn R_calloc_gc_unchecked(nelem: usize, eltsize: usize)
    -> *mut ::std::os::raw::c_void;
    #[doc = " GC-aware realloc."]
    #[doc = ""]
    #[doc = " Triggers GC if allocation fails, then retries."]
    #[doc = " Memory must be freed with `free()`."]
    #[doc = "Unchecked FFI binding for `R_realloc_gc`."]
    #[doc = "Generated from source location line 2206, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_realloc_gc"]
    pub fn R_realloc_gc_unchecked(ptr: *mut ::std::os::raw::c_void,
    size: usize)
    -> *mut ::std::os::raw::c_void;
}
#[doc = " Get the current R memory stack watermark."]
#[doc = ""]
#[doc = " Use with `vmaxset()` to restore memory stack state."]
#[doc =
" Memory allocated with `R_alloc()` between `vmaxget()` and `vmaxset()`"]
#[doc = " will be freed when `vmaxset()` is called."]
#[doc = ""]
#[doc = " # Example"]
#[doc = ""]
#[doc = " ```ignore"]
#[doc = " unsafe {"]
#[doc = "     let watermark = vmaxget();"]
#[doc = "     let buf = R_alloc(100, 1);"]
#[doc = "     // ... use buf ..."]
#[doc = "     vmaxset(watermark); // frees buf"]
#[doc = " }"]
#[doc = " ```"]
#[doc =
"Checked wrapper for `vmaxget`. Calls `vmaxget_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2125, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn vmaxget() -> *mut ::std::os::raw::c_void {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            vmaxget_unchecked()
                        })
                });
    result.0
}
#[doc =
" Set the R memory stack watermark, freeing memory allocated since the mark."]
#[doc = ""]
#[doc = " # Safety"]
#[doc = ""]
#[doc =
" `ovmax` must be a value returned by `vmaxget()` called earlier in the"]
#[doc = " same R evaluation context."]
#[doc =
"Checked wrapper for `vmaxset`. Calls `vmaxset_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2133, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn vmaxset(ovmax: *const ::std::os::raw::c_void) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            vmaxset_unchecked(ovmax)
                        })
                });
    result.0
}
#[doc = " Run the R garbage collector."]
#[doc = ""]
#[doc = " Forces a full garbage collection cycle."]
#[doc =
"Checked wrapper for `R_gc`. Calls `R_gc_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2138, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_gc() {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_gc_unchecked()
                        })
                });
    result.0
}
#[doc = " Check if the garbage collector is currently running."]
#[doc = ""]
#[doc = " Returns non-zero if GC is in progress."]
#[doc =
"Checked wrapper for `R_gc_running`. Calls `R_gc_running_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2143, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_gc_running() -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_gc_running_unchecked()
                        })
                });
    result.0
}
#[doc = " Allocate memory on R\'s memory stack."]
#[doc = ""]
#[doc =
" This memory is automatically freed when the calling R function returns,"]
#[doc = " or can be freed earlier with `vmaxset()`."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `nelem`: Number of elements to allocate"]
#[doc = " - `eltsize`: Size of each element in bytes"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Pointer to allocated memory (as `char*` for compatibility with S)."]
#[doc =
"Checked wrapper for `R_alloc`. Calls `R_alloc_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2158, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_alloc(nelem: usize, eltsize: ::std::os::raw::c_int)
    -> *mut ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_alloc_unchecked(nelem, eltsize)
                        })
                });
    result.0
}
#[doc = " Allocate an array of long doubles on R\'s memory stack."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `nelem`: Number of long double elements to allocate"]
#[doc =
"Checked wrapper for `R_allocLD`. Calls `R_allocLD_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2165, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_allocLD(nelem: usize) -> *mut f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_allocLD_unchecked(nelem)
                        })
                });
    result.0
}
#[doc = " S compatibility: allocate zeroed memory on R\'s memory stack."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `nelem`: Number of elements"]
#[doc = " - `eltsize`: Size of each element"]
#[doc =
"Checked wrapper for `S_alloc`. Calls `S_alloc_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2173, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn S_alloc(nelem: ::std::os::raw::c_long,
    eltsize: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            S_alloc_unchecked(nelem, eltsize)
                        })
                });
    result.0
}
#[doc = " S compatibility: reallocate memory on R\'s memory stack."]
#[doc = ""]
#[doc = " # Safety"]
#[doc = ""]
#[doc = " `ptr` must have been allocated by `S_alloc`."]
#[doc =
"Checked wrapper for `S_realloc`. Calls `S_realloc_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2183, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn S_realloc(ptr: *mut ::std::os::raw::c_char,
    newsize: ::std::os::raw::c_long, oldsize: ::std::os::raw::c_long,
    eltsize: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            S_realloc_unchecked(ptr, newsize, oldsize, eltsize)
                        })
                });
    result.0
}
#[doc = " GC-aware malloc."]
#[doc = ""]
#[doc = " Triggers GC if allocation fails, then retries."]
#[doc = " Memory must be freed with `free()`."]
#[doc =
"Checked wrapper for `R_malloc_gc`. Calls `R_malloc_gc_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2194, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_malloc_gc(size: usize) -> *mut ::std::os::raw::c_void {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_malloc_gc_unchecked(size)
                        })
                });
    result.0
}
#[doc = " GC-aware calloc."]
#[doc = ""]
#[doc = " Triggers GC if allocation fails, then retries."]
#[doc = " Memory must be freed with `free()`."]
#[doc =
"Checked wrapper for `R_calloc_gc`. Calls `R_calloc_gc_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2200, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_calloc_gc(nelem: usize, eltsize: usize)
    -> *mut ::std::os::raw::c_void {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_calloc_gc_unchecked(nelem, eltsize)
                        })
                });
    result.0
}
#[doc = " GC-aware realloc."]
#[doc = ""]
#[doc = " Triggers GC if allocation fails, then retries."]
#[doc = " Memory must be freed with `free()`."]
#[doc =
"Checked wrapper for `R_realloc_gc`. Calls `R_realloc_gc_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2206, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_realloc_gc(ptr: *mut ::std::os::raw::c_void, size: usize)
    -> *mut ::std::os::raw::c_void {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_realloc_gc_unchecked(ptr, size)
                        })
                });
    result.0
}#[r_ffi_checked]
2108unsafe extern "C-unwind" {
2109    /// Get the current R memory stack watermark.
2110    ///
2111    /// Use with `vmaxset()` to restore memory stack state.
2112    /// Memory allocated with `R_alloc()` between `vmaxget()` and `vmaxset()`
2113    /// will be freed when `vmaxset()` is called.
2114    ///
2115    /// # Example
2116    ///
2117    /// ```ignore
2118    /// unsafe {
2119    ///     let watermark = vmaxget();
2120    ///     let buf = R_alloc(100, 1);
2121    ///     // ... use buf ...
2122    ///     vmaxset(watermark); // frees buf
2123    /// }
2124    /// ```
2125    pub fn vmaxget() -> *mut ::std::os::raw::c_void;
2126
2127    /// Set the R memory stack watermark, freeing memory allocated since the mark.
2128    ///
2129    /// # Safety
2130    ///
2131    /// `ovmax` must be a value returned by `vmaxget()` called earlier in the
2132    /// same R evaluation context.
2133    pub fn vmaxset(ovmax: *const ::std::os::raw::c_void);
2134
2135    /// Run the R garbage collector.
2136    ///
2137    /// Forces a full garbage collection cycle.
2138    pub fn R_gc();
2139
2140    /// Check if the garbage collector is currently running.
2141    ///
2142    /// Returns non-zero if GC is in progress.
2143    pub fn R_gc_running() -> ::std::os::raw::c_int;
2144
2145    /// Allocate memory on R's memory stack.
2146    ///
2147    /// This memory is automatically freed when the calling R function returns,
2148    /// or can be freed earlier with `vmaxset()`.
2149    ///
2150    /// # Parameters
2151    ///
2152    /// - `nelem`: Number of elements to allocate
2153    /// - `eltsize`: Size of each element in bytes
2154    ///
2155    /// # Returns
2156    ///
2157    /// Pointer to allocated memory (as `char*` for compatibility with S).
2158    pub fn R_alloc(nelem: usize, eltsize: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char;
2159
2160    /// Allocate an array of long doubles on R's memory stack.
2161    ///
2162    /// # Parameters
2163    ///
2164    /// - `nelem`: Number of long double elements to allocate
2165    pub fn R_allocLD(nelem: usize) -> *mut f64; // Note: f64 is close enough for most uses
2166
2167    /// S compatibility: allocate zeroed memory on R's memory stack.
2168    ///
2169    /// # Parameters
2170    ///
2171    /// - `nelem`: Number of elements
2172    /// - `eltsize`: Size of each element
2173    pub fn S_alloc(
2174        nelem: ::std::os::raw::c_long,
2175        eltsize: ::std::os::raw::c_int,
2176    ) -> *mut ::std::os::raw::c_char;
2177
2178    /// S compatibility: reallocate memory on R's memory stack.
2179    ///
2180    /// # Safety
2181    ///
2182    /// `ptr` must have been allocated by `S_alloc`.
2183    pub fn S_realloc(
2184        ptr: *mut ::std::os::raw::c_char,
2185        newsize: ::std::os::raw::c_long,
2186        oldsize: ::std::os::raw::c_long,
2187        eltsize: ::std::os::raw::c_int,
2188    ) -> *mut ::std::os::raw::c_char;
2189
2190    /// GC-aware malloc.
2191    ///
2192    /// Triggers GC if allocation fails, then retries.
2193    /// Memory must be freed with `free()`.
2194    pub fn R_malloc_gc(size: usize) -> *mut ::std::os::raw::c_void;
2195
2196    /// GC-aware calloc.
2197    ///
2198    /// Triggers GC if allocation fails, then retries.
2199    /// Memory must be freed with `free()`.
2200    pub fn R_calloc_gc(nelem: usize, eltsize: usize) -> *mut ::std::os::raw::c_void;
2201
2202    /// GC-aware realloc.
2203    ///
2204    /// Triggers GC if allocation fails, then retries.
2205    /// Memory must be freed with `free()`.
2206    pub fn R_realloc_gc(
2207        ptr: *mut ::std::os::raw::c_void,
2208        size: usize,
2209    ) -> *mut ::std::os::raw::c_void;
2210}
2211
2212// endregion
2213
2214// region: Sorting and utility functions (R_ext/Utils.h)
2215
2216unsafe extern "C-unwind" {
    #[doc = " Sort an integer vector in place (ascending order)."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Pointer to integer array"]
    #[doc = " - `n`: Number of elements"]
    #[doc = "Unchecked FFI binding for `R_isort`."]
    #[doc = "Generated from source location line 2224, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_isort"]
    pub fn R_isort_unchecked(x: *mut ::std::os::raw::c_int,
    n: ::std::os::raw::c_int);
    #[doc = " Sort a double vector in place (ascending order)."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Pointer to double array"]
    #[doc = " - `n`: Number of elements"]
    #[doc = "Unchecked FFI binding for `R_rsort`."]
    #[doc = "Generated from source location line 2232, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_rsort"]
    pub fn R_rsort_unchecked(x: *mut f64, n: ::std::os::raw::c_int);
    #[doc = " Sort a complex vector in place."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Pointer to Rcomplex array"]
    #[doc = " - `n`: Number of elements"]
    #[doc = "Unchecked FFI binding for `R_csort`."]
    #[doc = "Generated from source location line 2240, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_csort"]
    pub fn R_csort_unchecked(x: *mut Rcomplex, n: ::std::os::raw::c_int);
    #[doc =
    " Sort doubles in descending order, carrying along an index array."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `a`: Pointer to double array (sorted in place, descending)"]
    #[doc = " - `ib`: Pointer to integer array (permuted alongside `a`)"]
    #[doc = " - `n`: Number of elements"]
    #[doc(alias = "Rf_revsort")]
    #[doc = "Unchecked FFI binding for `revsort`."]
    #[doc = "Generated from source location line 2250, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "revsort"]
    pub fn revsort_unchecked(a: *mut f64, ib: *mut ::std::os::raw::c_int,
    n: ::std::os::raw::c_int);
    #[doc = " Sort doubles with index array."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Pointer to double array (sorted in place)"]
    #[doc = " - `indx`: Pointer to integer array (permuted alongside `x`)"]
    #[doc = " - `n`: Number of elements"]
    #[doc = "Unchecked FFI binding for `rsort_with_index`."]
    #[doc = "Generated from source location line 2259, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "rsort_with_index"]
    pub fn rsort_with_index_unchecked(x: *mut f64,
    indx: *mut ::std::os::raw::c_int, n: ::std::os::raw::c_int);
    #[doc = " Partial sort integers (moves k-th smallest to position k)."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Pointer to integer array"]
    #[doc = " - `n`: Number of elements"]
    #[doc = " - `k`: Target position (0-indexed)"]
    #[doc(alias = "Rf_iPsort")]
    #[doc = "Unchecked FFI binding for `iPsort`."]
    #[doc = "Generated from source location line 2273, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "iPsort"]
    pub fn iPsort_unchecked(x: *mut ::std::os::raw::c_int,
    n: ::std::os::raw::c_int, k: ::std::os::raw::c_int);
    #[doc = " Partial sort doubles (moves k-th smallest to position k)."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Pointer to double array"]
    #[doc = " - `n`: Number of elements"]
    #[doc = " - `k`: Target position (0-indexed)"]
    #[doc(alias = "Rf_rPsort")]
    #[doc = "Unchecked FFI binding for `rPsort`."]
    #[doc = "Generated from source location line 2287, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "rPsort"]
    pub fn rPsort_unchecked(x: *mut f64, n: ::std::os::raw::c_int,
    k: ::std::os::raw::c_int);
    #[doc = " Partial sort complex numbers."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Pointer to Rcomplex array"]
    #[doc = " - `n`: Number of elements"]
    #[doc = " - `k`: Target position (0-indexed)"]
    #[doc(alias = "Rf_cPsort")]
    #[doc = "Unchecked FFI binding for `cPsort`."]
    #[doc = "Generated from source location line 2297, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "cPsort"]
    pub fn cPsort_unchecked(x: *mut Rcomplex, n: ::std::os::raw::c_int,
    k: ::std::os::raw::c_int);
    #[doc = " Quicksort doubles in place."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `v`: Pointer to double array"]
    #[doc = " - `i`: Start index (1-indexed for R compatibility)"]
    #[doc = " - `j`: End index (1-indexed)"]
    #[doc = "Unchecked FFI binding for `R_qsort`."]
    #[doc = "Generated from source location line 2306, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_qsort"]
    pub fn R_qsort_unchecked(v: *mut f64, i: usize, j: usize);
    #[doc = " Quicksort doubles with index array."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `v`: Pointer to double array"]
    #[doc = " - `indx`: Pointer to index array (permuted alongside v)"]
    #[doc = " - `i`: Start index (1-indexed)"]
    #[doc = " - `j`: End index (1-indexed)"]
    #[doc = "Unchecked FFI binding for `R_qsort_I`."]
    #[doc = "Generated from source location line 2316, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_qsort_I"]
    pub fn R_qsort_I_unchecked(v: *mut f64, indx: *mut ::std::os::raw::c_int,
    i: ::std::os::raw::c_int, j: ::std::os::raw::c_int);
    #[doc = " Quicksort integers in place."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `iv`: Pointer to integer array"]
    #[doc = " - `i`: Start index (1-indexed)"]
    #[doc = " - `j`: End index (1-indexed)"]
    #[doc = "Unchecked FFI binding for `R_qsort_int`."]
    #[doc = "Generated from source location line 2330, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_qsort_int"]
    pub fn R_qsort_int_unchecked(iv: *mut ::std::os::raw::c_int, i: usize,
    j: usize);
    #[doc = " Quicksort integers with index array."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `iv`: Pointer to integer array"]
    #[doc = " - `indx`: Pointer to index array"]
    #[doc = " - `i`: Start index (1-indexed)"]
    #[doc = " - `j`: End index (1-indexed)"]
    #[doc = "Unchecked FFI binding for `R_qsort_int_I`."]
    #[doc = "Generated from source location line 2340, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_qsort_int_I"]
    pub fn R_qsort_int_I_unchecked(iv: *mut ::std::os::raw::c_int,
    indx: *mut ::std::os::raw::c_int, i: ::std::os::raw::c_int,
    j: ::std::os::raw::c_int);
    #[doc = " Expand a filename, resolving `~` and environment variables."]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc =
    " Pointer to expanded path (in R\'s internal buffer, do not free)."]
    #[doc = "Unchecked FFI binding for `R_ExpandFileName`."]
    #[doc = "Generated from source location line 2352, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ExpandFileName"]
    pub fn R_ExpandFileName_unchecked(s: *const ::std::os::raw::c_char)
    -> *const ::std::os::raw::c_char;
    #[doc = " Convert string to double, always using \'.\' as decimal point."]
    #[doc = ""]
    #[doc = " Also accepts \"NA\" as input, returning NA_REAL."]
    #[doc = "Unchecked FFI binding for `R_atof`."]
    #[doc = "Generated from source location line 2357, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_atof"]
    pub fn R_atof_unchecked(str: *const ::std::os::raw::c_char)
    -> f64;
    #[doc =
    " Convert string to double with end pointer, using \'.\' as decimal point."]
    #[doc = ""]
    #[doc = " Like `strtod()` but locale-independent."]
    #[doc = "Unchecked FFI binding for `R_strtod`."]
    #[doc = "Generated from source location line 2362, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_strtod"]
    pub fn R_strtod_unchecked(c: *const ::std::os::raw::c_char,
    end: *mut *mut ::std::os::raw::c_char)
    -> f64;
    #[doc = " Generate a temporary filename."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `prefix`: Filename prefix"]
    #[doc = " - `tempdir`: Directory for temp file"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " Newly allocated string (must be freed with `R_free_tmpnam`)."]
    #[doc = "Unchecked FFI binding for `R_tmpnam`."]
    #[doc = "Generated from source location line 2375, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_tmpnam"]
    pub fn R_tmpnam_unchecked(prefix: *const ::std::os::raw::c_char,
    tempdir: *const ::std::os::raw::c_char)
    -> *mut ::std::os::raw::c_char;
    #[doc = " Generate a temporary filename with extension."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `prefix`: Filename prefix"]
    #[doc = " - `tempdir`: Directory for temp file"]
    #[doc = " - `fileext`: File extension (e.g., \".txt\")"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " Newly allocated string (must be freed with `R_free_tmpnam`)."]
    #[doc = "Unchecked FFI binding for `R_tmpnam2`."]
    #[doc = "Generated from source location line 2391, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_tmpnam2"]
    pub fn R_tmpnam2_unchecked(prefix: *const ::std::os::raw::c_char,
    tempdir: *const ::std::os::raw::c_char,
    fileext: *const ::std::os::raw::c_char)
    -> *mut ::std::os::raw::c_char;
    #[doc =
    " Free a temporary filename allocated by `R_tmpnam` or `R_tmpnam2`."]
    #[doc = "Unchecked FFI binding for `R_free_tmpnam`."]
    #[doc = "Generated from source location line 2398, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_free_tmpnam"]
    pub fn R_free_tmpnam_unchecked(name: *mut ::std::os::raw::c_char);
    #[doc = " Check for R stack overflow."]
    #[doc = ""]
    #[doc = " Throws an R error if stack is nearly exhausted."]
    #[doc = "Unchecked FFI binding for `R_CheckStack`."]
    #[doc = "Generated from source location line 2403, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_CheckStack"]
    pub fn R_CheckStack_unchecked();
    #[doc = " Check for R stack overflow with extra space requirement."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `extra`: Additional bytes needed"]
    #[doc = "Unchecked FFI binding for `R_CheckStack2`."]
    #[doc = "Generated from source location line 2410, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_CheckStack2"]
    pub fn R_CheckStack2_unchecked(extra: usize);
    #[doc = " Find the interval containing a value (binary search)."]
    #[doc = ""]
    #[doc = " Used for interpolation and binning."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `xt`: Sorted breakpoints array"]
    #[doc = " - `n`: Number of breakpoints"]
    #[doc = " - `x`: Value to find"]
    #[doc = " - `rightmost_closed`: If TRUE, rightmost interval is closed"]
    #[doc = " - `all_inside`: If TRUE, out-of-bounds values map to endpoints"]
    #[doc = " - `ilo`: Initial guess for interval (1-indexed)"]
    #[doc = " - `mflag`: Output flag (see R documentation)"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " Interval index (1-indexed)."]
    #[doc = "Unchecked FFI binding for `findInterval`."]
    #[doc = "Generated from source location line 2429, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "findInterval"]
    pub fn findInterval_unchecked(xt: *const f64, n: ::std::os::raw::c_int,
    x: f64, rightmost_closed: Rboolean, all_inside: Rboolean,
    ilo: ::std::os::raw::c_int, mflag: *mut ::std::os::raw::c_int)
    -> ::std::os::raw::c_int;
    #[doc = " Extended interval finding with left-open option."]
    #[allow(clippy::too_many_arguments)]
    #[doc = "Unchecked FFI binding for `findInterval2`."]
    #[doc = "Generated from source location line 2441, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "findInterval2"]
    pub fn findInterval2_unchecked(xt: *const f64, n: ::std::os::raw::c_int,
    x: f64, rightmost_closed: Rboolean, all_inside: Rboolean,
    left_open: Rboolean, ilo: ::std::os::raw::c_int,
    mflag: *mut ::std::os::raw::c_int)
    -> ::std::os::raw::c_int;
    #[doc = " Find column maxima in a matrix."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `matrix`: Column-major matrix data"]
    #[doc = " - `nr`: Number of rows"]
    #[doc = " - `nc`: Number of columns"]
    #[doc = " - `maxes`: Output array for column maxima indices (1-indexed)"]
    #[doc = " - `ties_meth`: How to handle ties (1=first, 2=random, 3=last)"]
    #[doc = "Unchecked FFI binding for `R_max_col`."]
    #[doc = "Generated from source location line 2461, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_max_col"]
    pub fn R_max_col_unchecked(matrix: *const f64,
    nr: *const ::std::os::raw::c_int, nc: *const ::std::os::raw::c_int,
    maxes: *mut ::std::os::raw::c_int,
    ties_meth: *const ::std::os::raw::c_int);
    #[doc = " Check if a string represents FALSE in R."]
    #[doc = ""]
    #[doc = " Recognizes \"FALSE\", \"false\", \"False\", \"F\", \"f\", etc."]
    #[doc(alias = "Rf_StringFalse")]
    #[doc = "Unchecked FFI binding for `StringFalse`."]
    #[doc = "Generated from source location line 2473, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "StringFalse"]
    pub fn StringFalse_unchecked(s: *const ::std::os::raw::c_char)
    -> Rboolean;
    #[doc = " Check if a string represents TRUE in R."]
    #[doc = ""]
    #[doc = " Recognizes \"TRUE\", \"true\", \"True\", \"T\", \"t\", etc."]
    #[doc(alias = "Rf_StringTrue")]
    #[doc = "Unchecked FFI binding for `StringTrue`."]
    #[doc = "Generated from source location line 2479, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "StringTrue"]
    pub fn StringTrue_unchecked(s: *const ::std::os::raw::c_char)
    -> Rboolean;
    #[doc = " Check if a string is blank (empty or only whitespace)."]
    #[doc(alias = "Rf_isBlankString")]
    #[doc = "Unchecked FFI binding for `isBlankString`."]
    #[doc = "Generated from source location line 2483, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "isBlankString"]
    pub fn isBlankString_unchecked(s: *const ::std::os::raw::c_char)
    -> Rboolean;
}
#[doc = " Sort an integer vector in place (ascending order)."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Pointer to integer array"]
#[doc = " - `n`: Number of elements"]
#[doc =
"Checked wrapper for `R_isort`. Calls `R_isort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2224, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_isort(x: *mut ::std::os::raw::c_int,
    n: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_isort_unchecked(x, n)
                        })
                });
    result.0
}
#[doc = " Sort a double vector in place (ascending order)."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Pointer to double array"]
#[doc = " - `n`: Number of elements"]
#[doc =
"Checked wrapper for `R_rsort`. Calls `R_rsort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2232, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_rsort(x: *mut f64, n: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_rsort_unchecked(x, n)
                        })
                });
    result.0
}
#[doc = " Sort a complex vector in place."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Pointer to Rcomplex array"]
#[doc = " - `n`: Number of elements"]
#[doc =
"Checked wrapper for `R_csort`. Calls `R_csort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2240, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_csort(x: *mut Rcomplex, n: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_csort_unchecked(x, n)
                        })
                });
    result.0
}
#[doc = " Sort doubles in descending order, carrying along an index array."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `a`: Pointer to double array (sorted in place, descending)"]
#[doc = " - `ib`: Pointer to integer array (permuted alongside `a`)"]
#[doc = " - `n`: Number of elements"]
#[doc(alias = "Rf_revsort")]
#[doc =
"Checked wrapper for `revsort`. Calls `revsort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2250, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn revsort(a: *mut f64, ib: *mut ::std::os::raw::c_int,
    n: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            revsort_unchecked(a, ib, n)
                        })
                });
    result.0
}
#[doc = " Sort doubles with index array."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Pointer to double array (sorted in place)"]
#[doc = " - `indx`: Pointer to integer array (permuted alongside `x`)"]
#[doc = " - `n`: Number of elements"]
#[doc =
"Checked wrapper for `rsort_with_index`. Calls `rsort_with_index_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2259, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn rsort_with_index(x: *mut f64, indx: *mut ::std::os::raw::c_int,
    n: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            rsort_with_index_unchecked(x, indx, n)
                        })
                });
    result.0
}
#[doc = " Partial sort integers (moves k-th smallest to position k)."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Pointer to integer array"]
#[doc = " - `n`: Number of elements"]
#[doc = " - `k`: Target position (0-indexed)"]
#[doc(alias = "Rf_iPsort")]
#[doc =
"Checked wrapper for `iPsort`. Calls `iPsort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2273, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn iPsort(x: *mut ::std::os::raw::c_int, n: ::std::os::raw::c_int,
    k: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            iPsort_unchecked(x, n, k)
                        })
                });
    result.0
}
#[doc = " Partial sort doubles (moves k-th smallest to position k)."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Pointer to double array"]
#[doc = " - `n`: Number of elements"]
#[doc = " - `k`: Target position (0-indexed)"]
#[doc(alias = "Rf_rPsort")]
#[doc =
"Checked wrapper for `rPsort`. Calls `rPsort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2287, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn rPsort(x: *mut f64, n: ::std::os::raw::c_int,
    k: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            rPsort_unchecked(x, n, k)
                        })
                });
    result.0
}
#[doc = " Partial sort complex numbers."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Pointer to Rcomplex array"]
#[doc = " - `n`: Number of elements"]
#[doc = " - `k`: Target position (0-indexed)"]
#[doc(alias = "Rf_cPsort")]
#[doc =
"Checked wrapper for `cPsort`. Calls `cPsort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2297, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn cPsort(x: *mut Rcomplex, n: ::std::os::raw::c_int,
    k: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            cPsort_unchecked(x, n, k)
                        })
                });
    result.0
}
#[doc = " Quicksort doubles in place."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `v`: Pointer to double array"]
#[doc = " - `i`: Start index (1-indexed for R compatibility)"]
#[doc = " - `j`: End index (1-indexed)"]
#[doc =
"Checked wrapper for `R_qsort`. Calls `R_qsort_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2306, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_qsort(v: *mut f64, i: usize, j: usize) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_qsort_unchecked(v, i, j)
                        })
                });
    result.0
}
#[doc = " Quicksort doubles with index array."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `v`: Pointer to double array"]
#[doc = " - `indx`: Pointer to index array (permuted alongside v)"]
#[doc = " - `i`: Start index (1-indexed)"]
#[doc = " - `j`: End index (1-indexed)"]
#[doc =
"Checked wrapper for `R_qsort_I`. Calls `R_qsort_I_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2316, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_qsort_I(v: *mut f64, indx: *mut ::std::os::raw::c_int,
    i: ::std::os::raw::c_int, j: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_qsort_I_unchecked(v, indx, i, j)
                        })
                });
    result.0
}
#[doc = " Quicksort integers in place."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `iv`: Pointer to integer array"]
#[doc = " - `i`: Start index (1-indexed)"]
#[doc = " - `j`: End index (1-indexed)"]
#[doc =
"Checked wrapper for `R_qsort_int`. Calls `R_qsort_int_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2330, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_qsort_int(iv: *mut ::std::os::raw::c_int, i: usize,
    j: usize) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_qsort_int_unchecked(iv, i, j)
                        })
                });
    result.0
}
#[doc = " Quicksort integers with index array."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `iv`: Pointer to integer array"]
#[doc = " - `indx`: Pointer to index array"]
#[doc = " - `i`: Start index (1-indexed)"]
#[doc = " - `j`: End index (1-indexed)"]
#[doc =
"Checked wrapper for `R_qsort_int_I`. Calls `R_qsort_int_I_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2340, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_qsort_int_I(iv: *mut ::std::os::raw::c_int,
    indx: *mut ::std::os::raw::c_int, i: ::std::os::raw::c_int,
    j: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_qsort_int_I_unchecked(iv, indx, i, j)
                        })
                });
    result.0
}
#[doc = " Expand a filename, resolving `~` and environment variables."]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Pointer to expanded path (in R\'s internal buffer, do not free)."]
#[doc =
"Checked wrapper for `R_ExpandFileName`. Calls `R_ExpandFileName_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2352, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_ExpandFileName(s: *const ::std::os::raw::c_char)
    -> *const ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ExpandFileName_unchecked(s)
                        })
                });
    result.0
}
#[doc = " Convert string to double, always using \'.\' as decimal point."]
#[doc = ""]
#[doc = " Also accepts \"NA\" as input, returning NA_REAL."]
#[doc =
"Checked wrapper for `R_atof`. Calls `R_atof_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2357, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_atof(str: *const ::std::os::raw::c_char) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_atof_unchecked(str)
                        })
                });
    result.0
}
#[doc =
" Convert string to double with end pointer, using \'.\' as decimal point."]
#[doc = ""]
#[doc = " Like `strtod()` but locale-independent."]
#[doc =
"Checked wrapper for `R_strtod`. Calls `R_strtod_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2362, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_strtod(c: *const ::std::os::raw::c_char,
    end: *mut *mut ::std::os::raw::c_char) -> f64 {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_strtod_unchecked(c, end)
                        })
                });
    result.0
}
#[doc = " Generate a temporary filename."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `prefix`: Filename prefix"]
#[doc = " - `tempdir`: Directory for temp file"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Newly allocated string (must be freed with `R_free_tmpnam`)."]
#[doc =
"Checked wrapper for `R_tmpnam`. Calls `R_tmpnam_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2375, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_tmpnam(prefix: *const ::std::os::raw::c_char,
    tempdir: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_tmpnam_unchecked(prefix, tempdir)
                        })
                });
    result.0
}
#[doc = " Generate a temporary filename with extension."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `prefix`: Filename prefix"]
#[doc = " - `tempdir`: Directory for temp file"]
#[doc = " - `fileext`: File extension (e.g., \".txt\")"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Newly allocated string (must be freed with `R_free_tmpnam`)."]
#[doc =
"Checked wrapper for `R_tmpnam2`. Calls `R_tmpnam2_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2391, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_tmpnam2(prefix: *const ::std::os::raw::c_char,
    tempdir: *const ::std::os::raw::c_char,
    fileext: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_tmpnam2_unchecked(prefix, tempdir, fileext)
                        })
                });
    result.0
}
#[doc = " Free a temporary filename allocated by `R_tmpnam` or `R_tmpnam2`."]
#[doc =
"Checked wrapper for `R_free_tmpnam`. Calls `R_free_tmpnam_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2398, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_free_tmpnam(name: *mut ::std::os::raw::c_char) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_free_tmpnam_unchecked(name)
                        })
                });
    result.0
}
#[doc = " Check for R stack overflow."]
#[doc = ""]
#[doc = " Throws an R error if stack is nearly exhausted."]
#[doc =
"Checked wrapper for `R_CheckStack`. Calls `R_CheckStack_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2403, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_CheckStack() {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_CheckStack_unchecked()
                        })
                });
    result.0
}
#[doc = " Check for R stack overflow with extra space requirement."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `extra`: Additional bytes needed"]
#[doc =
"Checked wrapper for `R_CheckStack2`. Calls `R_CheckStack2_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2410, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_CheckStack2(extra: usize) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_CheckStack2_unchecked(extra)
                        })
                });
    result.0
}
#[doc = " Find the interval containing a value (binary search)."]
#[doc = ""]
#[doc = " Used for interpolation and binning."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `xt`: Sorted breakpoints array"]
#[doc = " - `n`: Number of breakpoints"]
#[doc = " - `x`: Value to find"]
#[doc = " - `rightmost_closed`: If TRUE, rightmost interval is closed"]
#[doc = " - `all_inside`: If TRUE, out-of-bounds values map to endpoints"]
#[doc = " - `ilo`: Initial guess for interval (1-indexed)"]
#[doc = " - `mflag`: Output flag (see R documentation)"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Interval index (1-indexed)."]
#[doc =
"Checked wrapper for `findInterval`. Calls `findInterval_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2429, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn findInterval(xt: *const f64, n: ::std::os::raw::c_int, x: f64,
    rightmost_closed: Rboolean, all_inside: Rboolean,
    ilo: ::std::os::raw::c_int, mflag: *mut ::std::os::raw::c_int)
    -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            findInterval_unchecked(xt, n, x, rightmost_closed,
                                all_inside, ilo, mflag)
                        })
                });
    result.0
}
#[doc = " Extended interval finding with left-open option."]
#[allow(clippy::too_many_arguments)]
#[doc =
"Checked wrapper for `findInterval2`. Calls `findInterval2_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2441, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn findInterval2(xt: *const f64, n: ::std::os::raw::c_int, x: f64,
    rightmost_closed: Rboolean, all_inside: Rboolean, left_open: Rboolean,
    ilo: ::std::os::raw::c_int, mflag: *mut ::std::os::raw::c_int)
    -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            findInterval2_unchecked(xt, n, x, rightmost_closed,
                                all_inside, left_open, ilo, mflag)
                        })
                });
    result.0
}
#[doc = " Find column maxima in a matrix."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `matrix`: Column-major matrix data"]
#[doc = " - `nr`: Number of rows"]
#[doc = " - `nc`: Number of columns"]
#[doc = " - `maxes`: Output array for column maxima indices (1-indexed)"]
#[doc = " - `ties_meth`: How to handle ties (1=first, 2=random, 3=last)"]
#[doc =
"Checked wrapper for `R_max_col`. Calls `R_max_col_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2461, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_max_col(matrix: *const f64, nr: *const ::std::os::raw::c_int,
    nc: *const ::std::os::raw::c_int, maxes: *mut ::std::os::raw::c_int,
    ties_meth: *const ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_max_col_unchecked(matrix, nr, nc, maxes, ties_meth)
                        })
                });
    result.0
}
#[doc = " Check if a string represents FALSE in R."]
#[doc = ""]
#[doc = " Recognizes \"FALSE\", \"false\", \"False\", \"F\", \"f\", etc."]
#[doc(alias = "Rf_StringFalse")]
#[doc =
"Checked wrapper for `StringFalse`. Calls `StringFalse_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2473, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn StringFalse(s: *const ::std::os::raw::c_char) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            StringFalse_unchecked(s)
                        })
                });
    result.0
}
#[doc = " Check if a string represents TRUE in R."]
#[doc = ""]
#[doc = " Recognizes \"TRUE\", \"true\", \"True\", \"T\", \"t\", etc."]
#[doc(alias = "Rf_StringTrue")]
#[doc =
"Checked wrapper for `StringTrue`. Calls `StringTrue_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2479, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn StringTrue(s: *const ::std::os::raw::c_char) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            StringTrue_unchecked(s)
                        })
                });
    result.0
}
#[doc = " Check if a string is blank (empty or only whitespace)."]
#[doc(alias = "Rf_isBlankString")]
#[doc =
"Checked wrapper for `isBlankString`. Calls `isBlankString_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2483, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn isBlankString(s: *const ::std::os::raw::c_char) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            isBlankString_unchecked(s)
                        })
                });
    result.0
}#[r_ffi_checked]
2217unsafe extern "C-unwind" {
2218    /// Sort an integer vector in place (ascending order).
2219    ///
2220    /// # Parameters
2221    ///
2222    /// - `x`: Pointer to integer array
2223    /// - `n`: Number of elements
2224    pub fn R_isort(x: *mut ::std::os::raw::c_int, n: ::std::os::raw::c_int);
2225
2226    /// Sort a double vector in place (ascending order).
2227    ///
2228    /// # Parameters
2229    ///
2230    /// - `x`: Pointer to double array
2231    /// - `n`: Number of elements
2232    pub fn R_rsort(x: *mut f64, n: ::std::os::raw::c_int);
2233
2234    /// Sort a complex vector in place.
2235    ///
2236    /// # Parameters
2237    ///
2238    /// - `x`: Pointer to Rcomplex array
2239    /// - `n`: Number of elements
2240    pub fn R_csort(x: *mut Rcomplex, n: ::std::os::raw::c_int);
2241
2242    /// Sort doubles in descending order, carrying along an index array.
2243    ///
2244    /// # Parameters
2245    ///
2246    /// - `a`: Pointer to double array (sorted in place, descending)
2247    /// - `ib`: Pointer to integer array (permuted alongside `a`)
2248    /// - `n`: Number of elements
2249    #[doc(alias = "Rf_revsort")]
2250    pub fn revsort(a: *mut f64, ib: *mut ::std::os::raw::c_int, n: ::std::os::raw::c_int);
2251
2252    /// Sort doubles with index array.
2253    ///
2254    /// # Parameters
2255    ///
2256    /// - `x`: Pointer to double array (sorted in place)
2257    /// - `indx`: Pointer to integer array (permuted alongside `x`)
2258    /// - `n`: Number of elements
2259    pub fn rsort_with_index(
2260        x: *mut f64,
2261        indx: *mut ::std::os::raw::c_int,
2262        n: ::std::os::raw::c_int,
2263    );
2264
2265    /// Partial sort integers (moves k-th smallest to position k).
2266    ///
2267    /// # Parameters
2268    ///
2269    /// - `x`: Pointer to integer array
2270    /// - `n`: Number of elements
2271    /// - `k`: Target position (0-indexed)
2272    #[doc(alias = "Rf_iPsort")]
2273    pub fn iPsort(
2274        x: *mut ::std::os::raw::c_int,
2275        n: ::std::os::raw::c_int,
2276        k: ::std::os::raw::c_int,
2277    );
2278
2279    /// Partial sort doubles (moves k-th smallest to position k).
2280    ///
2281    /// # Parameters
2282    ///
2283    /// - `x`: Pointer to double array
2284    /// - `n`: Number of elements
2285    /// - `k`: Target position (0-indexed)
2286    #[doc(alias = "Rf_rPsort")]
2287    pub fn rPsort(x: *mut f64, n: ::std::os::raw::c_int, k: ::std::os::raw::c_int);
2288
2289    /// Partial sort complex numbers.
2290    ///
2291    /// # Parameters
2292    ///
2293    /// - `x`: Pointer to Rcomplex array
2294    /// - `n`: Number of elements
2295    /// - `k`: Target position (0-indexed)
2296    #[doc(alias = "Rf_cPsort")]
2297    pub fn cPsort(x: *mut Rcomplex, n: ::std::os::raw::c_int, k: ::std::os::raw::c_int);
2298
2299    /// Quicksort doubles in place.
2300    ///
2301    /// # Parameters
2302    ///
2303    /// - `v`: Pointer to double array
2304    /// - `i`: Start index (1-indexed for R compatibility)
2305    /// - `j`: End index (1-indexed)
2306    pub fn R_qsort(v: *mut f64, i: usize, j: usize);
2307
2308    /// Quicksort doubles with index array.
2309    ///
2310    /// # Parameters
2311    ///
2312    /// - `v`: Pointer to double array
2313    /// - `indx`: Pointer to index array (permuted alongside v)
2314    /// - `i`: Start index (1-indexed)
2315    /// - `j`: End index (1-indexed)
2316    pub fn R_qsort_I(
2317        v: *mut f64,
2318        indx: *mut ::std::os::raw::c_int,
2319        i: ::std::os::raw::c_int,
2320        j: ::std::os::raw::c_int,
2321    );
2322
2323    /// Quicksort integers in place.
2324    ///
2325    /// # Parameters
2326    ///
2327    /// - `iv`: Pointer to integer array
2328    /// - `i`: Start index (1-indexed)
2329    /// - `j`: End index (1-indexed)
2330    pub fn R_qsort_int(iv: *mut ::std::os::raw::c_int, i: usize, j: usize);
2331
2332    /// Quicksort integers with index array.
2333    ///
2334    /// # Parameters
2335    ///
2336    /// - `iv`: Pointer to integer array
2337    /// - `indx`: Pointer to index array
2338    /// - `i`: Start index (1-indexed)
2339    /// - `j`: End index (1-indexed)
2340    pub fn R_qsort_int_I(
2341        iv: *mut ::std::os::raw::c_int,
2342        indx: *mut ::std::os::raw::c_int,
2343        i: ::std::os::raw::c_int,
2344        j: ::std::os::raw::c_int,
2345    );
2346
2347    /// Expand a filename, resolving `~` and environment variables.
2348    ///
2349    /// # Returns
2350    ///
2351    /// Pointer to expanded path (in R's internal buffer, do not free).
2352    pub fn R_ExpandFileName(s: *const ::std::os::raw::c_char) -> *const ::std::os::raw::c_char;
2353
2354    /// Convert string to double, always using '.' as decimal point.
2355    ///
2356    /// Also accepts "NA" as input, returning NA_REAL.
2357    pub fn R_atof(str: *const ::std::os::raw::c_char) -> f64;
2358
2359    /// Convert string to double with end pointer, using '.' as decimal point.
2360    ///
2361    /// Like `strtod()` but locale-independent.
2362    pub fn R_strtod(c: *const ::std::os::raw::c_char, end: *mut *mut ::std::os::raw::c_char)
2363    -> f64;
2364
2365    /// Generate a temporary filename.
2366    ///
2367    /// # Parameters
2368    ///
2369    /// - `prefix`: Filename prefix
2370    /// - `tempdir`: Directory for temp file
2371    ///
2372    /// # Returns
2373    ///
2374    /// Newly allocated string (must be freed with `R_free_tmpnam`).
2375    pub fn R_tmpnam(
2376        prefix: *const ::std::os::raw::c_char,
2377        tempdir: *const ::std::os::raw::c_char,
2378    ) -> *mut ::std::os::raw::c_char;
2379
2380    /// Generate a temporary filename with extension.
2381    ///
2382    /// # Parameters
2383    ///
2384    /// - `prefix`: Filename prefix
2385    /// - `tempdir`: Directory for temp file
2386    /// - `fileext`: File extension (e.g., ".txt")
2387    ///
2388    /// # Returns
2389    ///
2390    /// Newly allocated string (must be freed with `R_free_tmpnam`).
2391    pub fn R_tmpnam2(
2392        prefix: *const ::std::os::raw::c_char,
2393        tempdir: *const ::std::os::raw::c_char,
2394        fileext: *const ::std::os::raw::c_char,
2395    ) -> *mut ::std::os::raw::c_char;
2396
2397    /// Free a temporary filename allocated by `R_tmpnam` or `R_tmpnam2`.
2398    pub fn R_free_tmpnam(name: *mut ::std::os::raw::c_char);
2399
2400    /// Check for R stack overflow.
2401    ///
2402    /// Throws an R error if stack is nearly exhausted.
2403    pub fn R_CheckStack();
2404
2405    /// Check for R stack overflow with extra space requirement.
2406    ///
2407    /// # Parameters
2408    ///
2409    /// - `extra`: Additional bytes needed
2410    pub fn R_CheckStack2(extra: usize);
2411
2412    /// Find the interval containing a value (binary search).
2413    ///
2414    /// Used for interpolation and binning.
2415    ///
2416    /// # Parameters
2417    ///
2418    /// - `xt`: Sorted breakpoints array
2419    /// - `n`: Number of breakpoints
2420    /// - `x`: Value to find
2421    /// - `rightmost_closed`: If TRUE, rightmost interval is closed
2422    /// - `all_inside`: If TRUE, out-of-bounds values map to endpoints
2423    /// - `ilo`: Initial guess for interval (1-indexed)
2424    /// - `mflag`: Output flag (see R documentation)
2425    ///
2426    /// # Returns
2427    ///
2428    /// Interval index (1-indexed).
2429    pub fn findInterval(
2430        xt: *const f64,
2431        n: ::std::os::raw::c_int,
2432        x: f64,
2433        rightmost_closed: Rboolean,
2434        all_inside: Rboolean,
2435        ilo: ::std::os::raw::c_int,
2436        mflag: *mut ::std::os::raw::c_int,
2437    ) -> ::std::os::raw::c_int;
2438
2439    /// Extended interval finding with left-open option.
2440    #[allow(clippy::too_many_arguments)]
2441    pub fn findInterval2(
2442        xt: *const f64,
2443        n: ::std::os::raw::c_int,
2444        x: f64,
2445        rightmost_closed: Rboolean,
2446        all_inside: Rboolean,
2447        left_open: Rboolean,
2448        ilo: ::std::os::raw::c_int,
2449        mflag: *mut ::std::os::raw::c_int,
2450    ) -> ::std::os::raw::c_int;
2451
2452    /// Find column maxima in a matrix.
2453    ///
2454    /// # Parameters
2455    ///
2456    /// - `matrix`: Column-major matrix data
2457    /// - `nr`: Number of rows
2458    /// - `nc`: Number of columns
2459    /// - `maxes`: Output array for column maxima indices (1-indexed)
2460    /// - `ties_meth`: How to handle ties (1=first, 2=random, 3=last)
2461    pub fn R_max_col(
2462        matrix: *const f64,
2463        nr: *const ::std::os::raw::c_int,
2464        nc: *const ::std::os::raw::c_int,
2465        maxes: *mut ::std::os::raw::c_int,
2466        ties_meth: *const ::std::os::raw::c_int,
2467    );
2468
2469    /// Check if a string represents FALSE in R.
2470    ///
2471    /// Recognizes "FALSE", "false", "False", "F", "f", etc.
2472    #[doc(alias = "Rf_StringFalse")]
2473    pub fn StringFalse(s: *const ::std::os::raw::c_char) -> Rboolean;
2474
2475    /// Check if a string represents TRUE in R.
2476    ///
2477    /// Recognizes "TRUE", "true", "True", "T", "t", etc.
2478    #[doc(alias = "Rf_StringTrue")]
2479    pub fn StringTrue(s: *const ::std::os::raw::c_char) -> Rboolean;
2480
2481    /// Check if a string is blank (empty or only whitespace).
2482    #[doc(alias = "Rf_isBlankString")]
2483    pub fn isBlankString(s: *const ::std::os::raw::c_char) -> Rboolean;
2484}
2485
2486// endregion
2487
2488// region: Additional Rinternals.h functions
2489
2490unsafe extern "C-unwind" {
    #[doc = " Create a CHARSXP with specified encoding."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `s`: C string"]
    #[doc = " - `encoding`: Character encoding (CE_UTF8, CE_LATIN1, etc.)"]
    #[doc(alias = "mkCharCE")]
    #[doc = "Unchecked FFI binding for `Rf_mkCharCE`."]
    #[doc = "Generated from source location line 2502, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_mkCharCE"]
    pub(crate) fn Rf_mkCharCE_unchecked(s: *const ::std::os::raw::c_char,
    encoding: cetype_t)
    -> SEXP;
    #[doc = " Get the number of characters in a string/character."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: A string SEXP"]
    #[doc = " - `ntype`: Type of count (0=bytes, 1=chars, 2=width)"]
    #[doc = " - `allowNA`: Whether to allow NA values"]
    #[doc = " - `keepNA`: Whether to keep NA in result"]
    #[doc = " - `msg_name`: Name for error messages"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " Character count or -1 on error."]
    #[doc = "Unchecked FFI binding for `R_nchar`."]
    #[doc = "Generated from source location line 2517, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_nchar"]
    pub fn R_nchar_unchecked(x: SEXP, ntype: ::std::os::raw::c_int,
    allowNA: Rboolean, keepNA: Rboolean,
    msg_name: *const ::std::os::raw::c_char)
    -> ::std::os::raw::c_int;
    #[doc = " Convert SEXPTYPE to C string name."]
    #[doc = ""]
    #[doc = " Returns a string like \"INTSXP\", \"REALSXP\", etc."]
    #[doc(alias = "type2char")]
    #[doc = "Unchecked FFI binding for `Rf_type2char`."]
    #[doc = "Generated from source location line 2529, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_type2char"]
    pub fn Rf_type2char_unchecked(sexptype: SEXPTYPE)
    -> *const ::std::os::raw::c_char;
    #[doc = " Print an R value to the console."]
    #[doc = ""]
    #[doc = " Uses R\'s standard print method for the object."]
    #[doc(alias = "PrintValue")]
    #[doc = "Unchecked FFI binding for `Rf_PrintValue`."]
    #[doc = "Generated from source location line 2535, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_PrintValue"]
    pub fn Rf_PrintValue_unchecked(x: SEXP);
    #[doc = " Create a new environment."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `enclos`: Enclosing environment"]
    #[doc = " - `hash`: Whether to use a hash table"]
    #[doc = " - `size`: Initial hash table size (if hash is TRUE)"]
    #[doc = "Unchecked FFI binding for `R_NewEnv`."]
    #[doc = "Generated from source location line 2547, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_NewEnv"]
    pub(crate) fn R_NewEnv_unchecked(enclos: SEXP, hash: Rboolean,
    size: ::std::os::raw::c_int)
    -> SEXP;
    #[doc = " Check if a variable exists in an environment frame."]
    #[doc = ""]
    #[doc = " Does not search enclosing environments."]
    #[doc = "Unchecked FFI binding for `R_existsVarInFrame`."]
    #[doc = "Generated from source location line 2552, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_existsVarInFrame"]
    pub fn R_existsVarInFrame_unchecked(rho: SEXP, symbol: SEXP)
    -> Rboolean;
    #[doc = " Remove a variable from an environment frame."]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc = " The removed value, or R_NilValue if not found."]
    #[doc = "Unchecked FFI binding for `R_removeVarFromFrame`."]
    #[doc = "Generated from source location line 2559, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_removeVarFromFrame"]
    pub fn R_removeVarFromFrame_unchecked(symbol: SEXP, env: SEXP)
    -> SEXP;
    #[doc = " Get the top-level environment."]
    #[doc = ""]
    #[doc = " Walks up enclosing environments until reaching a top-level env"]
    #[doc = " (global, namespace, or base)."]
    #[doc(alias = "topenv")]
    #[doc = "Unchecked FFI binding for `Rf_topenv`."]
    #[doc = "Generated from source location line 2566, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_topenv"]
    pub fn Rf_topenv_unchecked(target: SEXP, envir: SEXP)
    -> SEXP;
    #[doc = " Match elements of first vector in second vector."]
    #[doc = ""]
    #[doc = " Like R\'s `match()` function."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Vector of values to match"]
    #[doc = " - `table`: Vector to match against"]
    #[doc = " - `nomatch`: Value to return for non-matches"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc =
    " Integer vector of match positions (1-indexed, nomatch for non-matches)."]
    #[doc(alias = "match")]
    #[doc = "Unchecked FFI binding for `Rf_match`."]
    #[doc = "Generated from source location line 2584, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_match"]
    pub fn Rf_match_unchecked(x: SEXP, table: SEXP,
    nomatch: ::std::os::raw::c_int)
    -> SEXP;
    #[doc = " Copy most attributes from source to target."]
    #[doc = ""]
    #[doc = " Copies all attributes except names, dim, and dimnames."]
    #[doc(alias = "copyMostAttrib")]
    #[doc = "Unchecked FFI binding for `Rf_copyMostAttrib`."]
    #[doc = "Generated from source location line 2592, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_copyMostAttrib"]
    pub fn Rf_copyMostAttrib_unchecked(source: SEXP, target: SEXP);
    #[doc = " Find first duplicated element."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Vector to search"]
    #[doc = " - `fromLast`: If TRUE, search from end"]
    #[doc = ""]
    #[doc = " # Returns"]
    #[doc = ""]
    #[doc =
    " 0 if no duplicates, otherwise 1-indexed position of first duplicate."]
    #[doc(alias = "any_duplicated")]
    #[doc = "Unchecked FFI binding for `Rf_any_duplicated`."]
    #[doc = "Generated from source location line 2605, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_any_duplicated"]
    pub fn Rf_any_duplicated_unchecked(x: SEXP, fromLast: Rboolean)
    -> R_xlen_t;
    #[doc = " Convert to an S4 object."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `object`: Object to convert"]
    #[doc = " - `flag`: Conversion flag"]
    #[doc(alias = "asS4")]
    #[doc = "Unchecked FFI binding for `Rf_asS4`."]
    #[doc = "Generated from source location line 2616, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_asS4"]
    pub fn Rf_asS4_unchecked(object: SEXP, flag: Rboolean,
    complete: ::std::os::raw::c_int)
    -> SEXP;
    #[doc = " Get the S3 class of an S4 object."]
    #[doc(alias = "S3Class")]
    #[doc = "Unchecked FFI binding for `Rf_S3Class`."]
    #[doc = "Generated from source location line 2620, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_S3Class"]
    pub fn Rf_S3Class_unchecked(object: SEXP)
    -> SEXP;
    #[doc = " Get an R option value."]
    #[doc = ""]
    #[doc = " Equivalent to `getOption(\"name\")` in R."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `tag`: Symbol for option name"]
    #[doc(alias = "GetOption1")]
    #[doc = "Unchecked FFI binding for `Rf_GetOption1`."]
    #[doc = "Generated from source location line 2632, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_GetOption1"]
    pub fn Rf_GetOption1_unchecked(tag: SEXP)
    -> SEXP;
    #[doc = " Get the `digits` option."]
    #[doc = ""]
    #[doc = " Returns the value of `getOption(\"digits\")`."]
    #[doc(alias = "GetOptionDigits")]
    #[doc = "Unchecked FFI binding for `Rf_GetOptionDigits`."]
    #[doc = "Generated from source location line 2638, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_GetOptionDigits"]
    pub fn Rf_GetOptionDigits_unchecked()
    -> ::std::os::raw::c_int;
    #[doc = " Get the `width` option."]
    #[doc = ""]
    #[doc = " Returns the value of `getOption(\"width\")`."]
    #[doc(alias = "GetOptionWidth")]
    #[doc = "Unchecked FFI binding for `Rf_GetOptionWidth`."]
    #[doc = "Generated from source location line 2644, column 19."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_GetOptionWidth"]
    pub(crate) fn Rf_GetOptionWidth_unchecked()
    -> ::std::os::raw::c_int;
    #[doc = " Check if a factor is ordered."]
    #[doc(alias = "isOrdered")]
    #[doc = "Unchecked FFI binding for `Rf_isOrdered`."]
    #[doc = "Generated from source location line 2650, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isOrdered"]
    pub fn Rf_isOrdered_unchecked(s: SEXP)
    -> Rboolean;
    #[doc = " Check if a factor is unordered."]
    #[doc(alias = "isUnordered")]
    #[doc = "Unchecked FFI binding for `Rf_isUnordered`."]
    #[doc = "Generated from source location line 2654, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isUnordered"]
    pub fn Rf_isUnordered_unchecked(s: SEXP)
    -> Rboolean;
    #[doc = " Check if a vector is unsorted."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `x`: Vector to check"]
    #[doc = " - `strictly`: If TRUE, check for strictly increasing"]
    #[doc(alias = "isUnsorted")]
    #[doc = "Unchecked FFI binding for `Rf_isUnsorted`."]
    #[doc = "Generated from source location line 2663, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_isUnsorted"]
    pub fn Rf_isUnsorted_unchecked(x: SEXP, strictly: Rboolean)
    -> ::std::os::raw::c_int;
    #[doc = " Substitute in an expression."]
    #[doc = ""]
    #[doc = " Like R\'s `substitute()` function."]
    #[doc(alias = "substitute")]
    #[doc = "Unchecked FFI binding for `Rf_substitute`."]
    #[doc = "Generated from source location line 2671, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_substitute"]
    pub fn Rf_substitute_unchecked(lang: SEXP, rho: SEXP)
    -> SEXP;
    #[doc = " Set vector length."]
    #[doc = ""]
    #[doc = " For short vectors (length < 2^31)."]
    #[doc(alias = "lengthgets")]
    #[doc = "Unchecked FFI binding for `Rf_lengthgets`."]
    #[doc = "Generated from source location line 2677, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_lengthgets"]
    pub fn Rf_lengthgets_unchecked(x: SEXP, newlen: R_xlen_t)
    -> SEXP;
    #[doc = " Set vector length (long vector version)."]
    #[doc(alias = "xlengthgets")]
    #[doc = "Unchecked FFI binding for `Rf_xlengthgets`."]
    #[doc = "Generated from source location line 2681, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_xlengthgets"]
    pub fn Rf_xlengthgets_unchecked(x: SEXP, newlen: R_xlen_t)
    -> SEXP;
    #[doc =
    " Protect a SEXP and record its stack index for later `R_Reprotect`."]
    #[doc = ""]
    #[doc =
    " **Cost: O(1)** — same array write as `Rf_protect`, plus stores the index."]
    #[doc =
    " No allocation. Use when you need to replace a protected value in-place"]
    #[doc =
    " (e.g., inside a loop that allocates) without unprotect/re-protect churn."]
    #[doc(alias = "PROTECT_WITH_INDEX")]
    #[doc = "Unchecked FFI binding for `R_ProtectWithIndex`."]
    #[doc = "Generated from source location line 2691, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_ProtectWithIndex"]
    pub fn R_ProtectWithIndex_unchecked(s: SEXP,
    index: *mut ::std::os::raw::c_int);
    #[doc = " Replace the SEXP at a previously recorded protect stack index."]
    #[doc = ""]
    #[doc =
    " **Cost: O(1)** — direct array write (`R_PPStack[index] = s`). No allocation."]
    #[doc = ""]
    #[doc = " # Safety"]
    #[doc = ""]
    #[doc =
    " `index` must be from a previous `R_ProtectWithIndex` call and the"]
    #[doc = " stack must not have been unprotected past that index."]
    #[doc(alias = "REPROTECT")]
    #[doc = "Unchecked FFI binding for `R_Reprotect`."]
    #[doc = "Generated from source location line 2702, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_Reprotect"]
    pub fn R_Reprotect_unchecked(s: SEXP, index: ::std::os::raw::c_int);
    #[doc = " Create a weak reference."]
    #[doc = ""]
    #[doc = " # Parameters"]
    #[doc = ""]
    #[doc = " - `key`: The key object (weak reference target)"]
    #[doc = " - `val`: The value to associate"]
    #[doc = " - `fin`: Finalizer function (or R_NilValue)"]
    #[doc = " - `onexit`: Whether to run finalizer on R exit"]
    #[doc = "Unchecked FFI binding for `R_MakeWeakRef`."]
    #[doc = "Generated from source location line 2714, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_MakeWeakRef"]
    pub fn R_MakeWeakRef_unchecked(key: SEXP, val: SEXP, fin: SEXP,
    onexit: Rboolean)
    -> SEXP;
    #[doc = " Create a weak reference with C finalizer."]
    #[doc = "Unchecked FFI binding for `R_MakeWeakRefC`."]
    #[doc = "Generated from source location line 2717, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_MakeWeakRefC"]
    pub fn R_MakeWeakRefC_unchecked(key: SEXP, val: SEXP, fin: R_CFinalizer_t,
    onexit: Rboolean)
    -> SEXP;
    #[doc = " Get the key from a weak reference."]
    #[doc = "Unchecked FFI binding for `R_WeakRefKey`."]
    #[doc = "Generated from source location line 2720, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_WeakRefKey"]
    pub fn R_WeakRefKey_unchecked(w: SEXP)
    -> SEXP;
    #[doc = " Get the value from a weak reference."]
    #[doc = "Unchecked FFI binding for `R_WeakRefValue`."]
    #[doc = "Generated from source location line 2723, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_WeakRefValue"]
    pub fn R_WeakRefValue_unchecked(w: SEXP)
    -> SEXP;
    #[doc = " Run pending finalizers."]
    #[doc = "Unchecked FFI binding for `R_RunPendingFinalizers`."]
    #[doc = "Generated from source location line 2726, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "R_RunPendingFinalizers"]
    pub fn R_RunPendingFinalizers_unchecked();
    #[doc = " Convert a pairlist to a generic vector (list)."]
    #[doc(alias = "PairToVectorList")]
    #[doc = "Unchecked FFI binding for `Rf_PairToVectorList`."]
    #[doc = "Generated from source location line 2732, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_PairToVectorList"]
    pub fn Rf_PairToVectorList_unchecked(x: SEXP)
    -> SEXP;
    #[doc = " Convert a generic vector (list) to a pairlist."]
    #[doc(alias = "VectorToPairList")]
    #[doc = "Unchecked FFI binding for `Rf_VectorToPairList`."]
    #[doc = "Generated from source location line 2736, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_VectorToPairList"]
    pub fn Rf_VectorToPairList_unchecked(x: SEXP)
    -> SEXP;
    #[doc = " Install a symbol from a CHARSXP."]
    #[doc = ""]
    #[doc = " Like `Rf_install()` but takes a CHARSXP instead of C string."]
    #[doc(alias = "installChar")]
    #[doc = "Unchecked FFI binding for `Rf_installChar`."]
    #[doc = "Generated from source location line 2744, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "Rf_installChar"]
    pub fn Rf_installChar_unchecked(x: SEXP)
    -> SEXP;
}
#[doc = " Create a CHARSXP with specified encoding."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `s`: C string"]
#[doc = " - `encoding`: Character encoding (CE_UTF8, CE_LATIN1, etc.)"]
#[doc(alias = "mkCharCE")]
#[doc =
"Checked wrapper for `Rf_mkCharCE`. Calls `Rf_mkCharCE_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2502, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn Rf_mkCharCE(s: *const ::std::os::raw::c_char,
    encoding: cetype_t) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_mkCharCE_unchecked(s, encoding)
                        })
                });
    result.0
}
#[doc = " Get the number of characters in a string/character."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: A string SEXP"]
#[doc = " - `ntype`: Type of count (0=bytes, 1=chars, 2=width)"]
#[doc = " - `allowNA`: Whether to allow NA values"]
#[doc = " - `keepNA`: Whether to keep NA in result"]
#[doc = " - `msg_name`: Name for error messages"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " Character count or -1 on error."]
#[doc =
"Checked wrapper for `R_nchar`. Calls `R_nchar_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2517, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_nchar(x: SEXP, ntype: ::std::os::raw::c_int,
    allowNA: Rboolean, keepNA: Rboolean,
    msg_name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_nchar_unchecked(x, ntype, allowNA, keepNA, msg_name)
                        })
                });
    result.0
}
#[doc = " Convert SEXPTYPE to C string name."]
#[doc = ""]
#[doc = " Returns a string like \"INTSXP\", \"REALSXP\", etc."]
#[doc(alias = "type2char")]
#[doc =
"Checked wrapper for `Rf_type2char`. Calls `Rf_type2char_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2529, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_type2char(sexptype: SEXPTYPE)
    -> *const ::std::os::raw::c_char {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_type2char_unchecked(sexptype)
                        })
                });
    result.0
}
#[doc = " Print an R value to the console."]
#[doc = ""]
#[doc = " Uses R\'s standard print method for the object."]
#[doc(alias = "PrintValue")]
#[doc =
"Checked wrapper for `Rf_PrintValue`. Calls `Rf_PrintValue_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2535, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_PrintValue(x: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_PrintValue_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Create a new environment."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `enclos`: Enclosing environment"]
#[doc = " - `hash`: Whether to use a hash table"]
#[doc = " - `size`: Initial hash table size (if hash is TRUE)"]
#[doc =
"Checked wrapper for `R_NewEnv`. Calls `R_NewEnv_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2547, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_NewEnv(enclos: SEXP, hash: Rboolean,
    size: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_NewEnv_unchecked(enclos, hash, size)
                        })
                });
    result.0
}
#[doc = " Check if a variable exists in an environment frame."]
#[doc = ""]
#[doc = " Does not search enclosing environments."]
#[doc =
"Checked wrapper for `R_existsVarInFrame`. Calls `R_existsVarInFrame_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2552, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_existsVarInFrame(rho: SEXP, symbol: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_existsVarInFrame_unchecked(rho, symbol)
                        })
                });
    result.0
}
#[doc = " Remove a variable from an environment frame."]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc = " The removed value, or R_NilValue if not found."]
#[doc =
"Checked wrapper for `R_removeVarFromFrame`. Calls `R_removeVarFromFrame_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2559, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_removeVarFromFrame(symbol: SEXP, env: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_removeVarFromFrame_unchecked(symbol, env)
                        })
                });
    result.0
}
#[doc = " Get the top-level environment."]
#[doc = ""]
#[doc = " Walks up enclosing environments until reaching a top-level env"]
#[doc = " (global, namespace, or base)."]
#[doc(alias = "topenv")]
#[doc =
"Checked wrapper for `Rf_topenv`. Calls `Rf_topenv_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2566, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_topenv(target: SEXP, envir: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_topenv_unchecked(target, envir)
                        })
                });
    result.0
}
#[doc = " Match elements of first vector in second vector."]
#[doc = ""]
#[doc = " Like R\'s `match()` function."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Vector of values to match"]
#[doc = " - `table`: Vector to match against"]
#[doc = " - `nomatch`: Value to return for non-matches"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc =
" Integer vector of match positions (1-indexed, nomatch for non-matches)."]
#[doc(alias = "match")]
#[doc =
"Checked wrapper for `Rf_match`. Calls `Rf_match_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2584, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_match(x: SEXP, table: SEXP, nomatch: ::std::os::raw::c_int)
    -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_match_unchecked(x, table, nomatch)
                        })
                });
    result.0
}
#[doc = " Copy most attributes from source to target."]
#[doc = ""]
#[doc = " Copies all attributes except names, dim, and dimnames."]
#[doc(alias = "copyMostAttrib")]
#[doc =
"Checked wrapper for `Rf_copyMostAttrib`. Calls `Rf_copyMostAttrib_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2592, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_copyMostAttrib(source: SEXP, target: SEXP) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_copyMostAttrib_unchecked(source, target)
                        })
                });
    result.0
}
#[doc = " Find first duplicated element."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Vector to search"]
#[doc = " - `fromLast`: If TRUE, search from end"]
#[doc = ""]
#[doc = " # Returns"]
#[doc = ""]
#[doc =
" 0 if no duplicates, otherwise 1-indexed position of first duplicate."]
#[doc(alias = "any_duplicated")]
#[doc =
"Checked wrapper for `Rf_any_duplicated`. Calls `Rf_any_duplicated_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2605, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_any_duplicated(x: SEXP, fromLast: Rboolean) -> R_xlen_t {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_any_duplicated_unchecked(x, fromLast)
                        })
                });
    result.0
}
#[doc = " Convert to an S4 object."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `object`: Object to convert"]
#[doc = " - `flag`: Conversion flag"]
#[doc(alias = "asS4")]
#[doc =
"Checked wrapper for `Rf_asS4`. Calls `Rf_asS4_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2616, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_asS4(object: SEXP, flag: Rboolean,
    complete: ::std::os::raw::c_int) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_asS4_unchecked(object, flag, complete)
                        })
                });
    result.0
}
#[doc = " Get the S3 class of an S4 object."]
#[doc(alias = "S3Class")]
#[doc =
"Checked wrapper for `Rf_S3Class`. Calls `Rf_S3Class_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2620, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_S3Class(object: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_S3Class_unchecked(object)
                        })
                });
    result.0
}
#[doc = " Get an R option value."]
#[doc = ""]
#[doc = " Equivalent to `getOption(\"name\")` in R."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `tag`: Symbol for option name"]
#[doc(alias = "GetOption1")]
#[doc =
"Checked wrapper for `Rf_GetOption1`. Calls `Rf_GetOption1_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2632, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_GetOption1(tag: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_GetOption1_unchecked(tag)
                        })
                });
    result.0
}
#[doc = " Get the `digits` option."]
#[doc = ""]
#[doc = " Returns the value of `getOption(\"digits\")`."]
#[doc(alias = "GetOptionDigits")]
#[doc =
"Checked wrapper for `Rf_GetOptionDigits`. Calls `Rf_GetOptionDigits_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2638, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_GetOptionDigits() -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_GetOptionDigits_unchecked()
                        })
                });
    result.0
}
#[doc = " Get the `width` option."]
#[doc = ""]
#[doc = " Returns the value of `getOption(\"width\")`."]
#[doc(alias = "GetOptionWidth")]
#[doc =
"Checked wrapper for `Rf_GetOptionWidth`. Calls `Rf_GetOptionWidth_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2644, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn Rf_GetOptionWidth() -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_GetOptionWidth_unchecked()
                        })
                });
    result.0
}
#[doc = " Check if a factor is ordered."]
#[doc(alias = "isOrdered")]
#[doc =
"Checked wrapper for `Rf_isOrdered`. Calls `Rf_isOrdered_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2650, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isOrdered(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isOrdered_unchecked(s)
                        })
                });
    result.0
}
#[doc = " Check if a factor is unordered."]
#[doc(alias = "isUnordered")]
#[doc =
"Checked wrapper for `Rf_isUnordered`. Calls `Rf_isUnordered_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2654, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isUnordered(s: SEXP) -> Rboolean {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isUnordered_unchecked(s)
                        })
                });
    result.0
}
#[doc = " Check if a vector is unsorted."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `x`: Vector to check"]
#[doc = " - `strictly`: If TRUE, check for strictly increasing"]
#[doc(alias = "isUnsorted")]
#[doc =
"Checked wrapper for `Rf_isUnsorted`. Calls `Rf_isUnsorted_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2663, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_isUnsorted(x: SEXP, strictly: Rboolean)
    -> ::std::os::raw::c_int {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_isUnsorted_unchecked(x, strictly)
                        })
                });
    result.0
}
#[doc = " Substitute in an expression."]
#[doc = ""]
#[doc = " Like R\'s `substitute()` function."]
#[doc(alias = "substitute")]
#[doc =
"Checked wrapper for `Rf_substitute`. Calls `Rf_substitute_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2671, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_substitute(lang: SEXP, rho: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_substitute_unchecked(lang, rho)
                        })
                });
    result.0
}
#[doc = " Set vector length."]
#[doc = ""]
#[doc = " For short vectors (length < 2^31)."]
#[doc(alias = "lengthgets")]
#[doc =
"Checked wrapper for `Rf_lengthgets`. Calls `Rf_lengthgets_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2677, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_lengthgets(x: SEXP, newlen: R_xlen_t) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_lengthgets_unchecked(x, newlen)
                        })
                });
    result.0
}
#[doc = " Set vector length (long vector version)."]
#[doc(alias = "xlengthgets")]
#[doc =
"Checked wrapper for `Rf_xlengthgets`. Calls `Rf_xlengthgets_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2681, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_xlengthgets(x: SEXP, newlen: R_xlen_t) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_xlengthgets_unchecked(x, newlen)
                        })
                });
    result.0
}
#[doc = " Protect a SEXP and record its stack index for later `R_Reprotect`."]
#[doc = ""]
#[doc =
" **Cost: O(1)** — same array write as `Rf_protect`, plus stores the index."]
#[doc =
" No allocation. Use when you need to replace a protected value in-place"]
#[doc =
" (e.g., inside a loop that allocates) without unprotect/re-protect churn."]
#[doc(alias = "PROTECT_WITH_INDEX")]
#[doc =
"Checked wrapper for `R_ProtectWithIndex`. Calls `R_ProtectWithIndex_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2691, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_ProtectWithIndex(s: SEXP, index: *mut ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_ProtectWithIndex_unchecked(s, index)
                        })
                });
    result.0
}
#[doc = " Replace the SEXP at a previously recorded protect stack index."]
#[doc = ""]
#[doc =
" **Cost: O(1)** — direct array write (`R_PPStack[index] = s`). No allocation."]
#[doc = ""]
#[doc = " # Safety"]
#[doc = ""]
#[doc = " `index` must be from a previous `R_ProtectWithIndex` call and the"]
#[doc = " stack must not have been unprotected past that index."]
#[doc(alias = "REPROTECT")]
#[doc =
"Checked wrapper for `R_Reprotect`. Calls `R_Reprotect_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2702, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_Reprotect(s: SEXP, index: ::std::os::raw::c_int) {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_Reprotect_unchecked(s, index)
                        })
                });
    result.0
}
#[doc = " Create a weak reference."]
#[doc = ""]
#[doc = " # Parameters"]
#[doc = ""]
#[doc = " - `key`: The key object (weak reference target)"]
#[doc = " - `val`: The value to associate"]
#[doc = " - `fin`: Finalizer function (or R_NilValue)"]
#[doc = " - `onexit`: Whether to run finalizer on R exit"]
#[doc =
"Checked wrapper for `R_MakeWeakRef`. Calls `R_MakeWeakRef_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2714, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_MakeWeakRef(key: SEXP, val: SEXP, fin: SEXP, onexit: Rboolean)
    -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_MakeWeakRef_unchecked(key, val, fin, onexit)
                        })
                });
    result.0
}
#[doc = " Create a weak reference with C finalizer."]
#[doc =
"Checked wrapper for `R_MakeWeakRefC`. Calls `R_MakeWeakRefC_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2717, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_MakeWeakRefC(key: SEXP, val: SEXP, fin: R_CFinalizer_t,
    onexit: Rboolean) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_MakeWeakRefC_unchecked(key, val, fin, onexit)
                        })
                });
    result.0
}
#[doc = " Get the key from a weak reference."]
#[doc =
"Checked wrapper for `R_WeakRefKey`. Calls `R_WeakRefKey_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2720, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_WeakRefKey(w: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_WeakRefKey_unchecked(w)
                        })
                });
    result.0
}
#[doc = " Get the value from a weak reference."]
#[doc =
"Checked wrapper for `R_WeakRefValue`. Calls `R_WeakRefValue_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2723, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_WeakRefValue(w: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_WeakRefValue_unchecked(w)
                        })
                });
    result.0
}
#[doc = " Run pending finalizers."]
#[doc =
"Checked wrapper for `R_RunPendingFinalizers`. Calls `R_RunPendingFinalizers_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2726, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_RunPendingFinalizers() {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            R_RunPendingFinalizers_unchecked()
                        })
                });
    result.0
}
#[doc = " Convert a pairlist to a generic vector (list)."]
#[doc(alias = "PairToVectorList")]
#[doc =
"Checked wrapper for `Rf_PairToVectorList`. Calls `Rf_PairToVectorList_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2732, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_PairToVectorList(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_PairToVectorList_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Convert a generic vector (list) to a pairlist."]
#[doc(alias = "VectorToPairList")]
#[doc =
"Checked wrapper for `Rf_VectorToPairList`. Calls `Rf_VectorToPairList_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2736, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_VectorToPairList(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_VectorToPairList_unchecked(x)
                        })
                });
    result.0
}
#[doc = " Install a symbol from a CHARSXP."]
#[doc = ""]
#[doc = " Like `Rf_install()` but takes a CHARSXP instead of C string."]
#[doc(alias = "installChar")]
#[doc =
"Checked wrapper for `Rf_installChar`. Calls `Rf_installChar_unchecked` and routes through `with_r_thread`."]
#[doc = "Generated from source location line 2744, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn Rf_installChar(x: SEXP) -> SEXP {
    let result =
        ::miniextendr_api::worker::with_r_thread(move ||
                {
                    ::miniextendr_api::worker::Sendable(unsafe {
                            Rf_installChar_unchecked(x)
                        })
                });
    result.0
}#[r_ffi_checked]
2491unsafe extern "C-unwind" {
2492    // String/character functions
2493
2494    /// Create a CHARSXP with specified encoding.
2495    ///
2496    /// # Parameters
2497    ///
2498    /// - `s`: C string
2499    /// - `encoding`: Character encoding (CE_UTF8, CE_LATIN1, etc.)
2500    // Issue #112 cat. 10: kept pub(crate) — 2 callers in encoding.rs; wrapping adds no value
2501    #[doc(alias = "mkCharCE")]
2502    pub(crate) fn Rf_mkCharCE(s: *const ::std::os::raw::c_char, encoding: cetype_t) -> SEXP;
2503
2504    /// Get the number of characters in a string/character.
2505    ///
2506    /// # Parameters
2507    ///
2508    /// - `x`: A string SEXP
2509    /// - `ntype`: Type of count (0=bytes, 1=chars, 2=width)
2510    /// - `allowNA`: Whether to allow NA values
2511    /// - `keepNA`: Whether to keep NA in result
2512    /// - `msg_name`: Name for error messages
2513    ///
2514    /// # Returns
2515    ///
2516    /// Character count or -1 on error.
2517    pub fn R_nchar(
2518        x: SEXP,
2519        ntype: ::std::os::raw::c_int,
2520        allowNA: Rboolean,
2521        keepNA: Rboolean,
2522        msg_name: *const ::std::os::raw::c_char,
2523    ) -> ::std::os::raw::c_int;
2524
2525    /// Convert SEXPTYPE to C string name.
2526    ///
2527    /// Returns a string like "INTSXP", "REALSXP", etc.
2528    #[doc(alias = "type2char")]
2529    pub fn Rf_type2char(sexptype: SEXPTYPE) -> *const ::std::os::raw::c_char;
2530
2531    /// Print an R value to the console.
2532    ///
2533    /// Uses R's standard print method for the object.
2534    #[doc(alias = "PrintValue")]
2535    pub fn Rf_PrintValue(x: SEXP);
2536
2537    // Environment functions
2538
2539    /// Create a new environment.
2540    ///
2541    /// # Parameters
2542    ///
2543    /// - `enclos`: Enclosing environment
2544    /// - `hash`: Whether to use a hash table
2545    /// - `size`: Initial hash table size (if hash is TRUE)
2546    // Issue #112 cat. 10: kept pub(crate) — 2 callers in environment.rs; wrapping adds no value
2547    pub(crate) fn R_NewEnv(enclos: SEXP, hash: Rboolean, size: ::std::os::raw::c_int) -> SEXP;
2548
2549    /// Check if a variable exists in an environment frame.
2550    ///
2551    /// Does not search enclosing environments.
2552    pub fn R_existsVarInFrame(rho: SEXP, symbol: SEXP) -> Rboolean;
2553
2554    /// Remove a variable from an environment frame.
2555    ///
2556    /// # Returns
2557    ///
2558    /// The removed value, or R_NilValue if not found.
2559    pub fn R_removeVarFromFrame(symbol: SEXP, env: SEXP) -> SEXP;
2560
2561    /// Get the top-level environment.
2562    ///
2563    /// Walks up enclosing environments until reaching a top-level env
2564    /// (global, namespace, or base).
2565    #[doc(alias = "topenv")]
2566    pub fn Rf_topenv(target: SEXP, envir: SEXP) -> SEXP;
2567
2568    // Matching functions
2569
2570    /// Match elements of first vector in second vector.
2571    ///
2572    /// Like R's `match()` function.
2573    ///
2574    /// # Parameters
2575    ///
2576    /// - `x`: Vector of values to match
2577    /// - `table`: Vector to match against
2578    /// - `nomatch`: Value to return for non-matches
2579    ///
2580    /// # Returns
2581    ///
2582    /// Integer vector of match positions (1-indexed, nomatch for non-matches).
2583    #[doc(alias = "match")]
2584    pub fn Rf_match(x: SEXP, table: SEXP, nomatch: ::std::os::raw::c_int) -> SEXP;
2585
2586    // Duplication and copying
2587
2588    /// Copy most attributes from source to target.
2589    ///
2590    /// Copies all attributes except names, dim, and dimnames.
2591    #[doc(alias = "copyMostAttrib")]
2592    pub fn Rf_copyMostAttrib(source: SEXP, target: SEXP);
2593
2594    /// Find first duplicated element.
2595    ///
2596    /// # Parameters
2597    ///
2598    /// - `x`: Vector to search
2599    /// - `fromLast`: If TRUE, search from end
2600    ///
2601    /// # Returns
2602    ///
2603    /// 0 if no duplicates, otherwise 1-indexed position of first duplicate.
2604    #[doc(alias = "any_duplicated")]
2605    pub fn Rf_any_duplicated(x: SEXP, fromLast: Rboolean) -> R_xlen_t;
2606
2607    // S4 functions
2608
2609    /// Convert to an S4 object.
2610    ///
2611    /// # Parameters
2612    ///
2613    /// - `object`: Object to convert
2614    /// - `flag`: Conversion flag
2615    #[doc(alias = "asS4")]
2616    pub fn Rf_asS4(object: SEXP, flag: Rboolean, complete: ::std::os::raw::c_int) -> SEXP;
2617
2618    /// Get the S3 class of an S4 object.
2619    #[doc(alias = "S3Class")]
2620    pub fn Rf_S3Class(object: SEXP) -> SEXP;
2621
2622    // Option access
2623
2624    /// Get an R option value.
2625    ///
2626    /// Equivalent to `getOption("name")` in R.
2627    ///
2628    /// # Parameters
2629    ///
2630    /// - `tag`: Symbol for option name
2631    #[doc(alias = "GetOption1")]
2632    pub fn Rf_GetOption1(tag: SEXP) -> SEXP;
2633
2634    /// Get the `digits` option.
2635    ///
2636    /// Returns the value of `getOption("digits")`.
2637    #[doc(alias = "GetOptionDigits")]
2638    pub fn Rf_GetOptionDigits() -> ::std::os::raw::c_int;
2639
2640    /// Get the `width` option.
2641    ///
2642    /// Returns the value of `getOption("width")`.
2643    #[doc(alias = "GetOptionWidth")]
2644    pub(crate) fn Rf_GetOptionWidth() -> ::std::os::raw::c_int;
2645
2646    // Factor functions
2647
2648    /// Check if a factor is ordered.
2649    #[doc(alias = "isOrdered")]
2650    pub fn Rf_isOrdered(s: SEXP) -> Rboolean;
2651
2652    /// Check if a factor is unordered.
2653    #[doc(alias = "isUnordered")]
2654    pub fn Rf_isUnordered(s: SEXP) -> Rboolean;
2655
2656    /// Check if a vector is unsorted.
2657    ///
2658    /// # Parameters
2659    ///
2660    /// - `x`: Vector to check
2661    /// - `strictly`: If TRUE, check for strictly increasing
2662    #[doc(alias = "isUnsorted")]
2663    pub fn Rf_isUnsorted(x: SEXP, strictly: Rboolean) -> ::std::os::raw::c_int;
2664
2665    // Expression and evaluation
2666
2667    /// Substitute in an expression.
2668    ///
2669    /// Like R's `substitute()` function.
2670    #[doc(alias = "substitute")]
2671    pub fn Rf_substitute(lang: SEXP, rho: SEXP) -> SEXP;
2672
2673    /// Set vector length.
2674    ///
2675    /// For short vectors (length < 2^31).
2676    #[doc(alias = "lengthgets")]
2677    pub fn Rf_lengthgets(x: SEXP, newlen: R_xlen_t) -> SEXP;
2678
2679    /// Set vector length (long vector version).
2680    #[doc(alias = "xlengthgets")]
2681    pub fn Rf_xlengthgets(x: SEXP, newlen: R_xlen_t) -> SEXP;
2682
2683    // Protection (indexed — see cost table in the "GC protection" region above)
2684
2685    /// Protect a SEXP and record its stack index for later `R_Reprotect`.
2686    ///
2687    /// **Cost: O(1)** — same array write as `Rf_protect`, plus stores the index.
2688    /// No allocation. Use when you need to replace a protected value in-place
2689    /// (e.g., inside a loop that allocates) without unprotect/re-protect churn.
2690    #[doc(alias = "PROTECT_WITH_INDEX")]
2691    pub fn R_ProtectWithIndex(s: SEXP, index: *mut ::std::os::raw::c_int);
2692
2693    /// Replace the SEXP at a previously recorded protect stack index.
2694    ///
2695    /// **Cost: O(1)** — direct array write (`R_PPStack[index] = s`). No allocation.
2696    ///
2697    /// # Safety
2698    ///
2699    /// `index` must be from a previous `R_ProtectWithIndex` call and the
2700    /// stack must not have been unprotected past that index.
2701    #[doc(alias = "REPROTECT")]
2702    pub fn R_Reprotect(s: SEXP, index: ::std::os::raw::c_int);
2703
2704    // Weak references
2705
2706    /// Create a weak reference.
2707    ///
2708    /// # Parameters
2709    ///
2710    /// - `key`: The key object (weak reference target)
2711    /// - `val`: The value to associate
2712    /// - `fin`: Finalizer function (or R_NilValue)
2713    /// - `onexit`: Whether to run finalizer on R exit
2714    pub fn R_MakeWeakRef(key: SEXP, val: SEXP, fin: SEXP, onexit: Rboolean) -> SEXP;
2715
2716    /// Create a weak reference with C finalizer.
2717    pub fn R_MakeWeakRefC(key: SEXP, val: SEXP, fin: R_CFinalizer_t, onexit: Rboolean) -> SEXP;
2718
2719    /// Get the key from a weak reference.
2720    pub fn R_WeakRefKey(w: SEXP) -> SEXP;
2721
2722    /// Get the value from a weak reference.
2723    pub fn R_WeakRefValue(w: SEXP) -> SEXP;
2724
2725    /// Run pending finalizers.
2726    pub fn R_RunPendingFinalizers();
2727
2728    // Conversion list/vector
2729
2730    /// Convert a pairlist to a generic vector (list).
2731    #[doc(alias = "PairToVectorList")]
2732    pub fn Rf_PairToVectorList(x: SEXP) -> SEXP;
2733
2734    /// Convert a generic vector (list) to a pairlist.
2735    #[doc(alias = "VectorToPairList")]
2736    pub fn Rf_VectorToPairList(x: SEXP) -> SEXP;
2737
2738    // Install with CHARSXP
2739
2740    /// Install a symbol from a CHARSXP.
2741    ///
2742    /// Like `Rf_install()` but takes a CHARSXP instead of C string.
2743    #[doc(alias = "installChar")]
2744    pub fn Rf_installChar(x: SEXP) -> SEXP;
2745}
2746
2747// endregion