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::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 on R's main thread through [`crate::with_r_thread`], and panics for
25//!   any other caller. **Use these by default.**
26//! - **`*_unchecked`** (e.g. `Rf_allocVector_unchecked`): bypass the check.
27//!   Calling one off the R main thread is undefined behaviour. They exist for three known-safe contexts:
28//!     1. Inside ALTREP callbacks — R is already calling us on the main thread.
29//!     2. Inside a [`crate::unwind_protect::with_r_unwind_protect`] body —
30//!        the guard has already established main-thread context.
31//!     3. Inside a [`crate::with_r_thread`] body — the check would be
32//!        redundant.
33//!
34//! The build-time lint **MXL301** enforces this: any `*_unchecked` call
35//! outside those contexts is a compile-time error.
36//!
37//! # Don't raise R errors directly
38//!
39//! `Rf_error`, `Rf_errorcall`, and their `_unchecked` siblings longjmp,
40//! which **skips Rust destructors** and leaks resources. The lint **MXL300**
41//! forbids them in user code. Use `panic!()` instead; the framework converts
42//! the panic into a structured R condition with `rust_*` class layering via
43//! the tagged-SEXP transport (see [`crate::error_value`]).
44//!
45//! # Cross references
46//!
47//! - [`crate::ffi_guard`] — guard taxonomy.
48//! - [`crate::thread`] — R's main thread.
49//! - [`crate::altrep_traits`] / [`crate::altrep_bridge`] — guard modes
50//!   inside ALTREP callbacks.
51//! - [`crate::error_value`] / [`mod@crate::condition`] — panic → R condition
52//!   transport.
53
54/// Raw ALTREP C API method type aliases.
55pub mod altrep;
56
57// `extern "C-unwind"` signatures below reference the type vocabulary by
58// bare name. Bring it into scope as a private `use` (NOT `pub use`) — the
59// vocab's canonical home is the crate root (`crate::SEXP`, etc.) and
60// `crate::sexp_types` for the niche helpers. Adding these to the public
61// API of `sys::` would re-create the bridge.
62use crate::sexp::SEXP;
63use crate::sexp_types::{R_CFinalizer_t, R_xlen_t, Rboolean, Rbyte, Rcomplex, SEXPTYPE, cetype_t};
64
65// region: Connections types (gated behind `connections` feature)
66// WARNING: R's connection API is explicitly marked as UNSTABLE.
67
68/// Opaque R connection implementation (from R_ext/Connections.h).
69///
70/// This is an opaque type representing R's internal connection structure.
71/// The actual structure is explicitly unstable and may change between R versions.
72#[cfg(feature = "connections")]
73#[repr(C)]
74#[allow(non_camel_case_types)]
75pub struct Rconnection_impl(::std::os::raw::c_void);
76
77/// Pointer to an R connection handle.
78///
79/// This is the typed equivalent of R's `Rconnection` type, which is a pointer
80/// to the opaque `Rconn` struct. Using this instead of `*mut c_void` provides
81/// type safety for connection APIs.
82#[cfg(feature = "connections")]
83#[allow(non_camel_case_types)]
84pub type Rconnection = *mut Rconnection_impl;
85
86/// R connections API version from R's `R_ext/Connections.h` at compile time.
87///
88/// This is a compile-time constant baked into the Rust FFI bindings when they
89/// were generated against a particular R version's headers. It does **not**
90/// dynamically probe the running R session.
91///
92/// From R_ext/Connections.h: "you *must* check the version and proceed only
93/// if it matches what you expect. We explicitly reserve the right to change
94/// the connection implementation without a compatibility layer."
95///
96/// Before using any connection APIs, check that this equals the expected version (1).
97#[cfg(feature = "connections")]
98#[allow(non_upper_case_globals)]
99pub const R_CONNECTIONS_VERSION: ::std::os::raw::c_int = 1;
100
101// endregion
102
103use miniextendr_macros::r_ffi_checked;
104
105// Unchecked variadic functions (internal use only, no thread check)
106#[allow(clashing_extern_declarations)]
107#[allow(varargs_without_pattern)]
108unsafe extern "C-unwind" {
109    /// Unchecked variadic `Rf_error`; call checked wrapper when possible.
110    #[link_name = "Rf_error"]
111    pub fn Rf_error_unchecked(arg1: *const ::std::os::raw::c_char, ...) -> !;
112    /// Unchecked variadic `Rf_errorcall`; call checked wrapper when possible.
113    #[link_name = "Rf_errorcall"]
114    pub fn Rf_errorcall_unchecked(arg1: SEXP, arg2: *const ::std::os::raw::c_char, ...) -> !;
115    /// Unchecked variadic `Rf_warning`; call checked wrapper when possible.
116    #[link_name = "Rf_warning"]
117    pub fn Rf_warning_unchecked(arg1: *const ::std::os::raw::c_char, ...);
118    /// Unchecked variadic `Rprintf`; call checked wrapper when possible.
119    #[link_name = "Rprintf"]
120    pub fn Rprintf_unchecked(arg1: *const ::std::os::raw::c_char, ...);
121    /// Unchecked variadic `REprintf`; call checked wrapper when possible.
122    #[link_name = "REprintf"]
123    pub fn REprintf_unchecked(arg1: *const ::std::os::raw::c_char, ...);
124}
125
126// Console hooks (non-API; declared in Rinterface.h)
127#[cfg(feature = "nonapi")]
128unsafe extern "C-unwind" {
129    #[expect(dead_code, reason = "declared for future use")]
130    pub(crate) static ptr_R_WriteConsoleEx: Option<
131        unsafe extern "C-unwind" fn(
132            *const ::std::os::raw::c_char,
133            ::std::os::raw::c_int,
134            ::std::os::raw::c_int,
135        ),
136    >;
137}
138
139/// Checked wrapper for `Rf_error` - panics if called from non-main thread.
140/// Common usage: `Rf_error(c"%s".as_ptr(), message.as_ptr())`
141///
142/// # Safety
143///
144/// - Must be called from the R main thread
145/// - `fmt` and `arg1` must be valid null-terminated C strings
146#[inline(always)]
147#[allow(non_snake_case)]
148pub unsafe fn Rf_error(
149    fmt: *const ::std::os::raw::c_char,
150    arg1: *const ::std::os::raw::c_char,
151) -> ! {
152    if !crate::is_r_main_thread() {
153        {
    ::core::panicking::panic_fmt(format_args!("Rf_error called from non-main thread"));
};panic!("Rf_error called from non-main thread");
154    }
155    unsafe { Rf_error_unchecked(fmt, arg1) }
156}
157
158/// Checked wrapper for `Rf_errorcall` - panics if called from non-main thread.
159///
160/// # Safety
161///
162/// - Must be called from the R main thread
163/// - `call` must be a valid SEXP or R_NilValue
164/// - `fmt` and `arg1` must be valid null-terminated C strings
165#[inline(always)]
166#[allow(non_snake_case)]
167pub unsafe fn Rf_errorcall(
168    call: SEXP,
169    fmt: *const ::std::os::raw::c_char,
170    arg1: *const ::std::os::raw::c_char,
171) -> ! {
172    if !crate::is_r_main_thread() {
173        {
    ::core::panicking::panic_fmt(format_args!("Rf_errorcall called from non-main thread"));
};panic!("Rf_errorcall called from non-main thread");
174    }
175    unsafe { Rf_errorcall_unchecked(call, fmt, arg1) }
176}
177
178/// Checked wrapper for `Rf_warning` - panics if called from non-main thread.
179///
180/// # Safety
181///
182/// - Must be called from the R main thread
183/// - `fmt` and `arg1` must be valid null-terminated C strings
184#[inline(always)]
185#[allow(non_snake_case)]
186pub unsafe fn Rf_warning(fmt: *const ::std::os::raw::c_char, arg1: *const ::std::os::raw::c_char) {
187    if !crate::is_r_main_thread() {
188        {
    ::core::panicking::panic_fmt(format_args!("Rf_warning called from non-main thread"));
};panic!("Rf_warning called from non-main thread");
189    }
190    unsafe { Rf_warning_unchecked(fmt, arg1) }
191}
192
193/// Checked wrapper for `Rprintf` - panics if called from non-main thread.
194///
195/// # Safety
196///
197/// - Must be called from the R main thread
198/// - `fmt` and `arg1` must be valid null-terminated C strings
199#[inline(always)]
200#[allow(non_snake_case)]
201pub unsafe fn Rprintf(fmt: *const ::std::os::raw::c_char, arg1: *const ::std::os::raw::c_char) {
202    if !crate::is_r_main_thread() {
203        {
    ::core::panicking::panic_fmt(format_args!("Rprintf called from non-main thread"));
};panic!("Rprintf called from non-main thread");
204    }
205    unsafe { Rprintf_unchecked(fmt, arg1) }
206}
207
208/// Print to R's stderr (via R_ShowMessage or error console).
209///
210/// # Safety
211///
212/// - Must be called from the R main thread
213/// - `fmt` and `arg1` must be valid null-terminated C strings
214#[inline(always)]
215#[allow(non_snake_case)]
216pub unsafe fn REprintf(fmt: *const ::std::os::raw::c_char, arg1: *const ::std::os::raw::c_char) {
217    if !crate::is_r_main_thread() {
218        {
    ::core::panicking::panic_fmt(format_args!("REprintf called from non-main thread"));
};panic!("REprintf called from non-main thread");
219    }
220    unsafe { REprintf_unchecked(fmt, arg1) }
221}
222
223// Imported R symbols and functions with runtime thread checks enabled.
224#[allow(missing_docs)]
225#[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 272, 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 288, 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 290, 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 292, 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 299, 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 301, 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 303, 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 305, 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 307, 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 309, 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 312, 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 313, 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 314, 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 343, 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 344, 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 345, 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 346, 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 347, 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 348, 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 349, 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 350, 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 352, 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 353, 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 354, 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 355, 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 356, 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 357, 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 362, 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 368, 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 416, 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 426, 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 438, 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 447, 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 454, 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 459, 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 461, 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 467, 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 469, 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 479, 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 483, 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 485, 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 488, 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 489, 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 493, 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 497, 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 499, 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 501, 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 503, 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 505, 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 507, 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 514, 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 515, 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 543, 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 544, 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 545, 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 546, 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 547, 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 548, 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 549, 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 550, 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 551, 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 552, 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 553, 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 554, 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 555, 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 556, 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 557, 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 558, 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 559, 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 560, 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 561, 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 562, 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 563, 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 564, 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 567, 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 568, 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 569, 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 570, 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 571, 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 572, 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 573, 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 574, 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 575, 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 576, 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 577, 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 578, 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 579, 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 580, 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 590, 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 595, 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 606, 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 664, 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 665, 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 666, 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 667, 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 668, 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 673, 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 688, 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 694, 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 700, 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 706, 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 712, 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 719, 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 725, 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 731, 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 733, 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 736, 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 744, 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 747, 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 750, 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 754, 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 756, 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 =
    " Mark an object as shared for good: R code that modifies it (`x[1] <- 0`,"]
    #[doc =
    " `attr(x, \"a\") <- 1`) copies it first, whatever else references it."]
    #[doc = " Allocates nothing."]
    #[doc = "Unchecked FFI binding for `MARK_NOT_MUTABLE`."]
    #[doc = "Generated from source location line 760, column 12."]
    #[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
    #[link_name = "MARK_NOT_MUTABLE"]
    pub fn MARK_NOT_MUTABLE_unchecked(x: 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 780, 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 272, column 19."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub(crate) unsafe fn R_FlushConsole() {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_FlushConsole_unchecked() })
}
#[doc(alias = "mkChar")]
#[doc =
"Checked wrapper for `Rf_mkChar`. Calls `Rf_mkChar_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 288, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_mkChar_unchecked(s) })
}
#[doc(alias = "mkCharLen")]
#[doc =
"Checked wrapper for `Rf_mkCharLen`. Calls `Rf_mkCharLen_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 290, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_mkCharLen_unchecked(s, len) })
}
#[doc(alias = "mkCharLenCE")]
#[doc =
"Checked wrapper for `Rf_mkCharLenCE`. Calls `Rf_mkCharLenCE_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 292, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_mkCharLenCE_unchecked(x, len, ce) })
}
#[doc(alias = "xlength")]
#[doc(alias = "XLENGTH")]
#[doc =
"Checked wrapper for `Rf_xlength`. Calls `Rf_xlength_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 299, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_xlength_unchecked(x) })
}
#[doc(alias = "translateCharUTF8")]
#[doc =
"Checked wrapper for `Rf_translateCharUTF8`. Calls `Rf_translateCharUTF8_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 301, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_translateCharUTF8_unchecked(x) })
}
#[doc(alias = "getCharCE")]
#[doc =
"Checked wrapper for `Rf_getCharCE`. Calls `Rf_getCharCE_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 303, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_getCharCE_unchecked(x) })
}
#[doc(alias = "charIsASCII")]
#[doc =
"Checked wrapper for `Rf_charIsASCII`. Calls `Rf_charIsASCII_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 305, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_charIsASCII_unchecked(x) })
}
#[doc(alias = "charIsUTF8")]
#[doc =
"Checked wrapper for `Rf_charIsUTF8`. Calls `Rf_charIsUTF8_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 307, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_charIsUTF8_unchecked(x) })
}
#[doc(alias = "charIsLatin1")]
#[doc =
"Checked wrapper for `Rf_charIsLatin1`. Calls `Rf_charIsLatin1_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 309, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_charIsLatin1_unchecked(x) })
}
#[doc =
"Checked wrapper for `R_MakeUnwindCont`. Calls `R_MakeUnwindCont_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 312, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_MakeUnwindCont_unchecked() })
}
#[doc =
"Checked wrapper for `R_ContinueUnwind`. Calls `R_ContinueUnwind_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 313, 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::with_r_thread(move ||
            unsafe { R_ContinueUnwind_unchecked(cont) })
}
#[doc =
"Checked wrapper for `R_UnwindProtect`. Calls `R_UnwindProtect_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 314, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe {
                R_UnwindProtect_unchecked(fun, fun_data, cleanfun,
                    cleanfun_data, cont)
            })
}
#[doc = " External pointer interface"]
#[doc =
"Checked wrapper for `R_MakeExternalPtr`. Calls `R_MakeExternalPtr_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 343, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_MakeExternalPtr_unchecked(p, tag, prot) })
}
#[doc =
"Checked wrapper for `R_ExternalPtrAddr`. Calls `R_ExternalPtrAddr_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 344, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ExternalPtrAddr_unchecked(s) })
}
#[doc =
"Checked wrapper for `R_ExternalPtrTag`. Calls `R_ExternalPtrTag_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 345, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ExternalPtrTag_unchecked(s) })
}
#[doc =
"Checked wrapper for `R_ExternalPtrProtected`. Calls `R_ExternalPtrProtected_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 346, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ExternalPtrProtected_unchecked(s) })
}
#[doc =
"Checked wrapper for `R_ClearExternalPtr`. Calls `R_ClearExternalPtr_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 347, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ClearExternalPtr_unchecked(s) })
}
#[doc =
"Checked wrapper for `R_SetExternalPtrAddr`. Calls `R_SetExternalPtrAddr_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 348, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_SetExternalPtrAddr_unchecked(s, p) })
}
#[doc =
"Checked wrapper for `R_SetExternalPtrTag`. Calls `R_SetExternalPtrTag_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 349, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_SetExternalPtrTag_unchecked(s, tag) })
}
#[doc =
"Checked wrapper for `R_SetExternalPtrProtected`. Calls `R_SetExternalPtrProtected_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 350, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_SetExternalPtrProtected_unchecked(s, p) })
}
#[doc = " Added in R 3.4.0"]
#[doc =
"Checked wrapper for `R_MakeExternalPtrFn`. Calls `R_MakeExternalPtrFn_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 352, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_MakeExternalPtrFn_unchecked(p, tag, prot) })
}
#[doc =
"Checked wrapper for `R_ExternalPtrAddrFn`. Calls `R_ExternalPtrAddrFn_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 353, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ExternalPtrAddrFn_unchecked(s) })
}
#[doc =
"Checked wrapper for `R_RegisterFinalizer`. Calls `R_RegisterFinalizer_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 354, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_RegisterFinalizer_unchecked(s, fun) })
}
#[doc =
"Checked wrapper for `R_RegisterCFinalizer`. Calls `R_RegisterCFinalizer_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 355, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_RegisterCFinalizer_unchecked(s, fun) })
}
#[doc =
"Checked wrapper for `R_RegisterFinalizerEx`. Calls `R_RegisterFinalizerEx_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 356, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_RegisterFinalizerEx_unchecked(s, fun, onexit) })
}
#[doc =
"Checked wrapper for `R_RegisterCFinalizerEx`. Calls `R_RegisterCFinalizerEx_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 357, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_RegisterCFinalizerEx_unchecked(s, fun, onexit) })
}
#[doc = " Register a C-callable function for cross-package access."]
#[doc =
"Checked wrapper for `R_RegisterCCallable`. Calls `R_RegisterCCallable_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 362, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_RegisterCCallable_unchecked(package, name, fptr) })
}
#[doc = " Get a C-callable function from another package."]
#[doc =
"Checked wrapper for `R_GetCCallable`. Calls `R_GetCCallable_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 368, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_GetCCallable_unchecked(package, name) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 416, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_protect_unchecked(s) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 426, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_unprotect_unchecked(l) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 438, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_unprotect_ptr_unchecked(s) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 447, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_PreserveObject_unchecked(object) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 454, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ReleaseObject_unchecked(object) })
}
#[doc(alias = "allocVector")]
#[doc =
"Checked wrapper for `Rf_allocVector`. Calls `Rf_allocVector_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 459, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_allocVector_unchecked(sexptype, length) })
}
#[doc(alias = "allocMatrix")]
#[doc =
"Checked wrapper for `Rf_allocMatrix`. Calls `Rf_allocMatrix_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 461, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_allocMatrix_unchecked(sexptype, nrow, ncol) })
}
#[doc(alias = "allocArray")]
#[doc =
"Checked wrapper for `Rf_allocArray`. Calls `Rf_allocArray_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 467, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_allocArray_unchecked(sexptype, dims) })
}
#[doc(alias = "alloc3DArray")]
#[doc =
"Checked wrapper for `Rf_alloc3DArray`. Calls `Rf_alloc3DArray_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 469, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_alloc3DArray_unchecked(sexptype, nrow, ncol, nface) })
}
#[doc(alias = "allocList")]
#[doc =
"Checked wrapper for `Rf_allocList`. Calls `Rf_allocList_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 479, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_allocList_unchecked(n) })
}
#[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` inside `with_r_thread`, which panics off R's main 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_allocLang(n: ::std::os::raw::c_int) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_allocLang_unchecked(n) })
}
#[doc(alias = "allocS4Object")]
#[doc =
"Checked wrapper for `Rf_allocS4Object`. Calls `Rf_allocS4Object_unchecked` inside `with_r_thread`, which panics off R's main 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_allocS4Object() -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_allocS4Object_unchecked() })
}
#[doc =
"Checked wrapper for `Rf_cons`. Calls `Rf_cons_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 488, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_cons_unchecked(car, cdr) })
}
#[doc =
"Checked wrapper for `Rf_lcons`. Calls `Rf_lcons_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 489, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_lcons_unchecked(car, cdr) })
}
#[doc(alias = "setAttrib")]
#[doc =
"Checked wrapper for `Rf_setAttrib`. Calls `Rf_setAttrib_unchecked` inside `with_r_thread`, which panics off R's main 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_setAttrib(vec: SEXP, name: SEXP, val: SEXP) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_setAttrib_unchecked(vec, name, val) })
}
#[doc(alias = "ScalarComplex")]
#[doc =
"Checked wrapper for `Rf_ScalarComplex`. Calls `Rf_ScalarComplex_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 497, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_ScalarComplex_unchecked(x) })
}
#[doc(alias = "ScalarInteger")]
#[doc =
"Checked wrapper for `Rf_ScalarInteger`. Calls `Rf_ScalarInteger_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 499, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_ScalarInteger_unchecked(x) })
}
#[doc(alias = "ScalarLogical")]
#[doc =
"Checked wrapper for `Rf_ScalarLogical`. Calls `Rf_ScalarLogical_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 501, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_ScalarLogical_unchecked(x) })
}
#[doc(alias = "ScalarRaw")]
#[doc =
"Checked wrapper for `Rf_ScalarRaw`. Calls `Rf_ScalarRaw_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 503, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_ScalarRaw_unchecked(x) })
}
#[doc(alias = "ScalarReal")]
#[doc =
"Checked wrapper for `Rf_ScalarReal`. Calls `Rf_ScalarReal_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 505, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_ScalarReal_unchecked(x) })
}
#[doc(alias = "ScalarString")]
#[doc =
"Checked wrapper for `Rf_ScalarString`. Calls `Rf_ScalarString_unchecked` inside `with_r_thread`, which panics off R's main 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_ScalarString(x: SEXP) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_ScalarString_unchecked(x) })
}
#[doc =
"Checked wrapper for `DATAPTR_RO`. Calls `DATAPTR_RO_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 514, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { DATAPTR_RO_unchecked(x) })
}
#[doc =
"Checked wrapper for `DATAPTR_OR_NULL`. Calls `DATAPTR_OR_NULL_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 515, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { DATAPTR_OR_NULL_unchecked(x) })
}
#[doc =
"Checked wrapper for `CAR`. Calls `CAR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 543, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CAR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CDR`. Calls `CDR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 544, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CDR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CAAR`. Calls `CAAR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 545, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CAAR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CDAR`. Calls `CDAR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 546, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CDAR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CADR`. Calls `CADR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 547, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CADR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CDDR`. Calls `CDDR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 548, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CDDR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CADDR`. Calls `CADDR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 549, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CADDR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CADDDR`. Calls `CADDDR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 550, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CADDDR_unchecked(e) })
}
#[doc =
"Checked wrapper for `CAD4R`. Calls `CAD4R_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 551, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { CAD4R_unchecked(e) })
}
#[doc =
"Checked wrapper for `TAG`. Calls `TAG_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 552, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { TAG_unchecked(e) })
}
#[doc =
"Checked wrapper for `SET_TAG`. Calls `SET_TAG_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 553, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_TAG_unchecked(x, y) })
}
#[doc =
"Checked wrapper for `SETCAR`. Calls `SETCAR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 554, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SETCAR_unchecked(x, y) })
}
#[doc =
"Checked wrapper for `SETCDR`. Calls `SETCDR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 555, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SETCDR_unchecked(x, y) })
}
#[doc =
"Checked wrapper for `SETCADR`. Calls `SETCADR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 556, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SETCADR_unchecked(x, y) })
}
#[doc =
"Checked wrapper for `SETCADDR`. Calls `SETCADDR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 557, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SETCADDR_unchecked(x, y) })
}
#[doc =
"Checked wrapper for `SETCADDDR`. Calls `SETCADDDR_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 558, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SETCADDDR_unchecked(x, y) })
}
#[doc =
"Checked wrapper for `SETCAD4R`. Calls `SETCAD4R_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 559, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SETCAD4R_unchecked(e, y) })
}
#[doc =
"Checked wrapper for `LOGICAL_OR_NULL`. Calls `LOGICAL_OR_NULL_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 560, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { LOGICAL_OR_NULL_unchecked(x) })
}
#[doc =
"Checked wrapper for `INTEGER_OR_NULL`. Calls `INTEGER_OR_NULL_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 561, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { INTEGER_OR_NULL_unchecked(x) })
}
#[doc =
"Checked wrapper for `REAL_OR_NULL`. Calls `REAL_OR_NULL_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 562, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { REAL_OR_NULL_unchecked(x) })
}
#[doc =
"Checked wrapper for `COMPLEX_OR_NULL`. Calls `COMPLEX_OR_NULL_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 563, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { COMPLEX_OR_NULL_unchecked(x) })
}
#[doc =
"Checked wrapper for `RAW_OR_NULL`. Calls `RAW_OR_NULL_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 564, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { RAW_OR_NULL_unchecked(x) })
}
#[doc =
"Checked wrapper for `INTEGER_ELT`. Calls `INTEGER_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 INTEGER_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { INTEGER_ELT_unchecked(x, i) })
}
#[doc =
"Checked wrapper for `REAL_ELT`. Calls `REAL_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 REAL_ELT(x: SEXP, i: R_xlen_t) -> f64 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { REAL_ELT_unchecked(x, i) })
}
#[doc =
"Checked wrapper for `LOGICAL_ELT`. Calls `LOGICAL_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 LOGICAL_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { LOGICAL_ELT_unchecked(x, i) })
}
#[doc =
"Checked wrapper for `COMPLEX_ELT`. Calls `COMPLEX_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 COMPLEX_ELT(x: SEXP, i: R_xlen_t) -> Rcomplex {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { COMPLEX_ELT_unchecked(x, i) })
}
#[doc =
"Checked wrapper for `RAW_ELT`. Calls `RAW_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 RAW_ELT(x: SEXP, i: R_xlen_t) -> Rbyte {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { RAW_ELT_unchecked(x, i) })
}
#[doc =
"Checked wrapper for `VECTOR_ELT`. Calls `VECTOR_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 VECTOR_ELT(x: SEXP, i: R_xlen_t) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { VECTOR_ELT_unchecked(x, i) })
}
#[doc =
"Checked wrapper for `STRING_ELT`. Calls `STRING_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 STRING_ELT(x: SEXP, i: R_xlen_t) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { STRING_ELT_unchecked(x, i) })
}
#[doc =
"Checked wrapper for `SET_STRING_ELT`. Calls `SET_STRING_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 SET_STRING_ELT(x: SEXP, i: R_xlen_t, v: SEXP) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_STRING_ELT_unchecked(x, i, v) })
}
#[doc =
"Checked wrapper for `SET_LOGICAL_ELT`. Calls `SET_LOGICAL_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 SET_LOGICAL_ELT(x: SEXP, i: R_xlen_t,
    v: ::std::os::raw::c_int) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_LOGICAL_ELT_unchecked(x, i, v) })
}
#[doc =
"Checked wrapper for `SET_INTEGER_ELT`. Calls `SET_INTEGER_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 SET_INTEGER_ELT(x: SEXP, i: R_xlen_t,
    v: ::std::os::raw::c_int) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_INTEGER_ELT_unchecked(x, i, v) })
}
#[doc =
"Checked wrapper for `SET_REAL_ELT`. Calls `SET_REAL_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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_REAL_ELT(x: SEXP, i: R_xlen_t, v: f64) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_REAL_ELT_unchecked(x, i, v) })
}
#[doc =
"Checked wrapper for `SET_COMPLEX_ELT`. Calls `SET_COMPLEX_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 SET_COMPLEX_ELT(x: SEXP, i: R_xlen_t, v: Rcomplex) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_COMPLEX_ELT_unchecked(x, i, v) })
}
#[doc =
"Checked wrapper for `SET_RAW_ELT`. Calls `SET_RAW_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 SET_RAW_ELT(x: SEXP, i: R_xlen_t, v: Rbyte) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_RAW_ELT_unchecked(x, i, v) })
}
#[doc =
"Checked wrapper for `SET_VECTOR_ELT`. Calls `SET_VECTOR_ELT_unchecked` inside `with_r_thread`, which panics off R's main 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 SET_VECTOR_ELT(x: SEXP, i: R_xlen_t, v: SEXP) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { SET_VECTOR_ELT_unchecked(x, i, v) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 590, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { LENGTH_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main 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 XLENGTH(x: SEXP) -> R_xlen_t {
    ::miniextendr_api::with_r_thread(move || unsafe { XLENGTH_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 606, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { ANY_ATTRIB_unchecked(x) })
}
#[doc =
"Checked wrapper for `ALTREP_CLASS`. Calls `ALTREP_CLASS_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 664, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { ALTREP_CLASS_unchecked(x) })
}
#[doc =
"Checked wrapper for `R_altrep_data1`. Calls `R_altrep_data1_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 665, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_altrep_data1_unchecked(x) })
}
#[doc =
"Checked wrapper for `R_altrep_data2`. Calls `R_altrep_data2_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 666, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_altrep_data2_unchecked(x) })
}
#[doc =
"Checked wrapper for `R_set_altrep_data1`. Calls `R_set_altrep_data1_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 667, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_set_altrep_data1_unchecked(x, v) })
}
#[doc =
"Checked wrapper for `R_set_altrep_data2`. Calls `R_set_altrep_data2_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 668, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_set_altrep_data2_unchecked(x, v) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 673, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { ALTREP_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main 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 LOGICAL(x: SEXP) -> *mut ::std::os::raw::c_int {
    ::miniextendr_api::with_r_thread(move || unsafe { LOGICAL_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 694, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { INTEGER_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 700, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { REAL_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 706, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { COMPLEX_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main 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 RAW(x: SEXP) -> *mut Rbyte {
    ::miniextendr_api::with_r_thread(move || unsafe { RAW_unchecked(x) })
}
#[doc =
"Checked wrapper for `R_CheckUserInterrupt`. Calls `R_CheckUserInterrupt_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 719, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_CheckUserInterrupt() {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_CheckUserInterrupt_unchecked() })
}
#[doc =
"Checked wrapper for `TYPEOF`. Calls `TYPEOF_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 725, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { TYPEOF_unchecked(x) })
}
#[doc(alias = "install")]
#[doc =
"Checked wrapper for `Rf_install`. Calls `Rf_install_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 731, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_install_unchecked(name) })
}
#[doc = " Get the print name (CHARSXP) of a symbol (SYMSXP)"]
#[doc =
"Checked wrapper for `PRINTNAME`. Calls `PRINTNAME_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 733, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { PRINTNAME_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 736, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { R_CHAR_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 744, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_getAttrib_unchecked(vec, name) })
}
#[doc = " Set the `names` attribute; returns the updated object."]
#[doc(alias = "namesgets")]
#[doc =
"Checked wrapper for `Rf_namesgets`. Calls `Rf_namesgets_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 747, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_namesgets_unchecked(vec, val) })
}
#[doc = " Set the `dim` attribute; returns the updated object."]
#[doc(alias = "dimgets")]
#[doc =
"Checked wrapper for `Rf_dimgets`. Calls `Rf_dimgets_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 750, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_dimgets_unchecked(vec, val) })
}
#[doc(alias = "duplicate")]
#[doc =
"Checked wrapper for `Rf_duplicate`. Calls `Rf_duplicate_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 754, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_duplicate_unchecked(s) })
}
#[doc(alias = "shallow_duplicate")]
#[doc =
"Checked wrapper for `Rf_shallow_duplicate`. Calls `Rf_shallow_duplicate_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 756, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_shallow_duplicate_unchecked(s) })
}
#[doc =
" Mark an object as shared for good: R code that modifies it (`x[1] <- 0`,"]
#[doc =
" `attr(x, \"a\") <- 1`) copies it first, whatever else references it."]
#[doc = " Allocates nothing."]
#[doc =
"Checked wrapper for `MARK_NOT_MUTABLE`. Calls `MARK_NOT_MUTABLE_unchecked` inside `with_r_thread`, which panics off R's main 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 MARK_NOT_MUTABLE(x: SEXP) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { MARK_NOT_MUTABLE_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main 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 R_compute_identical(x: SEXP, y: SEXP,
    flags: ::std::os::raw::c_int) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_compute_identical_unchecked(x, y, flags) })
}#[r_ffi_checked]
226#[allow(clashing_extern_declarations)]
227unsafe extern "C-unwind" {
228    /// The canonical R `NULL` value.
229    pub static R_NilValue: SEXP;
230
231    #[doc(alias = "NA_STRING")]
232    /// Missing string singleton — encapsulated by SEXP::na_string()
233    pub static R_NaString: SEXP;
234    /// Empty string CHARSXP — encapsulated by SEXP::blank_string()
235    pub static R_BlankString: SEXP;
236    /// Symbol for `names` attribute.
237    // Attribute symbols — encapsulated by SexpExt methods and SEXP::*_symbol()
238    pub static R_NamesSymbol: SEXP;
239    pub static R_DimSymbol: SEXP;
240    pub static R_DimNamesSymbol: SEXP;
241    pub static R_ClassSymbol: SEXP;
242    pub static R_RowNamesSymbol: SEXP;
243    pub static R_LevelsSymbol: SEXP;
244    pub static R_TspSymbol: SEXP;
245
246    /// Global environment (`.GlobalEnv`).
247    pub static R_GlobalEnv: SEXP;
248    /// Base package namespace environment.
249    pub static R_BaseEnv: SEXP;
250    /// Empty root environment.
251    pub static R_EmptyEnv: SEXP;
252    /// Base package namespace — encapsulated by SEXP::base_namespace()
253    pub static R_BaseNamespace: SEXP;
254
255    /// The "missing argument" sentinel value.
256    ///
257    /// When an R function is called without providing a value for a formal
258    /// argument, R passes `R_MissingArg` as a placeholder. This is different
259    /// from `R_NilValue` (NULL) - a missing argument means "not provided",
260    /// while NULL is an explicit value.
261    ///
262    /// In R: `f <- function(x) missing(x); f()` returns `TRUE`.
263    /// Encapsulated by SEXP::missing_arg()
264    pub static R_MissingArg: SEXP;
265
266    /// Sentinel returned by `R_getVarEx` (via its `ifnotfound` argument) when
267    /// the symbol has no binding in the searched frame(s).
268    pub static R_UnboundValue: SEXP;
269
270    // Issue #112 cat. 10: kept pub(crate) — single-caller utilities; wrapping adds no value
271    // Rinterface.h
272    pub(crate) fn R_FlushConsole();
273
274    // Special logical values (from internal Defn.h, not public API)
275    // These are gated behind `nonapi` feature as they may change across R versions.
276    #[cfg(feature = "nonapi")]
277    /// Non-API TRUE singleton.
278    pub static R_TrueValue: SEXP;
279    #[cfg(feature = "nonapi")]
280    /// Non-API FALSE singleton.
281    pub static R_FalseValue: SEXP;
282    #[cfg(feature = "nonapi")]
283    /// Non-API NA logical singleton.
284    pub static R_LogicalNAValue: SEXP;
285
286    // Rinternals.h
287    #[doc(alias = "mkChar")]
288    pub fn Rf_mkChar(s: *const ::std::os::raw::c_char) -> SEXP;
289    #[doc(alias = "mkCharLen")]
290    pub fn Rf_mkCharLen(s: *const ::std::os::raw::c_char, len: i32) -> SEXP;
291    #[doc(alias = "mkCharLenCE")]
292    pub fn Rf_mkCharLenCE(
293        x: *const ::std::os::raw::c_char,
294        len: ::std::os::raw::c_int,
295        ce: cetype_t,
296    ) -> SEXP;
297    #[doc(alias = "xlength")]
298    #[doc(alias = "XLENGTH")]
299    pub fn Rf_xlength(x: SEXP) -> R_xlen_t;
300    #[doc(alias = "translateCharUTF8")]
301    pub fn Rf_translateCharUTF8(x: SEXP) -> *const ::std::os::raw::c_char;
302    #[doc(alias = "getCharCE")]
303    pub fn Rf_getCharCE(x: SEXP) -> cetype_t;
304    #[doc(alias = "charIsASCII")]
305    pub fn Rf_charIsASCII(x: SEXP) -> Rboolean;
306    #[doc(alias = "charIsUTF8")]
307    pub fn Rf_charIsUTF8(x: SEXP) -> Rboolean;
308    #[doc(alias = "charIsLatin1")]
309    pub fn Rf_charIsLatin1(x: SEXP) -> Rboolean;
310
311    // Issue #112 cat. 3: kept pub(crate) — only called from unwind_protect.rs; users go through with_r_unwind_protect
312    pub(crate) fn R_MakeUnwindCont() -> SEXP;
313    pub(crate) fn R_ContinueUnwind(cont: SEXP) -> !;
314    pub(crate) fn R_UnwindProtect(
315        fun: ::std::option::Option<
316            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void) -> SEXP,
317        >,
318        fun_data: *mut ::std::os::raw::c_void,
319        cleanfun: ::std::option::Option<
320            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void, Rboolean),
321        >,
322        cleanfun_data: *mut ::std::os::raw::c_void,
323        cont: SEXP,
324    ) -> SEXP;
325
326    /// Version of `R_UnwindProtect` that accepts `extern "C-unwind"` function pointers
327    #[link_name = "R_UnwindProtect"]
328    pub(crate) fn R_UnwindProtect_C_unwind(
329        fun: ::std::option::Option<
330            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void) -> SEXP,
331        >,
332        fun_data: *mut ::std::os::raw::c_void,
333        cleanfun: ::std::option::Option<
334            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void, Rboolean),
335        >,
336        cleanfun_data: *mut ::std::os::raw::c_void,
337        cont: SEXP,
338    ) -> SEXP;
339
340    // Rinternals.h
341    // Issue #112 cat. 2: kept pub(crate) — ExternalPtr<T> encapsulates these for users; raw access needed within externalptr.rs
342    #[doc = " External pointer interface"]
343    pub(crate) fn R_MakeExternalPtr(p: *mut ::std::os::raw::c_void, tag: SEXP, prot: SEXP) -> SEXP;
344    pub fn R_ExternalPtrAddr(s: SEXP) -> *mut ::std::os::raw::c_void;
345    pub(crate) fn R_ExternalPtrTag(s: SEXP) -> SEXP;
346    pub(crate) fn R_ExternalPtrProtected(s: SEXP) -> SEXP;
347    pub(crate) fn R_ClearExternalPtr(s: SEXP);
348    pub(crate) fn R_SetExternalPtrAddr(s: SEXP, p: *mut ::std::os::raw::c_void);
349    pub(crate) fn R_SetExternalPtrTag(s: SEXP, tag: SEXP);
350    pub(crate) fn R_SetExternalPtrProtected(s: SEXP, p: SEXP);
351    #[doc = " Added in R 3.4.0"]
352    pub fn R_MakeExternalPtrFn(p: DL_FUNC, tag: SEXP, prot: SEXP) -> SEXP;
353    pub fn R_ExternalPtrAddrFn(s: SEXP) -> DL_FUNC;
354    pub fn R_RegisterFinalizer(s: SEXP, fun: SEXP);
355    pub(crate) fn R_RegisterCFinalizer(s: SEXP, fun: R_CFinalizer_t);
356    pub fn R_RegisterFinalizerEx(s: SEXP, fun: SEXP, onexit: Rboolean);
357    pub(crate) fn R_RegisterCFinalizerEx(s: SEXP, fun: R_CFinalizer_t, onexit: Rboolean);
358
359    // R_ext/Rdynload.h - C-callable interface
360    // Issue #112 cat. 10: kept pub(crate) — cross-package ABI helpers used from mx_abi.rs; wrapping adds no value
361    /// Register a C-callable function for cross-package access.
362    pub(crate) fn R_RegisterCCallable(
363        package: *const ::std::os::raw::c_char,
364        name: *const ::std::os::raw::c_char,
365        fptr: DL_FUNC,
366    );
367    /// Get a C-callable function from another package.
368    pub(crate) fn R_GetCCallable(
369        package: *const ::std::os::raw::c_char,
370        name: *const ::std::os::raw::c_char,
371    ) -> DL_FUNC;
372
373    // region: GC protection
374    //
375    // R has two GC protection mechanisms with very different cost profiles:
376    //
377    // ## Protect stack (`Rf_protect` / `Rf_unprotect`)
378    //
379    // A pre-allocated array (`R_PPStack`) with an integer index (`R_PPStackTop`).
380    // Protect pushes: `R_PPStack[R_PPStackTop++] = s`.
381    // Unprotect pops: `R_PPStackTop -= n`.
382    // **No heap allocation. No GC pressure. Essentially a single memory write.**
383    // Use this for temporary protection within a function.
384    // Requires LIFO discipline — nested scopes are fine, interleaved are not.
385    //
386    // ## Precious list (`R_PreserveObject` / `R_ReleaseObject`)
387    //
388    // A global linked list of CONSXP cells (`R_PreciousList`).
389    // Preserve: `CONS(object, R_PreciousList)` — **allocates a cons cell every call**.
390    // Release: linear scan of the entire list to find and unlink the object — **O(n)**.
391    // (Optional `R_HASH_PRECIOUS` env var enables a 1069-bucket hash table, improving
392    // Release to O(bucket_size), but Preserve still allocates.)
393    // Use this only for long-lived objects that outlive any single protect scope.
394    //
395    // ## Cost summary
396    //
397    // | Operation            | Cost               | Allocates? |
398    // |----------------------|--------------------|------------|
399    // | `Rf_protect`         | array write        | no         |
400    // | `Rf_unprotect(n)`    | integer subtract   | no         |
401    // | `Rf_unprotect_ptr`   | scan + shift       | no         |
402    // | `R_PreserveObject`   | cons cell alloc    | **yes**    |
403    // | `R_ReleaseObject`    | linked list scan   | no (O(n))  |
404    // | `R_ProtectWithIndex` | array write + save | no         |
405    // | `R_Reprotect`        | array index write  | no         |
406
407    /// Add a SEXP to the protect stack, preventing GC collection.
408    ///
409    /// **Cost: O(1)** — single array write (`R_PPStack[top++] = s`). No allocation.
410    ///
411    /// Must be balanced by a corresponding `Rf_unprotect`. The protect stack is
412    /// LIFO — nested scopes are safe, but interleaved usage from different scopes
413    /// will cause incorrect unprotection.
414    #[doc(alias = "PROTECT")]
415    #[doc(alias = "protect")]
416    pub fn Rf_protect(s: SEXP) -> SEXP;
417
418    /// Pop the top `l` entries from the protect stack.
419    ///
420    /// **Cost: O(1)** — single integer subtract (`R_PPStackTop -= l`). No allocation.
421    ///
422    /// The popped SEXPs become eligible for GC. Must match the number of
423    /// `Rf_protect` calls in the current scope (LIFO order).
424    #[doc(alias = "UNPROTECT")]
425    #[doc(alias = "unprotect")]
426    pub fn Rf_unprotect(l: ::std::os::raw::c_int);
427
428    /// Remove a specific SEXP from anywhere in the protect stack.
429    ///
430    /// **Cost: O(k)** — scans backwards from top (k = distance from top), then
431    /// shifts remaining entries down. No allocation. R source comment:
432    /// *"should be among the top few items"*.
433    ///
434    /// Unlike `Rf_unprotect`, this is order-independent — it finds and removes
435    /// the specific pointer regardless of stack position. Useful when LIFO
436    /// discipline cannot be maintained, but more expensive than `Rf_unprotect`.
437    #[doc(alias = "UNPROTECT_PTR")]
438    pub fn Rf_unprotect_ptr(s: SEXP);
439
440    /// Add a SEXP to the global precious list, preventing GC indefinitely.
441    ///
442    /// **Cost: O(1) but allocates a CONSXP cell** — creates GC pressure on every
443    /// call. The precious list is a global linked list (`R_PreciousList`).
444    ///
445    /// Use only for long-lived objects (e.g., ExternalPtr stored across R calls).
446    /// For temporary protection within a function, prefer `Rf_protect`.
447    pub fn R_PreserveObject(object: SEXP);
448
449    /// Remove a SEXP from the global precious list, allowing GC.
450    ///
451    /// **Cost: O(n)** — linear scan of the entire precious list to find and unlink
452    /// the cons cell. With `R_HASH_PRECIOUS` env var, O(bucket_size) average
453    /// via a 1069-bucket hash table, but this is off by default.
454    pub fn R_ReleaseObject(object: SEXP);
455
456    // endregion
457    // Vector allocation functions
458    #[doc(alias = "allocVector")]
459    pub fn Rf_allocVector(sexptype: SEXPTYPE, length: R_xlen_t) -> SEXP;
460    #[doc(alias = "allocMatrix")]
461    pub fn Rf_allocMatrix(
462        sexptype: SEXPTYPE,
463        nrow: ::std::os::raw::c_int,
464        ncol: ::std::os::raw::c_int,
465    ) -> SEXP;
466    #[doc(alias = "allocArray")]
467    pub fn Rf_allocArray(sexptype: SEXPTYPE, dims: SEXP) -> SEXP;
468    #[doc(alias = "alloc3DArray")]
469    pub fn Rf_alloc3DArray(
470        sexptype: SEXPTYPE,
471        nrow: ::std::os::raw::c_int,
472        ncol: ::std::os::raw::c_int,
473        nface: ::std::os::raw::c_int,
474    ) -> SEXP;
475
476    // Pairlist allocation
477    // Issue #112 cat. 10: kept pub(crate) — 2 callers in expression.rs/dots.rs; wrapping adds no value
478    #[doc(alias = "allocList")]
479    pub(crate) fn Rf_allocList(n: ::std::os::raw::c_int) -> SEXP;
480    /// Allocate a language object. Requires R >= 4.4.1; the portable
481    /// [`crate::gc_protect::ProtectScope::alloc_lang`] also supports R 4.4.0.
482    #[doc(alias = "allocLang")]
483    pub fn Rf_allocLang(n: ::std::os::raw::c_int) -> SEXP;
484    #[doc(alias = "allocS4Object")]
485    pub fn Rf_allocS4Object() -> SEXP;
486
487    // Pairlist construction — encapsulated by PairListExt trait
488    pub fn Rf_cons(car: SEXP, cdr: SEXP) -> SEXP;
489    pub fn Rf_lcons(car: SEXP, cdr: SEXP) -> SEXP;
490
491    // Attribute manipulation — encapsulated by SexpExt methods
492    #[doc(alias = "setAttrib")]
493    pub fn Rf_setAttrib(vec: SEXP, name: SEXP, val: SEXP) -> SEXP;
494
495    // Rinternals.h — scalar constructors; encapsulated by SEXP::scalar_*() / scalar_*_unchecked()
496    #[doc(alias = "ScalarComplex")]
497    pub fn Rf_ScalarComplex(x: Rcomplex) -> SEXP;
498    #[doc(alias = "ScalarInteger")]
499    pub fn Rf_ScalarInteger(x: ::std::os::raw::c_int) -> SEXP;
500    #[doc(alias = "ScalarLogical")]
501    pub fn Rf_ScalarLogical(x: ::std::os::raw::c_int) -> SEXP;
502    #[doc(alias = "ScalarRaw")]
503    pub fn Rf_ScalarRaw(x: Rbyte) -> SEXP;
504    #[doc(alias = "ScalarReal")]
505    pub fn Rf_ScalarReal(x: f64) -> SEXP;
506    #[doc(alias = "ScalarString")]
507    pub fn Rf_ScalarString(x: SEXP) -> SEXP;
508
509    // Rinternals.h
510    /// Non-API function - use DATAPTR_RO or DATAPTR_OR_NULL instead.
511    /// Only available with `nonapi` feature.
512    #[cfg(feature = "nonapi")]
513    pub(crate) fn DATAPTR(x: SEXP) -> *mut ::std::os::raw::c_void;
514    pub fn DATAPTR_RO(x: SEXP) -> *const ::std::os::raw::c_void;
515    pub fn DATAPTR_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_void;
516
517    // region: Cons Cell (Pairlist) Accessors
518    //
519    // R's pairlists (LISTSXP) are cons cells like in Lisp/Scheme. Each node has:
520    // - CAR: The value/head element
521    // - CDR: The rest/tail of the list (another pairlist or R_NilValue)
522    // - TAG: An optional name (symbol) for named lists/arguments
523    //
524    // Example R pairlist: list(a = 1, b = 2, 3)
525    // - First node:  CAR=1,    TAG="a",  CDR=<next node>
526    // - Second node: CAR=2,    TAG="b",  CDR=<next node>
527    // - Third node:  CAR=3,    TAG=NULL, CDR=R_NilValue
528    //
529    // Pairlists are used for:
530    // - Function arguments (formal parameters and actual arguments)
531    // - Language objects (calls)
532    // - Dotted pairs in old-style lists
533    //
534    // The names CAR/CDR come from Lisp:
535    // - CAR = "Contents of Address part of Register"
536    // - CDR = "Contents of Decrement part of Register" (pronounced "could-er")
537    //
538    // Modern R mostly uses generic vectors (VECSXP) instead of pairlists,
539    // but pairlists are still used internally for function calls.
540
541    // Pairlist accessors — basic ops encapsulated by PairListExt trait,
542    // compound accessors (CAAR, CADR, etc.) module-private since no callers exist.
543    pub fn CAR(e: SEXP) -> SEXP;
544    pub fn CDR(e: SEXP) -> SEXP;
545    pub fn CAAR(e: SEXP) -> SEXP;
546    pub fn CDAR(e: SEXP) -> SEXP;
547    pub fn CADR(e: SEXP) -> SEXP;
548    pub fn CDDR(e: SEXP) -> SEXP;
549    pub fn CADDR(e: SEXP) -> SEXP;
550    pub fn CADDDR(e: SEXP) -> SEXP;
551    pub fn CAD4R(e: SEXP) -> SEXP;
552    pub fn TAG(e: SEXP) -> SEXP;
553    pub fn SET_TAG(x: SEXP, y: SEXP);
554    pub fn SETCAR(x: SEXP, y: SEXP) -> SEXP;
555    pub fn SETCDR(x: SEXP, y: SEXP) -> SEXP;
556    pub fn SETCADR(x: SEXP, y: SEXP) -> SEXP;
557    pub fn SETCADDR(x: SEXP, y: SEXP) -> SEXP;
558    pub fn SETCADDDR(x: SEXP, y: SEXP) -> SEXP;
559    pub fn SETCAD4R(e: SEXP, y: SEXP) -> SEXP;
560    pub fn LOGICAL_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_int;
561    pub fn INTEGER_OR_NULL(x: SEXP) -> *const ::std::os::raw::c_int;
562    pub fn REAL_OR_NULL(x: SEXP) -> *const f64;
563    pub fn COMPLEX_OR_NULL(x: SEXP) -> *const Rcomplex;
564    pub fn RAW_OR_NULL(x: SEXP) -> *const Rbyte;
565
566    // Element-wise accessors (ALTREP-aware) — encapsulated by SexpExt methods
567    pub fn INTEGER_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int;
568    pub fn REAL_ELT(x: SEXP, i: R_xlen_t) -> f64;
569    pub fn LOGICAL_ELT(x: SEXP, i: R_xlen_t) -> ::std::os::raw::c_int;
570    pub fn COMPLEX_ELT(x: SEXP, i: R_xlen_t) -> Rcomplex;
571    pub fn RAW_ELT(x: SEXP, i: R_xlen_t) -> Rbyte;
572    pub fn VECTOR_ELT(x: SEXP, i: R_xlen_t) -> SEXP;
573    pub fn STRING_ELT(x: SEXP, i: R_xlen_t) -> SEXP;
574    pub fn SET_STRING_ELT(x: SEXP, i: R_xlen_t, v: SEXP);
575    pub fn SET_LOGICAL_ELT(x: SEXP, i: R_xlen_t, v: ::std::os::raw::c_int);
576    pub fn SET_INTEGER_ELT(x: SEXP, i: R_xlen_t, v: ::std::os::raw::c_int);
577    pub fn SET_REAL_ELT(x: SEXP, i: R_xlen_t, v: f64);
578    pub fn SET_COMPLEX_ELT(x: SEXP, i: R_xlen_t, v: Rcomplex);
579    pub fn SET_RAW_ELT(x: SEXP, i: R_xlen_t, v: Rbyte);
580    pub fn SET_VECTOR_ELT(x: SEXP, i: R_xlen_t, v: SEXP) -> SEXP;
581
582    // endregion
583
584    // region: SEXP metadata accessors
585
586    /// Get the length of a SEXP as `int` (for short vectors < 2^31).
587    ///
588    /// For long vectors, use `Rf_xlength()` instead.
589    /// Returns 0 for R_NilValue.
590    pub fn LENGTH(x: SEXP) -> ::std::os::raw::c_int;
591
592    /// Get the length of a SEXP as `R_xlen_t` (supports long vectors).
593    ///
594    /// ALTREP-aware: will call ALTREP Length method if needed.
595    pub fn XLENGTH(x: SEXP) -> R_xlen_t;
596
597    /// Non-zero if `x` has any attributes (`ATTRIB(x) != R_NilValue`).
598    ///
599    /// The API replacement for testing `ATTRIB`. R 4.5.0 added it: R 4.4's
600    /// libR does not export it, so a package that references it fails to
601    /// load there, and it is declared only when building against R >= 4.5
602    /// (`r_4_5`, #1905). `SexpExt::has_attributes` works on R 4.4 as well.
603    /// Unlike `attributes()`, it ignores the tag names of a pairlist.
604    #[cfg(r_4_5)]
605    #[doc(alias = "NO_ATTRIB")]
606    pub fn ANY_ATTRIB(x: SEXP) -> ::std::os::raw::c_int;
607
608    // Non-API attribute / header-bit accessors. `R CMD check` (R >= 4.6)
609    // reports each as a non-API entry point, so they need the `nonapi`
610    // feature. The API routes are `SexpExt::has_attributes`,
611    // `SexpExt::get_attr` / `SexpExt::set_attr`, `SexpExt::is_object`,
612    // `SexpExt::is_identical` and `DUPLICATE_ATTRIB` / `SHALLOW_DUPLICATE_ATTRIB`.
613
614    /// Get the attributes pairlist of a SEXP. Non-API (`nonapi` feature).
615    ///
616    /// Returns R_NilValue if no attributes. To ask whether there are any
617    /// attributes, use `SexpExt::has_attributes`; to read one, use
618    /// `SexpExt::get_attr`.
619    #[cfg(feature = "nonapi")]
620    pub fn ATTRIB(x: SEXP) -> SEXP;
621
622    /// Set the attributes pairlist of a SEXP. Non-API (`nonapi` feature).
623    ///
624    /// Prefer `SexpExt::set_attr` (one attribute) or `DUPLICATE_ATTRIB` /
625    /// `SHALLOW_DUPLICATE_ATTRIB` (copy all of them), which keep the object
626    /// bit consistent with the `class` attribute.
627    ///
628    /// # Safety
629    ///
630    /// `v` must be a pairlist or R_NilValue
631    #[cfg(feature = "nonapi")]
632    pub fn SET_ATTRIB(x: SEXP, v: SEXP);
633
634    /// Check if SEXP has the "object" bit set (has a class). Non-API
635    /// (`nonapi` feature); use `SexpExt::is_object` (`Rf_isObject`).
636    ///
637    /// Returns non-zero if object has a class attribute.
638    #[cfg(feature = "nonapi")]
639    pub fn OBJECT(x: SEXP) -> ::std::os::raw::c_int;
640
641    /// Set the "object" bit. Non-API (`nonapi` feature); setting a `class`
642    /// attribute with `SexpExt::set_class` sets it.
643    #[cfg(feature = "nonapi")]
644    pub fn SET_OBJECT(x: SEXP, v: ::std::os::raw::c_int);
645
646    /// Get the `gp` header bits. Non-API (`nonapi` feature).
647    ///
648    /// Not a factor's levels: those are the `levels` attribute
649    /// (`SexpExt::get_levels`).
650    #[cfg(feature = "nonapi")]
651    pub fn LEVELS(x: SEXP) -> ::std::os::raw::c_int;
652
653    /// Set the `gp` header bits. Non-API (`nonapi` feature).
654    ///
655    /// Returns the value that was set.
656    #[cfg(feature = "nonapi")]
657    pub fn SETLEVELS(x: SEXP, v: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
658
659    // endregion
660
661    // region: ALTREP support — data2 encapsulated by AltrepSexpExt; data1 via standalone helpers
662
663    // Issue #112 cat. 6: pub(crate) — no AltrepSexpExt method yet; available for future callers
664    pub(crate) fn ALTREP_CLASS(x: SEXP) -> SEXP;
665    pub fn R_altrep_data1(x: SEXP) -> SEXP;
666    pub fn R_altrep_data2(x: SEXP) -> SEXP;
667    pub fn R_set_altrep_data1(x: SEXP, v: SEXP);
668    pub fn R_set_altrep_data2(x: SEXP, v: SEXP);
669
670    /// Check if a SEXP is an ALTREP object (returns non-zero if true).
671    ///
672    /// Use `SexpExt::is_altrep()` instead of calling this directly.
673    pub fn ALTREP(x: SEXP) -> ::std::os::raw::c_int;
674
675    // endregion
676
677    // region: Vector data accessors (mutable pointers)
678    // Issue #112 cat. 5: kept pub(crate) — raw pointer access needed in RNativeType impls and scattered callers;
679    //   partial migration to SexpExt::as_mut_slice() tracked in follow-up issue
680
681    /// Get mutable pointer to logical vector data.
682    ///
683    /// For ALTREP vectors, this may force materialization.
684    /// Get mutable pointer to logical vector data.
685    ///
686    /// For ALTREP vectors, this may force materialization.
687    /// Prefer `SexpExt::set_logical_elt()` / `SexpExt::logical_elt()`.
688    pub(crate) fn LOGICAL(x: SEXP) -> *mut ::std::os::raw::c_int;
689
690    /// Get mutable pointer to integer vector data.
691    ///
692    /// For ALTREP vectors, this may force materialization.
693    /// Prefer `SexpExt::set_integer_elt()` / `SexpExt::integer_elt()`.
694    pub(crate) fn INTEGER(x: SEXP) -> *mut ::std::os::raw::c_int;
695
696    /// Get mutable pointer to real vector data.
697    ///
698    /// For ALTREP vectors, this may force materialization.
699    /// Prefer `SexpExt::set_real_elt()` / `SexpExt::real_elt()`.
700    pub(crate) fn REAL(x: SEXP) -> *mut f64;
701
702    /// Get mutable pointer to complex vector data.
703    ///
704    /// For ALTREP vectors, this may force materialization.
705    /// Prefer `SexpExt::set_complex_elt()` / `SexpExt::complex_elt()`.
706    pub(crate) fn COMPLEX(x: SEXP) -> *mut Rcomplex;
707
708    /// Get mutable pointer to raw vector data.
709    ///
710    /// For ALTREP vectors, this may force materialization.
711    /// Prefer `SexpExt::set_raw_elt()` / `SexpExt::raw_elt()`.
712    pub(crate) fn RAW(x: SEXP) -> *mut Rbyte;
713
714    // endregion
715
716    // region: User interrupt and utilities
717
718    // utils.h
719    pub fn R_CheckUserInterrupt();
720
721    // endregion
722
723    // region: Type checking — encapsulated by SexpExt::type_of()
724
725    pub fn TYPEOF(x: SEXP) -> SEXPTYPE;
726
727    // endregion
728
729    // Symbol creation and access
730    #[doc(alias = "install")]
731    pub fn Rf_install(name: *const ::std::os::raw::c_char) -> SEXP;
732    /// Get the print name (CHARSXP) of a symbol (SYMSXP)
733    pub fn PRINTNAME(x: SEXP) -> SEXP;
734    /// Get the C string pointer from a CHARSXP — encapsulated by SexpExt::r_char()
735    #[doc(alias = "CHAR")]
736    pub fn R_CHAR(x: SEXP) -> *const ::std::os::raw::c_char;
737
738    // Attribute access
739    // Attribute accessors — encapsulated by SexpExt methods
740    /// Read an attribute from an object by symbol (e.g. `R_NamesSymbol`).
741    ///
742    /// Returns `R_NilValue` if the attribute is not set.
743    #[doc(alias = "getAttrib")]
744    pub fn Rf_getAttrib(vec: SEXP, name: SEXP) -> SEXP;
745    /// Set the `names` attribute; returns the updated object.
746    #[doc(alias = "namesgets")]
747    pub fn Rf_namesgets(vec: SEXP, val: SEXP) -> SEXP;
748    /// Set the `dim` attribute; returns the updated object.
749    #[doc(alias = "dimgets")]
750    pub fn Rf_dimgets(vec: SEXP, val: SEXP) -> SEXP;
751
752    // Duplication
753    #[doc(alias = "duplicate")]
754    pub fn Rf_duplicate(s: SEXP) -> SEXP;
755    #[doc(alias = "shallow_duplicate")]
756    pub fn Rf_shallow_duplicate(s: SEXP) -> SEXP;
757    /// Mark an object as shared for good: R code that modifies it (`x[1] <- 0`,
758    /// `attr(x, "a") <- 1`) copies it first, whatever else references it.
759    /// Allocates nothing.
760    pub fn MARK_NOT_MUTABLE(x: SEXP);
761
762    // Object comparison
763    /// Check if two R objects are identical (deep semantic equality).
764    ///
765    /// This is the C implementation of R's `identical()` function.
766    ///
767    /// # Flags
768    ///
769    /// Use the `IDENT_*` constants below. Flags are inverted: set bit = disable that check.
770    ///
771    /// **Default from R**: `IDENT_USE_CLOENV` (16) - ignore closure environments
772    ///
773    /// # Returns
774    ///
775    /// `TRUE` if identical, `FALSE` otherwise.
776    ///
777    /// # Performance
778    ///
779    /// Fast-path: Returns `TRUE` immediately if pointers are equal.
780    pub fn R_compute_identical(x: SEXP, y: SEXP, flags: ::std::os::raw::c_int) -> Rboolean;
781}
782
783/// Flags for `R_compute_identical` (bitmask, inverted logic: set bit = disable check).
784pub const IDENT_NUM_AS_BITS: ::std::os::raw::c_int = 1;
785/// Treat all NAs as identical (ignore NA payload differences).
786pub const IDENT_NA_AS_BITS: ::std::os::raw::c_int = 2;
787/// Compare attributes in order (not as a set).
788pub const IDENT_ATTR_BY_ORDER: ::std::os::raw::c_int = 4;
789/// Include bytecode in comparison.
790pub const IDENT_USE_BYTECODE: ::std::os::raw::c_int = 8;
791/// Include closure environments in comparison.
792pub const IDENT_USE_CLOENV: ::std::os::raw::c_int = 16;
793/// Include source references in comparison.
794pub const IDENT_USE_SRCREF: ::std::os::raw::c_int = 32;
795/// Compare external pointers as references (not by address).
796pub const IDENT_EXTPTR_AS_REF: ::std::os::raw::c_int = 64;
797
798// Additional checked R API declarations used by conversion and reflection code.
799#[allow(missing_docs)]
800#[allow(missing_docs)]
unsafe extern "C-unwind" {
    #[doc(alias = "asLogical")]
    #[doc = "Unchecked FFI binding for `Rf_asLogical`."]
    #[doc = "Generated from source location line 804, 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 806, 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 808, 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 810, 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 812, 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 816, 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 818, 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 822, 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 826, 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 828, 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 830, 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 832, 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 834, 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 836, 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 838, 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 840, 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 844, 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 846, 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 848, 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 850, 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 852, 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 854, 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 856, 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 858, 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 860, 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 862, 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 864, 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 866, 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 870, 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 872, 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 874, 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 876, 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 892, 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 903, 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 906, 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 908, 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 920, 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 922, 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 924, 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 926, 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 931, 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 937, 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 941, 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 943, 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 951, 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 961, 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 971, 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 981, 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 992, 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 804, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_asLogical_unchecked(x) })
}
#[doc(alias = "asInteger")]
#[doc =
"Checked wrapper for `Rf_asInteger`. Calls `Rf_asInteger_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 806, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_asInteger_unchecked(x) })
}
#[doc(alias = "asReal")]
#[doc =
"Checked wrapper for `Rf_asReal`. Calls `Rf_asReal_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 808, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_asReal_unchecked(x) })
}
#[doc(alias = "asChar")]
#[doc =
"Checked wrapper for `Rf_asChar`. Calls `Rf_asChar_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 810, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_asChar_unchecked(x) })
}
#[doc(alias = "coerceVector")]
#[doc =
"Checked wrapper for `Rf_coerceVector`. Calls `Rf_coerceVector_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 812, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_coerceVector_unchecked(v, sexptype) })
}
#[doc(alias = "nrows")]
#[doc =
"Checked wrapper for `Rf_nrows`. Calls `Rf_nrows_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 816, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { Rf_nrows_unchecked(x) })
}
#[doc(alias = "ncols")]
#[doc =
"Checked wrapper for `Rf_ncols`. Calls `Rf_ncols_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 818, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { Rf_ncols_unchecked(x) })
}
#[doc(alias = "inherits")]
#[doc =
"Checked wrapper for `Rf_inherits`. Calls `Rf_inherits_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 822, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_inherits_unchecked(x, klass) })
}
#[doc(alias = "isNull")]
#[doc =
"Checked wrapper for `Rf_isNull`. Calls `Rf_isNull_unchecked` inside `with_r_thread`, which panics off R's main 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_isNull(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isNull_unchecked(s) })
}
#[doc(alias = "isSymbol")]
#[doc =
"Checked wrapper for `Rf_isSymbol`. Calls `Rf_isSymbol_unchecked` inside `with_r_thread`, which panics off R's main 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_isSymbol(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isSymbol_unchecked(s) })
}
#[doc(alias = "isLogical")]
#[doc =
"Checked wrapper for `Rf_isLogical`. Calls `Rf_isLogical_unchecked` inside `with_r_thread`, which panics off R's main 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_isLogical(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isLogical_unchecked(s) })
}
#[doc(alias = "isReal")]
#[doc =
"Checked wrapper for `Rf_isReal`. Calls `Rf_isReal_unchecked` inside `with_r_thread`, which panics off R's main 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_isReal(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isReal_unchecked(s) })
}
#[doc(alias = "isComplex")]
#[doc =
"Checked wrapper for `Rf_isComplex`. Calls `Rf_isComplex_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 834, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isComplex_unchecked(s) })
}
#[doc(alias = "isExpression")]
#[doc =
"Checked wrapper for `Rf_isExpression`. Calls `Rf_isExpression_unchecked` inside `with_r_thread`, which panics off R's main 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_isExpression(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isExpression_unchecked(s) })
}
#[doc(alias = "isEnvironment")]
#[doc =
"Checked wrapper for `Rf_isEnvironment`. Calls `Rf_isEnvironment_unchecked` inside `with_r_thread`, which panics off R's main 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_isEnvironment(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isEnvironment_unchecked(s) })
}
#[doc(alias = "isString")]
#[doc =
"Checked wrapper for `Rf_isString`. Calls `Rf_isString_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 840, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isString_unchecked(s) })
}
#[doc(alias = "isArray")]
#[doc =
"Checked wrapper for `Rf_isArray`. Calls `Rf_isArray_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 844, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isArray_unchecked(s) })
}
#[doc(alias = "isMatrix")]
#[doc =
"Checked wrapper for `Rf_isMatrix`. Calls `Rf_isMatrix_unchecked` inside `with_r_thread`, which panics off R's main 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_isMatrix(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isMatrix_unchecked(s) })
}
#[doc(alias = "isList")]
#[doc =
"Checked wrapper for `Rf_isList`. Calls `Rf_isList_unchecked` inside `with_r_thread`, which panics off R's main 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_isList(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isList_unchecked(s) })
}
#[doc(alias = "isNewList")]
#[doc =
"Checked wrapper for `Rf_isNewList`. Calls `Rf_isNewList_unchecked` inside `with_r_thread`, which panics off R's main 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_isNewList(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isNewList_unchecked(s) })
}
#[doc(alias = "isPairList")]
#[doc =
"Checked wrapper for `Rf_isPairList`. Calls `Rf_isPairList_unchecked` inside `with_r_thread`, which panics off R's main 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_isPairList(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isPairList_unchecked(s) })
}
#[doc(alias = "isFunction")]
#[doc =
"Checked wrapper for `Rf_isFunction`. Calls `Rf_isFunction_unchecked` inside `with_r_thread`, which panics off R's main 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_isFunction(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isFunction_unchecked(s) })
}
#[doc(alias = "isPrimitive")]
#[doc =
"Checked wrapper for `Rf_isPrimitive`. Calls `Rf_isPrimitive_unchecked` inside `with_r_thread`, which panics off R's main 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_isPrimitive(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isPrimitive_unchecked(s) })
}
#[doc(alias = "isLanguage")]
#[doc =
"Checked wrapper for `Rf_isLanguage`. Calls `Rf_isLanguage_unchecked` inside `with_r_thread`, which panics off R's main 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_isLanguage(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isLanguage_unchecked(s) })
}
#[doc(alias = "isDataFrame")]
#[doc =
"Checked wrapper for `Rf_isDataFrame`. Calls `Rf_isDataFrame_unchecked` inside `with_r_thread`, which panics off R's main 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_isDataFrame(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isDataFrame_unchecked(s) })
}
#[doc(alias = "isFactor")]
#[doc =
"Checked wrapper for `Rf_isFactor`. Calls `Rf_isFactor_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 862, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isFactor_unchecked(s) })
}
#[doc(alias = "isInteger")]
#[doc =
"Checked wrapper for `Rf_isInteger`. Calls `Rf_isInteger_unchecked` inside `with_r_thread`, which panics off R's main 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_isInteger(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isInteger_unchecked(s) })
}
#[doc(alias = "isObject")]
#[doc =
"Checked wrapper for `Rf_isObject`. Calls `Rf_isObject_unchecked` inside `with_r_thread`, which panics off R's main 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_isObject(s: SEXP) -> Rboolean {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isObject_unchecked(s) })
}
#[doc(alias = "elt")]
#[doc =
"Checked wrapper for `Rf_elt`. Calls `Rf_elt_unchecked` inside `with_r_thread`, which panics off R's main 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_elt(list: SEXP, i: ::std::os::raw::c_int) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_elt_unchecked(list, i) })
}
#[doc(alias = "lastElt")]
#[doc =
"Checked wrapper for `Rf_lastElt`. Calls `Rf_lastElt_unchecked` inside `with_r_thread`, which panics off R's main 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_lastElt(list: SEXP) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_lastElt_unchecked(list) })
}
#[doc(alias = "nthcdr")]
#[doc =
"Checked wrapper for `Rf_nthcdr`. Calls `Rf_nthcdr_unchecked` inside `with_r_thread`, which panics off R's main 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_nthcdr(list: SEXP, n: ::std::os::raw::c_int) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_nthcdr_unchecked(list, n) })
}
#[doc(alias = "listAppend")]
#[doc =
"Checked wrapper for `Rf_listAppend`. Calls `Rf_listAppend_unchecked` inside `with_r_thread`, which panics off R's main 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_listAppend(s: SEXP, t: SEXP) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_listAppend_unchecked(s, t) })
}
#[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` inside `with_r_thread`, which panics off R's main 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_classgets(vec: SEXP, klass: SEXP) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_classgets_unchecked(vec, klass) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 903, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_dimnamesgets_unchecked(vec, val) })
}
#[doc(alias = "GetRowNames")]
#[doc =
"Checked wrapper for `Rf_GetRowNames`. Calls `Rf_GetRowNames_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 906, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_GetRowNames_unchecked(dimnames) })
}
#[doc(alias = "GetColNames")]
#[doc =
"Checked wrapper for `Rf_GetColNames`. Calls `Rf_GetColNames_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 908, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_GetColNames_unchecked(dimnames) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 920, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_getVarEx_unchecked(sym, rho, inherits, ifnotfound) })
}
#[doc(alias = "defineVar")]
#[doc =
"Checked wrapper for `Rf_defineVar`. Calls `Rf_defineVar_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 922, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_defineVar_unchecked(symbol, value, rho) })
}
#[doc(alias = "setVar")]
#[doc =
"Checked wrapper for `Rf_setVar`. Calls `Rf_setVar_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 924, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_setVar_unchecked(symbol, value, rho) })
}
#[doc(alias = "findFun")]
#[doc =
"Checked wrapper for `Rf_findFun`. Calls `Rf_findFun_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 926, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_findFun_unchecked(symbol, rho) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 931, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_FindNamespace_unchecked(info) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 937, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_GetCurrentEnv_unchecked() })
}
#[doc(alias = "eval")]
#[doc =
"Checked wrapper for `Rf_eval`. Calls `Rf_eval_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 941, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_eval_unchecked(expr, rho) })
}
#[doc(alias = "applyClosure")]
#[doc =
"Checked wrapper for `Rf_applyClosure`. Calls `Rf_applyClosure_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 943, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe {
                Rf_applyClosure_unchecked(call, op, args, rho, suppliedvars,
                    check)
            })
}
#[doc =
"Checked wrapper for `R_tryEval`. Calls `R_tryEval_unchecked` inside `with_r_thread`, which panics off R's main 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_tryEval(expr: SEXP, env: SEXP,
    error_occurred: *mut ::std::os::raw::c_int) -> SEXP {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_tryEval_unchecked(expr, env, error_occurred) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 961, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ToplevelExec_unchecked(fun, data) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 971, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_tryCatchError_unchecked(body, bdata, handler, hdata) })
}
#[doc =
"Checked wrapper for `R_forceAndCall`. Calls `R_forceAndCall_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 981, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_forceAndCall_unchecked(e, n, rho) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 992, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ParseVector_unchecked(text, n, status, srcfile) })
}#[r_ffi_checked]
801unsafe extern "C-unwind" {
802    // Type coercion — encapsulated by SexpExt methods
803    #[doc(alias = "asLogical")]
804    pub fn Rf_asLogical(x: SEXP) -> ::std::os::raw::c_int;
805    #[doc(alias = "asInteger")]
806    pub fn Rf_asInteger(x: SEXP) -> ::std::os::raw::c_int;
807    #[doc(alias = "asReal")]
808    pub fn Rf_asReal(x: SEXP) -> f64;
809    #[doc(alias = "asChar")]
810    pub fn Rf_asChar(x: SEXP) -> SEXP;
811    #[doc(alias = "coerceVector")]
812    pub fn Rf_coerceVector(v: SEXP, sexptype: SEXPTYPE) -> SEXP;
813
814    // Matrix utilities — no callers outside ffi.rs
815    #[doc(alias = "nrows")]
816    pub fn Rf_nrows(x: SEXP) -> ::std::os::raw::c_int;
817    #[doc(alias = "ncols")]
818    pub fn Rf_ncols(x: SEXP) -> ::std::os::raw::c_int;
819
820    // Inheritance checking — encapsulated by SexpExt::inherits_class()
821    #[doc(alias = "inherits")]
822    pub fn Rf_inherits(x: SEXP, klass: *const ::std::os::raw::c_char) -> Rboolean;
823
824    // Type checking predicates — encapsulated by SexpExt type-check methods
825    #[doc(alias = "isNull")]
826    pub fn Rf_isNull(s: SEXP) -> Rboolean;
827    #[doc(alias = "isSymbol")]
828    pub fn Rf_isSymbol(s: SEXP) -> Rboolean;
829    #[doc(alias = "isLogical")]
830    pub fn Rf_isLogical(s: SEXP) -> Rboolean;
831    #[doc(alias = "isReal")]
832    pub fn Rf_isReal(s: SEXP) -> Rboolean;
833    #[doc(alias = "isComplex")]
834    pub fn Rf_isComplex(s: SEXP) -> Rboolean;
835    #[doc(alias = "isExpression")]
836    pub fn Rf_isExpression(s: SEXP) -> Rboolean;
837    #[doc(alias = "isEnvironment")]
838    pub fn Rf_isEnvironment(s: SEXP) -> Rboolean;
839    #[doc(alias = "isString")]
840    pub fn Rf_isString(s: SEXP) -> Rboolean;
841
842    // Composite type checking (from inline functions)
843    #[doc(alias = "isArray")]
844    pub fn Rf_isArray(s: SEXP) -> Rboolean;
845    #[doc(alias = "isMatrix")]
846    pub fn Rf_isMatrix(s: SEXP) -> Rboolean;
847    #[doc(alias = "isList")]
848    pub fn Rf_isList(s: SEXP) -> Rboolean;
849    #[doc(alias = "isNewList")]
850    pub fn Rf_isNewList(s: SEXP) -> Rboolean;
851    #[doc(alias = "isPairList")]
852    pub fn Rf_isPairList(s: SEXP) -> Rboolean;
853    #[doc(alias = "isFunction")]
854    pub fn Rf_isFunction(s: SEXP) -> Rboolean;
855    #[doc(alias = "isPrimitive")]
856    pub fn Rf_isPrimitive(s: SEXP) -> Rboolean;
857    #[doc(alias = "isLanguage")]
858    pub fn Rf_isLanguage(s: SEXP) -> Rboolean;
859    #[doc(alias = "isDataFrame")]
860    pub fn Rf_isDataFrame(s: SEXP) -> Rboolean;
861    #[doc(alias = "isFactor")]
862    pub fn Rf_isFactor(s: SEXP) -> Rboolean;
863    #[doc(alias = "isInteger")]
864    pub fn Rf_isInteger(s: SEXP) -> Rboolean;
865    #[doc(alias = "isObject")]
866    pub fn Rf_isObject(s: SEXP) -> Rboolean;
867
868    // Pairlist utilities
869    #[doc(alias = "elt")]
870    pub fn Rf_elt(list: SEXP, i: ::std::os::raw::c_int) -> SEXP;
871    #[doc(alias = "lastElt")]
872    pub fn Rf_lastElt(list: SEXP) -> SEXP;
873    #[doc(alias = "nthcdr")]
874    pub fn Rf_nthcdr(list: SEXP, n: ::std::os::raw::c_int) -> SEXP;
875    #[doc(alias = "listAppend")]
876    pub fn Rf_listAppend(s: SEXP, t: SEXP) -> SEXP;
877
878    // More attribute setters (using R's "gets" suffix convention)
879    //
880    // See "Attribute access" section above for explanation of the "gets" suffix.
881    // These are setter functions equivalent to R's `attr(x) <- value` syntax.
882
883    /// Set the class attribute of a vector.
884    ///
885    /// Equivalent to R's `class(vec) <- klass` syntax.
886    /// The "gets" suffix indicates this is a setter function.
887    ///
888    /// # Returns
889    ///
890    /// Returns the modified vector (like all "*gets" functions).
891    #[doc(alias = "classgets")]
892    pub fn Rf_classgets(vec: SEXP, klass: SEXP) -> SEXP;
893
894    /// Set the dimnames attribute of an array/matrix.
895    ///
896    /// Equivalent to R's `dimnames(vec) <- val` syntax.
897    /// The "gets" suffix indicates this is a setter function.
898    ///
899    /// # Returns
900    ///
901    /// Returns the modified vector.
902    #[doc(alias = "dimnamesgets")]
903    pub fn Rf_dimnamesgets(vec: SEXP, val: SEXP) -> SEXP;
904    // Issue #112 cat. 10: kept pub(crate) — 2 callers each in factor.rs/matrix helpers; wrapping adds no value
905    #[doc(alias = "GetRowNames")]
906    pub(crate) fn Rf_GetRowNames(dimnames: SEXP) -> SEXP;
907    #[doc(alias = "GetColNames")]
908    pub(crate) fn Rf_GetColNames(dimnames: SEXP) -> SEXP;
909
910    // Environment operations
911    /// Single-frame (`inherits = FALSE`) or inherited variable lookup with an
912    /// `ifnotfound` default — the API-blessed replacement for
913    /// `Rf_findVarInFrame`. R 4.5.0 added it, so it is declared only when
914    /// building against R >= 4.5 (`r_4_5`, #1905); for R 4.4, evaluate
915    /// `base::get0()` instead.
916    /// **Longjmps** if `rho` is not an environment or
917    /// the binding is `R_MissingArg`; forces promises.
918    #[cfg(r_4_5)]
919    #[doc(alias = "getVarEx")]
920    pub fn R_getVarEx(sym: SEXP, rho: SEXP, inherits: Rboolean, ifnotfound: SEXP) -> SEXP;
921    #[doc(alias = "defineVar")]
922    pub fn Rf_defineVar(symbol: SEXP, value: SEXP, rho: SEXP);
923    #[doc(alias = "setVar")]
924    pub fn Rf_setVar(symbol: SEXP, value: SEXP, rho: SEXP);
925    #[doc(alias = "findFun")]
926    pub fn Rf_findFun(symbol: SEXP, rho: SEXP) -> SEXP;
927
928    /// Find a registered namespace by name. **Longjmps on error** — prefer
929    /// `REnv::package_namespace()` which wraps this safely.
930    #[doc(alias = "FindNamespace")]
931    pub fn R_FindNamespace(info: SEXP) -> SEXP;
932
933    // Issue #112 cat. 9: kept pub(crate) — R_GetCurrentEnv used from s4_helpers.rs
934    /// Return the current execution environment (innermost closure on call
935    /// stack, or `R_GlobalEnv` if none).
936    #[doc(alias = "GetCurrentEnv")]
937    pub(crate) fn R_GetCurrentEnv() -> SEXP;
938
939    // Evaluation
940    #[doc(alias = "eval")]
941    pub fn Rf_eval(expr: SEXP, rho: SEXP) -> SEXP;
942    #[doc(alias = "applyClosure")]
943    pub fn Rf_applyClosure(
944        call: SEXP,
945        op: SEXP,
946        args: SEXP,
947        rho: SEXP,
948        suppliedvars: SEXP,
949        check: Rboolean,
950    ) -> SEXP;
951    pub fn R_tryEval(expr: SEXP, env: SEXP, error_occurred: *mut ::std::os::raw::c_int) -> SEXP;
952    // Kept pub(crate): the safe entries are `RCall::eval` / `r_eval_str`
953    // (expression.rs), which combine the two below, and
954    // `try_eval_with_handlers`, which runs `R_tryCatchError` alone inside its
955    // own `R_UnwindProtect`.
956    /// Run `fun(data)` in a new top-level context: the caller's condition
957    /// handlers and restarts are hidden from it, and any jump out of it
958    /// (an unhandled error, an interrupt, an `abort` restart) stops here.
959    /// `TRUE` when `fun` returned, `FALSE` after such a jump.
960    #[doc(alias = "ToplevelExec")]
961    pub(crate) fn R_ToplevelExec(
962        fun: ::std::option::Option<unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void)>,
963        data: *mut ::std::os::raw::c_void,
964    ) -> Rboolean;
965    /// Call `body(bdata)` with an exiting handler for conditions of class
966    /// `error`: on such a condition, `handler(cond, hdata)` runs after the
967    /// unwind and its value is returned. Built on R's `tryCatch()`, so the
968    /// caller's handlers stay visible to `body` (wrap it in
969    /// [`R_ToplevelExec`] to hide them).
970    #[doc(alias = "tryCatchError")]
971    pub(crate) fn R_tryCatchError(
972        body: ::std::option::Option<
973            unsafe extern "C-unwind" fn(*mut ::std::os::raw::c_void) -> SEXP,
974        >,
975        bdata: *mut ::std::os::raw::c_void,
976        handler: ::std::option::Option<
977            unsafe extern "C-unwind" fn(SEXP, *mut ::std::os::raw::c_void) -> SEXP,
978        >,
979        hdata: *mut ::std::os::raw::c_void,
980    ) -> SEXP;
981    pub fn R_forceAndCall(e: SEXP, n: ::std::os::raw::c_int, rho: SEXP) -> SEXP;
982
983    /// Parse R source text into an EXPRSXP (a list of parsed expressions).
984    ///
985    /// `text` is a STRSXP holding the source, `n` is the number of expressions
986    /// to parse (`-1` for all), `status` receives the [`ParseStatus`] outcome,
987    /// and `srcfile` is a srcref/`R_NilValue`. Allocates; protect the result.
988    ///
989    /// Prefer the safe [`crate::expression::r_eval_str`] wrapper, which does the
990    /// STRSXP construction, status check, and protection bookkeeping for you.
991    #[doc(alias = "ParseVector")]
992    pub fn R_ParseVector(
993        text: SEXP,
994        n: ::std::os::raw::c_int,
995        status: *mut ParseStatus,
996        srcfile: SEXP,
997    ) -> SEXP;
998}
999
1000/// Outcome of [`R_ParseVector`] (from `R_ext/Parse.h`).
1001///
1002/// `PARSE_NULL` is never returned by `R_ParseVector`; the meaningful success
1003/// value is [`ParseStatus::PARSE_OK`]. The remaining variants indicate parse
1004/// failures (`PARSE_ERROR`), incomplete input (`PARSE_INCOMPLETE`), or
1005/// end-of-input (`PARSE_EOF`).
1006#[allow(non_camel_case_types)]
1007#[repr(i32)]
1008#[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::debug_c_like_enum_write_str(f,
            "PARSE_NULL PARSE_OK PARSE_INCOMPLETE PARSE_ERROR PARSE_EOF",
            match self {
                ParseStatus::PARSE_NULL => 0usize,
                ParseStatus::PARSE_OK => 11usize,
                ParseStatus::PARSE_INCOMPLETE => 20usize,
                ParseStatus::PARSE_ERROR => 37usize,
                ParseStatus::PARSE_EOF => 49usize,
            })
    }
}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)]
1009pub enum ParseStatus {
1010    /// Never returned by `R_ParseVector`; the default-initialized sentinel.
1011    PARSE_NULL,
1012    /// Parse succeeded.
1013    PARSE_OK,
1014    /// Input ended mid-expression (e.g. an unbalanced delimiter).
1015    PARSE_INCOMPLETE,
1016    /// A syntax error was encountered.
1017    PARSE_ERROR,
1018    /// End of input reached with no further expressions.
1019    PARSE_EOF,
1020}
1021
1022// region: Connections API (R_ext/Connections.h)
1023//
1024// Gated behind `connections` feature because R's connection API is explicitly UNSTABLE.
1025// From R_ext/Connections.h:
1026//   "IMPORTANT: we do not expect future connection APIs to be
1027//    backward-compatible so if you use this, you *must* check the
1028//    version and proceeds only if it matches what you expect.
1029//
1030//    We explicitly reserve the right to change the connection
1031//    implementation without a compatibility layer."
1032//
1033// Use with caution and always check R_CONNECTIONS_VERSION.
1034// Issue #112 cat. 8: kept pub(crate) — feature-gated behind `connections`; behind Connection type for users
1035#[r_ffi_checked]
1036#[cfg(feature = "connections")]
1037unsafe extern "C-unwind" {
1038    /// Create a new custom connection.
1039    ///
1040    /// # WARNING
1041    ///
1042    /// This API is UNSTABLE. Check `R_CONNECTIONS_VERSION` before use.
1043    /// The connection implementation may change without notice.
1044    ///
1045    /// # Safety
1046    ///
1047    /// - `description`, `mode`, and `class_name` must be valid C strings
1048    /// - `ptr` must be a valid pointer to store the connection handle
1049    pub(crate) fn R_new_custom_connection(
1050        description: *const ::std::os::raw::c_char,
1051        mode: *const ::std::os::raw::c_char,
1052        class_name: *const ::std::os::raw::c_char,
1053        ptr: *mut Rconnection,
1054    ) -> SEXP;
1055
1056    /// Read from a connection.
1057    ///
1058    /// # WARNING
1059    ///
1060    /// This API is UNSTABLE and may change.
1061    ///
1062    /// # Safety
1063    ///
1064    /// - `con` must be a valid Rconnection handle
1065    /// - `buf` must be a valid buffer with at least `n` bytes
1066    pub(crate) fn R_ReadConnection(
1067        con: Rconnection,
1068        buf: *mut ::std::os::raw::c_void,
1069        n: usize,
1070    ) -> usize;
1071
1072    /// Write to a connection.
1073    ///
1074    /// # WARNING
1075    ///
1076    /// This API is UNSTABLE and may change.
1077    ///
1078    /// # Safety
1079    ///
1080    /// - `con` must be a valid Rconnection handle
1081    /// - `buf` must contain at least `n` valid bytes
1082    pub(crate) fn R_WriteConnection(
1083        con: Rconnection,
1084        buf: *const ::std::os::raw::c_void,
1085        n: usize,
1086    ) -> usize;
1087
1088    /// Get a connection from a SEXP.
1089    ///
1090    /// # WARNING
1091    ///
1092    /// This API is UNSTABLE and may change.
1093    /// Added in R 3.3.0.
1094    ///
1095    /// # Safety
1096    ///
1097    /// - `sConn` must be a valid connection SEXP
1098    pub(crate) fn R_GetConnection(sConn: SEXP) -> Rconnection;
1099}
1100// endregion: Connections API
1101
1102/// Check if a SEXP is an S4 object.
1103///
1104/// # Safety
1105///
1106/// - `arg1` must be a valid SEXP
1107#[allow(non_snake_case)]
1108pub unsafe fn Rf_isS4(arg1: SEXP) -> Rboolean {
1109    unsafe extern "C-unwind" {
1110        #[link_name = "Rf_isS4"]
1111        pub fn Rf_isS4_original(arg1: SEXP) -> u32;
1112    }
1113
1114    unsafe {
1115        if Rf_isS4_original(arg1) == 0 {
1116            Rboolean::FALSE
1117        } else {
1118            Rboolean::TRUE
1119        }
1120    }
1121}
1122
1123// region: registration!
1124
1125#[repr(C)]
1126#[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_struct_field1_finish(f, "DllInfo",
            &&self.0)
    }
}Debug)]
1127/// Opaque dynamic library descriptor from R.
1128pub struct DllInfo(::std::os::raw::c_void);
1129
1130/// Generic dynamic library function pointer.
1131///
1132/// R defines this as `void *(*)(void)` - a function taking no arguments and
1133/// returning `void*`. This is used for method registration and external pointer
1134/// functions. The actual function signatures vary; callers cast to the appropriate
1135/// concrete function type before calling.
1136///
1137/// We use `fn() -> *mut c_void` to match R's signature. The function pointer is
1138/// stored generically and cast to the appropriate type when called by R.
1139#[allow(non_camel_case_types)]
1140pub type DL_FUNC =
1141    ::std::option::Option<unsafe extern "C-unwind" fn() -> *mut ::std::os::raw::c_void>;
1142
1143/// Type descriptor for native primitive arguments in .C/.Fortran calls.
1144///
1145/// This is used in `R_CMethodDef` and `R_FortranMethodDef` to specify
1146/// argument types for type checking.
1147#[allow(non_camel_case_types)]
1148pub type R_NativePrimitiveArgType = ::std::os::raw::c_uint;
1149
1150/// Method definition for .C interface routines.
1151///
1152/// Used to register C functions callable via `.C()` from R.
1153#[repr(C)]
1154#[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 fun numArgs types", &self.name, &self.fun,
            &self.numArgs, &&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)]
1155#[allow(non_camel_case_types)]
1156#[allow(non_snake_case)]
1157pub struct R_CMethodDef {
1158    /// Exported symbol name.
1159    pub name: *const ::std::os::raw::c_char,
1160    /// Function pointer implementing the routine.
1161    pub fun: DL_FUNC,
1162    /// Declared arity.
1163    pub numArgs: ::std::os::raw::c_int,
1164    /// Optional array of argument types for type checking. May be null.
1165    pub types: *const R_NativePrimitiveArgType,
1166}
1167
1168/// Method definition for .Fortran interface routines.
1169///
1170/// Structurally identical to `R_CMethodDef`.
1171#[allow(non_camel_case_types)]
1172pub type R_FortranMethodDef = R_CMethodDef;
1173
1174/// Method definition for .Call interface routines.
1175///
1176/// Used to register C functions callable via `.Call()` from R.
1177/// Unlike `.C()` routines, `.Call()` functions receive and return SEXP values directly.
1178#[repr(C)]
1179#[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 fun numArgs", &self.name, &self.fun,
            &&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)]
1180#[allow(non_camel_case_types)]
1181#[allow(non_snake_case)]
1182pub struct R_CallMethodDef {
1183    /// Exported symbol name.
1184    pub name: *const ::std::os::raw::c_char,
1185    /// Function pointer implementing the routine.
1186    pub fun: DL_FUNC,
1187    /// Declared arity.
1188    pub numArgs: ::std::os::raw::c_int,
1189}
1190
1191// SAFETY: `name` points to a static CStr literal, `fun` is a function pointer.
1192// Both are valid for program lifetime and safe to read from any thread.
1193unsafe impl Sync for R_CallMethodDef {}
1194unsafe impl Send for R_CallMethodDef {}
1195
1196/// Method definition for .External interface routines.
1197///
1198/// Structurally identical to `R_CallMethodDef`.
1199#[allow(non_camel_case_types)]
1200pub type R_ExternalMethodDef = R_CallMethodDef;
1201
1202// Checked routine registration API declarations.
1203// Issue #112 cat. 7: kept pub(crate) — only called from init.rs during package init; not worth a wrapper type
1204#[allow(missing_docs)]
1205#[allow(missing_docs)]
#[allow(clashing_extern_declarations)]
unsafe extern "C-unwind" {
    #[doc = "Unchecked FFI binding for `R_registerRoutines`."]
    #[doc = "Generated from source location line 1208, 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 1216, 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 1217, 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1208, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe {
                R_registerRoutines_unchecked(info, croutines, callRoutines,
                    fortranRoutines, externalRoutines)
            })
}
#[doc =
"Checked wrapper for `R_useDynamicSymbols`. Calls `R_useDynamicSymbols_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1216, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_useDynamicSymbols_unchecked(info, value) })
}
#[doc =
"Checked wrapper for `R_forceSymbols`. Calls `R_forceSymbols_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1217, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_forceSymbols_unchecked(info, value) })
}#[r_ffi_checked]
1206#[allow(clashing_extern_declarations)]
1207unsafe extern "C-unwind" {
1208    pub(crate) fn R_registerRoutines(
1209        info: *mut DllInfo,
1210        croutines: *const R_CMethodDef,
1211        callRoutines: *const R_CallMethodDef,
1212        fortranRoutines: *const R_FortranMethodDef,
1213        externalRoutines: *const R_ExternalMethodDef,
1214    ) -> ::std::os::raw::c_int;
1215
1216    pub(crate) fn R_useDynamicSymbols(info: *mut DllInfo, value: Rboolean) -> Rboolean;
1217    pub(crate) fn R_forceSymbols(info: *mut DllInfo, value: Rboolean) -> Rboolean;
1218}
1219
1220// endregion
1221
1222// region: Non-API encoding/locale state (Defn.h)
1223
1224/// Non-API encoding / locale helpers from R's `Defn.h`.
1225///
1226/// These are not part of the stable R API and may break across R versions.
1227///
1228/// Only symbols R's shared library actually **exports** may be declared here.
1229/// `Defn.h` marks most locale globals `extern0` (= `attribute_hidden`) —
1230/// referencing one of those (e.g. `known_to_be_utf8`, `latin1locale`,
1231/// `R_nativeEncoding`) compiles fine but aborts `dyn.load` of any binary that
1232/// carries the reference: data relocations resolve eagerly at load, whether or
1233/// not the code path ever runs. That made every `nonapi` build un-loadable
1234/// (caught by the feature-legs CI, audit A5). `utf8locale`, `mbcslocale`, and
1235/// `known_to_be_latin1` are plain `extern` and exported (verified against
1236/// R 4.6's libR).
1237#[cfg(feature = "nonapi")]
1238pub mod nonapi_encoding {
1239    use super::r_ffi_checked;
1240
1241    // Issue #112 cat. 10: kept pub(crate) — nonapi encoding helpers; single-caller utilities in encoding.rs
1242    #[r_ffi_checked]
1243    #[allow(clashing_extern_declarations)]
1244    unsafe extern "C-unwind" {
1245        // Locale flags (exported, non-hidden)
1246        pub(crate) static utf8locale: super::Rboolean;
1247        pub(crate) static mbcslocale: super::Rboolean;
1248        pub(crate) static known_to_be_latin1: super::Rboolean;
1249    }
1250}
1251
1252// endregion
1253
1254// region: Non-API stack checking variables (Rinterface.h)
1255
1256/// Non-API stack checking variables from `Rinterface.h`.
1257///
1258/// R uses these to detect stack overflow. On a different thread the values do
1259/// not describe the current stack, so a stack check can fail spuriously.
1260///
1261/// # Not a package thread-safety mechanism
1262///
1263/// Setting `R_CStackLimit` to `usize::MAX` disables only R's stack-address
1264/// check. It does not make the R API, GC, global state, or error signaling safe
1265/// on a secondary thread. R packages must keep R API calls on the main thread
1266/// and must not rewrite these globals for off-main calls. The higher-level
1267/// [`StackCheckGuard`](crate::thread::StackCheckGuard) has the same limitation;
1268/// removal or relocation of this surface is tracked in #1352.
1269#[cfg(feature = "nonapi")]
1270pub mod nonapi_stack {
1271    unsafe extern "C" {
1272        /// Top of the stack (set during `Rf_initialize_R` for main thread).
1273        ///
1274        /// On Unix, determined via `__libc_stack_end`, `KERN_USRSTACK`, or
1275        /// `thr_stksegment`. On Windows, via `VirtualQuery`.
1276        #[allow(non_upper_case_globals)]
1277        pub(crate) static R_CStackStart: usize;
1278
1279        /// Stack size limit. Set to `usize::MAX` to disable stack checking.
1280        ///
1281        /// From R source: `if(R_CStackStart == -1) R_CStackLimit = -1; /* never set */`
1282        #[allow(non_upper_case_globals)]
1283        pub static R_CStackLimit: usize;
1284
1285        /// Stack growth direction: 1 = grows up, -1 = grows down.
1286        ///
1287        /// Most systems (x86, ARM) grow down (-1).
1288        #[allow(non_upper_case_globals)]
1289        pub(crate) static R_CStackDir: ::std::os::raw::c_int;
1290    }
1291
1292    /// Write to `R_CStackLimit`.
1293    ///
1294    /// # Safety
1295    /// Must be called from R's main thread.
1296    #[inline]
1297    pub unsafe fn set_r_cstack_limit(value: usize) {
1298        unsafe {
1299            let ptr = (&raw const R_CStackLimit).cast_mut();
1300            ptr.write(value);
1301        }
1302    }
1303
1304    // Issue #112 cat. 10: kept pub(crate) — nonapi stack helpers; used from thread.rs; wrapping adds no value
1305    /// Read `R_CStackLimit`.
1306    #[inline]
1307    pub(crate) fn get_r_cstack_limit() -> usize {
1308        unsafe { R_CStackLimit }
1309    }
1310
1311    /// Read `R_CStackStart`.
1312    #[inline]
1313    pub(crate) fn get_r_cstack_start() -> usize {
1314        unsafe { R_CStackStart }
1315    }
1316
1317    /// Read `R_CStackDir`.
1318    #[inline]
1319    pub(crate) fn get_r_cstack_dir() -> ::std::os::raw::c_int {
1320        unsafe { R_CStackDir }
1321    }
1322}
1323
1324// endregion
1325
1326// region: Inline Helper Functions (Rust implementations of R's inline functions)
1327
1328/// Create a length-1 string vector from a C string.
1329///
1330/// Rust equivalent of R's inline `Rf_mkString(s)`, which is
1331/// shorthand for `ScalarString(mkChar(s))`.
1332///
1333/// # Safety
1334///
1335/// - `s` must be a valid null-terminated C string
1336/// - Must be called from R's main thread
1337/// - Result must be protected from GC
1338#[doc(alias = "mkString")]
1339#[allow(non_snake_case)]
1340#[inline]
1341pub unsafe fn Rf_mkString(s: *const ::std::os::raw::c_char) -> SEXP {
1342    unsafe {
1343        let charsxp = Rf_mkChar(s);
1344        let protected = Rf_protect(charsxp);
1345        let result = Rf_ScalarString(protected);
1346        Rf_unprotect(1);
1347        result
1348    }
1349}
1350
1351/// Build a pairlist with 1 element.
1352///
1353/// Rust equivalent of R's inline `Rf_list1(s)`.
1354///
1355/// # Safety
1356///
1357/// - `s` must be a valid SEXP
1358/// - Must be called from R's main thread
1359/// - Result must be protected from GC
1360#[doc(alias = "list1")]
1361#[allow(non_snake_case)]
1362#[inline]
1363pub unsafe fn Rf_list1(s: SEXP) -> SEXP {
1364    unsafe { Rf_cons(s, R_NilValue) }
1365}
1366
1367/// Build a pairlist with 2 elements.
1368///
1369/// Rust equivalent of R's inline `Rf_list2(s, t)`.
1370///
1371/// # Safety
1372///
1373/// - Both SEXPs must be valid
1374/// - Must be called from R's main thread
1375/// - Result must be protected from GC
1376#[doc(alias = "list2")]
1377#[allow(non_snake_case)]
1378#[inline]
1379pub unsafe fn Rf_list2(s: SEXP, t: SEXP) -> SEXP {
1380    unsafe { Rf_cons(s, Rf_cons(t, R_NilValue)) }
1381}
1382
1383/// Build a pairlist with 3 elements.
1384///
1385/// Rust equivalent of R's inline `Rf_list3(s, t, u)`.
1386///
1387/// # Safety
1388///
1389/// - All SEXPs must be valid
1390/// - Must be called from R's main thread
1391/// - Result must be protected from GC
1392#[doc(alias = "list3")]
1393#[allow(non_snake_case)]
1394#[inline]
1395pub unsafe fn Rf_list3(s: SEXP, t: SEXP, u: SEXP) -> SEXP {
1396    unsafe { Rf_cons(s, Rf_cons(t, Rf_cons(u, R_NilValue))) }
1397}
1398
1399/// Build a pairlist with 4 elements.
1400///
1401/// Rust equivalent of R's inline `Rf_list4(s, t, u, v)`.
1402///
1403/// # Safety
1404///
1405/// - All SEXPs must be valid
1406/// - Must be called from R's main thread
1407/// - Result must be protected from GC
1408#[doc(alias = "list4")]
1409#[allow(non_snake_case)]
1410#[inline]
1411pub unsafe fn Rf_list4(s: SEXP, t: SEXP, u: SEXP, v: SEXP) -> SEXP {
1412    unsafe { Rf_cons(s, Rf_cons(t, Rf_cons(u, Rf_cons(v, R_NilValue)))) }
1413}
1414
1415/// Build a language object (call) with 1 element (the function).
1416///
1417/// Rust equivalent of R's inline `Rf_lang1(s)`.
1418/// Creates a call like `f()` where `s` is the function.
1419///
1420/// # Safety
1421///
1422/// - `s` must be a valid SEXP (typically a symbol or closure)
1423/// - Must be called from R's main thread
1424/// - Result must be protected from GC
1425#[doc(alias = "lang1")]
1426#[allow(non_snake_case)]
1427#[inline]
1428pub unsafe fn Rf_lang1(s: SEXP) -> SEXP {
1429    unsafe { Rf_lcons(s, R_NilValue) }
1430}
1431
1432/// Build a language object (call) with function and 1 argument.
1433///
1434/// Rust equivalent of R's inline `Rf_lang2(s, t)`.
1435/// Creates a call like `f(arg)` where `s` is the function and `t` is the argument.
1436///
1437/// # Safety
1438///
1439/// - Both SEXPs must be valid
1440/// - Must be called from R's main thread
1441/// - Result must be protected from GC
1442#[doc(alias = "lang2")]
1443#[allow(non_snake_case)]
1444#[inline]
1445pub unsafe fn Rf_lang2(s: SEXP, t: SEXP) -> SEXP {
1446    unsafe { Rf_lcons(s, Rf_list1(t)) }
1447}
1448
1449/// Build a language object (call) with function and 2 arguments.
1450///
1451/// Rust equivalent of R's inline `Rf_lang3(s, t, u)`.
1452/// Creates a call like `f(arg1, arg2)`.
1453///
1454/// # Safety
1455///
1456/// - All SEXPs must be valid
1457/// - Must be called from R's main thread
1458/// - Result must be protected from GC
1459#[doc(alias = "lang3")]
1460#[allow(non_snake_case)]
1461#[inline]
1462pub unsafe fn Rf_lang3(s: SEXP, t: SEXP, u: SEXP) -> SEXP {
1463    unsafe { Rf_lcons(s, Rf_list2(t, u)) }
1464}
1465
1466/// Build a language object (call) with function and 3 arguments.
1467///
1468/// Rust equivalent of R's inline `Rf_lang4(s, t, u, v)`.
1469/// Creates a call like `f(arg1, arg2, arg3)`.
1470///
1471/// # Safety
1472///
1473/// - All SEXPs must be valid
1474/// - Must be called from R's main thread
1475/// - Result must be protected from GC
1476#[doc(alias = "lang4")]
1477#[allow(non_snake_case)]
1478#[inline]
1479pub unsafe fn Rf_lang4(s: SEXP, t: SEXP, u: SEXP, v: SEXP) -> SEXP {
1480    unsafe { Rf_lcons(s, Rf_list3(t, u, v)) }
1481}
1482
1483/// Build a language object (call) with function and 4 arguments.
1484///
1485/// Rust equivalent of R's inline `Rf_lang5(s, t, u, v, w)`.
1486/// Creates a call like `f(arg1, arg2, arg3, arg4)`.
1487///
1488/// # Safety
1489///
1490/// - All SEXPs must be valid
1491/// - Must be called from R's main thread
1492/// - Result must be protected from GC
1493#[doc(alias = "lang5")]
1494#[allow(non_snake_case)]
1495#[inline]
1496pub unsafe fn Rf_lang5(s: SEXP, t: SEXP, u: SEXP, v: SEXP, w: SEXP) -> SEXP {
1497    unsafe { Rf_lcons(s, Rf_list4(t, u, v, w)) }
1498}
1499
1500/// Build a language object (call) with function and 5 arguments.
1501///
1502/// Rust equivalent of R's inline `Rf_lang6(s, t, u, v, w, x)`.
1503/// Creates a call like `f(arg1, arg2, arg3, arg4, arg5)`.
1504///
1505/// # Safety
1506///
1507/// - All SEXPs must be valid
1508/// - Must be called from R's main thread
1509/// - Result must be protected from GC
1510#[doc(alias = "lang6")]
1511#[allow(non_snake_case)]
1512#[inline]
1513pub unsafe fn Rf_lang6(s: SEXP, t: SEXP, u: SEXP, v: SEXP, w: SEXP, x: SEXP) -> SEXP {
1514    unsafe {
1515        let protected = Rf_protect(s);
1516        let list = Rf_cons(t, Rf_list4(u, v, w, x));
1517        let result = Rf_lcons(protected, list);
1518        Rf_unprotect(1);
1519        result
1520    }
1521}
1522
1523// endregion
1524
1525// region: RNG functions (R_ext/Random.h)
1526
1527/// RNG type enum from R_ext/Random.h
1528#[repr(u32)]
1529#[non_exhaustive]
1530#[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::debug_c_like_enum_write_str(f,
            "WICHMANN_HILL MARSAGLIA_MULTICARRY SUPER_DUPER MERSENNE_TWISTER KNUTH_TAOCP USER_UNIF KNUTH_TAOCP2 LECUYER_CMRG",
            match self {
                RNGtype::WICHMANN_HILL => 0usize,
                RNGtype::MARSAGLIA_MULTICARRY => 14usize,
                RNGtype::SUPER_DUPER => 35usize,
                RNGtype::MERSENNE_TWISTER => 47usize,
                RNGtype::KNUTH_TAOCP => 64usize,
                RNGtype::USER_UNIF => 76usize,
                RNGtype::KNUTH_TAOCP2 => 86usize,
                RNGtype::LECUYER_CMRG => 99usize,
            })
    }
}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)]
1531#[allow(non_camel_case_types)]
1532pub enum RNGtype {
1533    /// Wichmann-Hill generator.
1534    WICHMANN_HILL = 0,
1535    /// Marsaglia-Multicarry generator.
1536    MARSAGLIA_MULTICARRY = 1,
1537    /// Super-Duper generator.
1538    SUPER_DUPER = 2,
1539    /// Mersenne Twister generator.
1540    MERSENNE_TWISTER = 3,
1541    /// Knuth TAOCP generator.
1542    KNUTH_TAOCP = 4,
1543    /// User-supplied uniform generator.
1544    USER_UNIF = 5,
1545    /// Knuth TAOCP 2002 variant.
1546    KNUTH_TAOCP2 = 6,
1547    /// L'Ecuyer-CMRG generator.
1548    LECUYER_CMRG = 7,
1549}
1550
1551/// Normal distribution generator type enum from R_ext/Random.h
1552#[repr(u32)]
1553#[non_exhaustive]
1554#[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::debug_c_like_enum_write_str(f,
            "BUGGY_KINDERMAN_RAMAGE AHRENS_DIETER BOX_MULLER USER_NORM INVERSION KINDERMAN_RAMAGE",
            match self {
                N01type::BUGGY_KINDERMAN_RAMAGE => 0usize,
                N01type::AHRENS_DIETER => 23usize,
                N01type::BOX_MULLER => 37usize,
                N01type::USER_NORM => 48usize,
                N01type::INVERSION => 58usize,
                N01type::KINDERMAN_RAMAGE => 68usize,
            })
    }
}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)]
1555#[allow(non_camel_case_types)]
1556pub enum N01type {
1557    /// Legacy buggy Kinderman-Ramage method.
1558    BUGGY_KINDERMAN_RAMAGE = 0,
1559    /// Ahrens-Dieter method.
1560    AHRENS_DIETER = 1,
1561    /// Box-Muller transform.
1562    BOX_MULLER = 2,
1563    /// User-supplied normal generator.
1564    USER_NORM = 3,
1565    /// Inversion method.
1566    INVERSION = 4,
1567    /// Fixed Kinderman-Ramage method.
1568    KINDERMAN_RAMAGE = 5,
1569}
1570
1571/// Discrete uniform sample method 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 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)]
1575#[allow(non_camel_case_types)]
1576pub enum Sampletype {
1577    /// Rounding method for integer sampling.
1578    ROUNDING = 0,
1579    /// Rejection sampling method.
1580    REJECTION = 1,
1581}
1582
1583unsafe 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 1602, 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 1608, 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 1616, 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 1624, 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 1632, 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 1642, 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 1645, 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1602, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn GetRNGstate() {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { 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 =
"Checked wrapper for `PutRNGstate`. Calls `PutRNGstate_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1608, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn PutRNGstate() {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { 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 =
"Checked wrapper for `unif_rand`. Calls `unif_rand_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1616, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn unif_rand() -> f64 {
    ::miniextendr_api::with_r_thread(move || unsafe { unif_rand_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1624, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn norm_rand() -> f64 {
    ::miniextendr_api::with_r_thread(move || unsafe { norm_rand_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1632, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn exp_rand() -> f64 {
    ::miniextendr_api::with_r_thread(move || unsafe { exp_rand_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1642, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_unif_index_unchecked(dn) })
}
#[doc = " Get the current discrete uniform sample method."]
#[doc =
"Checked wrapper for `R_sample_kind`. Calls `R_sample_kind_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1645, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_sample_kind_unchecked() })
}#[r_ffi_checked]
1584unsafe extern "C-unwind" {
1585    /// Save the current RNG state from R's global state.
1586    ///
1587    /// Must be called before using `unif_rand()`, `norm_rand()`, etc.
1588    /// The state is restored with `PutRNGstate()`. The safe forms are
1589    /// [`RngGuard`](crate::rng::RngGuard), [`with_rng`](crate::rng::with_rng)
1590    /// and `#[miniextendr(rng)]`.
1591    ///
1592    /// # Example
1593    ///
1594    /// ```ignore
1595    /// unsafe {
1596    ///     GetRNGstate();
1597    ///     let x = unif_rand();
1598    ///     let y = norm_rand();
1599    ///     PutRNGstate();
1600    /// }
1601    /// ```
1602    pub fn GetRNGstate();
1603
1604    /// Restore the RNG state to R's global state.
1605    ///
1606    /// Must be called after using `unif_rand()`, `norm_rand()`, etc.
1607    /// to ensure R's `.Random.seed` is updated.
1608    pub fn PutRNGstate();
1609
1610    /// Generate a uniform random number in (0, 1).
1611    ///
1612    /// # Important
1613    ///
1614    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1615    /// form is [`RngGuard::unif_rand`](crate::rng::RngGuard::unif_rand).
1616    pub fn unif_rand() -> f64;
1617
1618    /// Generate a standard normal random number (mean 0, sd 1).
1619    ///
1620    /// # Important
1621    ///
1622    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1623    /// form is [`RngGuard::norm_rand`](crate::rng::RngGuard::norm_rand).
1624    pub fn norm_rand() -> f64;
1625
1626    /// Generate an exponential random number with rate 1.
1627    ///
1628    /// # Important
1629    ///
1630    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1631    /// form is [`RngGuard::exp_rand`](crate::rng::RngGuard::exp_rand).
1632    pub fn exp_rand() -> f64;
1633
1634    /// Generate a uniform random index in [0, dn).
1635    ///
1636    /// Used for sampling without bias for large n.
1637    ///
1638    /// # Important
1639    ///
1640    /// Must call `GetRNGstate()` before and `PutRNGstate()` after. The safe
1641    /// form is [`RngGuard::unif_index`](crate::rng::RngGuard::unif_index).
1642    pub fn R_unif_index(dn: f64) -> f64;
1643
1644    /// Get the current discrete uniform sample method.
1645    pub fn R_sample_kind() -> Sampletype;
1646}
1647
1648// endregion
1649
1650// region: Rmath distribution functions (Rmath.h)
1651//
1652// Unless `MATHLIB_STANDALONE` is defined, `Rmath.h` remaps the short names
1653// (`dnorm` -> `dnorm4` -> `Rf_dnorm4`, `pnorm` -> `pnorm5` -> `Rf_pnorm5`,
1654// `qnorm` -> `qnorm5` -> `Rf_qnorm5`, `qchisq` -> `Rf_qchisq`); these are the
1655// symbols libR exports, with these prototypes, from the R 4.4 floor on.
1656// `tools:::funAPI()` lists all four as `api` (R 4.6 and R-devel 4.7) and none
1657// is in `tools:::nonAPI` (R 4.4 to 4.7), so they need no feature gate.
1658//
1659// These are the scalar C routines, not the vectorised `stats::` functions:
1660// arguments are passed through unchanged (the `lower_tail` / `log_p` flags
1661// select R's own tail and log-scale code paths), and NA, NaN and infinite
1662// inputs come back as R's C code computes them.
1663
1664unsafe 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 the main-thread check only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_dnorm4`."]
    #[doc = "Generated from source location line 1683, 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 the main-thread check only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_pnorm5`."]
    #[doc = "Generated from source location line 1703, 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 the main-thread check only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_qnorm5`."]
    #[doc = "Generated from source location line 1731, 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 the main-thread check only, not an"]
    #[doc = " unwind guard."]
    #[doc = "Unchecked FFI binding for `Rf_qchisq`."]
    #[doc = "Generated from source location line 1759, 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 the main-thread check only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_dnorm4`. Calls `Rf_dnorm4_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1683, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_dnorm4_unchecked(x, mu, sigma, give_log) })
}
#[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 the main-thread check only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_pnorm5`. Calls `Rf_pnorm5_unchecked` inside `with_r_thread`, which panics off R's main 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_pnorm5(x: f64, mu: f64, sigma: f64,
    lower_tail: ::std::os::raw::c_int, log_p: ::std::os::raw::c_int) -> f64 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_pnorm5_unchecked(x, mu, sigma, lower_tail, log_p) })
}
#[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 the main-thread check only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_qnorm5`. Calls `Rf_qnorm5_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1731, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_qnorm5_unchecked(p, mu, sigma, lower_tail, log_p) })
}
#[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 the main-thread check only, not an"]
#[doc = " unwind guard."]
#[doc =
"Checked wrapper for `Rf_qchisq`. Calls `Rf_qchisq_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1759, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_qchisq_unchecked(p, df, lower_tail, log_p) })
}#[r_ffi_checked]
1665unsafe extern "C-unwind" {
1666    /// Normal density: `dnorm(x, mean = mu, sd = sigma, log = give_log)`.
1667    ///
1668    /// `Rf_dnorm4` from `Rmath.h` (the `dnorm` and `dnorm4` macros resolve
1669    /// to it). A non-zero `give_log` returns the log density.
1670    ///
1671    /// # R conditions
1672    ///
1673    /// An invalid `sigma` (negative) returns `NaN` without a warning: nmath
1674    /// does not report domain errors, and the "NaNs produced" warning that
1675    /// `stats::dnorm` gives comes from R's vectorised wrapper. nmath reports
1676    /// other problems (precision loss, non-convergence) through R's
1677    /// `warning()`, and under `options(warn = 2)` a warning becomes an R
1678    /// error, which longjmps. Call this where such a longjmp is caught: a
1679    /// `#[miniextendr]` function body, or
1680    /// [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1681    /// `#[r_ffi_checked]` gives the main-thread check only, not an
1682    /// unwind guard.
1683    pub fn Rf_dnorm4(x: f64, mu: f64, sigma: f64, give_log: ::std::os::raw::c_int) -> f64;
1684
1685    /// Normal distribution function:
1686    /// `pnorm(x, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`.
1687    ///
1688    /// `Rf_pnorm5` from `Rmath.h` (the `pnorm` and `pnorm5` macros resolve
1689    /// to it). `lower_tail = 0` computes the upper tail `P[X > x]` directly
1690    /// (accurate far into the tail, unlike `1 - P[X <= x]`); a non-zero
1691    /// `log_p` returns the log probability.
1692    ///
1693    /// # R conditions
1694    ///
1695    /// An invalid `sigma` (negative) returns `NaN` without a warning (nmath
1696    /// does not report domain errors). nmath reports other problems through
1697    /// R's `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 the main-thread check only, not an
1702    /// unwind guard.
1703    pub fn Rf_pnorm5(
1704        x: f64,
1705        mu: f64,
1706        sigma: f64,
1707        lower_tail: ::std::os::raw::c_int,
1708        log_p: ::std::os::raw::c_int,
1709    ) -> f64;
1710
1711    /// Normal quantile function:
1712    /// `qnorm(p, mean = mu, sd = sigma, lower.tail = lower_tail, log.p = log_p)`.
1713    ///
1714    /// `Rf_qnorm5` from `Rmath.h` (the `qnorm` and `qnorm5` macros resolve
1715    /// to it). With a non-zero `log_p`, `p` is a log probability; with
1716    /// `lower_tail = 0`, `p` is an upper-tail probability. `p = 0` and
1717    /// `p = 1` (or `-Inf` / `0` on the log scale) return `-Inf` / `Inf` as
1718    /// the tail requires.
1719    ///
1720    /// # R conditions
1721    ///
1722    /// A `p` outside `[0, 1]` (outside `[-Inf, 0]` on the log scale) or a
1723    /// negative `sigma` returns `NaN` without a warning (nmath does not
1724    /// report domain errors). nmath reports other problems through R's
1725    /// `warning()`, and under `options(warn = 2)` a warning becomes an R
1726    /// error, which longjmps. Call this where such a longjmp is caught: a
1727    /// `#[miniextendr]` function body, or
1728    /// [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1729    /// `#[r_ffi_checked]` gives the main-thread check only, not an
1730    /// unwind guard.
1731    pub fn Rf_qnorm5(
1732        p: f64,
1733        mu: f64,
1734        sigma: f64,
1735        lower_tail: ::std::os::raw::c_int,
1736        log_p: ::std::os::raw::c_int,
1737    ) -> f64;
1738
1739    /// Chi-squared quantile function:
1740    /// `qchisq(p, df, lower.tail = lower_tail, log.p = log_p)` (central only;
1741    /// `stats::qchisq` with `ncp` calls a different routine).
1742    ///
1743    /// `Rf_qchisq` from `Rmath.h` (the `qchisq` macro resolves to it). It is
1744    /// R's gamma quantile with shape `df / 2` and scale `2`. The flags have
1745    /// the same meaning as for [`Rf_qnorm5`].
1746    ///
1747    /// # R conditions
1748    ///
1749    /// A `p` outside the probability range or a negative `df` returns `NaN`
1750    /// without a warning (nmath does not report domain errors). The gamma
1751    /// quantile iterates, and nmath reports non-convergence or precision
1752    /// loss in it (and in the gamma distribution function it calls) through
1753    /// R's `warning()`; under `options(warn = 2)` that warning becomes an R
1754    /// error, which longjmps. Call this where such a longjmp is caught: a
1755    /// `#[miniextendr]` function body, or
1756    /// [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1757    /// `#[r_ffi_checked]` gives the main-thread check only, not an
1758    /// unwind guard.
1759    pub fn Rf_qchisq(
1760        p: f64,
1761        df: f64,
1762        lower_tail: ::std::os::raw::c_int,
1763        log_p: ::std::os::raw::c_int,
1764    ) -> f64;
1765}
1766
1767// endregion
1768
1769// region: Optimisation (R_ext/Applic.h)
1770//
1771// `R_ext/Applic.h` lists `lbfgsb` under "Entry points in the R API" (no `Rf_`
1772// prefix), libR exports it with this prototype from the R 4.4 floor on,
1773// `tools:::funAPI()` lists it as `api` (R 4.6 and R-devel 4.7), and it is not
1774// in `tools:::nonAPI` (R 4.4 to 4.7), so it needs no feature gate. Only the
1775// raw ABI is declared here; there is no safe adapter.
1776
1777/// Objective callback type for R's optimisers: `optimfn` in `R_ext/Applic.h`,
1778/// `typedef double optimfn(int n, double *par, void *ex)`.
1779///
1780/// Called with the parameter count, a pointer to `n` parameter values, and
1781/// the `ex` pointer given to the optimiser; returns the objective value.
1782/// [`lbfgsb`] requires a finite value: it raises an R error otherwise.
1783///
1784/// A Rust panic must not unwind out of the callback through R's C frames:
1785/// catch it inside the callback (`std::panic::catch_unwind`), store the
1786/// payload in the `ex` state, return a finite value, and resume the panic
1787/// after the optimiser returns.
1788#[allow(non_camel_case_types)]
1789pub type optimfn = unsafe extern "C-unwind" fn(
1790    n: ::std::os::raw::c_int,
1791    par: *mut f64,
1792    ex: *mut ::std::os::raw::c_void,
1793) -> f64;
1794
1795/// Gradient callback type for R's optimisers: `optimgr` in `R_ext/Applic.h`,
1796/// `typedef void optimgr(int n, double *par, double *gr, void *ex)`.
1797///
1798/// Called with the parameter count, a pointer to `n` parameter values, a
1799/// pointer to `n` gradient slots to fill, and the `ex` pointer given to the
1800/// optimiser. The panic rule of [`optimfn`] applies: catch it inside, store
1801/// the payload in `ex`, fill the slots (zeros will do), resume afterwards.
1802#[allow(non_camel_case_types)]
1803pub type optimgr = unsafe extern "C-unwind" fn(
1804    n: ::std::os::raw::c_int,
1805    par: *mut f64,
1806    gr: *mut f64,
1807    ex: *mut ::std::os::raw::c_void,
1808);
1809
1810unsafe 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 the main-thread check 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 1874, 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 the main-thread check 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 1874, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe {
                lbfgsb_unchecked(n, m, x, l, u, nbd, fmin, fn_, gr, fail, ex,
                    factr, pgtol, fncount, grcount, maxit, msg, trace, nreport)
            })
}#[r_ffi_checked]
1811unsafe extern "C-unwind" {
1812    /// Bound-constrained limited-memory BFGS minimiser: `lbfgsb` in
1813    /// `R_ext/Applic.h`, the routine behind `optim(method = "L-BFGS-B")`.
1814    ///
1815    /// # Arguments
1816    ///
1817    /// - `n`: number of parameters. With `n = 0` it calls `fn_(0, u, ex)`
1818    ///   once and returns `fail = 0`, `fncount = 1`, `grcount = 0` and the
1819    ///   message `"NOTHING TO DO"`.
1820    /// - `m`: number of correction pairs kept (`optim`'s `lmm`, default 5).
1821    /// - `x`: `n` starting values; overwritten with the solution.
1822    /// - `l`, `u`: `n` lower and upper bounds, read where `nbd` says so.
1823    /// - `nbd`: `n` bound codes: `0` unbounded, `1` lower bound only, `2`
1824    ///   both bounds, `3` upper bound only. Code `2` with `l[i] == u[i]`
1825    ///   fixes parameter `i`.
1826    /// - `fmin`: receives the last objective value computed, the one at the
1827    ///   returned `x` on convergence. It is not meaningful when the input
1828    ///   checks fail (`fail = 52` before any evaluation).
1829    /// - `fn_`, `gr`: objective and gradient callbacks. Both are required
1830    ///   (R calls them unconditionally).
1831    /// - `fail`: receives `0` (converged), `1` (`maxit` reached; the message
1832    ///   is then `"NEW_X"`), `51` (a `"WARNING: ..."` from the line search)
1833    ///   or `52` (an `"ERROR: ..."`, such as an invalid `nbd` code or
1834    ///   `l[i] > u[i]` under code `2`).
1835    /// - `ex`: passed unchanged to both callbacks.
1836    /// - `factr`: relative-reduction tolerance in units of machine epsilon
1837    ///   (`optim`'s default `1e7`).
1838    /// - `pgtol`: projected-gradient tolerance (with `optim`'s default `0`
1839    ///   only an exactly zero projected gradient stops on it).
1840    /// - `fncount`, `grcount`: receive the evaluation counts (R stores the
1841    ///   same count in both, except with `n = 0`: see `n` above).
1842    /// - `maxit`: iteration limit.
1843    /// - `msg`: caller-owned buffer of at least 60 bytes (C `char msg[60]`);
1844    ///   receives a NUL-terminated status such as
1845    ///   `"CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"`.
1846    /// - `trace`: `0` is silent; `1` to `6` print progress through `Rprintf`.
1847    /// - `nreport`: progress interval in iterations. It must be at least `1`
1848    ///   even when `trace = 0`.
1849    ///
1850    /// The routine keeps a limited-memory approximation of the inverse
1851    /// Hessian internally and does not return it. That approximation is a
1852    /// search device, not an inferential covariance: compute the Hessian at
1853    /// the optimum (as `stats::optimHess` does) for standard errors.
1854    ///
1855    /// # Safety
1856    ///
1857    /// - `x`, `l`, `u` and `nbd` must be valid for `n` elements, `msg` must
1858    ///   be writable for 60 bytes, and the other out-pointers must be valid.
1859    ///   `ex` must stay valid for the whole call: the callbacks receive it
1860    ///   on every evaluation.
1861    /// - `lbfgsb` raises R errors itself (an R longjmp): when
1862    ///   `nreport <= 0`, and when the objective returns a non-finite value
1863    ///   ("L-BFGS-B needs finite values of 'fn'"). Call it where such a
1864    ///   longjmp is caught: a `#[miniextendr]` function body, or
1865    ///   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
1866    ///   `#[r_ffi_checked]` gives the main-thread check only, not an
1867    ///   unwind guard.
1868    /// - The callbacks must not let a Rust panic unwind through `lbfgsb`'s
1869    ///   frames (see [`optimfn`]).
1870    /// - The workspace comes from `R_alloc` / `S_alloc`, R's transient
1871    ///   allocation stack. R reclaims it when the enclosing `.Call` returns;
1872    ///   outside `.Call`, bracket the call with [`vmaxget`] / [`vmaxset`].
1873    #[allow(clippy::too_many_arguments)]
1874    pub fn lbfgsb(
1875        n: ::std::os::raw::c_int,
1876        m: ::std::os::raw::c_int,
1877        x: *mut f64,
1878        l: *mut f64,
1879        u: *mut f64,
1880        nbd: *mut ::std::os::raw::c_int,
1881        fmin: *mut f64,
1882        fn_: optimfn,
1883        gr: optimgr,
1884        fail: *mut ::std::os::raw::c_int,
1885        ex: *mut ::std::os::raw::c_void,
1886        factr: f64,
1887        pgtol: f64,
1888        fncount: *mut ::std::os::raw::c_int,
1889        grcount: *mut ::std::os::raw::c_int,
1890        maxit: ::std::os::raw::c_int,
1891        msg: *mut ::std::os::raw::c_char,
1892        trace: ::std::os::raw::c_int,
1893        nreport: ::std::os::raw::c_int,
1894    );
1895}
1896
1897// endregion
1898
1899// region: BLAS and LAPACK (R_ext/BLAS.h, R_ext/Lapack.h), `blas-lapack` feature
1900//
1901// The BLAS and LAPACK that R itself was built with (`libRblas` / `libRlapack`
1902// or an external library chosen at R's configure time). `tools:::funAPI()`
1903// lists `dgemm_` (`R_ext/BLAS.h`) and `dgesv_` (`R_ext/Lapack.h`) as `api` in
1904// R 4.6.1 and R-devel 4.7.0, neither is in `tools:::nonAPI` (R 4.4 to 4.7),
1905// and R's BLAS/LAPACK export both from the R 4.4 floor on. The `blas-lapack`
1906// feature gates them only because they live in libraries a package must link
1907// itself: `PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)`.
1908//
1909// The ABI is Fortran's, as `R_ext/RS.h` and `R_ext/BLAS.h` spell it:
1910//
1911// - Symbol: `F77_NAME(dgemm)` is `dgemm_`. `Rconfig.h` defines
1912//   `HAVE_F77_UNDERSCORE` on every current R platform (macOS, Linux, Windows
1913//   and webR).
1914// - Every declared argument is a pointer, scalars included.
1915// - Each CHARACTER argument adds a hidden length, passed by value after all
1916//   the declared arguments, in the order of the character arguments (`FCLEN`
1917//   in the prototypes, `FCONE` = `(FC_LEN_T)1` at call sites). See
1918//   [`FC_LEN_T`].
1919// - INTEGER is `BLAS_INT` / `La_INT`, which the headers define as `int`
1920//   unless `ILP64` is defined. R never defines it, and R's configure requires
1921//   a 32-bit Fortran INTEGER equal to C `int`. There is no ILP64 variant
1922//   here: the assertion below refuses a target where `c_int` is not 32-bit.
1923//
1924// R replaces the BLAS/LAPACK invalid-argument handler `xerbla` with one that
1925// raises an R error ("BLAS/LAPACK routine 'DGEMM ' gave error code ...", in
1926// `src/main/print.c`), so an invalid argument longjmps out of the routine
1927// instead of returning. The safe adapters in [`crate::linalg`] validate every
1928// argument before calling.
1929
1930/// Type of the hidden CHARACTER-length arguments of R's Fortran BLAS/LAPACK:
1931/// `FC_LEN_T` in R's `Rconfig.h`.
1932///
1933/// gfortran (since version 8) and LLVM flang pass the length of each
1934/// CHARACTER argument as an extra by-value argument after the declared
1935/// ones. R's configure probes the Fortran compiler and defines `FC_LEN_T` as
1936/// `size_t`, and since R 4.3.0 `R_ext/BLAS.h` and `R_ext/Lapack.h` declare
1937/// one `FC_LEN_T` per character argument by default (`USE_FC_LEN_T`).
1938/// `usize` is `size_t` on every target R runs on: the macOS, Linux and
1939/// Windows `Rconfig.h` define
1940/// `FC_LEN_T size_t`, and so does webR's, where `size_t` is 32 bits (its
1941/// `libRblas.so` exports `dgemm_` with 15 `i32` parameters: 13 declared
1942/// arguments and two lengths).
1943///
1944/// Omitting the lengths, as the `blas-sys` / `lapack-sys` crates do, is
1945/// undefined behaviour with these compilers and a link-time signature
1946/// mismatch on webR. Pass `1` for each single-character flag, as `FCONE`
1947/// does.
1948#[allow(non_camel_case_types)]
1949#[cfg(feature = "blas-lapack")]
1950pub type FC_LEN_T = usize;
1951
1952// R's BLAS/LAPACK INTEGER is C `int` (32-bit); see the region comment.
1953#[cfg(feature = "blas-lapack")]
1954const _: () = assert!(
1955    ::std::mem::size_of::<::std::os::raw::c_int>() == 4,
1956    "R's BLAS/LAPACK use a 32-bit INTEGER (C int); ILP64 is not supported"
1957);
1958
1959#[cfg(feature = "blas-lapack")]
1960#[r_ffi_checked]
1961unsafe extern "C-unwind" {
1962    /// General matrix product: `C := alpha * op(A) * op(B) + beta * C`,
1963    /// `F77_NAME(dgemm)` from `R_ext/BLAS.h` (the routine behind R's `%*%`).
1964    ///
1965    /// All matrices are column-major. `op(X)` is `X` when its flag is
1966    /// `b'N'` (or `b'n'`) and `X'` when it is `b'T'` / `b'C'`.
1967    ///
1968    /// # Arguments
1969    ///
1970    /// - `transa`, `transb`: pointers to one ASCII flag character each.
1971    /// - `m`, `n`, `k`: `op(A)` is `m x k`, `op(B)` is `k x n`, `C` is
1972    ///   `m x n`.
1973    /// - `alpha`, `beta`: scalars. With `*beta == 0.0`, `C` need not be
1974    ///   initialised (NaNs in it are not propagated).
1975    /// - `a`, `lda`: `A` is `lda x ka` with `ka = k` for `'N'` and `ka = m`
1976    ///   for `'T'`; `lda >= max(1, rows of A)` (`m` for `'N'`, `k` for
1977    ///   `'T'`).
1978    /// - `b`, `ldb`: `B` is `ldb x kb` with `kb = n` for `'N'` and `kb = k`
1979    ///   for `'T'`; `ldb >= max(1, rows of B)` (`k` for `'N'`, `n` for
1980    ///   `'T'`).
1981    /// - `c`, `ldc`: `C` is `ldc x n`, `ldc >= max(1, m)`; overwritten with
1982    ///   the result.
1983    /// - `transa_len`, `transb_len`: the hidden lengths of `transa` and
1984    ///   `transb` ([`FC_LEN_T`]); pass `1` each.
1985    ///
1986    /// Non-finite inputs are not guaranteed to propagate: a BLAS may skip a
1987    /// term whose multiplier is zero, so `0 * Inf` or `0 * NaN` can vanish.
1988    /// R's `%*%` checks for NA/NaN first and uses its own loop in that case
1989    /// (`options(matprod = "default")`).
1990    ///
1991    /// # Safety
1992    ///
1993    /// - Every pointer must be valid for the reads (and, for `c`, writes)
1994    ///   the dimensions imply, `c` must not overlap `a` or `b`, and nothing
1995    ///   may mutate `a` or `b` during the call.
1996    /// - An invalid argument (a flag other than N/T/C, a negative dimension,
1997    ///   a leading dimension that is too small) makes R's `xerbla` raise an
1998    ///   R error, which longjmps over the Rust frames. Validate the
1999    ///   arguments first, as [`crate::linalg::matrix_product`] does, or call
2000    ///   it where such a longjmp is caught: a `#[miniextendr]` function
2001    ///   body, or
2002    ///   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
2003    ///   `#[r_ffi_checked]` gives the main-thread check only, not an
2004    ///   unwind guard.
2005    /// - Call it from R's main thread in a process where R is initialised:
2006    ///   `xerbla` is R's.
2007    ///   A standalone binary must start R first (`miniextendr-engine`).
2008    #[allow(clippy::too_many_arguments)]
2009    pub fn dgemm_(
2010        transa: *const ::std::os::raw::c_char,
2011        transb: *const ::std::os::raw::c_char,
2012        m: *const ::std::os::raw::c_int,
2013        n: *const ::std::os::raw::c_int,
2014        k: *const ::std::os::raw::c_int,
2015        alpha: *const f64,
2016        a: *const f64,
2017        lda: *const ::std::os::raw::c_int,
2018        b: *const f64,
2019        ldb: *const ::std::os::raw::c_int,
2020        beta: *const f64,
2021        c: *mut f64,
2022        ldc: *const ::std::os::raw::c_int,
2023        transa_len: FC_LEN_T,
2024        transb_len: FC_LEN_T,
2025    );
2026
2027    /// Solve `A X = B` for a general square `A` by LU factorisation with
2028    /// partial pivoting: `F77_NAME(dgesv)` from `R_ext/Lapack.h` (the
2029    /// routine behind `base::solve()`).
2030    ///
2031    /// All matrices are column-major. DGESV has no character arguments, so
2032    /// no hidden lengths.
2033    ///
2034    /// # Arguments
2035    ///
2036    /// - `n`: order of `A` (rows of `B`).
2037    /// - `nrhs`: number of right-hand sides (columns of `B`).
2038    /// - `a`, `lda`: `A`, `lda x n` with `lda >= max(1, n)`. Overwritten with
2039    ///   the factors `L` (unit diagonal not stored) and `U` of `A = P L U`.
2040    /// - `ipiv`: `n` pivot indices (1-based): row `i` was interchanged with
2041    ///   row `ipiv[i - 1]`.
2042    /// - `b`, `ldb`: `B`, `ldb x nrhs` with `ldb >= max(1, n)`. Overwritten
2043    ///   with the solution `X` when `*info == 0`.
2044    /// - `info`: receives `0` on success, or `i > 0` when `U(i, i)` is
2045    ///   exactly zero: `A` is singular, the factorisation is complete but `X`
2046    ///   was not computed. A negative value would report an invalid
2047    ///   argument, but under R `xerbla` raises an R error instead (see
2048    ///   Safety).
2049    ///
2050    /// Only an exactly zero pivot is reported: a nearly singular `A` returns
2051    /// `info = 0` and an inaccurate `X`. `base::solve()` additionally
2052    /// estimates the reciprocal condition number (`dgecon`) and errors below
2053    /// `tol`; DGESV does not.
2054    ///
2055    /// # Safety
2056    ///
2057    /// - `a` must be valid for `lda * n` reads and writes, `b` for
2058    ///   `ldb * nrhs`, `ipiv` for `n` writes, and none of them may overlap.
2059    /// - An invalid argument (a negative `n` or `nrhs`, `lda` or `ldb` below
2060    ///   `max(1, n)`) makes R's `xerbla` raise an R error, which longjmps
2061    ///   over the Rust frames. Validate the arguments first, as
2062    ///   [`crate::linalg::solve`] does, or call it where such a longjmp is
2063    ///   caught: a `#[miniextendr]` function body, or
2064    ///   [`with_r_unwind_protect`](crate::unwind_protect::with_r_unwind_protect).
2065    ///   `#[r_ffi_checked]` gives the main-thread check only, not an
2066    ///   unwind guard.
2067    /// - Call it from R's main thread in a process where R is initialised:
2068    ///   `xerbla` is R's.
2069    ///   A standalone binary must start R first (`miniextendr-engine`).
2070    #[allow(clippy::too_many_arguments)]
2071    pub fn dgesv_(
2072        n: *const ::std::os::raw::c_int,
2073        nrhs: *const ::std::os::raw::c_int,
2074        a: *mut f64,
2075        lda: *const ::std::os::raw::c_int,
2076        ipiv: *mut ::std::os::raw::c_int,
2077        b: *mut f64,
2078        ldb: *const ::std::os::raw::c_int,
2079        info: *mut ::std::os::raw::c_int,
2080    );
2081}
2082
2083// endregion
2084
2085// region: Memory allocation (R_ext/Memory.h)
2086
2087unsafe 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 2105, 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 2113, 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 2118, 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 2123, 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 2138, 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 2145, 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 2153, 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 2163, 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 2174, 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 2180, 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 2186, 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2105, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { vmaxget_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2113, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { vmaxset_unchecked(ovmax) })
}
#[doc = " Run the R garbage collector."]
#[doc = ""]
#[doc = " Forces a full garbage collection cycle."]
#[doc =
"Checked wrapper for `R_gc`. Calls `R_gc_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2118, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_gc() {
    ::miniextendr_api::with_r_thread(move || unsafe { R_gc_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2123, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_gc_running_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main 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_alloc(nelem: usize, eltsize: ::std::os::raw::c_int)
    -> *mut ::std::os::raw::c_char {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_alloc_unchecked(nelem, eltsize) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2145, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_allocLD_unchecked(nelem) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2153, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { S_alloc_unchecked(nelem, eltsize) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2163, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { S_realloc_unchecked(ptr, newsize, oldsize, eltsize) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2174, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_malloc_gc_unchecked(size) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2180, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_calloc_gc_unchecked(nelem, eltsize) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2186, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_realloc_gc_unchecked(ptr, size) })
}#[r_ffi_checked]
2088unsafe extern "C-unwind" {
2089    /// Get the current R memory stack watermark.
2090    ///
2091    /// Use with `vmaxset()` to restore memory stack state.
2092    /// Memory allocated with `R_alloc()` between `vmaxget()` and `vmaxset()`
2093    /// will be freed when `vmaxset()` is called.
2094    ///
2095    /// # Example
2096    ///
2097    /// ```ignore
2098    /// unsafe {
2099    ///     let watermark = vmaxget();
2100    ///     let buf = R_alloc(100, 1);
2101    ///     // ... use buf ...
2102    ///     vmaxset(watermark); // frees buf
2103    /// }
2104    /// ```
2105    pub fn vmaxget() -> *mut ::std::os::raw::c_void;
2106
2107    /// Set the R memory stack watermark, freeing memory allocated since the mark.
2108    ///
2109    /// # Safety
2110    ///
2111    /// `ovmax` must be a value returned by `vmaxget()` called earlier in the
2112    /// same R evaluation context.
2113    pub fn vmaxset(ovmax: *const ::std::os::raw::c_void);
2114
2115    /// Run the R garbage collector.
2116    ///
2117    /// Forces a full garbage collection cycle.
2118    pub fn R_gc();
2119
2120    /// Check if the garbage collector is currently running.
2121    ///
2122    /// Returns non-zero if GC is in progress.
2123    pub fn R_gc_running() -> ::std::os::raw::c_int;
2124
2125    /// Allocate memory on R's memory stack.
2126    ///
2127    /// This memory is automatically freed when the calling R function returns,
2128    /// or can be freed earlier with `vmaxset()`.
2129    ///
2130    /// # Parameters
2131    ///
2132    /// - `nelem`: Number of elements to allocate
2133    /// - `eltsize`: Size of each element in bytes
2134    ///
2135    /// # Returns
2136    ///
2137    /// Pointer to allocated memory (as `char*` for compatibility with S).
2138    pub fn R_alloc(nelem: usize, eltsize: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char;
2139
2140    /// Allocate an array of long doubles on R's memory stack.
2141    ///
2142    /// # Parameters
2143    ///
2144    /// - `nelem`: Number of long double elements to allocate
2145    pub fn R_allocLD(nelem: usize) -> *mut f64; // Note: f64 is close enough for most uses
2146
2147    /// S compatibility: allocate zeroed memory on R's memory stack.
2148    ///
2149    /// # Parameters
2150    ///
2151    /// - `nelem`: Number of elements
2152    /// - `eltsize`: Size of each element
2153    pub fn S_alloc(
2154        nelem: ::std::os::raw::c_long,
2155        eltsize: ::std::os::raw::c_int,
2156    ) -> *mut ::std::os::raw::c_char;
2157
2158    /// S compatibility: reallocate memory on R's memory stack.
2159    ///
2160    /// # Safety
2161    ///
2162    /// `ptr` must have been allocated by `S_alloc`.
2163    pub fn S_realloc(
2164        ptr: *mut ::std::os::raw::c_char,
2165        newsize: ::std::os::raw::c_long,
2166        oldsize: ::std::os::raw::c_long,
2167        eltsize: ::std::os::raw::c_int,
2168    ) -> *mut ::std::os::raw::c_char;
2169
2170    /// GC-aware malloc.
2171    ///
2172    /// Triggers GC if allocation fails, then retries.
2173    /// Memory must be freed with `free()`.
2174    pub fn R_malloc_gc(size: usize) -> *mut ::std::os::raw::c_void;
2175
2176    /// GC-aware calloc.
2177    ///
2178    /// Triggers GC if allocation fails, then retries.
2179    /// Memory must be freed with `free()`.
2180    pub fn R_calloc_gc(nelem: usize, eltsize: usize) -> *mut ::std::os::raw::c_void;
2181
2182    /// GC-aware realloc.
2183    ///
2184    /// Triggers GC if allocation fails, then retries.
2185    /// Memory must be freed with `free()`.
2186    pub fn R_realloc_gc(
2187        ptr: *mut ::std::os::raw::c_void,
2188        size: usize,
2189    ) -> *mut ::std::os::raw::c_void;
2190}
2191
2192// endregion
2193
2194// region: Sorting and utility functions (R_ext/Utils.h)
2195
2196unsafe 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 2204, 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 2212, 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 2220, 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 2230, 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 2239, 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 2253, 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 2267, 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 2277, 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 2286, 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 2296, 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 2310, 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 2320, 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 2332, 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 2337, 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 2342, 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 2355, 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 2371, 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 2378, 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 2383, 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 2390, 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 2409, 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 2421, 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 2441, 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 2453, 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 2459, 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 2463, 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2204, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_isort_unchecked(x, n) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2212, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_rsort_unchecked(x, n) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2220, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_csort_unchecked(x, n) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2230, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { revsort_unchecked(a, ib, n) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2239, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { rsort_with_index_unchecked(x, indx, n) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2253, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { iPsort_unchecked(x, n, k) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2267, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { rPsort_unchecked(x, n, k) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2277, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { cPsort_unchecked(x, n, k) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2286, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_qsort_unchecked(v, i, j) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2296, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_qsort_I_unchecked(v, indx, i, j) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2310, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_qsort_int_unchecked(iv, i, j) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2320, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_qsort_int_I_unchecked(iv, indx, i, j) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2332, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ExpandFileName_unchecked(s) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2337, 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 {
    ::miniextendr_api::with_r_thread(move || unsafe { R_atof_unchecked(str) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2342, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_strtod_unchecked(c, end) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2355, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_tmpnam_unchecked(prefix, tempdir) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2371, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_tmpnam2_unchecked(prefix, tempdir, fileext) })
}
#[doc = " Free a temporary filename allocated by `R_tmpnam` or `R_tmpnam2`."]
#[doc =
"Checked wrapper for `R_free_tmpnam`. Calls `R_free_tmpnam_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2378, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_free_tmpnam_unchecked(name) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2383, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_CheckStack() {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_CheckStack_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2390, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_CheckStack2_unchecked(extra) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2409, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe {
                findInterval_unchecked(xt, n, x, rightmost_closed, all_inside,
                    ilo, mflag)
            })
}
#[doc = " Extended interval finding with left-open option."]
#[allow(clippy::too_many_arguments)]
#[doc =
"Checked wrapper for `findInterval2`. Calls `findInterval2_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2421, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe {
                findInterval2_unchecked(xt, n, x, rightmost_closed,
                    all_inside, left_open, ilo, mflag)
            })
}
#[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` inside `with_r_thread`, which panics off R's main 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 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_max_col_unchecked(matrix, nr, nc, maxes, ties_meth) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2453, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { StringFalse_unchecked(s) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2459, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { StringTrue_unchecked(s) })
}
#[doc = " Check if a string is blank (empty or only whitespace)."]
#[doc(alias = "Rf_isBlankString")]
#[doc =
"Checked wrapper for `isBlankString`. Calls `isBlankString_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2463, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { isBlankString_unchecked(s) })
}#[r_ffi_checked]
2197unsafe extern "C-unwind" {
2198    /// Sort an integer vector in place (ascending order).
2199    ///
2200    /// # Parameters
2201    ///
2202    /// - `x`: Pointer to integer array
2203    /// - `n`: Number of elements
2204    pub fn R_isort(x: *mut ::std::os::raw::c_int, n: ::std::os::raw::c_int);
2205
2206    /// Sort a double vector in place (ascending order).
2207    ///
2208    /// # Parameters
2209    ///
2210    /// - `x`: Pointer to double array
2211    /// - `n`: Number of elements
2212    pub fn R_rsort(x: *mut f64, n: ::std::os::raw::c_int);
2213
2214    /// Sort a complex vector in place.
2215    ///
2216    /// # Parameters
2217    ///
2218    /// - `x`: Pointer to Rcomplex array
2219    /// - `n`: Number of elements
2220    pub fn R_csort(x: *mut Rcomplex, n: ::std::os::raw::c_int);
2221
2222    /// Sort doubles in descending order, carrying along an index array.
2223    ///
2224    /// # Parameters
2225    ///
2226    /// - `a`: Pointer to double array (sorted in place, descending)
2227    /// - `ib`: Pointer to integer array (permuted alongside `a`)
2228    /// - `n`: Number of elements
2229    #[doc(alias = "Rf_revsort")]
2230    pub fn revsort(a: *mut f64, ib: *mut ::std::os::raw::c_int, n: ::std::os::raw::c_int);
2231
2232    /// Sort doubles with index array.
2233    ///
2234    /// # Parameters
2235    ///
2236    /// - `x`: Pointer to double array (sorted in place)
2237    /// - `indx`: Pointer to integer array (permuted alongside `x`)
2238    /// - `n`: Number of elements
2239    pub fn rsort_with_index(
2240        x: *mut f64,
2241        indx: *mut ::std::os::raw::c_int,
2242        n: ::std::os::raw::c_int,
2243    );
2244
2245    /// Partial sort integers (moves k-th smallest to position k).
2246    ///
2247    /// # Parameters
2248    ///
2249    /// - `x`: Pointer to integer array
2250    /// - `n`: Number of elements
2251    /// - `k`: Target position (0-indexed)
2252    #[doc(alias = "Rf_iPsort")]
2253    pub fn iPsort(
2254        x: *mut ::std::os::raw::c_int,
2255        n: ::std::os::raw::c_int,
2256        k: ::std::os::raw::c_int,
2257    );
2258
2259    /// Partial sort doubles (moves k-th smallest to position k).
2260    ///
2261    /// # Parameters
2262    ///
2263    /// - `x`: Pointer to double array
2264    /// - `n`: Number of elements
2265    /// - `k`: Target position (0-indexed)
2266    #[doc(alias = "Rf_rPsort")]
2267    pub fn rPsort(x: *mut f64, n: ::std::os::raw::c_int, k: ::std::os::raw::c_int);
2268
2269    /// Partial sort complex numbers.
2270    ///
2271    /// # Parameters
2272    ///
2273    /// - `x`: Pointer to Rcomplex array
2274    /// - `n`: Number of elements
2275    /// - `k`: Target position (0-indexed)
2276    #[doc(alias = "Rf_cPsort")]
2277    pub fn cPsort(x: *mut Rcomplex, n: ::std::os::raw::c_int, k: ::std::os::raw::c_int);
2278
2279    /// Quicksort doubles in place.
2280    ///
2281    /// # Parameters
2282    ///
2283    /// - `v`: Pointer to double array
2284    /// - `i`: Start index (1-indexed for R compatibility)
2285    /// - `j`: End index (1-indexed)
2286    pub fn R_qsort(v: *mut f64, i: usize, j: usize);
2287
2288    /// Quicksort doubles with index array.
2289    ///
2290    /// # Parameters
2291    ///
2292    /// - `v`: Pointer to double array
2293    /// - `indx`: Pointer to index array (permuted alongside v)
2294    /// - `i`: Start index (1-indexed)
2295    /// - `j`: End index (1-indexed)
2296    pub fn R_qsort_I(
2297        v: *mut f64,
2298        indx: *mut ::std::os::raw::c_int,
2299        i: ::std::os::raw::c_int,
2300        j: ::std::os::raw::c_int,
2301    );
2302
2303    /// Quicksort integers in place.
2304    ///
2305    /// # Parameters
2306    ///
2307    /// - `iv`: Pointer to integer array
2308    /// - `i`: Start index (1-indexed)
2309    /// - `j`: End index (1-indexed)
2310    pub fn R_qsort_int(iv: *mut ::std::os::raw::c_int, i: usize, j: usize);
2311
2312    /// Quicksort integers with index array.
2313    ///
2314    /// # Parameters
2315    ///
2316    /// - `iv`: Pointer to integer array
2317    /// - `indx`: Pointer to index array
2318    /// - `i`: Start index (1-indexed)
2319    /// - `j`: End index (1-indexed)
2320    pub fn R_qsort_int_I(
2321        iv: *mut ::std::os::raw::c_int,
2322        indx: *mut ::std::os::raw::c_int,
2323        i: ::std::os::raw::c_int,
2324        j: ::std::os::raw::c_int,
2325    );
2326
2327    /// Expand a filename, resolving `~` and environment variables.
2328    ///
2329    /// # Returns
2330    ///
2331    /// Pointer to expanded path (in R's internal buffer, do not free).
2332    pub fn R_ExpandFileName(s: *const ::std::os::raw::c_char) -> *const ::std::os::raw::c_char;
2333
2334    /// Convert string to double, always using '.' as decimal point.
2335    ///
2336    /// Also accepts "NA" as input, returning NA_REAL.
2337    pub fn R_atof(str: *const ::std::os::raw::c_char) -> f64;
2338
2339    /// Convert string to double with end pointer, using '.' as decimal point.
2340    ///
2341    /// Like `strtod()` but locale-independent.
2342    pub fn R_strtod(c: *const ::std::os::raw::c_char, end: *mut *mut ::std::os::raw::c_char)
2343    -> f64;
2344
2345    /// Generate a temporary filename.
2346    ///
2347    /// # Parameters
2348    ///
2349    /// - `prefix`: Filename prefix
2350    /// - `tempdir`: Directory for temp file
2351    ///
2352    /// # Returns
2353    ///
2354    /// Newly allocated string (must be freed with `R_free_tmpnam`).
2355    pub fn R_tmpnam(
2356        prefix: *const ::std::os::raw::c_char,
2357        tempdir: *const ::std::os::raw::c_char,
2358    ) -> *mut ::std::os::raw::c_char;
2359
2360    /// Generate a temporary filename with extension.
2361    ///
2362    /// # Parameters
2363    ///
2364    /// - `prefix`: Filename prefix
2365    /// - `tempdir`: Directory for temp file
2366    /// - `fileext`: File extension (e.g., ".txt")
2367    ///
2368    /// # Returns
2369    ///
2370    /// Newly allocated string (must be freed with `R_free_tmpnam`).
2371    pub fn R_tmpnam2(
2372        prefix: *const ::std::os::raw::c_char,
2373        tempdir: *const ::std::os::raw::c_char,
2374        fileext: *const ::std::os::raw::c_char,
2375    ) -> *mut ::std::os::raw::c_char;
2376
2377    /// Free a temporary filename allocated by `R_tmpnam` or `R_tmpnam2`.
2378    pub fn R_free_tmpnam(name: *mut ::std::os::raw::c_char);
2379
2380    /// Check for R stack overflow.
2381    ///
2382    /// Throws an R error if stack is nearly exhausted.
2383    pub fn R_CheckStack();
2384
2385    /// Check for R stack overflow with extra space requirement.
2386    ///
2387    /// # Parameters
2388    ///
2389    /// - `extra`: Additional bytes needed
2390    pub fn R_CheckStack2(extra: usize);
2391
2392    /// Find the interval containing a value (binary search).
2393    ///
2394    /// Used for interpolation and binning.
2395    ///
2396    /// # Parameters
2397    ///
2398    /// - `xt`: Sorted breakpoints array
2399    /// - `n`: Number of breakpoints
2400    /// - `x`: Value to find
2401    /// - `rightmost_closed`: If TRUE, rightmost interval is closed
2402    /// - `all_inside`: If TRUE, out-of-bounds values map to endpoints
2403    /// - `ilo`: Initial guess for interval (1-indexed)
2404    /// - `mflag`: Output flag (see R documentation)
2405    ///
2406    /// # Returns
2407    ///
2408    /// Interval index (1-indexed).
2409    pub fn findInterval(
2410        xt: *const f64,
2411        n: ::std::os::raw::c_int,
2412        x: f64,
2413        rightmost_closed: Rboolean,
2414        all_inside: Rboolean,
2415        ilo: ::std::os::raw::c_int,
2416        mflag: *mut ::std::os::raw::c_int,
2417    ) -> ::std::os::raw::c_int;
2418
2419    /// Extended interval finding with left-open option.
2420    #[allow(clippy::too_many_arguments)]
2421    pub fn findInterval2(
2422        xt: *const f64,
2423        n: ::std::os::raw::c_int,
2424        x: f64,
2425        rightmost_closed: Rboolean,
2426        all_inside: Rboolean,
2427        left_open: Rboolean,
2428        ilo: ::std::os::raw::c_int,
2429        mflag: *mut ::std::os::raw::c_int,
2430    ) -> ::std::os::raw::c_int;
2431
2432    /// Find column maxima in a matrix.
2433    ///
2434    /// # Parameters
2435    ///
2436    /// - `matrix`: Column-major matrix data
2437    /// - `nr`: Number of rows
2438    /// - `nc`: Number of columns
2439    /// - `maxes`: Output array for column maxima indices (1-indexed)
2440    /// - `ties_meth`: How to handle ties (1=first, 2=random, 3=last)
2441    pub fn R_max_col(
2442        matrix: *const f64,
2443        nr: *const ::std::os::raw::c_int,
2444        nc: *const ::std::os::raw::c_int,
2445        maxes: *mut ::std::os::raw::c_int,
2446        ties_meth: *const ::std::os::raw::c_int,
2447    );
2448
2449    /// Check if a string represents FALSE in R.
2450    ///
2451    /// Recognizes "FALSE", "false", "False", "F", "f", etc.
2452    #[doc(alias = "Rf_StringFalse")]
2453    pub fn StringFalse(s: *const ::std::os::raw::c_char) -> Rboolean;
2454
2455    /// Check if a string represents TRUE in R.
2456    ///
2457    /// Recognizes "TRUE", "true", "True", "T", "t", etc.
2458    #[doc(alias = "Rf_StringTrue")]
2459    pub fn StringTrue(s: *const ::std::os::raw::c_char) -> Rboolean;
2460
2461    /// Check if a string is blank (empty or only whitespace).
2462    #[doc(alias = "Rf_isBlankString")]
2463    pub fn isBlankString(s: *const ::std::os::raw::c_char) -> Rboolean;
2464}
2465
2466// endregion
2467
2468// region: Additional Rinternals.h functions
2469
2470unsafe 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 2482, 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 2497, 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 2509, 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 2515, 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 2527, 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 2532, 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 2539, 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 2546, 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 2564, 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 2572, 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 2585, 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 2596, 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 2600, 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 2612, 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 2618, 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 2624, 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 2630, 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 2634, 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 2643, 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 2651, 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 2657, 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 2661, 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 2671, 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 2682, 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 2694, 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 2697, 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 2700, 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 2703, 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 2706, 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 2712, 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 2716, 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 2724, 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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2482, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_mkCharCE_unchecked(s, encoding) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2497, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_nchar_unchecked(x, ntype, allowNA, keepNA, msg_name) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2509, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_type2char_unchecked(sexptype) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2515, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_PrintValue_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2527, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_NewEnv_unchecked(enclos, hash, size) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2532, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_existsVarInFrame_unchecked(rho, symbol) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2539, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_removeVarFromFrame_unchecked(symbol, env) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2546, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_topenv_unchecked(target, envir) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2564, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_match_unchecked(x, table, nomatch) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2572, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_copyMostAttrib_unchecked(source, target) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2585, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_any_duplicated_unchecked(x, fromLast) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2596, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_asS4_unchecked(object, flag, complete) })
}
#[doc = " Get the S3 class of an S4 object."]
#[doc(alias = "S3Class")]
#[doc =
"Checked wrapper for `Rf_S3Class`. Calls `Rf_S3Class_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2600, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_S3Class_unchecked(object) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2612, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_GetOption1_unchecked(tag) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2618, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_GetOptionDigits_unchecked() })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2624, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_GetOptionWidth_unchecked() })
}
#[doc = " Check if a factor is ordered."]
#[doc(alias = "isOrdered")]
#[doc =
"Checked wrapper for `Rf_isOrdered`. Calls `Rf_isOrdered_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2630, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isOrdered_unchecked(s) })
}
#[doc = " Check if a factor is unordered."]
#[doc(alias = "isUnordered")]
#[doc =
"Checked wrapper for `Rf_isUnordered`. Calls `Rf_isUnordered_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2634, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isUnordered_unchecked(s) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2643, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_isUnsorted_unchecked(x, strictly) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2651, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_substitute_unchecked(lang, rho) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2657, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_lengthgets_unchecked(x, newlen) })
}
#[doc = " Set vector length (long vector version)."]
#[doc(alias = "xlengthgets")]
#[doc =
"Checked wrapper for `Rf_xlengthgets`. Calls `Rf_xlengthgets_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2661, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_xlengthgets_unchecked(x, newlen) })
}
#[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` inside `with_r_thread`, which panics off R's main 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 R_ProtectWithIndex(s: SEXP, index: *mut ::std::os::raw::c_int) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_ProtectWithIndex_unchecked(s, index) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2682, 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) {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_Reprotect_unchecked(s, index) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2694, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_MakeWeakRef_unchecked(key, val, fin, onexit) })
}
#[doc = " Create a weak reference with C finalizer."]
#[doc =
"Checked wrapper for `R_MakeWeakRefC`. Calls `R_MakeWeakRefC_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2697, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_MakeWeakRefC_unchecked(key, val, fin, onexit) })
}
#[doc = " Get the key from a weak reference."]
#[doc =
"Checked wrapper for `R_WeakRefKey`. Calls `R_WeakRefKey_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2700, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_WeakRefKey_unchecked(w) })
}
#[doc = " Get the value from a weak reference."]
#[doc =
"Checked wrapper for `R_WeakRefValue`. Calls `R_WeakRefValue_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2703, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_WeakRefValue_unchecked(w) })
}
#[doc = " Run pending finalizers."]
#[doc =
"Checked wrapper for `R_RunPendingFinalizers`. Calls `R_RunPendingFinalizers_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2706, column 12."]
#[doc = "Generated from source file `miniextendr-api/src/sys.rs`."]
#[inline(always)]
#[allow(non_snake_case)]
pub unsafe fn R_RunPendingFinalizers() {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { R_RunPendingFinalizers_unchecked() })
}
#[doc = " Convert a pairlist to a generic vector (list)."]
#[doc(alias = "PairToVectorList")]
#[doc =
"Checked wrapper for `Rf_PairToVectorList`. Calls `Rf_PairToVectorList_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2712, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_PairToVectorList_unchecked(x) })
}
#[doc = " Convert a generic vector (list) to a pairlist."]
#[doc(alias = "VectorToPairList")]
#[doc =
"Checked wrapper for `Rf_VectorToPairList`. Calls `Rf_VectorToPairList_unchecked` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2716, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_VectorToPairList_unchecked(x) })
}
#[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` inside `with_r_thread`, which panics off R's main thread."]
#[doc = "Generated from source location line 2724, 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 {
    ::miniextendr_api::with_r_thread(move ||
            unsafe { Rf_installChar_unchecked(x) })
}#[r_ffi_checked]
2471unsafe extern "C-unwind" {
2472    // String/character functions
2473
2474    /// Create a CHARSXP with specified encoding.
2475    ///
2476    /// # Parameters
2477    ///
2478    /// - `s`: C string
2479    /// - `encoding`: Character encoding (CE_UTF8, CE_LATIN1, etc.)
2480    // Issue #112 cat. 10: kept pub(crate) — 2 callers in encoding.rs; wrapping adds no value
2481    #[doc(alias = "mkCharCE")]
2482    pub(crate) fn Rf_mkCharCE(s: *const ::std::os::raw::c_char, encoding: cetype_t) -> SEXP;
2483
2484    /// Get the number of characters in a string/character.
2485    ///
2486    /// # Parameters
2487    ///
2488    /// - `x`: A string SEXP
2489    /// - `ntype`: Type of count (0=bytes, 1=chars, 2=width)
2490    /// - `allowNA`: Whether to allow NA values
2491    /// - `keepNA`: Whether to keep NA in result
2492    /// - `msg_name`: Name for error messages
2493    ///
2494    /// # Returns
2495    ///
2496    /// Character count or -1 on error.
2497    pub fn R_nchar(
2498        x: SEXP,
2499        ntype: ::std::os::raw::c_int,
2500        allowNA: Rboolean,
2501        keepNA: Rboolean,
2502        msg_name: *const ::std::os::raw::c_char,
2503    ) -> ::std::os::raw::c_int;
2504
2505    /// Convert SEXPTYPE to C string name.
2506    ///
2507    /// Returns a string like "INTSXP", "REALSXP", etc.
2508    #[doc(alias = "type2char")]
2509    pub fn Rf_type2char(sexptype: SEXPTYPE) -> *const ::std::os::raw::c_char;
2510
2511    /// Print an R value to the console.
2512    ///
2513    /// Uses R's standard print method for the object.
2514    #[doc(alias = "PrintValue")]
2515    pub fn Rf_PrintValue(x: SEXP);
2516
2517    // Environment functions
2518
2519    /// Create a new environment.
2520    ///
2521    /// # Parameters
2522    ///
2523    /// - `enclos`: Enclosing environment
2524    /// - `hash`: Whether to use a hash table
2525    /// - `size`: Initial hash table size (if hash is TRUE)
2526    // Issue #112 cat. 10: kept pub(crate) — 2 callers in environment.rs; wrapping adds no value
2527    pub(crate) fn R_NewEnv(enclos: SEXP, hash: Rboolean, size: ::std::os::raw::c_int) -> SEXP;
2528
2529    /// Check if a variable exists in an environment frame.
2530    ///
2531    /// Does not search enclosing environments.
2532    pub fn R_existsVarInFrame(rho: SEXP, symbol: SEXP) -> Rboolean;
2533
2534    /// Remove a variable from an environment frame.
2535    ///
2536    /// # Returns
2537    ///
2538    /// The removed value, or R_NilValue if not found.
2539    pub fn R_removeVarFromFrame(symbol: SEXP, env: SEXP) -> SEXP;
2540
2541    /// Get the top-level environment.
2542    ///
2543    /// Walks up enclosing environments until reaching a top-level env
2544    /// (global, namespace, or base).
2545    #[doc(alias = "topenv")]
2546    pub fn Rf_topenv(target: SEXP, envir: SEXP) -> SEXP;
2547
2548    // Matching functions
2549
2550    /// Match elements of first vector in second vector.
2551    ///
2552    /// Like R's `match()` function.
2553    ///
2554    /// # Parameters
2555    ///
2556    /// - `x`: Vector of values to match
2557    /// - `table`: Vector to match against
2558    /// - `nomatch`: Value to return for non-matches
2559    ///
2560    /// # Returns
2561    ///
2562    /// Integer vector of match positions (1-indexed, nomatch for non-matches).
2563    #[doc(alias = "match")]
2564    pub fn Rf_match(x: SEXP, table: SEXP, nomatch: ::std::os::raw::c_int) -> SEXP;
2565
2566    // Duplication and copying
2567
2568    /// Copy most attributes from source to target.
2569    ///
2570    /// Copies all attributes except names, dim, and dimnames.
2571    #[doc(alias = "copyMostAttrib")]
2572    pub fn Rf_copyMostAttrib(source: SEXP, target: SEXP);
2573
2574    /// Find first duplicated element.
2575    ///
2576    /// # Parameters
2577    ///
2578    /// - `x`: Vector to search
2579    /// - `fromLast`: If TRUE, search from end
2580    ///
2581    /// # Returns
2582    ///
2583    /// 0 if no duplicates, otherwise 1-indexed position of first duplicate.
2584    #[doc(alias = "any_duplicated")]
2585    pub fn Rf_any_duplicated(x: SEXP, fromLast: Rboolean) -> R_xlen_t;
2586
2587    // S4 functions
2588
2589    /// Convert to an S4 object.
2590    ///
2591    /// # Parameters
2592    ///
2593    /// - `object`: Object to convert
2594    /// - `flag`: Conversion flag
2595    #[doc(alias = "asS4")]
2596    pub fn Rf_asS4(object: SEXP, flag: Rboolean, complete: ::std::os::raw::c_int) -> SEXP;
2597
2598    /// Get the S3 class of an S4 object.
2599    #[doc(alias = "S3Class")]
2600    pub fn Rf_S3Class(object: SEXP) -> SEXP;
2601
2602    // Option access
2603
2604    /// Get an R option value.
2605    ///
2606    /// Equivalent to `getOption("name")` in R.
2607    ///
2608    /// # Parameters
2609    ///
2610    /// - `tag`: Symbol for option name
2611    #[doc(alias = "GetOption1")]
2612    pub fn Rf_GetOption1(tag: SEXP) -> SEXP;
2613
2614    /// Get the `digits` option.
2615    ///
2616    /// Returns the value of `getOption("digits")`.
2617    #[doc(alias = "GetOptionDigits")]
2618    pub fn Rf_GetOptionDigits() -> ::std::os::raw::c_int;
2619
2620    /// Get the `width` option.
2621    ///
2622    /// Returns the value of `getOption("width")`.
2623    #[doc(alias = "GetOptionWidth")]
2624    pub(crate) fn Rf_GetOptionWidth() -> ::std::os::raw::c_int;
2625
2626    // Factor functions
2627
2628    /// Check if a factor is ordered.
2629    #[doc(alias = "isOrdered")]
2630    pub fn Rf_isOrdered(s: SEXP) -> Rboolean;
2631
2632    /// Check if a factor is unordered.
2633    #[doc(alias = "isUnordered")]
2634    pub fn Rf_isUnordered(s: SEXP) -> Rboolean;
2635
2636    /// Check if a vector is unsorted.
2637    ///
2638    /// # Parameters
2639    ///
2640    /// - `x`: Vector to check
2641    /// - `strictly`: If TRUE, check for strictly increasing
2642    #[doc(alias = "isUnsorted")]
2643    pub fn Rf_isUnsorted(x: SEXP, strictly: Rboolean) -> ::std::os::raw::c_int;
2644
2645    // Expression and evaluation
2646
2647    /// Substitute in an expression.
2648    ///
2649    /// Like R's `substitute()` function.
2650    #[doc(alias = "substitute")]
2651    pub fn Rf_substitute(lang: SEXP, rho: SEXP) -> SEXP;
2652
2653    /// Set vector length.
2654    ///
2655    /// For short vectors (length < 2^31).
2656    #[doc(alias = "lengthgets")]
2657    pub fn Rf_lengthgets(x: SEXP, newlen: R_xlen_t) -> SEXP;
2658
2659    /// Set vector length (long vector version).
2660    #[doc(alias = "xlengthgets")]
2661    pub fn Rf_xlengthgets(x: SEXP, newlen: R_xlen_t) -> SEXP;
2662
2663    // Protection (indexed — see cost table in the "GC protection" region above)
2664
2665    /// Protect a SEXP and record its stack index for later `R_Reprotect`.
2666    ///
2667    /// **Cost: O(1)** — same array write as `Rf_protect`, plus stores the index.
2668    /// No allocation. Use when you need to replace a protected value in-place
2669    /// (e.g., inside a loop that allocates) without unprotect/re-protect churn.
2670    #[doc(alias = "PROTECT_WITH_INDEX")]
2671    pub fn R_ProtectWithIndex(s: SEXP, index: *mut ::std::os::raw::c_int);
2672
2673    /// Replace the SEXP at a previously recorded protect stack index.
2674    ///
2675    /// **Cost: O(1)** — direct array write (`R_PPStack[index] = s`). No allocation.
2676    ///
2677    /// # Safety
2678    ///
2679    /// `index` must be from a previous `R_ProtectWithIndex` call and the
2680    /// stack must not have been unprotected past that index.
2681    #[doc(alias = "REPROTECT")]
2682    pub fn R_Reprotect(s: SEXP, index: ::std::os::raw::c_int);
2683
2684    // Weak references
2685
2686    /// Create a weak reference.
2687    ///
2688    /// # Parameters
2689    ///
2690    /// - `key`: The key object (weak reference target)
2691    /// - `val`: The value to associate
2692    /// - `fin`: Finalizer function (or R_NilValue)
2693    /// - `onexit`: Whether to run finalizer on R exit
2694    pub fn R_MakeWeakRef(key: SEXP, val: SEXP, fin: SEXP, onexit: Rboolean) -> SEXP;
2695
2696    /// Create a weak reference with C finalizer.
2697    pub fn R_MakeWeakRefC(key: SEXP, val: SEXP, fin: R_CFinalizer_t, onexit: Rboolean) -> SEXP;
2698
2699    /// Get the key from a weak reference.
2700    pub fn R_WeakRefKey(w: SEXP) -> SEXP;
2701
2702    /// Get the value from a weak reference.
2703    pub fn R_WeakRefValue(w: SEXP) -> SEXP;
2704
2705    /// Run pending finalizers.
2706    pub fn R_RunPendingFinalizers();
2707
2708    // Conversion list/vector
2709
2710    /// Convert a pairlist to a generic vector (list).
2711    #[doc(alias = "PairToVectorList")]
2712    pub fn Rf_PairToVectorList(x: SEXP) -> SEXP;
2713
2714    /// Convert a generic vector (list) to a pairlist.
2715    #[doc(alias = "VectorToPairList")]
2716    pub fn Rf_VectorToPairList(x: SEXP) -> SEXP;
2717
2718    // Install with CHARSXP
2719
2720    /// Install a symbol from a CHARSXP.
2721    ///
2722    /// Like `Rf_install()` but takes a CHARSXP instead of C string.
2723    #[doc(alias = "installChar")]
2724    pub fn Rf_installChar(x: SEXP) -> SEXP;
2725}
2726
2727// endregion