1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 //! sendmsg
16 #![allow(missing_docs)]
17 #[cfg(not(target_os = "windows"))]
18 use std::ffi::c_int;
19 
20 #[cfg(not(target_os = "windows"))]
21 extern "C" {
SendMsgnull22     fn SendMsg(socket_fd: c_int, fd: c_int, data: *mut libc::c_char, size: c_int) -> c_int;
23 }
24 
25 #[cfg(not(target_os = "windows"))]
send_msgnull26 pub fn send_msg(socket_fd: i32, fd: i32, data: &[u8]) -> i32 {
27     unsafe {
28         SendMsg(
29             socket_fd,
30             fd,
31             data.as_ptr() as *mut libc::c_char,
32             data.len() as i32,
33         )
34     }
35 }
36