1use std::os::raw::{c_char, c_int, c_void};
5
6pub const CUFILE_VERSION: u32 = 1000;
8
9pub const CU_FILE_SUCCESS: i32 = 0;
11
12pub const CU_FILE_DRIVER_NOT_INITIALIZED: i32 = 5001;
14
15pub const CU_FILE_DRIVER_INVALID_PROPS: i32 = 5002;
17
18pub const CU_FILE_DRIVER_UNSUPPORTED_LIMIT: i32 = 5003;
20
21pub const CU_FILE_DRIVER_VERSION_MISMATCH: i32 = 5004;
23
24pub const CU_FILE_DRIVER_VERSION_READ_ERROR: i32 = 5005;
26
27pub const CU_FILE_DRIVER_CLOSING: i32 = 5006;
29
30pub const CU_FILE_PLATFORM_NOT_SUPPORTED: i32 = 500;
32
33pub const CU_FILE_IO_NOT_SUPPORTED: i32 = 5008;
35
36pub const CU_FILE_DEVICE_NOT_SUPPORTED: i32 = 5009;
38
39pub const CU_FILE_NVFS_DRIVER_ERROR: i32 = 5010;
41
42pub const CU_FILE_CUDA_DRIVER_ERROR: i32 = 5011;
47
48pub const CU_FILE_CUDA_POINTER_INVALID: i32 = 5012;
50
51pub const CU_FILE_CUDA_MEMORY_TYPE_INVALID: i32 = 5013;
53
54pub const CU_FILE_CUDA_POINTER_RANGE_ERROR: i32 = 5014;
56
57pub const CU_FILE_CUDA_CONTEXT_MISMATCH: i32 = 5015;
59
60pub const CU_FILE_INVALID_MAPPING_SIZE: i32 = 5016;
62
63pub const CU_FILE_INVALID_MAPPING_RANGE: i32 = 5017;
65
66pub const CU_FILE_INVALID_FILE_TYPE: i32 = 5018;
68
69pub const CU_FILE_INVALID_FILE_OPEN_FLAG: i32 = 5019;
71
72pub const CU_FILE_DIO_NOT_SET: i32 = 5020;
74
75pub const CU_FILE_INVALID_VALUE: i32 = 5022;
77
78pub const CU_FILE_MEMORY_ALREADY_REGISTERED: i32 = 5023;
80
81pub const CU_FILE_MEMORY_NOT_REGISTERED: i32 = 5024;
83
84pub const CU_FILE_PERMISSION_DENIED: i32 = 5025;
86
87pub const CU_FILE_DRIVER_ALREADY_OPEN: i32 = 5026;
89
90pub const CU_FILE_HANDLE_NOT_REGISTERED: i32 = 5027;
92
93pub const CU_FILE_HANDLE_ALREADY_REGISTERED: i32 = 5028;
95
96pub const CU_FILE_DEVICE_NOT_FOUND: i32 = 5029;
98
99pub const CU_FILE_INTERNAL_ERROR: i32 = 5030;
101
102pub const CU_FILE_GETNEWFD_FAILED: i32 = 5031;
104
105pub const CU_FILE_NVFS_SETUP_ERROR: i32 = 5033;
107
108pub const CU_FILE_IO_DISABLED: i32 = 5034;
110
111pub const CU_FILE_BATCH_SUBMIT_FAILED: i32 = 5035;
113
114pub const CU_FILE_GPU_MEMORY_PINNING_FAILED: i32 = 5036;
116
117pub const CU_FILE_BATCH_FULL: i32 = 5037;
119
120pub const CU_FILE_ASYNC_NOT_SUPPORTED: i32 = 5038;
122
123pub type CUfileHandle_t = *mut c_void;
125
126#[repr(C)]
127#[derive(Debug, Copy, Clone, PartialEq, Eq)]
128pub enum CUfileFileHandleType {
129 CU_FILE_HANDLE_TYPE_OPAQUE_FD = 1,
131 CU_FILE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
133 CU_FILE_HANDLE_TYPE_USERSPACE_FS = 3,
135}
136
137#[repr(C)]
138pub union CUfileDescrHandle {
139 pub fd: c_int, pub handle: *mut c_void, }
142
143#[repr(C)]
144pub struct CUfileDescr_t {
145 pub type_: CUfileFileHandleType,
146 pub handle: CUfileDescrHandle,
147 pub fs_ops: *const c_void,
148}
149
150
151pub type CUfileError_t = c_int;
153
154extern "C" {
155 pub fn cuFileDriverOpen() -> CUfileError_t;
157 pub fn cuFileDriverClose() -> CUfileError_t;
158
159 pub fn cuFileHandleRegister(
161 fh: *mut CUfileHandle_t,
162 descr: *mut CUfileDescr_t,
163 ) -> CUfileError_t;
164 pub fn cuFileHandleDeregister(fh: CUfileHandle_t) -> CUfileError_t;
165
166 pub fn cuFileBufRegister(devPtr_base: *const c_void, size: usize, flags: c_int) -> CUfileError_t;
168 pub fn cuFileBufDeregister(devPtr_base: *const c_void) -> CUfileError_t;
169
170 pub fn cuFileRead(
172 fh: CUfileHandle_t,
173 bufPtr_base: *mut c_void,
174 size: usize,
175 file_offset: i64,
176 bufPtr_offset: i64,
177 ) -> isize;
178
179 pub fn cuFileWrite(
180 fh: CUfileHandle_t,
181 bufPtr_base: *const c_void,
182 size: usize,
183 file_offset: i64,
184 bufPtr_offset: i64,
185 ) -> isize;
186
187 pub fn cuFileGetErrorString(error: CUfileError_t) -> *const c_char;
189}