diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/errno-0.2.8 | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/errno-0.2.8')
-rw-r--r-- | vendor/errno-0.2.8/.cargo-checksum.json | 1 | ||||
-rw-r--r-- | vendor/errno-0.2.8/CHANGELOG.md | 9 | ||||
-rw-r--r-- | vendor/errno-0.2.8/Cargo.toml | 35 | ||||
-rw-r--r-- | vendor/errno-0.2.8/LICENSE-APACHE | 201 | ||||
-rw-r--r-- | vendor/errno-0.2.8/LICENSE-MIT | 25 | ||||
-rw-r--r-- | vendor/errno-0.2.8/README.md | 38 | ||||
-rw-r--r-- | vendor/errno-0.2.8/src/hermit.rs | 32 | ||||
-rw-r--r-- | vendor/errno-0.2.8/src/lib.rs | 151 | ||||
-rw-r--r-- | vendor/errno-0.2.8/src/unix.rs | 79 | ||||
-rw-r--r-- | vendor/errno-0.2.8/src/wasi.rs | 65 | ||||
-rw-r--r-- | vendor/errno-0.2.8/src/windows.rs | 70 |
11 files changed, 0 insertions, 706 deletions
diff --git a/vendor/errno-0.2.8/.cargo-checksum.json b/vendor/errno-0.2.8/.cargo-checksum.json deleted file mode 100644 index e902c4f19..000000000 --- a/vendor/errno-0.2.8/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{"CHANGELOG.md":"4117e53ffe976635cceec0945cb500f5da2d7a5d54e360477d625e8382b585df","Cargo.toml":"8a810e953a0ae35ef3813fa470bb02d6315dee5020a81ba50319c23ce276c6c5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"8764a597675778ddfd4e25f81b08a05dbcf089ac05662df7613fe67f150e3aa2","README.md":"057f18de8b228ec7980ad3c30782158022b429013a849ae9faf641187a7c9722","src/hermit.rs":"79bf2148c39260b9f8c4859a5dc805905bf1f6e56cb1cf3c1954e38563fe5091","src/lib.rs":"8aac3a13cf7a85d5b6bc0945a0614a2413abac92e66e289531dca5288a3e6fdd","src/unix.rs":"09cd79b198b5cdb1fe6db9be4a0ef5f7cb8ee217ec4a1aa4fdcb20fc3bfb8d6c","src/wasi.rs":"0443c1e5c0552140458c31cdf8d0647a4c164f0206a25f1d002bd4abbebe9c02","src/windows.rs":"c32c74e663b9b81f1df9ee3c4776269f4210bce0b49ed3237b9ae10db259170b"},"package":"f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"}
\ No newline at end of file diff --git a/vendor/errno-0.2.8/CHANGELOG.md b/vendor/errno-0.2.8/CHANGELOG.md deleted file mode 100644 index 68fddd2d4..000000000 --- a/vendor/errno-0.2.8/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# [Unreleased] - -# [0.2.8] - 2021-10-27 - -- Optionally support no_std - [#31](https://github.com/lambda-fairy/rust-errno/pull/31) - -[Unreleased]: https://github.com/lambda-fairy/rust-errno/compare/v0.2.8...HEAD -[0.2.8]: https://github.com/lambda-fairy/rust-errno/compare/v0.2.7...v0.2.8 diff --git a/vendor/errno-0.2.8/Cargo.toml b/vendor/errno-0.2.8/Cargo.toml deleted file mode 100644 index 2349617b0..000000000 --- a/vendor/errno-0.2.8/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -name = "errno" -version = "0.2.8" -authors = ["Chris Wong <lambda.fairy@gmail.com>"] -description = "Cross-platform interface to the `errno` variable." -documentation = "https://docs.rs/errno" -categories = ["os"] -license = "MIT/Apache-2.0" -repository = "https://github.com/lambda-fairy/rust-errno" - -[features] -default = ["std"] -std = [] -[target."cfg(target_os=\"dragonfly\")".dependencies.errno-dragonfly] -version = "0.1.1" -[target."cfg(target_os=\"hermit\")".dependencies.libc] -version = "0.2" -[target."cfg(target_os=\"wasi\")".dependencies.libc] -version = "0.2" -[target."cfg(unix)".dependencies.libc] -version = "0.2" -[target."cfg(windows)".dependencies.winapi] -version = "0.3" -features = ["errhandlingapi", "minwindef", "ntdef", "winbase"] diff --git a/vendor/errno-0.2.8/LICENSE-APACHE b/vendor/errno-0.2.8/LICENSE-APACHE deleted file mode 100644 index 16fe87b06..000000000 --- a/vendor/errno-0.2.8/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vendor/errno-0.2.8/LICENSE-MIT b/vendor/errno-0.2.8/LICENSE-MIT deleted file mode 100644 index 66b6578d3..000000000 --- a/vendor/errno-0.2.8/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2014 Chris Wong - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/vendor/errno-0.2.8/README.md b/vendor/errno-0.2.8/README.md deleted file mode 100644 index a4762a7d0..000000000 --- a/vendor/errno-0.2.8/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# errno [![CI](https://github.com/lambda-fairy/rust-errno/actions/workflows/main.yml/badge.svg)](https://github.com/lambda-fairy/rust-errno/actions/workflows/main.yml) [![Cargo](https://img.shields.io/crates/v/errno.svg)](https://crates.io/crates/errno) - -Cross-platform interface to the [`errno`][errno] variable. Works on Rust 1.13 or newer. - -Documentation is available at <https://docs.rs/errno>. - -[errno]: https://en.wikipedia.org/wiki/Errno.h - - -## Dependency - -Add to your `Cargo.toml`: - -```toml -[dependencies] -errno = "*" -libc = "*" -``` - - -## Examples - -```rust -extern crate errno; -use errno::{Errno, errno, set_errno}; - -// Get the current value of errno -let e = errno(); - -// Set the current value of errno -set_errno(e); - -// Extract the error code as an i32 -let code = e.0; - -// Display a human-friendly error message -println!("Error {}: {}", code, e); -``` diff --git a/vendor/errno-0.2.8/src/hermit.rs b/vendor/errno-0.2.8/src/hermit.rs deleted file mode 100644 index d14a6c88f..000000000 --- a/vendor/errno-0.2.8/src/hermit.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! Implementation of `errno` functionality for RustyHermit. -//! -//! Currently, the error handling in RustyHermit isn't clearly -//! defined. At the current stage of RustyHermit, only a placeholder -//! is provided to be compatible to the classical errno interface. - -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use Errno; - -pub fn with_description<F, T>(_err: Errno, callback: F) -> T where - F: FnOnce(Result<&str, Errno>) -> T -{ - callback(Ok("unknown error")) -} - -pub const STRERROR_NAME: &'static str = "strerror_r"; - -pub fn errno() -> Errno { - Errno(0) -} - -pub fn set_errno(_: Errno) { -} diff --git a/vendor/errno-0.2.8/src/lib.rs b/vendor/errno-0.2.8/src/lib.rs deleted file mode 100644 index b3a1dcb1a..000000000 --- a/vendor/errno-0.2.8/src/lib.rs +++ /dev/null @@ -1,151 +0,0 @@ -//! Cross-platform interface to the `errno` variable. -//! -//! # Examples -//! ``` -//! use errno::{Errno, errno, set_errno}; -//! -//! // Get the current value of errno -//! let e = errno(); -//! -//! // Set the current value of errno -//! set_errno(e); -//! -//! // Extract the error code as an i32 -//! let code = e.0; -//! -//! // Display a human-friendly error message -//! println!("Error {}: {}", code, e); -//! ``` - -#![cfg_attr(target_os = "wasi", feature(thread_local))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(unix)] extern crate libc; -#[cfg(windows)] extern crate winapi; -#[cfg(target_os = "dragonfly")] extern crate errno_dragonfly; -#[cfg(target_os = "wasi")] extern crate libc; -#[cfg(target_os = "hermit")] extern crate libc; - -#[cfg_attr(unix, path = "unix.rs")] -#[cfg_attr(windows, path = "windows.rs")] -#[cfg_attr(target_os = "wasi", path = "wasi.rs")] -#[cfg_attr(target_os = "hermit", path = "hermit.rs")] -mod sys; - -#[cfg(feature = "std")] -use std::fmt; -#[cfg(feature = "std")] -use std::io; -#[cfg(feature = "std")] -use std::error::Error; - -/// Wraps a platform-specific error code. -/// -/// The `Display` instance maps the code to a human-readable string. It -/// calls [`strerror_r`][1] under POSIX, and [`FormatMessageW`][2] on -/// Windows. -/// -/// [1]: http://pubs.opengroup.org/onlinepubs/009695399/functions/strerror.html -/// [2]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms679351%28v=vs.85%29.aspx -#[derive(Copy, Clone, Eq, Ord, PartialEq, PartialOrd, Hash)] -pub struct Errno(pub i32); - -#[cfg(feature = "std")] -impl fmt::Debug for Errno { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - sys::with_description(*self, |desc| { - fmt.debug_struct("Errno") - .field("code", &self.0) - .field("description", &desc.ok()) - .finish() - }) - } -} - -#[cfg(feature = "std")] -impl fmt::Display for Errno { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - sys::with_description(*self, |desc| match desc { - Ok(desc) => fmt.write_str(&desc), - Err(fm_err) => write!( - fmt, "OS error {} ({} returned error {})", - self.0, sys::STRERROR_NAME, fm_err.0), - }) - } -} - -impl Into<i32> for Errno { - fn into(self) -> i32 { - self.0 - } -} - -#[cfg(feature = "std")] -impl Error for Errno { - // TODO: Remove when MSRV >= 1.27 - #[allow(deprecated)] - fn description(&self) -> &str { - "system error" - } -} - -#[cfg(feature = "std")] -impl From<Errno> for io::Error { - fn from(errno: Errno) -> Self { - io::Error::from_raw_os_error(errno.0) - } -} - -/// Returns the platform-specific value of `errno`. -pub fn errno() -> Errno { - sys::errno() -} - -/// Sets the platform-specific value of `errno`. -pub fn set_errno(err: Errno) { - sys::set_errno(err) -} - -#[test] -fn it_works() { - let x = errno(); - set_errno(x); -} - -#[cfg(feature = "std")] -#[test] -fn it_works_with_to_string() { - let x = errno(); - let _ = x.to_string(); -} - -#[cfg(feature = "std")] -#[test] -fn check_description() { - let expect = if cfg!(windows) { - "Incorrect function." - } else if cfg!(target_os = "illumos") { - "Not owner" - } else if cfg!(target_os = "wasi") { - "Argument list too long" - } else { - "Operation not permitted" - }; - - set_errno(Errno(1)); - - assert_eq!(errno().to_string(), expect); - assert_eq!( - format!("{:?}", errno()), - format!("Errno {{ code: 1, description: Some({:?}) }}", expect)); -} - -#[cfg(feature = "std")] -#[test] -fn check_error_into_errno() { - const ERROR_CODE: i32 = 1; - - let error = io::Error::from_raw_os_error(ERROR_CODE); - let new_error: io::Error = Errno(ERROR_CODE).into(); - assert_eq!(error.kind(), new_error.kind()); -} diff --git a/vendor/errno-0.2.8/src/unix.rs b/vendor/errno-0.2.8/src/unix.rs deleted file mode 100644 index 820d89748..000000000 --- a/vendor/errno-0.2.8/src/unix.rs +++ /dev/null @@ -1,79 +0,0 @@ -//! Implementation of `errno` functionality for Unix systems. -//! -//! Adapted from `src/libstd/sys/unix/os.rs` in the Rust distribution. - -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(feature = "std")] -use std::ffi::CStr; -use libc::c_int; -#[cfg(feature = "std")] -use libc::{self, c_char}; -#[cfg(target_os = "dragonfly")] -use errno_dragonfly::errno_location; - -use Errno; - -#[cfg(feature = "std")] -pub fn with_description<F, T>(err: Errno, callback: F) -> T where - F: FnOnce(Result<&str, Errno>) -> T -{ - let mut buf = [0 as c_char; 1024]; - unsafe { - if strerror_r(err.0, buf.as_mut_ptr(), buf.len() as libc::size_t) < 0 { - let fm_err = errno(); - if fm_err != Errno(libc::ERANGE) { - return callback(Err(fm_err)); - } - } - } - let c_str = unsafe { CStr::from_ptr(buf.as_ptr()) }; - callback(Ok(&String::from_utf8_lossy(c_str.to_bytes()))) -} - -#[cfg(feature = "std")] -pub const STRERROR_NAME: &'static str = "strerror_r"; - -pub fn errno() -> Errno { - unsafe { - Errno(*errno_location()) - } -} - -pub fn set_errno(Errno(errno): Errno) { - unsafe { - *errno_location() = errno; - } -} - -extern { - #[cfg(not(target_os = "dragonfly"))] - #[cfg_attr(any(target_os = "macos", - target_os = "ios", - target_os = "freebsd"), - link_name = "__error")] - #[cfg_attr(any(target_os = "openbsd", - target_os = "netbsd", - target_os = "bitrig", - target_os = "android"), - link_name = "__errno")] - #[cfg_attr(any(target_os = "solaris", - target_os = "illumos"), - link_name = "___errno")] - #[cfg_attr(target_os = "linux", - link_name = "__errno_location")] - fn errno_location() -> *mut c_int; - - #[cfg(feature = "std")] - #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] - fn strerror_r(errnum: c_int, buf: *mut c_char, - buflen: libc::size_t) -> c_int; -} diff --git a/vendor/errno-0.2.8/src/wasi.rs b/vendor/errno-0.2.8/src/wasi.rs deleted file mode 100644 index 28e3d9f11..000000000 --- a/vendor/errno-0.2.8/src/wasi.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! Implementation of `errno` functionality for WASI. -//! -//! Adapted from `unix.rs`. - -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(feature = "std")] -use std::ffi::CStr; -use libc::c_int; -#[cfg(feature = "std")] -use libc::{self, c_char}; - -use Errno; - -#[cfg(feature = "std")] -pub fn with_description<F, T>(err: Errno, callback: F) -> T where - F: FnOnce(Result<&str, Errno>) -> T -{ - let mut buf = [0 as c_char; 1024]; - unsafe { - if strerror_r(err.0, buf.as_mut_ptr(), buf.len() as libc::size_t) < 0 { - let fm_err = errno(); - if fm_err != Errno(libc::ERANGE) { - return callback(Err(fm_err)); - } - } - } - let c_str = unsafe { CStr::from_ptr(buf.as_ptr()) }; - callback(Ok(&String::from_utf8_lossy(c_str.to_bytes()))) -} - -#[cfg(feature = "std")] -pub const STRERROR_NAME: &'static str = "strerror_r"; - -pub fn errno() -> Errno { - // libc_errno is thread-local, so simply read its value. - unsafe { - Errno(libc_errno) - } -} - -pub fn set_errno(Errno(new_errno): Errno) { - // libc_errno is thread-local, so simply assign to it. - unsafe { - libc_errno = new_errno; - } -} - -extern { - #[thread_local] - #[link_name = "errno"] - static mut libc_errno: c_int; - - #[cfg(feature = "std")] - fn strerror_r(errnum: c_int, buf: *mut c_char, - buflen: libc::size_t) -> c_int; -} diff --git a/vendor/errno-0.2.8/src/windows.rs b/vendor/errno-0.2.8/src/windows.rs deleted file mode 100644 index 94e736210..000000000 --- a/vendor/errno-0.2.8/src/windows.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! Implementation of `errno` functionality for Windows. -//! -//! Adapted from `src/libstd/sys/windows/os.rs` in the Rust distribution. - -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(feature = "std")] -use std::ptr; -use winapi::shared::minwindef::DWORD; -#[cfg(feature = "std")] -use winapi::shared::ntdef::WCHAR; -#[cfg(feature = "std")] -use winapi::um::winbase::{FORMAT_MESSAGE_FROM_SYSTEM, FORMAT_MESSAGE_IGNORE_INSERTS}; - -use Errno; - -#[cfg(feature = "std")] -pub fn with_description<F, T>(err: Errno, callback: F) -> T where - F: FnOnce(Result<&str, Errno>) -> T -{ - // This value is calculated from the macro - // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) - let lang_id = 0x0800 as DWORD; - - let mut buf = [0 as WCHAR; 2048]; - - unsafe { - let res = ::winapi::um::winbase::FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - ptr::null_mut(), - err.0 as DWORD, - lang_id, - buf.as_mut_ptr(), - buf.len() as DWORD, - ptr::null_mut()); - if res == 0 { - // Sometimes FormatMessageW can fail e.g. system doesn't like lang_id - let fm_err = errno(); - return callback(Err(fm_err)); - } - - let msg = String::from_utf16_lossy(&buf[..res as usize]); - // Trim trailing CRLF inserted by FormatMessageW - #[allow(deprecated)] // TODO: remove when MSRV >= 1.30 - callback(Ok(msg.trim_right())) - } -} - -#[cfg(feature = "std")] -pub const STRERROR_NAME: &'static str = "FormatMessageW"; - -pub fn errno() -> Errno { - unsafe { - Errno(::winapi::um::errhandlingapi::GetLastError() as i32) - } -} - -pub fn set_errno(Errno(errno): Errno) { - unsafe { - ::winapi::um::errhandlingapi::SetLastError(errno as DWORD) - } -} |