ucx1_sys/
lib.rs

1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(improper_ctypes)]
5
6include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
7
8/// @ingroup UCP_DATATYPE
9/// @brief Generate an identifier for contiguous data type.
10///
11/// This macro creates an identifier for contiguous datatype that is defined by
12/// the size of the basic element.
13///
14/// @param [in]  _elem_size    Size of the basic element of the type.
15///
16/// @return Data-type identifier.
17///
18/// @note In case of partial receive, the buffer will be filled with integral
19///       count of elements.
20pub const fn ucp_dt_make_contig(elem_size: usize) -> ucp_datatype_t {
21    ((elem_size as ucp_datatype_t) << (ucp_dt_type::UCP_DATATYPE_SHIFT as ucp_datatype_t))
22        | ucp_dt_type::UCP_DATATYPE_CONTIG as ucp_datatype_t
23}
24
25pub fn UCS_PTR_IS_ERR(ptr: ucs_status_ptr_t) -> bool {
26    ptr as usize >= ucs_status_t::UCS_ERR_LAST as usize
27}
28
29pub fn UCS_PTR_IS_PTR(ptr: ucs_status_ptr_t) -> bool {
30    ptr as usize - 1 < ucs_status_t::UCS_ERR_LAST as usize - 1
31}
32
33pub fn UCS_PTR_RAW_STATUS(ptr: ucs_status_ptr_t) -> ucs_status_t {
34    unsafe { std::mem::transmute(ptr as i8) }
35}
36
37pub fn UCS_PTR_STATUS(ptr: ucs_status_ptr_t) -> ucs_status_t {
38    if UCS_PTR_IS_PTR(ptr) {
39        ucs_status_t::UCS_INPROGRESS
40    } else {
41        UCS_PTR_RAW_STATUS(ptr)
42    }
43}
44
45// #define UCS_PTR_IS_ERR(_ptr)       (((uintptr_t)(_ptr)) >= ((uintptr_t)UCS_ERR_LAST))
46// #define UCS_PTR_IS_PTR(_ptr)       (((uintptr_t)(_ptr) - 1) < ((uintptr_t)UCS_ERR_LAST - 1))
47// #define UCS_PTR_RAW_STATUS(_ptr)   ((ucs_status_t)(intptr_t)(_ptr))
48// #define UCS_PTR_STATUS(_ptr)       (UCS_PTR_IS_PTR(_ptr) ? UCS_INPROGRESS : UCS_PTR_RAW_STATUS(_ptr))
49// #define UCS_STATUS_PTR(_status)    ((void*)(intptr_t)(_status))
50// #define UCS_STATUS_IS_ERR(_status) ((_status) < 0)