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(crate) use emscripten::*;
62    } else if #[cfg(target_os = "espidf")] {
63        mod espidf;
64        // pub(crate) use espidf::*;
65    } else if #[cfg(target_os = "freebsd")] {
66        mod freebsd;
67        pub(crate) use freebsd::*;
68    } else if #[cfg(target_os = "fuchsia")] {
69        mod fuchsia;
70        pub(crate) use fuchsia::*;
71    } else if #[cfg(target_os = "haiku")] {
72        mod haiku;
73        pub(crate) use haiku::*;
74    } else if #[cfg(target_os = "hermit")] {
75        mod hermit_abi;
76        // pub(crate) use hermit_abi::*;
77    } else if #[cfg(target_os = "horizon")] {
78        mod horizon;
79        // pub(crate) use horizon::*;
80    } else if #[cfg(target_os = "hurd")] {
81        mod hurd;
82        // pub(crate) use hurd::*;
83    } else if #[cfg(target_os = "illumos")] {
84        mod illumos;
85        pub(crate) use illumos::*;
86    } else if #[cfg(target_os = "l4re")] {
87        mod l4re;
88        // pub(crate) use l4re::*;
89    } else if #[cfg(target_os = "linux")] {
90        mod linux_uapi;
91        pub(crate) use linux_uapi::*;
92    } else if #[cfg(target_os = "netbsd")] {
93        mod netbsd;
94        pub(crate) use netbsd::*;
95    } else if #[cfg(target_os = "nto")] {
96        mod nto;
97        pub(crate) use nto::*;
98    } else if #[cfg(target_os = "nuttx")] {
99        mod nuttx;
100        pub(crate) use nuttx::*;
101    } else if #[cfg(target_os = "openbsd")] {
102        mod openbsd;
103        pub(crate) use openbsd::*;
104    } else if #[cfg(target_os = "redox")] {
105        mod redox;
106        // pub(crate) use redox::*;
107    } else if #[cfg(target_os = "rtems")] {
108        mod rtems;
109        pub(crate) use rtems::*;
110    } else if #[cfg(target_os = "solaris")] {
111        mod solaris;
112        pub(crate) use solaris::*;
113    } else if #[cfg(target_os = "solid_asp3")] {
114        mod solid;
115        // pub(crate) use solid::*;
116    } else if #[cfg(target_os = "teeos")] {
117        mod teeos;
118        // pub(crate) use teeos::*;
119    } else if #[cfg(target_os = "trusty")] {
120        mod trusty;
121        // pub(crate) use trusty::*;
122    } else if #[cfg(target_os = "vita")] {
123        mod vita;
124        // pub(crate) use vita::*;
125    } else if #[cfg(target_os = "vxworks")] {
126        mod vxworks;
127        pub(crate) use vxworks::*;
128    } else if #[cfg(target_os = "wasi")] {
129        mod wasi;
130        // pub(crate) use wasi::*;
131    } else if #[cfg(target_os = "windows")] {
132        mod ucrt;
133        // pub(crate) use ucrt::*;
134    } else if #[cfg(target_os = "xous")] {
135        mod xous;
136        // pub(crate) use xous::*;
137    }
138}
139
140// Multi-platform libc
141cfg_if! {
142    // FIXME(vxworks): vxworks sets `target_env = "gnu"` but maybe shouldn't.
143    if #[cfg(all(
144        target_family = "unix",
145        target_env = "gnu",
146        not(target_os = "vxworks")
147    ))] {
148        mod glibc;
149        pub(crate) use glibc::*;
150    } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
151        // OhOS also uses the musl libc
152        mod musl;
153        pub(crate) use musl::*;
154    } else if #[cfg(target_env = "newlib")] {
155        mod newlib;
156        pub(crate) use newlib::*;
157    } else if #[cfg(target_env = "relibc")] {
158        mod relibc;
159        pub(crate) use relibc::*;
160    } else if #[cfg(target_env = "sgx")] {
161        mod sgx;
162        // pub(crate) use sgx::*;
163    } else if #[cfg(target_env = "uclibc")] {
164        mod uclibc;
165        pub(crate) use uclibc::*;
166    }
167}
168
169// Per-OS headers we export
170cfg_if! {
171    if #[cfg(target_os = "android")] {
172        pub use sys::socket::*;
173    } else if #[cfg(target_os = "linux")] {
174        pub use linux::can::bcm::*;
175        pub use linux::can::j1939::*;
176        pub use linux::can::raw::*;
177        pub use linux::can::*;
178        pub use linux::keyctl::*;
179        #[cfg(target_env = "gnu")]
180        pub use net::route::*;
181    } else if #[cfg(target_vendor = "apple")] {
182        pub use pthread::*;
183        pub use pthread_::introspection::*;
184        pub use pthread_::pthread_spis::*;
185        pub use pthread_::spawn::*;
186        pub use pthread_::stack_np::*;
187        pub use signal::*;
188    } else if #[cfg(target_os = "netbsd")] {
189        pub use net::if_::*;
190        pub use sys::ipc::*;
191        pub use sys::statvfs::*;
192        pub use sys::time::*;
193        pub use sys::timex::*;
194        pub use sys::types::*;
195        pub use utmp_::*;
196        pub use utmpx_::*;
197    } else if #[cfg(target_os = "openbsd")] {
198        pub use sys::ipc::*;
199    }
200}
201
202// Per-env headers we export
203cfg_if! {
204    if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
205        pub use sys::socket::*;
206    }
207}
208
209// Per-family headers we export
210cfg_if! {
211    if #[cfg(target_family = "unix")] {
212        // FIXME(pthread): eventually all platforms should use this module
213        #[cfg(any(
214            target_os = "android",
215            target_os = "emscripten",
216            target_os = "l4re",
217            target_os = "linux"
218        ))]
219        pub use pthread::*;
220        pub use unistd::*;
221    }
222}