libc/new/
mod.rs

1//! This module contains the future directory structure. If possible, new definitions should
2//! get added here.
3//!
4//! Eventually everything should be moved over, and we will move this directory to the top
5//! level in `src`.
6//!
7//! # Basic structure
8//!
9//! Each child module here represents a library or group of libraries that we are binding. Each of
10//! these has several submodules, representing either a directory or a header file in that library.
11//!
12//! `#include`s turn into `pub use ...*;` statements. Then at the root level (here), we choose
13//! which top-level headers we want to reexport the definitions for.
14//!
15//! All modules are only crate-public since we don't reexport this structure.
16
17mod common;
18
19/* The `pub(crate) use ...` statements are commented while the modules are empty */
20
21// Platform libraries and combined platform+libc
22//
23// Not supported or not needed:
24// * amdhsa
25// * cuda
26// * lynxos178
27// * managarm
28// * motor
29// * none
30// * psp
31// * psx
32// * uefi
33// * unknown
34// * vexos
35// * zkvm
36//
37// Combined to target_vendor = "apple"
38// * ios
39// * macos
40// * tvos
41// * visionos
42// * watchos
43cfg_if! {
44    if #[cfg(target_os = "aix")] {
45        mod aix;
46        pub(crate) use aix::*;
47    } else if #[cfg(target_os = "android")] {
48        mod bionic_libc;
49        pub(crate) use bionic_libc::*;
50    } else if #[cfg(target_vendor = "apple")] {
51        mod apple;
52        pub(crate) use apple::*;
53    } else if #[cfg(target_os = "cygwin")] {
54        mod cygwin;
55        pub(crate) use cygwin::*;
56    } else if #[cfg(target_os = "dragonfly")] {
57        mod dragonfly;
58        pub(crate) use dragonfly::*;
59    } else if #[cfg(target_os = "emscripten")] {
60        mod emscripten;
61        pub use emscripten::sched::*;
62        pub(crate) use emscripten::*;
63    } else if #[cfg(target_os = "espidf")] {
64        mod espidf;
65        // pub(crate) use espidf::*;
66    } else if #[cfg(target_os = "freebsd")] {
67        mod freebsd;
68        pub(crate) use freebsd::*;
69    } else if #[cfg(target_os = "fuchsia")] {
70        mod fuchsia;
71        pub(crate) use fuchsia::*;
72    } else if #[cfg(target_os = "haiku")] {
73        mod haiku;
74        pub(crate) use haiku::*;
75    } else if #[cfg(target_os = "hermit")] {
76        mod hermit_abi;
77        // pub(crate) use hermit_abi::*;
78    } else if #[cfg(target_os = "horizon")] {
79        mod horizon;
80        // pub(crate) use horizon::*;
81    } else if #[cfg(target_os = "hurd")] {
82        mod hurd;
83        // pub(crate) use hurd::*;
84    } else if #[cfg(target_os = "illumos")] {
85        mod illumos;
86        pub(crate) use illumos::*;
87    } else if #[cfg(target_os = "l4re")] {
88        mod l4re;
89        // pub(crate) use l4re::*;
90    } else if #[cfg(target_os = "linux")] {
91        mod linux_uapi;
92        pub(crate) use linux_uapi::*;
93    } else if #[cfg(target_os = "netbsd")] {
94        mod netbsd;
95        pub(crate) use netbsd::*;
96    } else if #[cfg(target_os = "nto")] {
97        mod nto;
98        pub(crate) use nto::*;
99    } else if #[cfg(target_os = "nuttx")] {
100        mod nuttx;
101        pub(crate) use nuttx::*;
102    } else if #[cfg(target_os = "openbsd")] {
103        mod openbsd;
104        pub(crate) use openbsd::*;
105    } else if #[cfg(target_os = "qurt")] {
106        mod qurt;
107        pub(crate) use qurt::*;
108    } else if #[cfg(target_os = "redox")] {
109        mod redox;
110        // pub(crate) use redox::*;
111    } else if #[cfg(target_os = "rtems")] {
112        mod rtems;
113        // pub(crate) use rtems::*;
114    } else if #[cfg(target_os = "solaris")] {
115        mod solaris;
116        pub(crate) use solaris::*;
117    } else if #[cfg(target_os = "solid_asp3")] {
118        mod solid;
119        // pub(crate) use solid::*;
120    } else if #[cfg(target_os = "teeos")] {
121        mod teeos;
122        // pub(crate) use teeos::*;
123    } else if #[cfg(target_os = "trusty")] {
124        mod trusty;
125        // pub(crate) use trusty::*;
126    } else if #[cfg(target_os = "vita")] {
127        mod vita;
128        // pub(crate) use vita::*;
129    } else if #[cfg(target_os = "vxworks")] {
130        mod vxworks;
131        pub(crate) use vxworks::*;
132    } else if #[cfg(target_os = "wasi")] {
133        mod wasi;
134        // pub(crate) use wasi::*;
135    } else if #[cfg(target_os = "windows")] {
136        mod ucrt;
137        // pub(crate) use ucrt::*;
138    } else if #[cfg(target_os = "xous")] {
139        mod xous;
140        // pub(crate) use xous::*;
141    }
142}
143
144// Multi-platform libc
145cfg_if! {
146    // FIXME(vxworks): vxworks sets `target_env = "gnu"` but maybe shouldn't.
147    if #[cfg(all(
148        target_family = "unix",
149        target_env = "gnu",
150        not(target_os = "vxworks")
151    ))] {
152        mod glibc;
153        pub(crate) use glibc::*;
154    } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
155        // OhOS also uses the musl libc
156        mod musl;
157        pub use musl::sched::*;
158        pub(crate) use musl::*;
159    } else if #[cfg(target_env = "newlib")] {
160        mod newlib;
161        pub(crate) use newlib::*;
162    } else if #[cfg(target_env = "relibc")] {
163        mod relibc;
164        pub(crate) use relibc::*;
165    } else if #[cfg(target_env = "sgx")] {
166        mod sgx;
167        // pub(crate) use sgx::*;
168    } else if #[cfg(target_env = "uclibc")] {
169        mod uclibc;
170        pub(crate) use uclibc::*;
171    }
172}
173
174// Per-OS headers we export
175cfg_if! {
176    if #[cfg(target_os = "android")] {
177        pub use sys::socket::*;
178    } else if #[cfg(target_os = "linux")] {
179        pub use linux::can::bcm::*;
180        pub use linux::can::j1939::*;
181        pub use linux::can::raw::*;
182        pub use linux::can::*;
183        pub use linux::keyctl::*;
184        pub use linux::membarrier::*;
185        pub use linux::netlink::*;
186        #[cfg(target_env = "gnu")]
187        pub use net::route::*;
188    } else if #[cfg(target_vendor = "apple")] {
189        pub use pthread::*;
190        pub use pthread_::introspection::*;
191        pub use pthread_::pthread_spis::*;
192        pub use pthread_::spawn::*;
193        pub use pthread_::stack_np::*;
194        pub use signal::*;
195    } else if #[cfg(target_os = "netbsd")] {
196        pub use net::if_::*;
197        pub use sys::ipc::*;
198        pub use sys::statvfs::*;
199        pub use sys::time::*;
200        pub use sys::timex::*;
201        pub use sys::types::*;
202        pub use utmp_::*;
203        pub use utmpx_::*;
204    } else if #[cfg(target_os = "openbsd")] {
205        pub use sys::ipc::*;
206    } else if #[cfg(target_os = "nto")] {
207        pub use net::bpf::*;
208        pub use net::if_::*;
209    }
210}
211
212// Per-env headers we export
213cfg_if! {
214    if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
215        pub use sys::socket::*;
216    }
217}
218
219// Per-family headers we export
220cfg_if! {
221    if #[cfg(all(target_family = "unix", not(target_os = "qurt")))] {
222        // FIXME(pthread): eventually all platforms should use this module
223        #[cfg(any(
224            target_os = "android",
225            target_os = "emscripten",
226            target_os = "l4re",
227            target_os = "linux"
228        ))]
229        pub use pthread::*;
230        pub use unistd::*;
231    }
232}