From 51a0587b538d6c2b51e0f907ad3a01df897304eb Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Wed, 23 Jan 2019 08:40:13 -0800 Subject: [PATCH 1/7] Remove Cargo.lock This was an artifact from when a git dependency on ctest was used. This is no longer the case, so removing it to simplify future PRs. --- Cargo.lock | 340 ----------------------------------------------------- 1 file changed, 340 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index a8165ea8ca7b2..0000000000000 --- a/Cargo.lock +++ /dev/null @@ -1,340 +0,0 @@ -[[package]] -name = "bitflags" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cc" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ctest" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "extprim" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "itoa" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "libc" -version = "0.2.47" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.48" -dependencies = [ - "rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "libc-test" -version = "0.1.0" -dependencies = [ - "ctest 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48", -] - -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num-traits" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "0.4.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-std-workspace-core" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "0.15.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_errors" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_pos" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syntex_syntax" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "term" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" -"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" -"checksum ctest 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3574c0edc91c25cb50d1e4238f35ae2651b0beadf72bfec31fb4ead46b4eb5b8" -"checksum extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "054bc2552b3f66fa8097e29e47255bfff583c08e737a67cbbb54b817ddaa5206" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" -"checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" -"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" -"checksum rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dee497e66d8d76bf08ce20c8d36e16f93749ab0bf89975b4f8ae5cee660c2da2" -"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum rustc-std-workspace-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" -"checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" -"checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" -"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" -"checksum syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3133289179676c9f5c5b2845bf5a2e127769f4889fcbada43035ef6bd662605e" -"checksum syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30ab669fa003d208c681f874bbc76d91cc3d32550d16b5d9d2087cf477316470" -"checksum syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03815b9f04d95828770d9c974aa39c6e1f6ef3114eb77a3ce09008a0d15dd142" -"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" From 868a85d05dd46af29346302cbc8135619280cd0f Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Wed, 30 Jan 2019 18:18:00 -0800 Subject: [PATCH 2/7] Implement PartialEq,Eq for all types --- Cargo.toml | 1 + README.md | 9 + ci/run.sh | 4 + libc-test/Cargo.toml | 1 + src/macros.rs | 15 + src/unix/bsd/apple/b32.rs | 25 +- src/unix/bsd/apple/b64.rs | 25 +- src/unix/bsd/apple/mod.rs | 340 ++++++++++++++++------ src/unix/bsd/mod.rs | 103 +++++-- src/unix/notbsd/android/b64/mod.rs | 83 ++++-- src/unix/notbsd/android/mod.rs | 185 +++++++++--- src/unix/notbsd/linux/mod.rs | 279 +++++++++++------- src/unix/notbsd/linux/musl/b32/x86.rs | 37 ++- src/unix/notbsd/linux/musl/b64/x86_64.rs | 38 ++- src/unix/notbsd/linux/musl/mod.rs | 24 ++ src/unix/notbsd/linux/other/b32/x86.rs | 86 ++++-- src/unix/notbsd/linux/other/b64/x86_64.rs | 85 ++++-- src/unix/notbsd/linux/other/mod.rs | 97 +++--- src/unix/notbsd/linux/s390x.rs | 23 +- src/unix/notbsd/mod.rs | 112 +++++-- 20 files changed, 1149 insertions(+), 423 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 91616442051d6..d20fc69ba86df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ default = ["use_std"] use_std = [] align = [] rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] +extra_traits = ["align"] [workspace] members = ["libc-test"] diff --git a/README.md b/README.md index 636f10e4ec2d6..ae45ce7f40434 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,15 @@ activate the *align* feature. This requires Rust 1.25 or newer: libc = { version = "0.2", features = ["align"] } ``` +All structs implemented by the libc crate have the `Copy` and `Clone` traits +implemented for them. The additional traits of `PartialEq` and `Eq` can be +enabled with the *extra_traits* feature (requires Rust 1.25 or newer): + +```toml +[dependencies] +libc = { version = "0.2", features = ["extra_traits"] } +``` + ## What is libc? The primary purpose of this crate is to provide all of the definitions necessary diff --git a/ci/run.sh b/ci/run.sh index 81ebd61055b2b..853b7c10537ff 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -96,4 +96,8 @@ fi if [ "$(rustc --version | sed -E 's/^rustc 1\.([0-9]*)\..*/\1/')" -ge 25 ]; then cargo test $opt --features align --manifest-path libc-test/Cargo.toml --target "${TARGET}" fi +# Test the `extra_traits` feature if this is building on Rust >= 1.25 +if [ "$(rustc --version | sed -E 's/^rustc 1\.([0-9]*)\..*/\1/')" -ge 25 ]; then + cargo test $opt --features extra_traits --manifest-path libc-test/Cargo.toml --target "${TARGET}" +fi exec cargo test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}" diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index b782a95af8a34..f8bd11b5edc90 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -15,6 +15,7 @@ ctest = "0.2.8" default = [ "use_std" ] use_std = [ "libc/use_std" ] align = [ "libc/align" ] +extra_traits = [ "libc/extra_traits" ] [[test]] name = "main" diff --git a/src/macros.rs b/src/macros.rs index 77205788c8a6d..175c0512592bc 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -35,6 +35,21 @@ macro_rules! __cfg_if_apply { } macro_rules! s { + ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( + __item! { + #[repr(C)] + $(#[$attr])* + #[cfg_attr(feature = "extra_traits", derive(Eq, PartialEq))] + pub $t $i { $($field)* } + } + impl ::dox::Copy for $i {} + impl ::dox::Clone for $i { + fn clone(&self) -> $i { *self } + } + )*) +} + +macro_rules! s_no_extra_traits { ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( __item! { #[repr(C)] diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 907ab02df44b6..95dc962a1d029 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -5,11 +5,6 @@ pub type c_ulong = u32; pub type boolean_t = ::c_int; s! { - pub struct pthread_attr_t { - __sig: c_long, - __opaque: [::c_char; 36] - } - pub struct if_data { pub ifi_type: ::c_uchar, pub ifi_typelen: ::c_uchar, @@ -50,6 +45,26 @@ s! { } } +s_no_extra_traits!{ + pub struct pthread_attr_t { + __sig: c_long, + __opaque: [::c_char; 36] + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_attr_t { + fn eq(&self, other: &pthread_attr_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_attr_t {} + pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index 8e8c87dd287a0..0eb2d45c6a960 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -5,11 +5,6 @@ pub type c_ulong = u64; pub type boolean_t = ::c_uint; s! { - pub struct pthread_attr_t { - __sig: c_long, - __opaque: [::c_char; 56] - } - pub struct timeval32 { pub tv_sec: i32, pub tv_usec: i32, @@ -55,6 +50,26 @@ s! { } } +s_no_extra_traits!{ + pub struct pthread_attr_t { + __sig: c_long, + __opaque: [::c_char; 56] + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_attr_t { + fn eq(&self, other: &pthread_attr_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_attr_t {} + pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 837efff53d5ce..80516388f49c2 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -47,17 +47,6 @@ s! { pub aio_lio_opcode: ::c_int } - pub struct utmpx { - pub ut_user: [::c_char; _UTX_USERSIZE], - pub ut_id: [::c_char; _UTX_IDSIZE], - pub ut_line: [::c_char; _UTX_LINESIZE], - pub ut_pid: ::pid_t, - pub ut_type: ::c_short, - pub ut_tv: ::timeval, - pub ut_host: [::c_char; _UTX_HOSTSIZE], - ut_pad: [::uint32_t; 16], - } - pub struct glob_t { pub gl_pathc: ::size_t, __unused1: ::c_int, @@ -74,14 +63,6 @@ s! { __unused8: *mut ::c_void, } - pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: ::sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -123,40 +104,16 @@ s! { pub st_qspare: [::int64_t; 2], } - pub struct dirent { - pub d_ino: u64, - pub d_seekoff: u64, - pub d_reclen: u16, - pub d_namlen: u16, - pub d_type: u8, - pub d_name: [::c_char; 1024], - } - - pub struct pthread_mutex_t { - __sig: ::c_long, - __opaque: [u8; __PTHREAD_MUTEX_SIZE__], - } - pub struct pthread_mutexattr_t { __sig: ::c_long, __opaque: [u8; 8], } - pub struct pthread_cond_t { - __sig: ::c_long, - __opaque: [u8; __PTHREAD_COND_SIZE__], - } - pub struct pthread_condattr_t { __sig: ::c_long, __opaque: [u8; __PTHREAD_CONDATTR_SIZE__], } - pub struct pthread_rwlock_t { - __sig: ::c_long, - __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], - } - pub struct pthread_rwlockattr_t { __sig: ::c_long, __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__], @@ -227,25 +184,6 @@ s! { pub sin_zero: [::c_char; 8], } - pub struct statfs { - pub f_bsize: ::uint32_t, - pub f_iosize: ::int32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::uint64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, - pub f_fsid: ::fsid_t, - pub f_owner: ::uid_t, - pub f_type: ::uint32_t, - pub f_flags: ::uint32_t, - pub f_fssubtype: ::uint32_t, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 1024], - pub f_mntfromname: [::c_char; 1024], - pub f_reserved: [::uint32_t; 8], - } - #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] pub struct kevent { pub ident: ::uintptr_t, @@ -400,20 +338,6 @@ s! { pub ptinfo: proc_taskinfo, } - pub struct proc_threadinfo { - pub pth_user_time: u64, - pub pth_system_time: u64, - pub pth_cpu_usage: i32, - pub pth_policy: i32, - pub pth_run_state: i32, - pub pth_flags: i32, - pub pth_sleep_time: i32, - pub pth_curpri: i32, - pub pth_priority: i32, - pub pth_maxpriority: i32, - pub pth_name: [::c_char; MAXTHREADNAMESIZE], - } - pub struct xsw_usage { pub xsu_total: u64, pub xsu_avail: u64, @@ -557,12 +481,6 @@ s! { pub sem_pad3: [::int32_t; 4], } - pub union semun { - pub val: ::c_int, - pub buf: *mut semid_ds, - pub array: *mut ::c_ushort, - } - // sys/shm.h #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] @@ -589,6 +507,264 @@ s! { } } +s_no_extra_traits!{ + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } + + pub struct proc_threadinfo { + pub pth_user_time: u64, + pub pth_system_time: u64, + pub pth_cpu_usage: i32, + pub pth_policy: i32, + pub pth_run_state: i32, + pub pth_flags: i32, + pub pth_sleep_time: i32, + pub pth_curpri: i32, + pub pth_priority: i32, + pub pth_maxpriority: i32, + pub pth_name: [::c_char; MAXTHREADNAMESIZE], + } + + pub struct statfs { + pub f_bsize: ::uint32_t, + pub f_iosize: ::int32_t, + pub f_blocks: ::uint64_t, + pub f_bfree: ::uint64_t, + pub f_bavail: ::uint64_t, + pub f_files: ::uint64_t, + pub f_ffree: ::uint64_t, + pub f_fsid: ::fsid_t, + pub f_owner: ::uid_t, + pub f_type: ::uint32_t, + pub f_flags: ::uint32_t, + pub f_fssubtype: ::uint32_t, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 1024], + pub f_mntfromname: [::c_char; 1024], + pub f_reserved: [::uint32_t; 8], + } + + pub struct dirent { + pub d_ino: u64, + pub d_seekoff: u64, + pub d_reclen: u16, + pub d_namlen: u16, + pub d_type: u8, + pub d_name: [::c_char; 1024], + } + + pub struct pthread_rwlock_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct pthread_mutex_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_MUTEX_SIZE__], + } + + pub struct pthread_cond_t { + __sig: ::c_long, + __opaque: [u8; __PTHREAD_COND_SIZE__], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + + pub struct utmpx { + pub ut_user: [::c_char; _UTX_USERSIZE], + pub ut_id: [::c_char; _UTX_IDSIZE], + pub ut_line: [::c_char; _UTX_LINESIZE], + pub ut_pid: ::pid_t, + pub ut_type: ::c_short, + pub ut_tv: ::timeval, + pub ut_host: [::c_char; _UTX_HOSTSIZE], + ut_pad: [::uint32_t; 16], + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for semun { + fn eq(&self, other: &semun) -> bool { + unsafe { self.val == other.val } + } +} +#[cfg(feature = "extra_traits")] +impl Eq for semun {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for semun { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("semun") + .field("val", unsafe { &self.val }) + .finish() + } +} +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for semun { + fn hash(&self, state: &mut H) { + unsafe { self.val.hash(state) }; + } +} +#[cfg(feature = "extra_traits")] +impl PartialEq for proc_threadinfo { + fn eq(&self, other: &proc_threadinfo) -> bool { + self.pth_user_time == other.pth_user_time + && self.pth_system_time == other.pth_system_time + && self.pth_cpu_usage == other.pth_cpu_usage + && self.pth_policy == other.pth_policy + && self.pth_run_state == other.pth_run_state + && self.pth_flags == other.pth_flags + && self.pth_sleep_time == other.pth_sleep_time + && self.pth_curpri == other.pth_curpri + && self.pth_priority == other.pth_priority + && self.pth_maxpriority == other.pth_maxpriority + && self + .pth_name + .iter() + .zip(other.pth_name.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for proc_threadinfo {} +#[cfg(feature = "extra_traits")] +impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_fsid == other.f_fsid + && self.f_owner == other.f_owner + && self.f_flags == other.f_flags + && self.f_fssubtype == other.f_fssubtype + && self.f_fstypename == other.f_fstypename + && self.f_type == other.f_type + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self.f_reserved == other.f_reserved + } +} +#[cfg(feature = "extra_traits")] +impl Eq for statfs {} +#[cfg(feature = "extra_traits")] +impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_seekoff == other.d_seekoff + && self.d_reclen == other.d_reclen + && self.d_namlen == other.d_namlen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for dirent {} +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_rwlock_t {} +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_mutex_t {} +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_cond_t {} +#[cfg(feature = "extra_traits")] +impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + && self + .__ss_pad1 + .iter() + .zip(other.__ss_pad1.iter()) + .all(|(a, b)| a == b) + && self.__ss_align == other.__ss_align + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for sockaddr_storage {} +#[cfg(feature = "extra_traits")] +impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_user + .iter() + .zip(other.ut_user.iter()) + .all(|(a,b)| a == b) + && self.ut_id == other.ut_id + && self.ut_line == other.ut_line + && self.ut_pid == other.ut_pid + && self.ut_type == other.ut_type + && self.ut_tv == other.ut_tv + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_pad == other.ut_pad + } +} +#[cfg(feature = "extra_traits")] +impl Eq for utmpx {} + pub const _UTX_USERSIZE: usize = 256; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_IDSIZE: usize = 4; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 12f6e14d93c7c..63bfe9588ae4b 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -25,12 +25,6 @@ s! { pub sin6_scope_id: u32, } - pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -85,6 +79,39 @@ s! { pub tm_zone: *mut ::c_char, } + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + + pub struct cmsghdr { + pub cmsg_len: ::socklen_t, + pub cmsg_level: ::c_int, + pub cmsg_type: ::c_int, + } + + pub struct fsid_t { + __fsid_val: [::int32_t; 2], + } + + pub struct if_nameindex { + pub if_index: ::c_uint, + pub if_name: *mut ::c_char, + } +} + +s_no_extra_traits!{ + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + pub struct utsname { #[cfg(not(target_os = "dragonfly"))] pub sysname: [::c_char; 256], @@ -108,31 +135,53 @@ s! { pub machine: [::c_char; 32], } - pub struct msghdr { - pub msg_name: *mut ::c_void, - pub msg_namelen: ::socklen_t, - pub msg_iov: *mut ::iovec, - pub msg_iovlen: ::c_int, - pub msg_control: *mut ::c_void, - pub msg_controllen: ::socklen_t, - pub msg_flags: ::c_int, - } - - pub struct cmsghdr { - pub cmsg_len: ::socklen_t, - pub cmsg_level: ::c_int, - pub cmsg_type: ::c_int, - } +} - pub struct fsid_t { - __fsid_val: [::int32_t; 2], +#[cfg(feature = "extra_traits")] +impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_len == other.sun_len + && self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a,b)| a == b) } - - pub struct if_nameindex { - pub if_index: ::c_uint, - pub if_name: *mut ::c_char, +} +#[cfg(feature = "extra_traits")] +impl Eq for sockaddr_un {} +#[cfg(feature = "extra_traits")] +impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a,b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a,b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a,b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a,b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a,b)| a == b) } } +#[cfg(feature = "extra_traits")] +impl Eq for utsname {} pub const LC_ALL: ::c_int = 0; pub const LC_COLLATE: ::c_int = 1; diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs index fb943349b3984..b57e7bdc3e4b3 100644 --- a/src/unix/notbsd/android/b64/mod.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -34,25 +34,6 @@ s! { __reserved: [::c_char; 16], } - pub struct pthread_mutex_t { - value: ::c_int, - __reserved: [::c_char; 36], - } - - pub struct pthread_cond_t { - value: ::c_int, - __reserved: [::c_char; 44], - } - - pub struct pthread_rwlock_t { - numLocks: ::c_int, - writerThreadId: ::c_int, - pendingReaders: ::c_int, - pendingWriters: ::c_int, - attr: i32, - __reserved: [::c_char; 36], - } - pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -126,6 +107,70 @@ s! { } } +s_no_extra_traits!{ + pub struct pthread_mutex_t { + value: ::c_int, + __reserved: [::c_char; 36], + } + + pub struct pthread_cond_t { + value: ::c_int, + __reserved: [::c_char; 44], + } + + pub struct pthread_rwlock_t { + numLocks: ::c_int, + writerThreadId: ::c_int, + pendingReaders: ::c_int, + pendingWriters: ::c_int, + attr: i32, + __reserved: [::c_char; 36], + } +} +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.value == other.value + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_mutex_t {} +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.value == other.value + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_cond_t {} +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.numLocks == other.numLocks + && self.writerThreadId == other.writerThreadId + && self.pendingReaders == other.pendingReaders + && self.pendingWriters == other.pendingWriters + && self.attr == other.attr + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_rwlock_t {} + pub const RTLD_GLOBAL: ::c_int = 0x00100; pub const RTLD_NOW: ::c_int = 2; pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 972281c8287b6..5345be0e4cb9f 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -25,36 +25,12 @@ pub type idtype_t = ::c_int; pub type loff_t = ::c_longlong; s! { - pub struct dirent { - pub d_ino: u64, - pub d_off: i64, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - - pub struct dirent64 { - pub d_ino: u64, - pub d_off: i64, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, pub ss_size: ::size_t } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct __fsid_t { __val: [::c_int; 2], } @@ -116,33 +92,11 @@ s! { __reserved: [::c_int; 3], } - pub struct lastlog { - ll_time: ::time_t, - ll_line: [::c_char; UT_LINESIZE], - ll_host: [::c_char; UT_HOSTSIZE], - } - pub struct exit_status { pub e_termination: ::c_short, pub e_exit: ::c_short, } - pub struct utmp { - pub ut_type: ::c_short, - pub ut_pid: ::pid_t, - pub ut_line: [::c_char; UT_LINESIZE], - pub ut_id: [::c_char; 4], - - pub ut_user: [::c_char; UT_NAMESIZE], - pub ut_host: [::c_char; UT_HOSTSIZE], - pub ut_exit: exit_status, - pub ut_session: ::c_long, - pub ut_tv: ::timeval, - - pub ut_addr_v6: [::int32_t; 4], - unused: [::c_char; 20], - } - pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, @@ -240,6 +194,145 @@ s! { } } +s_no_extra_traits!{ + pub struct dirent { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct dirent64 { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct lastlog { + ll_time: ::time_t, + ll_line: [::c_char; UT_LINESIZE], + ll_host: [::c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_type: ::c_short, + pub ut_pid: ::pid_t, + pub ut_line: [::c_char; UT_LINESIZE], + pub ut_id: [::c_char; 4], + pub ut_user: [::c_char; UT_NAMESIZE], + pub ut_host: [::c_char; UT_HOSTSIZE], + pub ut_exit: exit_status, + pub ut_session: ::c_long, + pub ut_tv: ::timeval, + pub ut_addr_v6: [::int32_t; 4], + unused: [::c_char; 20], + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for dirent {} +#[cfg(feature = "extra_traits")] +impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for dirent64 {} +#[cfg(feature = "extra_traits")] +impl PartialEq for siginfo_t { + fn eq(&self, other: &siginfo_t) -> bool { + self.si_signo == other.si_signo + && self.si_errno == other.si_errno + && self.si_code == other.si_code + // Ignore _pad + // Ignore _align + } +} +#[cfg(feature = "extra_traits")] +impl Eq for siginfo_t {} +#[cfg(feature = "extra_traits")] +impl PartialEq for lastlog { + fn eq(&self, other: &lastlog) -> bool { + self.ll_time == other.ll_time + && self + .ll_line + .iter() + .zip(other.ll_line.iter()) + .all(|(a,b)| a == b) + && self + .ll_host + .iter() + .zip(other.ll_host.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for lastlog {} +#[cfg(feature = "extra_traits")] +impl PartialEq for utmp { + fn eq(&self, other: &utmp) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self + .ut_line + .iter() + .zip(other.ut_line.iter()) + .all(|(a,b)| a == b) + && self.ut_id == other.ut_id + && self + .ut_user + .iter() + .zip(other.ut_user.iter()) + .all(|(a,b)| a == b) + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_addr_v6 == other.ut_addr_v6 + && self.unused == other.unused + } +} +#[cfg(feature = "extra_traits")] +impl Eq for utmp {} + pub const O_TRUNC: ::c_int = 512; pub const O_CLOEXEC: ::c_int = 0x80000; pub const O_PATH: ::c_int = 0o10000000; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 8669a06ca5954..bedcef2aa4b6a 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -41,22 +41,6 @@ pub type Elf64_Section = u16; pub enum fpos64_t {} // TODO: fill this out with a struct s! { - pub struct dirent { - pub d_ino: ::ino_t, - pub d_off: ::off_t, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - - pub struct dirent64 { - pub d_ino: ::ino64_t, - pub d_off: ::off64_t, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -75,74 +59,6 @@ s! { __unused5: *mut ::c_void, } - #[cfg_attr(all(feature = "align", - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(all(feature = "align", - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")))), - repr(align(8)))] - pub struct pthread_mutex_t { - #[cfg(all(not(feature = "align"), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(feature = "align", - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(feature = "align", - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(all(feature = "align", - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")))), - repr(align(8)))] - pub struct pthread_rwlock_t { - #[cfg(all(not(feature = "align"), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(feature = "align", - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } - #[cfg_attr(all(feature = "align", any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", @@ -188,30 +104,6 @@ s! { size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } - #[cfg_attr(all(feature = "align", - target_env = "musl", - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(feature = "align", - target_env = "musl", - target_pointer_width = "64"), - repr(align(8)))] - #[cfg_attr(all(feature = "align", - not(target_env = "musl"), - target_arch = "x86"), - repr(align(4)))] - #[cfg_attr(all(feature = "align", - not(target_env = "musl"), - not(target_arch = "x86")), - repr(align(8)))] - pub struct pthread_cond_t { - #[cfg(all(not(feature = "align"), target_env = "musl"))] - __align: [*const ::c_void; 0], - #[cfg(not(any(feature = "align", target_env = "musl")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - #[cfg_attr(feature = "align", repr(align(4)))] pub struct pthread_condattr_t { #[cfg(not(feature = "align"))] @@ -657,6 +549,177 @@ s! { } } +s_no_extra_traits!{ + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + #[cfg_attr(all(feature = "align", + target_env = "musl", + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + target_env = "musl", + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + not(target_env = "musl"), + not(target_arch = "x86")), + repr(align(8)))] + pub struct pthread_cond_t { + #[cfg(all(not(feature = "align"), target_env = "musl"))] + __align: [*const ::c_void; 0], + #[cfg(not(any(feature = "align", target_env = "musl")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")))), + repr(align(8)))] + pub struct pthread_mutex_t { + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_long; 0], + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(feature = "align", + target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(all(feature = "align", + any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")))), + repr(align(8)))] + pub struct pthread_rwlock_t { + #[cfg(all(not(feature = "align"), + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_long; 0], + #[cfg(not(any(feature = "align", + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for dirent {} + +#[cfg(feature = "extra_traits")] +impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for dirent64 {} + +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_cond_t {} + +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_mutex_t {} + +#[cfg(feature = "extra_traits")] +impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for pthread_rwlock_t {} + pub const ABDAY_1: ::nl_item = 0x20000; pub const ABDAY_2: ::nl_item = 0x20001; pub const ABDAY_3: ::nl_item = 0x20002; diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index b6ea8c120f6bf..222868e6dc39b 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -116,15 +116,6 @@ s! { __private: [u32; 22] } - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: ::sigset_t, - __private: [u8; 112], - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, @@ -176,6 +167,34 @@ s! { } } +s_no_extra_traits!{ + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 112], + } +} +#[cfg(feature = "extra_traits")] +impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + && self + .__private + .iter() + .zip(other.__private.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for ucontext_t {} + pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs index 0e0fcec4d2e7c..1033e6c6959d4 100644 --- a/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -51,15 +51,6 @@ s! { __private: [u64; 32], } - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: ::sigset_t, - __private: [u8; 512], - } - pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, @@ -73,6 +64,35 @@ s! { } } +s_no_extra_traits!{ + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 512], + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + && self + .__private + .iter() + .zip(other.__private.iter()) + .all(|(a,b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for ucontext_t {} + // Syscall table pub const SYS_read: ::c_long = 0; diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 5ab5d0f69193d..7eb52fc23586c 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -78,7 +78,9 @@ s! { pub l_len: ::off_t, pub l_pid: ::pid_t, } +} +s_no_extra_traits!{ pub struct sysinfo { pub uptime: ::c_ulong, pub loads: [::c_ulong; 3], @@ -97,6 +99,28 @@ s! { } } +#[cfg(feature = "extra_traits")] +impl PartialEq for sysinfo { + fn eq(&self, other: &sysinfo) -> bool { + self.uptime == other.uptime + && self.loads == other.loads + && self.totalram == other.totalram + && self.freeram == other.freeram + && self.sharedram == other.sharedram + && self.bufferram == other.bufferram + && self.totalswap == other.totalswap + && self.freeswap == other.freeswap + && self.procs == other.procs + && self.pad == other.pad + && self.totalhigh == other.totalhigh + && self.freehigh == other.freehigh + && self.mem_unit == other.mem_unit + // Ignore __reserved field + } +} +#[cfg(feature = "extra_traits")] +impl Eq for sysinfo {} + pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 6c41718d124b3..2d262b3b3eeee 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -31,22 +31,6 @@ s! { pub st_space: [::c_long; 20], } - pub struct user_fpxregs_struct { - pub cwd: ::c_ushort, - pub swd: ::c_ushort, - pub twd: ::c_ushort, - pub fop: ::c_ushort, - pub fip: ::c_long, - pub fcs: ::c_long, - pub foo: ::c_long, - pub fos: ::c_long, - pub mxcsr: ::c_long, - __reserved: ::c_long, - pub st_space: [::c_long; 32], - pub xmm_space: [::c_long; 32], - padding: [::c_long; 56], - } - pub struct user_regs_struct { pub ebx: ::c_long, pub ecx: ::c_long, @@ -92,15 +76,6 @@ s! { pub cr2: ::c_ulong, } - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: ::sigset_t, - __private: [u8; 112], - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -213,6 +188,67 @@ s! { } } +s_no_extra_traits!{ + pub struct user_fpxregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub twd: ::c_ushort, + pub fop: ::c_ushort, + pub fip: ::c_long, + pub fcs: ::c_long, + pub foo: ::c_long, + pub fos: ::c_long, + pub mxcsr: ::c_long, + __reserved: ::c_long, + pub st_space: [::c_long; 32], + pub xmm_space: [::c_long; 32], + padding: [::c_long; 56], + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 112], + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for user_fpxregs_struct { + fn eq(&self, other: &user_fpxregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.twd == other.twd + && self.fop == other.fop + && self.fip == other.fip + && self.fcs == other.fcs + && self.foo == other.foo + && self.fos == other.fos + && self.mxcsr == other.mxcsr + // Ignore __reserved field + && self.st_space == other.st_space + && self.xmm_space == other.xmm_space + // Ignore padding field + } +} +#[cfg(feature = "extra_traits")] +impl Eq for user_fpxregs_struct {} +#[cfg(feature = "extra_traits")] +impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + // Ignore __private field + } +} +#[cfg(feature = "extra_traits")] +impl Eq for ucontext_t {} + pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 0d7137e75c036..2257ea4267a01 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -112,20 +112,6 @@ s! { __private: [u64; 12], } - pub struct user_fpregs_struct { - pub cwd: ::c_ushort, - pub swd: ::c_ushort, - pub ftw: ::c_ushort, - pub fop: ::c_ushort, - pub rip: ::c_ulonglong, - pub rdp: ::c_ulonglong, - pub mxcsr: ::c_uint, - pub mxcr_mask: ::c_uint, - pub st_space: [::c_uint; 32], - pub xmm_space: [::c_uint; 64], - padding: [::c_uint; 24], - } - pub struct user_regs_struct { pub r15: ::c_ulonglong, pub r14: ::c_ulonglong, @@ -184,15 +170,6 @@ s! { __private: [u64; 8], } - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: ::sigset_t, - __private: [u8; 512], - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -232,6 +209,68 @@ s! { } } +s_no_extra_traits! { + pub struct user_fpregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub ftw: ::c_ushort, + pub fop: ::c_ushort, + pub rip: ::c_ulonglong, + pub rdp: ::c_ulonglong, + pub mxcsr: ::c_uint, + pub mxcr_mask: ::c_uint, + pub st_space: [::c_uint; 32], + pub xmm_space: [::c_uint; 64], + padding: [::c_uint; 24], + } + + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 512], + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for user_fpregs_struct { + fn eq(&self, other: &user_fpregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.ftw == other.ftw + && self.fop == other.fop + && self.rip == other.rip + && self.rdp == other.rdp + && self.mxcsr == other.mxcsr + && self.mxcr_mask == other.mxcr_mask + && self.st_space == other.st_space + && self + .xmm_space + .iter() + .zip(other.xmm_space.iter()) + .all(|(a,b)| a == b) + // Ignore padding field + } +} +#[cfg(feature = "extra_traits")] +impl Eq for user_fpregs_struct {} + +#[cfg(feature = "extra_traits")] +impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + // Ignore __private field + } +} +#[cfg(feature = "extra_traits")] +impl Eq for ucontext_t {} + pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index c1e339311d1db..67ddda300a0d2 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -29,42 +29,6 @@ s! { pub tv_usec: ::int32_t, } - pub struct utmpx { - pub ut_type: ::c_short, - pub ut_pid: ::pid_t, - pub ut_line: [::c_char; __UT_LINESIZE], - pub ut_id: [::c_char; 4], - - pub ut_user: [::c_char; __UT_NAMESIZE], - pub ut_host: [::c_char; __UT_HOSTSIZE], - pub ut_exit: __exit_status, - - #[cfg(any(target_arch = "aarch64", - target_arch = "sparc64", - all(target_pointer_width = "32", - not(target_arch = "x86_64"))))] - pub ut_session: ::c_long, - #[cfg(any(target_arch = "aarch64", - target_arch = "sparc64", - all(target_pointer_width = "32", - not(target_arch = "x86_64"))))] - pub ut_tv: ::timeval, - - #[cfg(not(any(target_arch = "aarch64", - target_arch = "sparc64", - all(target_pointer_width = "32", - not(target_arch = "x86_64")))))] - pub ut_session: ::int32_t, - #[cfg(not(any(target_arch = "aarch64", - target_arch = "sparc64", - all(target_pointer_width = "32", - not(target_arch = "x86_64")))))] - pub ut_tv: __timeval, - - pub ut_addr_v6: [::int32_t; 4], - __glibc_reserved: [::c_char; 20], - } - pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, @@ -244,6 +208,67 @@ s! { } } +s_no_extra_traits! { + pub struct utmpx { + pub ut_type: ::c_short, + pub ut_pid: ::pid_t, + pub ut_line: [::c_char; __UT_LINESIZE], + pub ut_id: [::c_char; 4], + + pub ut_user: [::c_char; __UT_NAMESIZE], + pub ut_host: [::c_char; __UT_HOSTSIZE], + pub ut_exit: __exit_status, + + #[cfg(any(target_arch = "aarch64", + target_arch = "sparc64", + all(target_pointer_width = "32", + not(target_arch = "x86_64"))))] + pub ut_session: ::c_long, + #[cfg(any(target_arch = "aarch64", + target_arch = "sparc64", + all(target_pointer_width = "32", + not(target_arch = "x86_64"))))] + pub ut_tv: ::timeval, + + #[cfg(not(any(target_arch = "aarch64", + target_arch = "sparc64", + all(target_pointer_width = "32", + not(target_arch = "x86_64")))))] + pub ut_session: ::int32_t, + #[cfg(not(any(target_arch = "aarch64", + target_arch = "sparc64", + all(target_pointer_width = "32", + not(target_arch = "x86_64")))))] + pub ut_tv: __timeval, + + pub ut_addr_v6: [::int32_t; 4], + __glibc_reserved: [::c_char; 20], + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_user == other.ut_user + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_addr_v6 == other.ut_addr_v6 + && self.__glibc_reserved == other.__glibc_reserved + } +} +#[cfg(feature = "extra_traits")] +impl Eq for utmpx {} + pub const __UT_LINESIZE: usize = 32; pub const __UT_NAMESIZE: usize = 32; pub const __UT_HOSTSIZE: usize = 256; diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index 9e3814f3c501f..6f21e94785fc7 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -262,12 +262,6 @@ s! { pub addr: u64, } - // FIXME: This is actually a union. - pub struct fpreg_t { - pub d: ::c_double, - // f: ::c_float, - } - pub struct fpregset_t { pub fpc: u32, __pad: u32, @@ -334,6 +328,23 @@ s! { } } +s_no_extra_traits!{ + // FIXME: This is actually a union. + pub struct fpreg_t { + pub d: ::c_double, + // f: ::c_float, + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for fpreg_t { + fn eq(&self, other: &fpreg_t) -> bool { + self.d == other.d + } +} +#[cfg(feature = "extra_traits")] +impl Eq for fpreg_t {} + pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 668c25f7fee22..9caa2866e53b0 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -31,20 +31,6 @@ s! { pub sin6_scope_id: u32, } - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [::c_char; 108] - } - - pub struct sockaddr_storage { - pub ss_family: sa_family_t, - __ss_align: ::size_t, - #[cfg(target_pointer_width = "32")] - __ss_pad2: [u8; 128 - 2 * 4], - #[cfg(target_pointer_width = "64")] - __ss_pad2: [u8; 128 - 2 * 8], - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -128,15 +114,6 @@ s! { pub u64: ::uint64_t, } - pub struct utsname { - pub sysname: [::c_char; 65], - pub nodename: [::c_char; 65], - pub release: [::c_char; 65], - pub version: [::c_char; 65], - pub machine: [::c_char; 65], - pub domainname: [::c_char; 65] - } - pub struct lconv { pub decimal_point: *mut ::c_char, pub thousands_sep: *mut ::c_char, @@ -230,6 +207,95 @@ s! { } } +s_no_extra_traits!{ + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108] + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_align: ::size_t, + #[cfg(target_pointer_width = "32")] + __ss_pad2: [u8; 128 - 2 * 4], + #[cfg(target_pointer_width = "64")] + __ss_pad2: [u8; 128 - 2 * 8], + } + + pub struct utsname { + pub sysname: [::c_char; 65], + pub nodename: [::c_char; 65], + pub release: [::c_char; 65], + pub version: [::c_char; 65], + pub machine: [::c_char; 65], + pub domainname: [::c_char; 65] + } +} + +#[cfg(feature = "extra_traits")] +impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a, b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for sockaddr_un {} + +#[cfg(feature = "extra_traits")] +impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_family == other.ss_family + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for sockaddr_storage {} + +#[cfg(feature = "extra_traits")] +impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a, b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a, b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a, b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a, b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a, b)| a == b) + && self + .domainname + .iter() + .zip(other.domainname.iter()) + .all(|(a, b)| a == b) + } +} +#[cfg(feature = "extra_traits")] +impl Eq for utsname {} // intentionally not public, only used for fd_set cfg_if! { if #[cfg(target_pointer_width = "32")] { From 79ae1217c2a1a220b1c3f39283ba1ab812350cdc Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Mon, 21 Jan 2019 19:40:02 -0800 Subject: [PATCH 3/7] Implement Debug for all types --- README.md | 4 +- src/macros.rs | 2 +- src/unix/bsd/apple/b32.rs | 9 ++ src/unix/bsd/apple/b64.rs | 9 ++ src/unix/bsd/apple/mod.rs | 114 ++++++++++++++++++++-- src/unix/bsd/mod.rs | 22 +++++ src/unix/notbsd/android/b64/mod.rs | 31 ++++++ src/unix/notbsd/android/mod.rs | 64 ++++++++++++ src/unix/notbsd/linux/mod.rs | 48 +++++++++ src/unix/notbsd/linux/musl/b32/x86.rs | 13 +++ src/unix/notbsd/linux/musl/b64/x86_64.rs | 13 +++ src/unix/notbsd/linux/musl/mod.rs | 21 ++++ src/unix/notbsd/linux/other/b32/x86.rs | 33 +++++++ src/unix/notbsd/linux/other/b64/x86_64.rs | 30 ++++++ src/unix/notbsd/linux/other/mod.rs | 18 ++++ src/unix/notbsd/linux/s390x.rs | 8 ++ src/unix/notbsd/mod.rs | 33 +++++++ 17 files changed, 463 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ae45ce7f40434..4885cc9e3c749 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ libc = { version = "0.2", features = ["align"] } ``` All structs implemented by the libc crate have the `Copy` and `Clone` traits -implemented for them. The additional traits of `PartialEq` and `Eq` can be -enabled with the *extra_traits* feature (requires Rust 1.25 or newer): +implemented for them. The additional traits of `Debug, `Eq`, and `PartialEq` +can be enabled with the *extra_traits* feature (requires Rust 1.25 or newer): ```toml [dependencies] diff --git a/src/macros.rs b/src/macros.rs index 175c0512592bc..3877797ce0602 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -39,7 +39,7 @@ macro_rules! s { __item! { #[repr(C)] $(#[$attr])* - #[cfg_attr(feature = "extra_traits", derive(Eq, PartialEq))] + #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, PartialEq))] pub $t $i { $($field)* } } impl ::dox::Copy for $i {} diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 95dc962a1d029..4950c19738296 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -64,6 +64,15 @@ impl PartialEq for pthread_attr_t { } #[cfg(feature = "extra_traits")] impl Eq for pthread_attr_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_attr_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } +} pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index 0eb2d45c6a960..c5f00384949da 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -69,6 +69,15 @@ impl PartialEq for pthread_attr_t { } #[cfg(feature = "extra_traits")] impl Eq for pthread_attr_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_attr_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } +} pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 80516388f49c2..16ce25f03e520 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -608,12 +608,6 @@ impl std::fmt::Debug for semun { } } #[cfg(feature = "extra_traits")] -impl std::hash::Hash for semun { - fn hash(&self, state: &mut H) { - unsafe { self.val.hash(state) }; - } -} -#[cfg(feature = "extra_traits")] impl PartialEq for proc_threadinfo { fn eq(&self, other: &proc_threadinfo) -> bool { self.pth_user_time == other.pth_user_time @@ -636,6 +630,24 @@ impl PartialEq for proc_threadinfo { #[cfg(feature = "extra_traits")] impl Eq for proc_threadinfo {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for proc_threadinfo { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("proc_threadinfo") + .field("pth_user_time", &self.pth_user_time) + .field("pth_system_time", &self.pth_system_time) + .field("pth_cpu_usage", &self.pth_cpu_usage) + .field("pth_policy", &self.pth_policy) + .field("pth_run_state", &self.pth_run_state) + .field("pth_flags", &self.pth_flags) + .field("pth_sleep_time", &self.pth_sleep_time) + .field("pth_curpri", &self.pth_curpri) + .field("pth_priority", &self.pth_priority) + .field("pth_maxpriority", &self.pth_maxpriority) + // FIXME: .field("pth_name", &self.pth_name) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for statfs { fn eq(&self, other: &statfs) -> bool { self.f_bsize == other.f_bsize @@ -667,6 +679,29 @@ impl PartialEq for statfs { #[cfg(feature = "extra_traits")] impl Eq for statfs {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for statfs { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_fsid", &self.f_fsid) + .field("f_owner", &self.f_owner) + .field("f_flags", &self.f_flags) + .field("f_fssubtype", &self.f_fssubtype) + .field("f_fstypename", &self.f_fstypename) + .field("f_type", &self.f_type) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + .field("f_reserved", &self.f_reserved) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for dirent { fn eq(&self, other: &dirent) -> bool { self.d_ino == other.d_ino @@ -684,6 +719,19 @@ impl PartialEq for dirent { #[cfg(feature = "extra_traits")] impl Eq for dirent {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for dirent { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_seekoff", &self.d_seekoff) + .field("d_reclen", &self.d_reclen) + .field("d_namlen", &self.d_namlen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_rwlock_t { fn eq(&self, other: &pthread_rwlock_t) -> bool { self.__sig == other.__sig @@ -697,6 +745,15 @@ impl PartialEq for pthread_rwlock_t { #[cfg(feature = "extra_traits")] impl Eq for pthread_rwlock_t {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_rwlock_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_mutex_t { fn eq(&self, other: &pthread_mutex_t) -> bool { self.__sig == other.__sig @@ -710,6 +767,15 @@ impl PartialEq for pthread_mutex_t { #[cfg(feature = "extra_traits")] impl Eq for pthread_mutex_t {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_mutex_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_cond_t { fn eq(&self, other: &pthread_cond_t) -> bool { self.__sig == other.__sig @@ -723,6 +789,15 @@ impl PartialEq for pthread_cond_t { #[cfg(feature = "extra_traits")] impl Eq for pthread_cond_t {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_cond_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for sockaddr_storage { fn eq(&self, other: &sockaddr_storage) -> bool { self.ss_len == other.ss_len @@ -743,6 +818,18 @@ impl PartialEq for sockaddr_storage { #[cfg(feature = "extra_traits")] impl Eq for sockaddr_storage {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &self.__ss_pad1) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for utmpx { fn eq(&self, other: &utmpx) -> bool { self.ut_user @@ -764,6 +851,21 @@ impl PartialEq for utmpx { } #[cfg(feature = "extra_traits")] impl Eq for utmpx {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for utmpx { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utmpx") + // FIXME: .field("ut_user", &self.ut_user) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + .field("ut_pid", &self.ut_pid) + .field("ut_type", &self.ut_type) + .field("ut_tv", &self.ut_tv) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_pad", &self.ut_pad) + .finish() + } +} pub const _UTX_USERSIZE: usize = 256; pub const _UTX_LINESIZE: usize = 32; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 63bfe9588ae4b..74bbaf75e7471 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -152,6 +152,16 @@ impl PartialEq for sockaddr_un { #[cfg(feature = "extra_traits")] impl Eq for sockaddr_un {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_len", &self.sun_len) + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for utsname { fn eq(&self, other: &utsname) -> bool { self.sysname @@ -182,6 +192,18 @@ impl PartialEq for utsname { } #[cfg(feature = "extra_traits")] impl Eq for utsname {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for utsname { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + .finish() + } +} pub const LC_ALL: ::c_int = 0; pub const LC_COLLATE: ::c_int = 1; diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs index b57e7bdc3e4b3..c5a6a79e4484b 100644 --- a/src/unix/notbsd/android/b64/mod.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -141,6 +141,15 @@ impl PartialEq for pthread_mutex_t { #[cfg(feature = "extra_traits")] impl Eq for pthread_mutex_t {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_mutex_t") + .field("value", &self.value) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_cond_t { fn eq(&self, other: &pthread_cond_t) -> bool { self.value == other.value @@ -154,6 +163,15 @@ impl PartialEq for pthread_cond_t { #[cfg(feature = "extra_traits")] impl Eq for pthread_cond_t {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_cond_t") + .field("value", &self.value) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_rwlock_t { fn eq(&self, other: &pthread_rwlock_t) -> bool { self.numLocks == other.numLocks @@ -170,6 +188,19 @@ impl PartialEq for pthread_rwlock_t { } #[cfg(feature = "extra_traits")] impl Eq for pthread_rwlock_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_rwlock_t") + .field("numLocks", &self.numLocks) + .field("writerThreadId", &self.writerThreadId) + .field("pendingReaders", &self.pendingReaders) + .field("pendingWriters", &self.pendingWriters) + .field("attr", &self.attr) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } +} pub const RTLD_GLOBAL: ::c_int = 0x00100; pub const RTLD_NOW: ::c_int = 2; diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 5345be0e4cb9f..99faaef6ba354 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -257,6 +257,18 @@ impl PartialEq for dirent { #[cfg(feature = "extra_traits")] impl Eq for dirent {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for dirent { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_name", &self.d_name) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for dirent64 { fn eq(&self, other: &dirent64) -> bool { self.d_ino == other.d_ino @@ -273,6 +285,18 @@ impl PartialEq for dirent64 { #[cfg(feature = "extra_traits")] impl Eq for dirent64 {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_name", &self.d_name) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for siginfo_t { fn eq(&self, other: &siginfo_t) -> bool { self.si_signo == other.si_signo @@ -285,6 +309,18 @@ impl PartialEq for siginfo_t { #[cfg(feature = "extra_traits")] impl Eq for siginfo_t {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("siginfo_t") + .field("si_signo", &self.si_signo) + .field("si_errno", &self.si_errno) + .field("si_code", &self.si_code) + // Ignore _pad + // Ignore _align + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for lastlog { fn eq(&self, other: &lastlog) -> bool { self.ll_time == other.ll_time @@ -303,6 +339,16 @@ impl PartialEq for lastlog { #[cfg(feature = "extra_traits")] impl Eq for lastlog {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for lastlog { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("lastlog") + .field("ll_time", &self.ll_time) + .field("ll_line", &self.ll_line) + .field("ll_host", &self.ll_host) + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for utmp { fn eq(&self, other: &utmp) -> bool { self.ut_type == other.ut_type @@ -332,6 +378,24 @@ impl PartialEq for utmp { } #[cfg(feature = "extra_traits")] impl Eq for utmp {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for utmp { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utmp") + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_line", &self.ut_line) + .field("ut_id", &self.ut_id) + .field("ut_user", &self.ut_user) + .field("ut_host", &self.ut_host) + .field("ut_exit", &self.ut_exit) + .field("ut_session", &self.ut_session) + .field("ut_tv", &self.ut_tv) + .field("ut_addr_v6", &self.ut_addr_v6) + .field("unused", &self.unused) + .finish() + } +} pub const O_TRUNC: ::c_int = 512; pub const O_CLOEXEC: ::c_int = 0x80000; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index bedcef2aa4b6a..b0eac45b66781 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -675,6 +675,18 @@ impl PartialEq for dirent { } #[cfg(feature = "extra_traits")] impl Eq for dirent {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for dirent { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } +} #[cfg(feature = "extra_traits")] impl PartialEq for dirent64 { @@ -692,6 +704,18 @@ impl PartialEq for dirent64 { } #[cfg(feature = "extra_traits")] impl Eq for dirent64 {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } +} #[cfg(feature = "extra_traits")] impl PartialEq for pthread_cond_t { @@ -701,6 +725,14 @@ impl PartialEq for pthread_cond_t { } #[cfg(feature = "extra_traits")] impl Eq for pthread_cond_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_cond_t") + // FIXME: .field("size", &self.size) + .finish() + } +} #[cfg(feature = "extra_traits")] impl PartialEq for pthread_mutex_t { @@ -710,6 +742,14 @@ impl PartialEq for pthread_mutex_t { } #[cfg(feature = "extra_traits")] impl Eq for pthread_mutex_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_mutex_t") + // FIXME: .field("size", &self.size) + .finish() + } +} #[cfg(feature = "extra_traits")] impl PartialEq for pthread_rwlock_t { @@ -719,6 +759,14 @@ impl PartialEq for pthread_rwlock_t { } #[cfg(feature = "extra_traits")] impl Eq for pthread_rwlock_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_rwlock_t") + // FIXME: .field("size", &self.size) + .finish() + } +} pub const ABDAY_1: ::nl_item = 0x20000; pub const ABDAY_2: ::nl_item = 0x20001; diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 222868e6dc39b..9b79356f5082f 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -194,6 +194,19 @@ impl PartialEq for ucontext_t { } #[cfg(feature = "extra_traits")] impl Eq for ucontext_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } +} pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs index 1033e6c6959d4..1679a3ab0228f 100644 --- a/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -92,6 +92,19 @@ impl PartialEq for ucontext_t { } #[cfg(feature = "extra_traits")] impl Eq for ucontext_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } +} // Syscall table diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 7eb52fc23586c..6d1a0a13d6685 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -120,6 +120,27 @@ impl PartialEq for sysinfo { } #[cfg(feature = "extra_traits")] impl Eq for sysinfo {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for sysinfo { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sysinfo") + .field("uptime", &self.uptime) + .field("loads", &self.loads) + .field("totalram", &self.totalram) + .field("freeram", &self.freeram) + .field("sharedram", &self.sharedram) + .field("bufferram", &self.bufferram) + .field("totalswap", &self.totalswap) + .field("freeswap", &self.freeswap) + .field("procs", &self.procs) + .field("pad", &self.pad) + .field("totalhigh", &self.totalhigh) + .field("freehigh", &self.freehigh) + .field("mem_unit", &self.mem_unit) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } +} pub const SFD_CLOEXEC: ::c_int = 0x080000; diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 2d262b3b3eeee..d3186c0fb1191 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -236,6 +236,26 @@ impl PartialEq for user_fpxregs_struct { #[cfg(feature = "extra_traits")] impl Eq for user_fpxregs_struct {} #[cfg(feature = "extra_traits")] +impl std::fmt::Debug for user_fpxregs_struct { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("user_fpxregs_struct") + .field("cwd", &self.cwd) + .field("swd", &self.swd) + .field("twd", &self.twd) + .field("fop", &self.fop) + .field("fip", &self.fip) + .field("fcs", &self.fcs) + .field("foo", &self.foo) + .field("fos", &self.fos) + .field("mxcsr", &self.mxcsr) + // Ignore __reserved field + .field("st_space", &self.st_space) + .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for ucontext_t { fn eq(&self, other: &ucontext_t) -> bool { self.uc_flags == other.uc_flags @@ -248,6 +268,19 @@ impl PartialEq for ucontext_t { } #[cfg(feature = "extra_traits")] impl Eq for ucontext_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } +} pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 2257ea4267a01..02745b9056485 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -256,6 +256,23 @@ impl PartialEq for user_fpregs_struct { } #[cfg(feature = "extra_traits")] impl Eq for user_fpregs_struct {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for user_fpregs_struct { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("user_fpregs_struct") + .field("cwd", &self.cwd) + .field("ftw", &self.ftw) + .field("fop", &self.fop) + .field("rip", &self.rip) + .field("rdp", &self.rdp) + .field("mxcsr", &self.mxcsr) + .field("mxcr_mask", &self.mxcr_mask) + .field("st_space", &self.st_space) + // FIXME: .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } +} #[cfg(feature = "extra_traits")] impl PartialEq for ucontext_t { @@ -270,6 +287,19 @@ impl PartialEq for ucontext_t { } #[cfg(feature = "extra_traits")] impl Eq for ucontext_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } +} pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 67ddda300a0d2..fa0e39ba447bf 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -268,6 +268,24 @@ impl PartialEq for utmpx { } #[cfg(feature = "extra_traits")] impl Eq for utmpx {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for utmpx { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utmpx") + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_line", &self.ut_line) + .field("ut_id", &self.ut_id) + .field("ut_user", &self.ut_user) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_exit", &self.ut_exit) + .field("ut_session", &self.ut_session) + .field("ut_tv", &self.ut_tv) + .field("ut_addr_v6", &self.ut_addr_v6) + .field("__glibc_reserved", &self.__glibc_reserved) + .finish() + } +} pub const __UT_LINESIZE: usize = 32; pub const __UT_NAMESIZE: usize = 32; diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index 6f21e94785fc7..8a6b88a8180e9 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -344,6 +344,14 @@ impl PartialEq for fpreg_t { } #[cfg(feature = "extra_traits")] impl Eq for fpreg_t {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for fpreg_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("fpreg_t") + .field("d", &self.d) + .finish() + } +} pub const SFD_CLOEXEC: ::c_int = 0x080000; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 9caa2866e53b0..cd613d448ca81 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -245,6 +245,15 @@ impl PartialEq for sockaddr_un { } #[cfg(feature = "extra_traits")] impl Eq for sockaddr_un {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } +} #[cfg(feature = "extra_traits")] impl PartialEq for sockaddr_storage { @@ -259,6 +268,16 @@ impl PartialEq for sockaddr_storage { } #[cfg(feature = "extra_traits")] impl Eq for sockaddr_storage {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_family", &self.ss_family) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } +} #[cfg(feature = "extra_traits")] impl PartialEq for utsname { @@ -296,6 +315,20 @@ impl PartialEq for utsname { } #[cfg(feature = "extra_traits")] impl Eq for utsname {} +#[cfg(feature = "extra_traits")] +impl std::fmt::Debug for utsname { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + // FIXME: .field("domainname", &self.domainname) + .finish() + } +} + // intentionally not public, only used for fd_set cfg_if! { if #[cfg(target_pointer_width = "32")] { From cd1e16d1afb70ed510565c52d053b40a9f7c6975 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Mon, 21 Jan 2019 19:49:48 -0800 Subject: [PATCH 4/7] Implement Hash for all types --- README.md | 5 +- src/macros.rs | 2 +- src/unix/bsd/apple/b32.rs | 7 ++ src/unix/bsd/apple/b64.rs | 7 ++ src/unix/bsd/apple/mod.rs | 98 +++++++++++++++++++++++ src/unix/bsd/mod.rs | 18 +++++ src/unix/notbsd/android/b64/mod.rs | 25 ++++++ src/unix/notbsd/android/mod.rs | 54 +++++++++++++ src/unix/notbsd/linux/mod.rs | 38 +++++++++ src/unix/notbsd/linux/musl/b32/x86.rs | 11 +++ src/unix/notbsd/linux/musl/b64/x86_64.rs | 11 +++ src/unix/notbsd/linux/musl/mod.rs | 19 +++++ src/unix/notbsd/linux/other/b32/x86.rs | 29 +++++++ src/unix/notbsd/linux/other/b64/x86_64.rs | 26 ++++++ src/unix/notbsd/linux/other/mod.rs | 16 ++++ src/unix/notbsd/linux/s390x.rs | 6 ++ src/unix/notbsd/mod.rs | 25 ++++++ 17 files changed, 394 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4885cc9e3c749..1caab85438577 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,9 @@ libc = { version = "0.2", features = ["align"] } ``` All structs implemented by the libc crate have the `Copy` and `Clone` traits -implemented for them. The additional traits of `Debug, `Eq`, and `PartialEq` -can be enabled with the *extra_traits* feature (requires Rust 1.25 or newer): +implemented for them. The additional traits of `Debug, `Eq`, `Hash`, and +`PartialEq` can be enabled with the *extra_traits* feature (requires Rust 1.25 +or newer): ```toml [dependencies] diff --git a/src/macros.rs b/src/macros.rs index 3877797ce0602..aabe6e8e7001f 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -39,7 +39,7 @@ macro_rules! s { __item! { #[repr(C)] $(#[$attr])* - #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, PartialEq))] + #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] pub $t $i { $($field)* } } impl ::dox::Copy for $i {} diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 4950c19738296..284eae399ddec 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -73,6 +73,13 @@ impl std::fmt::Debug for pthread_attr_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } +} pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index c5f00384949da..2161fc47590f9 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -78,6 +78,13 @@ impl std::fmt::Debug for pthread_attr_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } +} pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 16ce25f03e520..08995917d4331 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -608,6 +608,12 @@ impl std::fmt::Debug for semun { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for semun { + fn hash(&self, state: &mut H) { + unsafe { self.val.hash(state) }; + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for proc_threadinfo { fn eq(&self, other: &proc_threadinfo) -> bool { self.pth_user_time == other.pth_user_time @@ -648,6 +654,22 @@ impl std::fmt::Debug for proc_threadinfo { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for proc_threadinfo { + fn hash(&self, state: &mut H) { + self.pth_user_time.hash(state); + self.pth_system_time.hash(state); + self.pth_cpu_usage.hash(state); + self.pth_policy.hash(state); + self.pth_run_state.hash(state); + self.pth_flags.hash(state); + self.pth_sleep_time.hash(state); + self.pth_curpri.hash(state); + self.pth_priority.hash(state); + self.pth_maxpriority.hash(state); + self.pth_name.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for statfs { fn eq(&self, other: &statfs) -> bool { self.f_bsize == other.f_bsize @@ -702,6 +724,27 @@ impl std::fmt::Debug for statfs { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_fsid.hash(state); + self.f_owner.hash(state); + self.f_flags.hash(state); + self.f_fssubtype.hash(state); + self.f_fstypename.hash(state); + self.f_type.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + self.f_reserved.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for dirent { fn eq(&self, other: &dirent) -> bool { self.d_ino == other.d_ino @@ -732,6 +775,17 @@ impl std::fmt::Debug for dirent { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_seekoff.hash(state); + self.d_reclen.hash(state); + self.d_namlen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_rwlock_t { fn eq(&self, other: &pthread_rwlock_t) -> bool { self.__sig == other.__sig @@ -754,6 +808,13 @@ impl std::fmt::Debug for pthread_rwlock_t { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_mutex_t { fn eq(&self, other: &pthread_mutex_t) -> bool { self.__sig == other.__sig @@ -776,6 +837,13 @@ impl std::fmt::Debug for pthread_mutex_t { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_cond_t { fn eq(&self, other: &pthread_cond_t) -> bool { self.__sig == other.__sig @@ -798,6 +866,13 @@ impl std::fmt::Debug for pthread_cond_t { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for sockaddr_storage { fn eq(&self, other: &sockaddr_storage) -> bool { self.ss_len == other.ss_len @@ -830,6 +905,16 @@ impl std::fmt::Debug for sockaddr_storage { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + self.__ss_pad1.hash(state); + self.__ss_align.hash(state); + self.__ss_pad2.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for utmpx { fn eq(&self, other: &utmpx) -> bool { self.ut_user @@ -866,6 +951,19 @@ impl std::fmt::Debug for utmpx { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_user.hash(state); + self.ut_id.hash(state); + self.ut_line.hash(state); + self.ut_pid.hash(state); + self.ut_type.hash(state); + self.ut_tv.hash(state); + self.ut_host.hash(state); + self.ut_pad.hash(state); + } +} pub const _UTX_USERSIZE: usize = 256; pub const _UTX_LINESIZE: usize = 32; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 74bbaf75e7471..0541c5a005805 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -162,6 +162,14 @@ impl std::fmt::Debug for sockaddr_un { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_len.hash(state); + self.sun_family.hash(state); + self.sun_path.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for utsname { fn eq(&self, other: &utsname) -> bool { self.sysname @@ -204,6 +212,16 @@ impl std::fmt::Debug for utsname { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + } +} pub const LC_ALL: ::c_int = 0; pub const LC_COLLATE: ::c_int = 1; diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs index c5a6a79e4484b..1da667bccc0c2 100644 --- a/src/unix/notbsd/android/b64/mod.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -150,6 +150,13 @@ impl std::fmt::Debug for pthread_mutex_t { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.value.hash(state); + self.__reserved.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_cond_t { fn eq(&self, other: &pthread_cond_t) -> bool { self.value == other.value @@ -172,6 +179,13 @@ impl std::fmt::Debug for pthread_cond_t { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.value.hash(state); + self.__reserved.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for pthread_rwlock_t { fn eq(&self, other: &pthread_rwlock_t) -> bool { self.numLocks == other.numLocks @@ -201,6 +215,17 @@ impl std::fmt::Debug for pthread_rwlock_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.numLocks.hash(state); + self.writerThreadId.hash(state); + self.pendingReaders.hash(state); + self.pendingWriters.hash(state); + self.attr.hash(state); + self.__reserved.hash(state); + } +} pub const RTLD_GLOBAL: ::c_int = 0x00100; pub const RTLD_NOW: ::c_int = 2; diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 99faaef6ba354..de4ff593a0ba7 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -269,6 +269,16 @@ impl std::fmt::Debug for dirent { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for dirent64 { fn eq(&self, other: &dirent64) -> bool { self.d_ino == other.d_ino @@ -297,6 +307,16 @@ impl std::fmt::Debug for dirent64 { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for siginfo_t { fn eq(&self, other: &siginfo_t) -> bool { self.si_signo == other.si_signo @@ -321,6 +341,16 @@ impl std::fmt::Debug for siginfo_t { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_errno.hash(state); + self.si_code.hash(state); + // Ignore _pad + // Ignore _align + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for lastlog { fn eq(&self, other: &lastlog) -> bool { self.ll_time == other.ll_time @@ -349,6 +379,14 @@ impl std::fmt::Debug for lastlog { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { + self.ll_time.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for utmp { fn eq(&self, other: &utmp) -> bool { self.ut_type == other.ut_type @@ -396,6 +434,22 @@ impl std::fmt::Debug for utmp { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for utmp { + fn hash(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_user.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_addr_v6.hash(state); + self.unused.hash(state); + } +} pub const O_TRUNC: ::c_int = 512; pub const O_CLOEXEC: ::c_int = 0x80000; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index b0eac45b66781..31fc37922a890 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -687,6 +687,16 @@ impl std::fmt::Debug for dirent { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } +} #[cfg(feature = "extra_traits")] impl PartialEq for dirent64 { @@ -716,6 +726,16 @@ impl std::fmt::Debug for dirent64 { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } +} #[cfg(feature = "extra_traits")] impl PartialEq for pthread_cond_t { @@ -733,6 +753,12 @@ impl std::fmt::Debug for pthread_cond_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } +} #[cfg(feature = "extra_traits")] impl PartialEq for pthread_mutex_t { @@ -750,6 +776,12 @@ impl std::fmt::Debug for pthread_mutex_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } +} #[cfg(feature = "extra_traits")] impl PartialEq for pthread_rwlock_t { @@ -767,6 +799,12 @@ impl std::fmt::Debug for pthread_rwlock_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } +} pub const ABDAY_1: ::nl_item = 0x20000; pub const ABDAY_2: ::nl_item = 0x20001; diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 9b79356f5082f..42ff2a2847e27 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -207,6 +207,17 @@ impl std::fmt::Debug for ucontext_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + self.__private.hash(state); + } +} pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs index 1679a3ab0228f..8462a4f635876 100644 --- a/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -105,6 +105,17 @@ impl std::fmt::Debug for ucontext_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + self.__private.hash(state); + } +} // Syscall table diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 6d1a0a13d6685..b3ab650277187 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -141,6 +141,25 @@ impl std::fmt::Debug for sysinfo { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for sysinfo { + fn hash(&self, state: &mut H) { + self.uptime.hash(state); + self.loads.hash(state); + self.totalram.hash(state); + self.freeram.hash(state); + self.sharedram.hash(state); + self.bufferram.hash(state); + self.totalswap.hash(state); + self.freeswap.hash(state); + self.procs.hash(state); + self.pad.hash(state); + self.totalhigh.hash(state); + self.freehigh.hash(state); + self.mem_unit.hash(state); + self.__reserved.hash(state); + } +} pub const SFD_CLOEXEC: ::c_int = 0x080000; diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index d3186c0fb1191..fb48982162a34 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -256,6 +256,24 @@ impl std::fmt::Debug for user_fpxregs_struct { } } #[cfg(feature = "extra_traits")] +impl std::hash::Hash for user_fpxregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.swd.hash(state); + self.twd.hash(state); + self.fop.hash(state); + self.fip.hash(state); + self.fcs.hash(state); + self.foo.hash(state); + self.fos.hash(state); + self.mxcsr.hash(state); + // Ignore __reserved field + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } +} +#[cfg(feature = "extra_traits")] impl PartialEq for ucontext_t { fn eq(&self, other: &ucontext_t) -> bool { self.uc_flags == other.uc_flags @@ -281,6 +299,17 @@ impl std::fmt::Debug for ucontext_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + // Ignore __private field + } +} pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 02745b9056485..b2a67ee9aab79 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -273,6 +273,21 @@ impl std::fmt::Debug for user_fpregs_struct { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for user_fpregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.ftw.hash(state); + self.fop.hash(state); + self.rip.hash(state); + self.rdp.hash(state); + self.mxcsr.hash(state); + self.mxcr_mask.hash(state); + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } +} #[cfg(feature = "extra_traits")] impl PartialEq for ucontext_t { @@ -300,6 +315,17 @@ impl std::fmt::Debug for ucontext_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + // Ignore __private field + } +} pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index fa0e39ba447bf..4036ceab1d346 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -286,6 +286,22 @@ impl std::fmt::Debug for utmpx { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_user.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_addr_v6.hash(state); + self.__glibc_reserved.hash(state); + } +} pub const __UT_LINESIZE: usize = 32; pub const __UT_NAMESIZE: usize = 32; diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index 8a6b88a8180e9..f53e47e097cd0 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -352,6 +352,12 @@ impl std::fmt::Debug for fpreg_t { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { + self.d.to_bits().hash(state); + } +} pub const SFD_CLOEXEC: ::c_int = 0x080000; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index cd613d448ca81..4b06e6e6f6613 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -254,6 +254,13 @@ impl std::fmt::Debug for sockaddr_un { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_family.hash(state); + self.sun_path.hash(state); + } +} #[cfg(feature = "extra_traits")] impl PartialEq for sockaddr_storage { @@ -278,6 +285,13 @@ impl std::fmt::Debug for sockaddr_storage { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_family.hash(state); + self.__ss_pad2.hash(state); + } +} #[cfg(feature = "extra_traits")] impl PartialEq for utsname { @@ -328,6 +342,17 @@ impl std::fmt::Debug for utsname { .finish() } } +#[cfg(feature = "extra_traits")] +impl std::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + self.domainname.hash(state); + } +} // intentionally not public, only used for fd_set cfg_if! { From fa9cb78b4a04e6cbb12c3edc3efb9486d0f13b37 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Wed, 23 Jan 2019 07:18:32 -0800 Subject: [PATCH 5/7] Check for Debug impls for all types This was not compile-tested on all platforms, but instead all `pub enum` types had a `Debug` impl derived for them. --- src/cloudabi/mod.rs | 2 ++ src/fuchsia/mod.rs | 6 ++++++ src/lib.rs | 2 ++ src/redox/mod.rs | 2 ++ src/unix/bsd/apple/mod.rs | 1 + src/unix/bsd/freebsdlike/dragonfly/mod.rs | 1 + src/unix/bsd/freebsdlike/mod.rs | 1 + src/unix/bsd/netbsdlike/mod.rs | 2 ++ src/unix/haiku/mod.rs | 1 + src/unix/mod.rs | 4 ++++ src/unix/notbsd/android/mod.rs | 8 ++++---- src/unix/notbsd/emscripten.rs | 1 + src/unix/notbsd/linux/mod.rs | 1 + src/unix/notbsd/mod.rs | 1 + src/unix/solaris/mod.rs | 1 + src/unix/uclibc/mod.rs | 2 ++ src/windows/mod.rs | 5 ++++- 17 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/cloudabi/mod.rs b/src/cloudabi/mod.rs index df11de002ec62..520ed8deee437 100644 --- a/src/cloudabi/mod.rs +++ b/src/cloudabi/mod.rs @@ -122,7 +122,9 @@ pub const PTHREAD_STACK_MIN: ::size_t = 1024; pub const SOCK_DGRAM: ::c_int = 128; pub const SOCK_STREAM: ::c_int = 130; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct extern { diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index e785fabf8eae5..351ec7e37d801 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -100,9 +100,13 @@ pub type c_ulong = u64; // FIXME: why are these uninhabited types? that seems... wrong? // Presumably these should be `()` or an `extern type` (when that stabilizes). +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum DIR {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum locale_t {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct // PUB_STRUCT @@ -3042,7 +3046,9 @@ f! { #[link(name = "fdio")] extern {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct extern { diff --git a/src/lib.rs b/src/lib.rs index 03e78041ab617..86ab9b1368ace 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -156,6 +156,8 @@ #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr(feature = "rustc-dep-of-std", allow(warnings))] #![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)] +// Enable lints +#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] #[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; diff --git a/src/redox/mod.rs b/src/redox/mod.rs index 8dabd9063e169..cfe7fd613b027 100644 --- a/src/redox/mod.rs +++ b/src/redox/mod.rs @@ -219,7 +219,9 @@ pub const SIGIO: ::c_int = 29; pub const SIGPWR: ::c_int = 30; pub const SIGSYS: ::c_int = 31; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct // intentionally not public, only used for fd_set diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 08995917d4331..bb48d22709f91 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -34,6 +34,7 @@ pub type posix_spawn_file_actions_t = *mut ::c_void; pub type key_t = ::c_int; pub type shmatt_t = ::c_ushort; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} s! { diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 992d0082e4919..75afeb28fd57b 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -17,6 +17,7 @@ pub type fsfilcnt_t = u64; pub type sem_t = *mut sem; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum sem {} s! { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 22c11b3698a32..a402269a4785f 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -16,6 +16,7 @@ pub type speed_t = ::c_uint; pub type nl_item = ::c_int; pub type id_t = i64; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} s! { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 291c081b97bc7..dfe20518363ec 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -13,7 +13,9 @@ pub type clockid_t = ::c_int; pub type id_t = ::uint32_t; pub type sem_t = *mut sem; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum sem {} s! { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 2aa5d13a67381..a7fdffdc42daf 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -31,6 +31,7 @@ pub type nl_item = ::c_int; pub type id_t = i32; pub type idtype_t = ::c_uint; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} s! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 88e13c58c7706..bcd16f83ef608 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -41,7 +41,9 @@ pub type in_port_t = u16; pub type sighandler_t = ::size_t; pub type cc_t = ::c_uchar; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum DIR {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum locale_t {} s! { @@ -365,7 +367,9 @@ cfg_if! { } } +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct extern { diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index de4ff593a0ba7..0e2eebf056e39 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -264,7 +264,7 @@ impl std::fmt::Debug for dirent { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - .field("d_name", &self.d_name) + // FIXME: .field("d_name", &self.d_name) .finish() } } @@ -302,7 +302,7 @@ impl std::fmt::Debug for dirent64 { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - .field("d_name", &self.d_name) + // FIXME: .field("d_name", &self.d_name) .finish() } } @@ -374,7 +374,7 @@ impl std::fmt::Debug for lastlog { f.debug_struct("lastlog") .field("ll_time", &self.ll_time) .field("ll_line", &self.ll_line) - .field("ll_host", &self.ll_host) + // FIXME: .field("ll_host", &self.ll_host) .finish() } } @@ -425,7 +425,7 @@ impl std::fmt::Debug for utmp { .field("ut_line", &self.ut_line) .field("ut_id", &self.ut_id) .field("ut_user", &self.ut_user) - .field("ut_host", &self.ut_host) + // FIXME: .field("ut_host", &self.ut_host) .field("ut_exit", &self.ut_exit) .field("ut_session", &self.ut_session) .field("ut_tv", &self.ut_tv) diff --git a/src/unix/notbsd/emscripten.rs b/src/unix/notbsd/emscripten.rs index 28791d8fd5ac7..069631c1ff883 100644 --- a/src/unix/notbsd/emscripten.rs +++ b/src/unix/notbsd/emscripten.rs @@ -35,6 +35,7 @@ pub type c_long = i32; pub type c_ulong = u32; pub type nlink_t = u32; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct s! { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 31fc37922a890..3150887ab0dad 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -38,6 +38,7 @@ pub type Elf64_Sxword = i64; pub type Elf32_Section = u16; pub type Elf64_Section = u16; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct s! { diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 4b06e6e6f6613..7913508455523 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -8,6 +8,7 @@ pub type clockid_t = ::c_int; pub type key_t = ::c_int; pub type id_t = ::c_uint; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} s! { diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index c991e62045c31..c10f4c1844669 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -36,6 +36,7 @@ pub type nl_item = ::c_int; pub type id_t = ::c_int; pub type idtype_t = ::c_uint; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} s! { diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index c04c22aad9f41..e0620048dca63 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -24,8 +24,10 @@ pub type nfds_t = ::c_ulong; pub type nl_item = ::c_int; pub type idtype_t = ::c_uint; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} s! { diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 4bea45980b575..9deaf9b995293 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -47,6 +47,7 @@ cfg_if! { pub type off_t = i32; pub type dev_t = u32; pub type ino_t = u16; +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} pub type time64_t = i64; @@ -201,7 +202,9 @@ pub const SIG_ERR: ::c_int = -1; #[link(name = "libcmt", cfg(target_feature = "crt-static"))] extern {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct extern { @@ -446,4 +449,4 @@ cfg_if! { } else { // Unknown target_env } -} \ No newline at end of file +} From f3684584c99b8048cbfb056346dba34328e3a4f9 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Wed, 23 Jan 2019 07:23:09 -0800 Subject: [PATCH 6/7] Check for Copy impls for all types --- src/cloudabi/mod.rs | 9 ++++++++ src/fuchsia/mod.rs | 25 +++++++++++++++++++++++ src/lib.rs | 1 + src/redox/mod.rs | 9 ++++++++ src/sgx.rs | 1 + src/switch.rs | 1 + src/unix/bsd/apple/mod.rs | 4 ++++ src/unix/bsd/freebsdlike/dragonfly/mod.rs | 4 ++++ src/unix/bsd/freebsdlike/mod.rs | 4 ++++ src/unix/bsd/netbsdlike/mod.rs | 8 ++++++++ src/unix/haiku/mod.rs | 4 ++++ src/unix/mod.rs | 17 +++++++++++++++ src/unix/notbsd/emscripten.rs | 4 ++++ src/unix/notbsd/linux/mod.rs | 4 ++++ src/unix/notbsd/mod.rs | 4 ++++ src/unix/solaris/mod.rs | 4 ++++ src/unix/uclibc/mod.rs | 8 ++++++++ src/windows/mod.rs | 13 ++++++++++++ 18 files changed, 124 insertions(+) diff --git a/src/cloudabi/mod.rs b/src/cloudabi/mod.rs index 520ed8deee437..51859cb40b127 100644 --- a/src/cloudabi/mod.rs +++ b/src/cloudabi/mod.rs @@ -124,8 +124,16 @@ pub const SOCK_STREAM: ::c_int = 130; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +impl ::dox::Copy for FILE {} +impl ::dox::Clone for FILE { + fn clone(&self) -> FILE { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos_t {} +impl ::dox::Clone for fpos_t { + fn clone(&self) -> fpos_t { *self } +} extern { pub fn isalnum(c: c_int) -> c_int; @@ -315,6 +323,7 @@ cfg_if! { // enable more optimization opportunities around it recognizing things // like malloc/free. #[repr(u8)] + #[allow(missing_copy_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 351ec7e37d801..ba20979a748a3 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -102,12 +102,28 @@ pub type c_ulong = u64; // Presumably these should be `()` or an `extern type` (when that stabilizes). #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum DIR {} +impl ::dox::Copy for DIR {} +impl ::dox::Clone for DIR { + fn clone(&self) -> DIR { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum locale_t {} +impl ::dox::Copy for locale_t {} +impl ::dox::Clone for locale_t { + fn clone(&self) -> locale_t { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos64_t {} +impl ::dox::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { *self } +} // PUB_STRUCT @@ -3048,8 +3064,16 @@ extern {} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +impl ::dox::Copy for FILE {} +impl ::dox::Clone for FILE { + fn clone(&self) -> FILE { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos_t {} +impl ::dox::Clone for fpos_t { + fn clone(&self) -> fpos_t { *self } +} extern { pub fn isalnum(c: c_int) -> c_int; @@ -4103,6 +4127,7 @@ cfg_if! { // enable more optimization opportunities around it recognizing things // like malloc/free. #[repr(u8)] + #[allow(missing_copy_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/lib.rs b/src/lib.rs index 86ab9b1368ace..2300e823e9672 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,6 +158,7 @@ #![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)] // Enable lints #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] +#![deny(missing_copy_implementations)] #[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; diff --git a/src/redox/mod.rs b/src/redox/mod.rs index cfe7fd613b027..82782bc16404e 100644 --- a/src/redox/mod.rs +++ b/src/redox/mod.rs @@ -221,8 +221,16 @@ pub const SIGSYS: ::c_int = 31; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +impl ::dox::Copy for FILE {} +impl ::dox::Clone for FILE { + fn clone(&self) -> FILE { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos_t {} +impl ::dox::Clone for fpos_t { + fn clone(&self) -> fpos_t { *self } +} // intentionally not public, only used for fd_set cfg_if! { @@ -385,6 +393,7 @@ cfg_if! { // enable more optimization opportunities around it recognizing things // like malloc/free. #[repr(u8)] + #[allow(missing_copy_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/sgx.rs b/src/sgx.rs index 045133399b94e..1d5ca21292e9f 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -43,6 +43,7 @@ cfg_if! { // enable more optimization opportunities around it recognizing things // like malloc/free. #[repr(u8)] + #[allow(missing_copy_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/switch.rs b/src/switch.rs index e2d9b491cb762..89e259ea27ca2 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -45,6 +45,7 @@ cfg_if! { // enable more optimization opportunities around it recognizing things // like malloc/free. #[repr(u8)] + #[allow(missing_copy_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index bb48d22709f91..59394c6bcaf1b 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -36,6 +36,10 @@ pub type shmatt_t = ::c_ushort; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} s! { pub struct aiocb { diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 75afeb28fd57b..ebbebc457c779 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -19,6 +19,10 @@ pub type sem_t = *mut sem; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum sem {} +impl ::dox::Copy for sem {} +impl ::dox::Clone for sem { + fn clone(&self) -> sem { *self } +} s! { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index a402269a4785f..304bdeb5435ae 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -18,6 +18,10 @@ pub type id_t = i64; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} s! { pub struct glob_t { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index dfe20518363ec..764174d18ab7b 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -15,8 +15,16 @@ pub type sem_t = *mut sem; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum sem {} +impl ::dox::Copy for sem {} +impl ::dox::Clone for sem { + fn clone(&self) -> sem { *self } +} s! { pub struct sigaction { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index a7fdffdc42daf..94d8039006d2a 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -33,6 +33,10 @@ pub type idtype_t = ::c_uint; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} s! { pub struct sockaddr { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index bcd16f83ef608..409f2835fd04d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -43,8 +43,16 @@ pub type cc_t = ::c_uchar; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum DIR {} +impl ::dox::Copy for DIR {} +impl ::dox::Clone for DIR { + fn clone(&self) -> DIR { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum locale_t {} +impl ::dox::Copy for locale_t {} +impl ::dox::Clone for locale_t { + fn clone(&self) -> locale_t { *self } +} s! { pub struct group { @@ -369,8 +377,16 @@ cfg_if! { #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +impl ::dox::Copy for FILE {} +impl ::dox::Clone for FILE { + fn clone(&self) -> FILE { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos_t {} +impl ::dox::Clone for fpos_t { + fn clone(&self) -> fpos_t { *self } +} extern { pub fn isalnum(c: c_int) -> c_int; @@ -1160,6 +1176,7 @@ cfg_if! { // enable more optimization opportunities around it recognizing things // like malloc/free. #[repr(u8)] + #[allow(missing_copy_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/unix/notbsd/emscripten.rs b/src/unix/notbsd/emscripten.rs index 069631c1ff883..9bf2026b22e4d 100644 --- a/src/unix/notbsd/emscripten.rs +++ b/src/unix/notbsd/emscripten.rs @@ -37,6 +37,10 @@ pub type nlink_t = u32; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos64_t {} +impl ::dox::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { *self } +} s! { pub struct dirent { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 3150887ab0dad..443e7d5ccdddb 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -40,6 +40,10 @@ pub type Elf64_Section = u16; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos64_t {} +impl ::dox::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { *self } +} s! { pub struct rlimit64 { diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 7913508455523..51414e688d73d 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -10,6 +10,10 @@ pub type id_t = ::c_uint; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} s! { pub struct sockaddr { diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index c10f4c1844669..c9a53e1f57737 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -38,6 +38,10 @@ pub type idtype_t = ::c_uint; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} s! { pub struct sockaddr { diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index e0620048dca63..bb314196af608 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -26,9 +26,17 @@ pub type idtype_t = ::c_uint; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos64_t {} +impl ::dox::Clone for fpos64_t { + fn clone(&self) -> fpos64_t { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} s! { pub struct sockaddr { diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 9deaf9b995293..25a381ae72d27 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -49,6 +49,10 @@ pub type dev_t = u32; pub type ino_t = u16; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} +impl ::dox::Copy for timezone {} +impl ::dox::Clone for timezone { + fn clone(&self) -> timezone { *self } +} pub type time64_t = i64; pub type SOCKET = ::uintptr_t; @@ -204,8 +208,16 @@ extern {} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} +impl ::dox::Copy for FILE {} +impl ::dox::Clone for FILE { + fn clone(&self) -> FILE { *self } +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos_t {} // TODO: fill this out with a struct +impl ::dox::Copy for fpos_t {} +impl ::dox::Clone for fpos_t { + fn clone(&self) -> fpos_t { *self } +} extern { pub fn isalnum(c: c_int) -> c_int; @@ -429,6 +441,7 @@ cfg_if! { // enable more optimization opportunities around it recognizing things // like malloc/free. #[repr(u8)] + #[allow(missing_copy_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] From e33f7609bdd8cfbeef5da81dfb0a3f96f6151169 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Wed, 23 Jan 2019 08:42:03 -0800 Subject: [PATCH 7/7] Ignore the style executable used for testing This is used for running style checks on the libc codebase but shouldn't be committed, so adding it to the .gitignore file. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f0ff2599d09b5..bbbad4bc51532 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target Cargo.lock *~ +style