]> git.lizzy.rs Git - rust.git/blob - src/libstd/sys/mod.rs
Remove unnecessary stat64 pointer casts
[rust.git] / src / libstd / sys / mod.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Platform-dependent platform abstraction
12 //!
13 //! The `std::sys` module is the abstracted interface through which
14 //! `std` talks to the underlying operating system. It has different
15 //! implementations for different operating system families, today
16 //! just Unix and Windows, and initial support for Redox.
17 //!
18 //! The centralization of platform-specific code in this module is
19 //! enforced by the "platform abstraction layer" tidy script in
20 //! `tools/tidy/src/pal.rs`.
21 //!
22 //! This module is closely related to the platform-independent system
23 //! integration code in `std::sys_common`. See that module's
24 //! documentation for details.
25 //!
26 //! In the future it would be desirable for the independent
27 //! implementations of this module to be extracted to their own crates
28 //! that `std` can link to, thus enabling their implementation
29 //! out-of-tree via crate replacement. Though due to the complex
30 //! inter-dependencies within `std` that will be a challenging goal to
31 //! achieve.
32
33 #![allow(missing_debug_implementations)]
34
35 cfg_if! {
36     if #[cfg(unix)] {
37         mod unix;
38         pub use self::unix::*;
39     } else if #[cfg(windows)] {
40         mod windows;
41         pub use self::windows::*;
42     } else if #[cfg(target_os = "cloudabi")] {
43         mod cloudabi;
44         pub use self::cloudabi::*;
45     } else if #[cfg(target_os = "redox")] {
46         mod redox;
47         pub use self::redox::*;
48     } else if #[cfg(target_arch = "wasm32")] {
49         mod wasm;
50         pub use self::wasm::*;
51     } else {
52         compile_error!("libstd doesn't compile for this platform yet");
53     }
54 }
55
56 // Import essential modules from both platforms when documenting. These are
57 // then later used in the `std::os` module when documenting, for example,
58 // Windows when we're compiling for Linux.
59
60 #[cfg(dox)]
61 cfg_if! {
62     if #[cfg(any(unix, target_os = "redox"))] {
63         // On unix we'll document what's already available
64         pub use self::ext as unix_ext;
65     } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32"))] {
66         // On CloudABI and wasm right now the module below doesn't compile
67         // (missing things in `libc` which is empty) so just omit everything
68         // with an empty module
69         #[unstable(issue = "0", feature = "std_internals")]
70         pub mod unix_ext {}
71     } else {
72         // On other platforms like Windows document the bare bones of unix
73         use os::linux as platform;
74         #[path = "unix/ext/mod.rs"]
75         pub mod unix_ext;
76     }
77 }
78
79 #[cfg(dox)]
80 cfg_if! {
81     if #[cfg(windows)] {
82         // On windows we'll just be documenting what's already available
83         pub use self::ext as windows_ext;
84     } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32"))] {
85         // On CloudABI and wasm right now the shim below doesn't compile, so
86         // just omit it
87         #[unstable(issue = "0", feature = "std_internals")]
88         pub mod windows_ext {}
89     } else {
90         // On all other platforms (aka linux/osx/etc) then pull in a "minimal"
91         // amount of windows goop which ends up compiling
92         #[macro_use]
93         #[path = "windows/compat.rs"]
94         mod compat;
95
96         #[path = "windows/c.rs"]
97         mod c;
98
99         #[path = "windows/ext/mod.rs"]
100         pub mod windows_ext;
101     }
102 }