@@ -258,6 +258,10 @@ pub extern "C" fn atp_get_current_thread_info() -> *mut atp_thread_info {
258
258
/// # Return value
259
259
///
260
260
/// 0 in case of success, 1 otherwise (if `thread_info` is NULL).
261
+ ///
262
+ /// # Safety
263
+ ///
264
+ /// This function is safe only and only if the pointer comes from this library, of if is null.
261
265
#[ no_mangle]
262
266
pub unsafe extern "C" fn atp_free_thread_info( thread_info: * mut atp_thread_info) -> i32 {
263
267
if thread_info. is_null( ) {
@@ -276,6 +280,11 @@ pub unsafe extern "C" fn atp_free_thread_info(thread_info: *mut atp_thread_info)
276
280
///
277
281
/// This call is useful on Linux desktop only, when the process is sandboxed, cannot promote itself
278
282
/// directly, and the `atp_thread_info` struct must be passed via IPC.
283
+ ///
284
+ /// # Safety
285
+ ///
286
+ /// This function is safe only and only if the first pointer comes from this library, and the
287
+ /// second pointer is at least ATP_THREAD_INFO_SIZE bytes long.
279
288
#[ no_mangle]
280
289
pub unsafe extern "C" fn atp_serialize_thread_info(
281
290
thread_info: * mut atp_thread_info,
@@ -294,6 +303,10 @@ pub unsafe extern "C" fn atp_serialize_thread_info(
294
303
/// # Arguments
295
304
///
296
305
/// A byte buffer containing a serializezd `RtPriorityThreadInfo`.
306
+ ///
307
+ /// # Safety
308
+ ///
309
+ /// This function is safe only and only if pointer is at least ATP_THREAD_INFO_SIZE bytes long.
297
310
#[ no_mangle]
298
311
pub unsafe extern "C" fn atp_deserialize_thread_info(
299
312
in_bytes: * mut u8 ,
@@ -369,6 +382,10 @@ pub struct atp_thread_info(RtPriorityThreadInfo);
369
382
/// # Return value
370
383
///
371
384
/// A pointer to an `atp_handle` in case of success, NULL otherwise.
385
+ ///
386
+ /// # Safety
387
+ ///
388
+ /// This function is safe as long as the first pointer comes from this library.
372
389
#[ no_mangle]
373
390
pub unsafe extern "C" fn atp_promote_thread_to_real_time(
374
391
thread_info: * mut atp_thread_info,
@@ -391,6 +408,10 @@ pub unsafe extern "C" fn atp_promote_thread_to_real_time(
391
408
/// # Return value
392
409
///
393
410
/// 0 in case of success, non-zero otherwise.
411
+ ///
412
+ /// # Safety
413
+ ///
414
+ /// This function is safe as long as the first pointer comes from this library, or is null.
394
415
#[ no_mangle]
395
416
pub unsafe extern "C" fn atp_demote_thread_from_real_time( thread_info: * mut atp_thread_info) -> i32 {
396
417
if thread_info. is_null( ) {
0 commit comments