• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 macro_rules! syscall {
15     ($fn: ident ( $($arg: expr),* $(,)* ), $ret: expr) => {{
16         let res = unsafe { $fn($($arg, )*) };
17         if res == 0 {
18             Err(io::Error::last_os_error())
19         } else {
20             Ok($ret)
21         }
22     }};
23 }
24 
25 mod afd;
26 mod iocp;
27 
28 mod selector;
29 pub use selector::Selector;
30 
31 mod handle;
32 use handle::Handle;
33 
34 mod events;
35 pub use events::{Event, Events};
36 
37 mod overlapped;
38 pub(crate) use overlapped::Overlapped;
39 
40 mod io_status_block;
41 mod socket_addr;
42 
43 mod waker;
44 pub(crate) use waker::WakerInner;
45 
46 mod net;
47 pub(crate) use net::NetInner;
48 cfg_net! {
49     macro_rules! socket_syscall {
50         ($fn: ident ( $($arg: expr),* $(,)* ), $err_fn: path, $err_val: expr) => {{
51             let res = unsafe { $fn($($arg, )*) };
52             if $err_fn(&res, &$err_val) {
53                 Err(io::Error::last_os_error())
54             } else {
55                 Ok(res)
56             }
57         }};
58     }
59     pub(crate) use net::NetState;
60 }
61 
62 cfg_tcp! {
63     mod tcp;
64     pub use self::tcp::{TcpListener, TcpStream};
65 }
66 
67 cfg_udp! {
68     mod udp;
69     pub use self::udp::{UdpSocket, ConnectedUdpSocket};
70 }
71