/* automatically generated by rust-bindgen 0.72.1 */

pub type size_t = ::core::ffi::c_ulong;
/// The enumerated type nvrtcResult defines API call result codes.
///
/// NVRTC API functions return nvrtcResult to indicate the call result.
#[repr(u32)]
#[derive(
    Debug,
    Copy,
    Clone,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    TryFromPrimitive,
    IntoPrimitive,
)]
pub enum nvrtcResult {
    NVRTC_SUCCESS = 0,
    NVRTC_ERROR_OUT_OF_MEMORY = 1,
    NVRTC_ERROR_PROGRAM_CREATION_FAILURE = 2,
    NVRTC_ERROR_INVALID_INPUT = 3,
    NVRTC_ERROR_INVALID_PROGRAM = 4,
    NVRTC_ERROR_INVALID_OPTION = 5,
    NVRTC_ERROR_COMPILATION = 6,
    NVRTC_ERROR_BUILTIN_OPERATION_FAILURE = 7,
    NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 8,
    NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 9,
    NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 10,
    NVRTC_ERROR_INTERNAL_ERROR = 11,
    NVRTC_ERROR_TIME_FILE_WRITE_FAILED = 12,
    NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED = 13,
    NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED = 14,
    NVRTC_ERROR_PCH_CREATE = 15,
    NVRTC_ERROR_CANCELLED = 16,
    NVRTC_ERROR_TIME_TRACE_FILE_WRITE_FAILED = 17,
}
unsafe extern "C" {
    /// nvrtcGetErrorString is a helper function that returns a string describing the given nvrtcResult code, e.g., [`nvrtcResult::NVRTC_SUCCESS`] to `"NVRTC_SUCCESS"`.
    ///
    /// For unrecognized enumeration values, it returns `"NVRTC_ERROR unknown"`.
    ///
    /// # Parameters
    ///
    /// - `result`: CUDA Runtime Compilation API result code.
    pub fn nvrtcGetErrorString(result: nvrtcResult) -> *const ::core::ffi::c_char;
}
unsafe extern "C" {
    /// nvrtcVersion sets the output parameters `major` and `minor` with the CUDA Runtime Compilation version number.
    ///
    /// # Parameters
    ///
    /// - `major`: CUDA Runtime Compilation major version number.
    /// - `minor`: CUDA Runtime Compilation minor version number.
    pub fn nvrtcVersion(
        major: *mut ::core::ffi::c_int,
        minor: *mut ::core::ffi::c_int,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetNumSupportedArchs sets the output parameter `numArchs` with the number of architectures supported by NVRTC.
    ///
    /// This can then be used to pass an array to [`nvrtcGetSupportedArchs`] to get the supported architectures.
    ///
    /// see [`nvrtcGetSupportedArchs`].
    ///
    /// # Parameters
    ///
    /// - `numArchs`: number of supported architectures.
    pub fn nvrtcGetNumSupportedArchs(numArchs: *mut ::core::ffi::c_int) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetSupportedArchs populates the array passed via the output parameter `supportedArchs` with the architectures supported by NVRTC.
    ///
    /// The array is sorted in the ascending order. The size of the array to be passed can be determined using [`nvrtcGetNumSupportedArchs`].
    ///
    /// see [`nvrtcGetNumSupportedArchs`].
    ///
    /// # Parameters
    ///
    /// - `supportedArchs`: sorted array of supported architectures.
    pub fn nvrtcGetSupportedArchs(
        supportedArchs: *mut ::core::ffi::c_int,
    ) -> nvrtcResult;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _nvrtcProgram {
    _unused: [u8; 0],
}
/// nvrtcProgram is the unit of compilation, and an opaque handle for a program.
///
/// To compile a CUDA program string, an instance of nvrtcProgram must be created first with [`nvrtcCreateProgram`], then compiled with [`nvrtcCompileProgram`].
pub type nvrtcProgram = *mut _nvrtcProgram;
unsafe extern "C" {
    /// nvrtcCreateProgram creates an instance of nvrtcProgram with the given input parameters, and sets the output parameter `prog` with it.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `src`: CUDA program source.
    /// - `name`: CUDA program name. name can be NULL ; "default_program" is used when name is NULL or “”.
    /// - `numHeaders`: Number of headers used. numHeaders must be greater than or equal to 0.
    /// - `headers`: Sources of the headers. headers can be NULL when numHeaders is 0.
    /// - `includeNames`: Name of each header by which they can be included in the CUDA program source. includeNames can be NULL when numHeaders is 0. These headers must be included with the exact names specified here.
    pub fn nvrtcCreateProgram(
        prog: *mut nvrtcProgram,
        src: *const ::core::ffi::c_char,
        name: *const ::core::ffi::c_char,
        numHeaders: ::core::ffi::c_int,
        headers: *const *const ::core::ffi::c_char,
        includeNames: *const *const ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcDestroyProgram destroys the given program.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    pub fn nvrtcDestroyProgram(prog: *mut nvrtcProgram) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcCompileProgram compiles the given program.
    ///
    /// It supports compile options listed in Supported Compile Options.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `numOptions`: Number of compiler options passed.
    /// - `options`: Compiler options in the form of C string array. options can be NULL when numOptions is 0.
    pub fn nvrtcCompileProgram(
        prog: nvrtcProgram,
        numOptions: ::core::ffi::c_int,
        options: *const *const ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetPTXSize sets the value of `ptxSizeRet` with the size of the PTX generated by the previous compilation of `prog` (including the trailing `NULL`).
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `ptxSizeRet`: Size of the generated PTX (including the trailing NULL ).
    pub fn nvrtcGetPTXSize(prog: nvrtcProgram, ptxSizeRet: *mut size_t) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetPTX stores the PTX generated by the previous compilation of `prog` in the memory pointed by `ptx`.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `ptx`: Compiled result.
    pub fn nvrtcGetPTX(prog: nvrtcProgram, ptx: *mut ::core::ffi::c_char) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetCUBINSize sets the value of `cubinSizeRet` with the size of the cubin generated by the previous compilation of `prog`.
    ///
    /// The value of cubinSizeRet is set to 0 if the value specified to `-arch` is a virtual architecture instead of an actual architecture.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `cubinSizeRet`: Size of the generated cubin.
    pub fn nvrtcGetCUBINSize(
        prog: nvrtcProgram,
        cubinSizeRet: *mut size_t,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetCUBIN stores the cubin generated by the previous compilation of `prog` in the memory pointed by `cubin`.
    ///
    /// No cubin is available if the value specified to `-arch` is a virtual architecture instead of an actual architecture.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `cubin`: Compiled and assembled result.
    pub fn nvrtcGetCUBIN(
        prog: nvrtcProgram,
        cubin: *mut ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetLTOIRSize sets the value of `LTOIRSizeRet` with the size of the LTO IR generated by the previous compilation of `prog`.
    ///
    /// The value of LTOIRSizeRet is set to 0 if the program was not compiled with `-dlto`.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `LTOIRSizeRet`: Size of the generated LTO IR.
    pub fn nvrtcGetLTOIRSize(
        prog: nvrtcProgram,
        LTOIRSizeRet: *mut size_t,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetLTOIR stores the LTO IR generated by the previous compilation of `prog` in the memory pointed by `LTOIR`.
    ///
    /// No LTO IR is available if the program was compiled without `-dlto`.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `LTOIR`: Compiled result.
    pub fn nvrtcGetLTOIR(
        prog: nvrtcProgram,
        LTOIR: *mut ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetOptiXIRSize sets the value of `optixirSizeRet` with the size of the OptiX IR generated by the previous compilation of `prog`.
    ///
    /// The value of nvrtcGetOptiXIRSize is set to 0 if the program was compiled with options incompatible with OptiX IR generation.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `optixirSizeRet`: Size of the generated LTO IR.
    pub fn nvrtcGetOptiXIRSize(
        prog: nvrtcProgram,
        optixirSizeRet: *mut size_t,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetOptiXIR stores the OptiX IR generated by the previous compilation of `prog` in the memory pointed by `optixir`.
    ///
    /// No OptiX IR is available if the program was compiled with options incompatible with OptiX IR generation.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `optixir`: Optix IR Compiled result.
    pub fn nvrtcGetOptiXIR(
        prog: nvrtcProgram,
        optixir: *mut ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetProgramLogSize sets `logSizeRet` with the size of the log generated by the previous compilation of `prog` (including the trailing `NULL`).
    ///
    /// Note that compilation log may be generated with warnings and informative messages, even when the compilation of `prog` succeeds.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `logSizeRet`: Size of the compilation log (including the trailing NULL ).
    pub fn nvrtcGetProgramLogSize(
        prog: nvrtcProgram,
        logSizeRet: *mut size_t,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetProgramLog stores the log generated by the previous compilation of `prog` in the memory pointed by `log`.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `log`: Compilation log.
    pub fn nvrtcGetProgramLog(
        prog: nvrtcProgram,
        log: *mut ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcAddNameExpression notes the given name expression denoting the address of a **global** function or **device**/__constant__ variable.
    ///
    /// The identical name expression string must be provided on a subsequent call to nvrtcGetLoweredName to extract the lowered name.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `name_expression`: constant expression denoting the address of a global function or device /__constant__ variable.
    pub fn nvrtcAddNameExpression(
        prog: nvrtcProgram,
        name_expression: *const ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcGetLoweredName extracts the lowered (mangled) name for a **global** function or **device**/__constant__ variable, and updates \*lowered_name to point to it.
    ///
    /// The memory containing the name is released when the NVRTC program is destroyed by nvrtcDestroyProgram. The identical name expression must have been previously provided to nvrtcAddNameExpression.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `name_expression`: constant expression denoting the address of a global function or device /__constant__ variable.
    /// - `lowered_name`: initialized by the function to point to a C string containing the lowered (mangled) name corresponding to the provided name expression.
    pub fn nvrtcGetLoweredName(
        prog: nvrtcProgram,
        name_expression: *const ::core::ffi::c_char,
        lowered_name: *mut *const ::core::ffi::c_char,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// retrieve the current size of the PCH Heap.
    ///
    /// # Parameters
    ///
    /// - `ret`: pointer to location where the size of the PCH Heap will be stored.
    pub fn nvrtcGetPCHHeapSize(ret: *mut size_t) -> nvrtcResult;
}
unsafe extern "C" {
    /// set the size of the PCH Heap.
    ///
    /// The requested size may be rounded up to a platform dependent alignment (e.g. page size). If the PCH Heap has already been allocated, the heap memory will be freed and a new PCH Heap will be allocated.
    ///
    /// # Parameters
    ///
    /// - `size`: requested size of the PCH Heap, in bytes.
    pub fn nvrtcSetPCHHeapSize(size: size_t) -> nvrtcResult;
}
unsafe extern "C" {
    /// returns the PCH creation status.
    ///
    /// [`nvrtcResult::NVRTC_SUCCESS`] indicates that the PCH was successfully created. [`nvrtcResult::NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED`] indicates that no PCH creation was attempted, either because PCH functionality was not requested during the preceding nvrtcCompileProgram call, or automatic PCH processing was requested, and compiler chose not to create a PCH file. [`nvrtcResult::NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED`] indicates that a PCH file could potentially have been created, but the compiler ran out space in the PCH heap. In this scenario, the [`nvrtcGetPCHHeapSizeRequired`] can be used to query the required heap size, the heap can be reallocated for this size with [`nvrtcSetPCHHeapSize`] and PCH creation may be reattempted again invoking [`nvrtcCompileProgram`] with a new NVRTC program instance. [`nvrtcResult::NVRTC_ERROR_PCH_CREATE`] indicates that an error condition prevented the PCH file from being created.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    pub fn nvrtcGetPCHCreateStatus(prog: nvrtcProgram) -> nvrtcResult;
}
unsafe extern "C" {
    /// retrieve the required size of the PCH heap required to compile the given program.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `size`: pointer to location where the required size of the PCH Heap will be stored.
    ///
    /// # Return value
    ///
    /// - [`nvrtcResult::NVRTC_ERROR_INVALID_INPUT`]: The size retrieved using this function is only valid if nvrtcGetPCHCreateStatus() returned [`nvrtcResult::NVRTC_SUCCESS`] or [`nvrtcResult::NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED`].
    pub fn nvrtcGetPCHHeapSizeRequired(
        prog: nvrtcProgram,
        size: *mut size_t,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    /// nvrtcSetFlowCallback registers a callback function that the compiler will invoke at different points during a call to nvrtcCompileProgram, and the callback function can decide whether to cancel compilation by returning specific values.
    ///
    /// The callback function must satisfy the following constraints:
    ///
    /// (1) Its signature should be:
    ///
    /// (2) It must return 1 to cancel compilation or 0 to continue. Other return values are reserved for future use.
    ///
    /// (3) It must return consistent values. Once it returns 1 at one point, it must return 1 in all following invocations during the current nvrtcCompileProgram call in progress.
    ///
    /// (4) It must be thread-safe.
    ///
    /// (5) It must not invoke any nvrtc/libnvvm/ptx APIs.
    ///
    /// # Parameters
    ///
    /// - `prog`: CUDA Runtime Compilation program.
    /// - `callback`: the callback that issues cancellation signal.
    /// - `payload`: to be passed as a parameter when invoking the callback.
    pub fn nvrtcSetFlowCallback(
        prog: nvrtcProgram,
        callback: ::core::option::Option<
            unsafe extern "C" fn(
                arg1: *mut ::core::ffi::c_void,
                arg2: *mut ::core::ffi::c_void,
            ) -> ::core::ffi::c_int,
        >,
        payload: *mut ::core::ffi::c_void,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    pub fn nvrtcGetTileIRSize(
        prog: nvrtcProgram,
        TileIRSizeRet: *mut size_t,
    ) -> nvrtcResult;
}
unsafe extern "C" {
    pub fn nvrtcGetTileIR(
        prog: nvrtcProgram,
        TileIR: *mut ::core::ffi::c_char,
    ) -> nvrtcResult;
}
