commit 1124e606bed0de9431e09039e0da533fb1191ac2 parent a0a2f954aae3f7a7c95a7978c8fef491bf0c3d5a Author: Erich Gubler <erichdongubler@gmail.com> Date: Thu, 2 Oct 2025 18:09:19 +0000 Bug 1991226 - chore(rust): upgrade `libc` 0.2.171 → 0.2.176 r=supply-chain-reviewers Differential Revision: https://phabricator.services.mozilla.com/D266860 Diffstat:
147 files changed, 5436 insertions(+), 6353 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock @@ -3706,9 +3706,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.176" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" [[package]] name = "libcrux-hacl-rs" diff --git a/third_party/rust/libc/.cargo-checksum.json b/third_party/rust/libc/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"747b437db48b8ded620a8738f9c1dbc2fde3d26db03d0782796537a9e505a263","CONTRIBUTING.md":"155e7f4e96fafe9ee5c8adb5068be27a22de89a95ca9bfc7baf517b9850d20d6","Cargo.lock":"8f6d0b13c977c8016b568c0a35b5ae709318e0766af3cff4a84d351219013841","Cargo.toml":"7f31f2e612b4c14b57ecdcec4912ac1514e26e3c061d5b06b54e1e34e83191b1","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"a8d47ff51ca256f56a8932dba07660672dbfe3004257ca8de708aac1415937a1","README.md":"a198be444453fe0b24d4fb6a8b732eb9e6dc77ebcfd119fca95b97b45c77c77a","build.rs":"199eb63f03c4e90cad31c1f03a15bac3d81ca97f31bcb81c45bbd0d909e57d61","rustfmt.toml":"e9321ff995242e8cb0a4984254f0748ef11a89ca4618cab8f047ee59a88768e7","src/fuchsia/aarch64.rs":"9cd032304a54321a8926cf3157194c5d79a2491b1b974a05fe71729fa43b5738","src/fuchsia/mod.rs":"e27680db23fa506e379a86033b42813ea1f6c8f6b01d97a9a880d9d7be6d9f7f","src/fuchsia/riscv64.rs":"f2aba92cb88480bd72a9eb7a41aafc63c5db293b93113fa973fe5ab1fd819e29","src/fuchsia/x86_64.rs":"66c6ae7d3f81b1d7c962671aa074d709c39069e3b5830621a26d94c15caf588f","src/hermit.rs":"e414a3ecd5b5bc6c0bf7ce7c31639805943b789fbbf6006ceeb85ab44f3e4564","src/lib.rs":"d65975abfeac27f8dbef348fa7afa0b2b761a0a7073f4621c1bbff41334983cd","src/macros.rs":"076f328df1d51017bac70456e7b8290bee1b07390328fff48102e05048ada56a","src/primitives.rs":"0096ec3f32454a630fd1e78fa5aaaa033f107c1394a0d7b8dfe92594339a547b","src/psp.rs":"b88f5659011db6a189bd06de3a365c35a34cec6b7ab547719b8ae2b371f9cb21","src/sgx.rs":"964d6af358f5c85f948275090e5a7854e0169c43b5c338070b6a4cd156ebc9e6","src/solid/aarch64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/solid/arm.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/solid/mod.rs":"a2045b6089af91bd533a666773d3b99fcfaf03da7a06869382969eed059b0e4c","src/switch.rs":"bfdcaf0268d79652ee52c1a2837959b8253e6a4124fd94dda82727ecc442a758","src/teeos/mod.rs":"2cca695904dacb13c063fb6463a6e0b2bb47ed86be0fdc9476938297441d7795","src/trusty.rs":"c5012aeefc4307c11374f062ad1d530e2ec556e7069e375de326a49c77f65e22","src/unix/aix/mod.rs":"fa3fa1f33e381f9492321e47f683300460d02fa230f14965ee808eeab2884408","src/unix/aix/powerpc64.rs":"c2315d638bad020e75ef15f85989f8feffb4f38bac4b7e70642031c6ae1fb65d","src/unix/bsd/apple/b32/mod.rs":"39a7f5cf92cf2d26ca50f54182fe57028cf24147ec12cb89d251301d65862138","src/unix/bsd/apple/b64/aarch64/mod.rs":"3ce904e72d78e6465ca52fd3905208fbb8cbc49a1695a708b12dff2ee01f4d36","src/unix/bsd/apple/b64/mod.rs":"a77ef659cd2edadb39db562e655ea5efdb102ed0dfb872d8d004b38d1a0e9e49","src/unix/bsd/apple/b64/x86_64/mod.rs":"71bad5c051368805146168c4063534b010afcb358477c1f164712bb015bf3fb6","src/unix/bsd/apple/mod.rs":"39216bfe363384709f0b38df6b333206ad85361e6b1389f699b2b88d46aa3e1f","src/unix/bsd/freebsdlike/dragonfly/errno.rs":"07b19390b9ae8f541ac35fd4e14685d639b95152d6d7a33814bb749b8b927298","src/unix/bsd/freebsdlike/dragonfly/mod.rs":"9681882d03a9cc7e00db0d9f0be797426ce4e9f7584d3fe4ab43bc7967dd0e4e","src/unix/bsd/freebsdlike/freebsd/aarch64.rs":"9e8e5a9f1de648b248f257aab6e1bc8ccfe9e481554a52bdef06aefd262a15a2","src/unix/bsd/freebsdlike/freebsd/arm.rs":"36158ac5a31d86a919d8e477a9ba64467d38b57bc3910e19b082130811c2f289","src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs":"8d9bef35f3e490d04755a59a99ad054ef20498beff979ae8b14acbec1097318a","src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs":"45f718f556a8368f282944d9a14afae7261827ec4838d26719290466efc4f023","src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs":"77bef57a5697d837331cff8947c50d070b28bb7aaa51b23f4d604cedaba76806","src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs":"2dfe0dd90c956e3bcc8bbbd6926c5b370829f411f22b80fa749fe87ebf0ea47b","src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs":"64c4bd82eaf30a2681417f982fce28de7d1b0743bfaa14004692a56cee44be21","src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs":"f0d4d0fcd6c4e3bd77f84474a404be8a3a326731e9fe52008a09bcfb123a98a0","src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs":"64c4bd82eaf30a2681417f982fce28de7d1b0743bfaa14004692a56cee44be21","src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs":"c6efc4de30803d89d7c73ef59e5e18dfb3c4a0c0688855b9193b228573651106","src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs":"d6e66809e109dc779efe5584b79d34fcd6fdba91973a415d64ae66f481f45940","src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs":"48730e73367432bce709d5bcf316197c48f7501833a4798df5fc5f7043f04030","src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs":"d6e66809e109dc779efe5584b79d34fcd6fdba91973a415d64ae66f481f45940","src/unix/bsd/freebsdlike/freebsd/mod.rs":"59ba589299a415936aad6f99f253a5b31e9b1e83ab6f0db3ceba077b7ba198b7","src/unix/bsd/freebsdlike/freebsd/powerpc.rs":"36a03b20551864c92852e967ebf91c6a8105fd520e41a35273e2dc6487590267","src/unix/bsd/freebsdlike/freebsd/powerpc64.rs":"3de9344db84572975b5965ac4292cf475e3c96854c58b7a478b9972407ffd1fd","src/unix/bsd/freebsdlike/freebsd/riscv64.rs":"3dfdc394922c2cb66790309c76913576a7235513ad3bf9d8bd86b8671e284ff0","src/unix/bsd/freebsdlike/freebsd/x86.rs":"2521db73acc14867b2e16aa05dd55cc48a7650d2773a009b269bbceafd819fac","src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs":"85b4b6118ef4e08a74b8cc17d364b22949b2e05e642e3240e14f2651a2126d18","src/unix/bsd/freebsdlike/mod.rs":"eda51316ba108b78c3f6c383cb047855dbd04f5b4bb59d04e0f2978722c68101","src/unix/bsd/mod.rs":"c69855551561c4beeaed5ada823404c9b9d27e9e21c0e4bafb6f1b52ad09ad2b","src/unix/bsd/netbsdlike/mod.rs":"ef9b617c42084db1bd3aa4f5d5d1a75ce1963b23945c117b6076400905ff75ec","src/unix/bsd/netbsdlike/netbsd/aarch64.rs":"bd36c92099db501350fb8617414d1fea89a6bb12867498e1821167813ab70a02","src/unix/bsd/netbsdlike/netbsd/arm.rs":"237beaefcb12e7be9ccd4fef6e3be7db79ee63d4fc714e5eaf6084d4826d6fa2","src/unix/bsd/netbsdlike/netbsd/mips.rs":"d1ff114b268358e5d35e7b83d85f414d16b81ef39eeb1802682ff4424b102bc7","src/unix/bsd/netbsdlike/netbsd/mod.rs":"df73622ea883b9e44980e14eb7cee3b53bcdddd62190fe3d672ac5843b2e2e95","src/unix/bsd/netbsdlike/netbsd/powerpc.rs":"94494f348f011c6135d301944696c5b5a09979f5892abee4c8fdee1056388b94","src/unix/bsd/netbsdlike/netbsd/riscv64.rs":"f3778a9bd2ba923220537d167cfb10b91580ffbf583100789a46d2807f7a1e3e","src/unix/bsd/netbsdlike/netbsd/sparc64.rs":"d50816e830225779ac9e9a55a7e3e097882153d72987061d76a96ee736c8af9c","src/unix/bsd/netbsdlike/netbsd/x86.rs":"307a9aba68071b0589e459269ef10845c302599b0fd2b0ee7b5c480177904e89","src/unix/bsd/netbsdlike/netbsd/x86_64.rs":"4ced76b3640d465f6dead8beb5e947b3ce8297884260fb943d5f417d985dbafc","src/unix/bsd/netbsdlike/openbsd/aarch64.rs":"8be46bc5151ec1081feaf7685c18507f766f2501a2b5d35107db3babb896395a","src/unix/bsd/netbsdlike/openbsd/arm.rs":"f81c71e1cfe436b8f32cfe064991019cce0c83627f0d9c3a30d68691d71c7449","src/unix/bsd/netbsdlike/openbsd/mips64.rs":"bee7664d88f8451ae22552fc0721b6b6a6dee2493cc42bcb9829c1e47e4b05f5","src/unix/bsd/netbsdlike/openbsd/mod.rs":"dd9e56c95e324e90e3a7c8905c593025f65c36e98c9f95eb0e033ea04e6d949f","src/unix/bsd/netbsdlike/openbsd/powerpc.rs":"f81c71e1cfe436b8f32cfe064991019cce0c83627f0d9c3a30d68691d71c7449","src/unix/bsd/netbsdlike/openbsd/powerpc64.rs":"9bd3813fe2fd7ca66ee8d70d13887b4595fb8c9e819691a657ddf108ed9cafbf","src/unix/bsd/netbsdlike/openbsd/riscv64.rs":"7fb322e9f5425456dd53eb07de9fc84097ef35295802e8f50a7fb3c7e1f89ac6","src/unix/bsd/netbsdlike/openbsd/sparc64.rs":"8d4c5a4cae63e09e1c156164ddc82e0fc77926841d4d4e419dd2e7a7b7145f58","src/unix/bsd/netbsdlike/openbsd/x86.rs":"26c1b7e7f7799c5e434126c6c0ddd45f40939cae4151f8ce0a7a1836f83ac56a","src/unix/bsd/netbsdlike/openbsd/x86_64.rs":"312b77a50ee47f107e9cfd8e7e7e0d4945675a859d7286fedbf192840f8a4c34","src/unix/cygwin/mod.rs":"13c9af853fa35f3318f629b336fd8727e62ab106ac3a2cfa0a2ac13e77536900","src/unix/haiku/b32.rs":"c3f8678ceee65a3094d8133b0d1a94470860e0b1867977f0569c52c5a20e039f","src/unix/haiku/b64.rs":"f97ce9225f4710893dab03ab3e13bc62152cc84f90c597ec88f6dc1f4c27d242","src/unix/haiku/mod.rs":"991e5ab02e8607ece273e66ab8303dc7604488bf7e0b7533fdb69ea9adef83df","src/unix/haiku/native.rs":"fafc7daab134d37ed260373f9c3a8177cc0fd88ba147c1001b9867eb9bd0799b","src/unix/haiku/x86_64.rs":"4480c0423eac3f288202df587b54025292633869a868bd0ac2767cd40afb5173","src/unix/hurd/b32.rs":"501f426f7aeb60acf4119064100dd94bbdfebff2cec785428708059d853dc123","src/unix/hurd/b64.rs":"b9b2082e721a5ec89ba55fd5a16bbffcc8a05ca7cef6dbfbd78aff0806cb931f","src/unix/hurd/mod.rs":"4bc76f612d215300d01bd36bb5e6541cddbe62858571328a03c6b7bb8a208262","src/unix/linux_like/android/b32/arm.rs":"06dfde862400151e3a667650d73c8ac8ea9c3c44c5401ef2b2406b2cca4a8672","src/unix/linux_like/android/b32/mod.rs":"2df9e7337f299a12890bccca59d65619aa5a53991aa2c0c33b4fc49b64c3c93d","src/unix/linux_like/android/b32/x86/mod.rs":"ad5942e15c6603469e82144076c4837e9daebb40d0195865e7d574e6433136d0","src/unix/linux_like/android/b64/aarch64/mod.rs":"5ae558c8af8187155fa0ae8b8776459a60c08ce152f25d137f845d8371673b7e","src/unix/linux_like/android/b64/mod.rs":"6a87e7e673677882c31eb4b69375427b71f7f9f61f883322bb1fba8ecb9ff39c","src/unix/linux_like/android/b64/riscv64/mod.rs":"d826b0e4f078b8ea228f2244659fc700b95aa8a7ba87caef0bc34f54c9defd2c","src/unix/linux_like/android/b64/x86_64/mod.rs":"cab0e8cc6895e7af9e631196b2484e7ccb3bdf5b0a134ab14abb626eef8b2a3e","src/unix/linux_like/android/mod.rs":"980694e20136b3f83176af5b6a2fcc7c70aa8e7a76baef324cefb7c9ac3b1af8","src/unix/linux_like/emscripten/lfs64.rs":"3a1d1779bcf16525a578a68237f9854090eae4c9819e18ffb5a288f39be4afbe","src/unix/linux_like/emscripten/mod.rs":"356db0bbc7ee5c23cc79fc15add48febaf2976b0780a3c430b2f098715e4153a","src/unix/linux_like/linux/arch/generic/mod.rs":"affb1e1abc4d58d8f37ba834981cf86858242c2a01c1c4bfd905c9e3bbbeacab","src/unix/linux_like/linux/arch/mips/mod.rs":"abda6685083597ed88c1f5d4121b387288d29a7bfb5f9b47a1580a45d3f523d8","src/unix/linux_like/linux/arch/mod.rs":"8bc5898b03760a95dd4f124ac76ad92e5ae36b2d0644203d752ef2b37e487c3a","src/unix/linux_like/linux/arch/powerpc/mod.rs":"ca5e83ce5f0e6c7ef7f575dcc27a5669b64b759ae0871c13b91fce43ad152351","src/unix/linux_like/linux/arch/sparc/mod.rs":"9735216185ae78271e8333f8e8199480244d1a269b27b430f480a7b75c219c50","src/unix/linux_like/linux/gnu/b32/arm/mod.rs":"aa5958011a063d025f11cf0cfc999dbc987ca5cbe0aad5385ab5e7ff7fc55abe","src/unix/linux_like/linux/gnu/b32/csky/mod.rs":"e1c53b84e1c13d91d94a44da0c3f120788c135d4253834782db57cccf0a39db4","src/unix/linux_like/linux/gnu/b32/m68k/mod.rs":"4e8eaf62fefaaa57842259b47b21f02e21f299975a6d82a64729506781259e43","src/unix/linux_like/linux/gnu/b32/mips/mod.rs":"333c338367275ec420fc4c83779e3f0e52f86cace91d7940718a5b02c2e60297","src/unix/linux_like/linux/gnu/b32/mod.rs":"7a4767d2409a4764ec0735f7f47d7d082247b324d28bdd2baee03802f95fa3e3","src/unix/linux_like/linux/gnu/b32/powerpc.rs":"336f24e10b2dbd2faf0fb003cf43220c08f325695a02f4f7fd63fa06c23ce381","src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs":"e5882e019997612fac4fe839915dbef9b2bcc1bea5484efa4a2664a339fa5e14","src/unix/linux_like/linux/gnu/b32/sparc/mod.rs":"756ea27c90bee66496aac32fba1a2e38b4ecb1e9c104a3160010eaa505807efb","src/unix/linux_like/linux/gnu/b32/x86/mod.rs":"9d28eac7d1bf98aa38832b8e55757ddef3ee8bde4cb00ba5e4145d07038bf827","src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs":"638b2d717dcf5b59a0058c3dabab43edd84de9d1d7da6e16ad0c58e863000417","src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs":"28c11e70467b2f00735d3a04c369e96e04fd44d0587ee33359f38328b0677ee6","src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs":"335b220e43cd07c3f6a262fe161fb057dea6324ab8ad41cd419bc596e16cd640","src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs":"425047046086c6be01d35b6c630f70c560a58be772704329e0aae23102f7db51","src/unix/linux_like/linux/gnu/b64/mips64/mod.rs":"05c9fa18fb781f775d7fba8916b756752612590168ddc127315a0fcbbd5d8ad3","src/unix/linux_like/linux/gnu/b64/mod.rs":"d1d38f4a25d885be350bc6fdfa4a633a180717d60392010c40ec2c3899fc4d42","src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs":"8ea4a284cfb48c23ffa1a5dba69ac2e6433109ec00260dc3ffb241aec5219473","src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs":"c20634c01c22d0d618d0f6d555f35eb339f4e75fd6491cb4a77392b48e1b2265","src/unix/linux_like/linux/gnu/b64/s390x.rs":"67cad067e292b4d8cc0743adb4506f02c53bdf3c2e935fbfc1467a88451c645b","src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs":"8cbfa0d9c67893b18e836a7e9b70076dcbcb06386575fc261f2b8a9fefd2caa7","src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs":"10fcc444c2550be09ccf7a4231024b8af4acd6024de81da110ad932b62707698","src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs":"07240332eaf44996d86e37b12d71b519b499c9c9b57898441c58ac2e8c0cb6f7","src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs":"914898b781dfe6b2f755730d6000223d1beea177731e180ccbfdd84a0b8b3bd9","src/unix/linux_like/linux/gnu/mod.rs":"52e1300f6c25cefd4c3d491ec7e1385f423a1fbbeb97b774c9a400b1c1b2b822","src/unix/linux_like/linux/mod.rs":"07f336f3e08712d51a96380250784c5a3364361d6c75f1e135931779b8d752af","src/unix/linux_like/linux/musl/b32/arm/mod.rs":"8aefb482620db0e6853abc2313877f6bf87b3b4d63c0891d99189cdb12ce7733","src/unix/linux_like/linux/musl/b32/hexagon.rs":"400457049bad619da3accbca2c841206d1cd2673d670baf7210bf17427510271","src/unix/linux_like/linux/musl/b32/mips/mod.rs":"fa47a3a9614ec2a964e99d30cde2d2dd4f04015e6c4dcf3b3e3061a7538bd7c7","src/unix/linux_like/linux/musl/b32/mod.rs":"e0f53df7ca1dbe9b0b25ccecf1adf664227995e58d67a222a8d046d2a879dfc8","src/unix/linux_like/linux/musl/b32/powerpc.rs":"e97baedfe7f1a0cb48f0ba9e5389f86c19c4a08e22de1d82f18f411dba4c95e2","src/unix/linux_like/linux/musl/b32/riscv32/mod.rs":"435ba055ec51d48bea1f835aeea91d01a24a12db9363aa34d1587dc7f0ac99e4","src/unix/linux_like/linux/musl/b32/x86/mod.rs":"b27cf5ff9f1f734957af06f50881360dffb20538f7703daea01bbebf0e232bf0","src/unix/linux_like/linux/musl/b64/aarch64/mod.rs":"ef117d729a168607bc7ddbf6fa1289e62233b50cf154237151ba1ee842208178","src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs":"3075639f37378774f3991f05971a9b725766105e5884b1e97b3889b079f95514","src/unix/linux_like/linux/musl/b64/mips64.rs":"abf1eb14fff4dd1bdf081672ab92858e99c09666583d8f9952112da13036e50e","src/unix/linux_like/linux/musl/b64/mod.rs":"07081d3471292a46d5ed69a5a376fceac9c6a01533c76db277eb6f9923092d5f","src/unix/linux_like/linux/musl/b64/powerpc64.rs":"606be7895a1578916b2b1f1d01518307d46b79a9c64d239a37dc8693af697466","src/unix/linux_like/linux/musl/b64/riscv64/mod.rs":"a76a7a24d52f2fc3811d72f69e9a369d0547bdee166a5a943b94396e320b077c","src/unix/linux_like/linux/musl/b64/s390x.rs":"ffbfdefb58d27d6463757a256b1480b83e53b19fc0f9c7fc1af461be33fae359","src/unix/linux_like/linux/musl/b64/wasm32/mod.rs":"f44f7b2ade822aa468f4abd6ba3f1ce86d6ffd307c4b4eb50684156458abd137","src/unix/linux_like/linux/musl/b64/wasm32/wali.rs":"69e0d06289f1c86898ef3ab505e397af2acce146accb62efff654fe458b6af02","src/unix/linux_like/linux/musl/b64/x86_64/mod.rs":"a317282fb504c35a83e0de335caa01c09f8f9b2649d1250dbcedb1ebf0f75e7f","src/unix/linux_like/linux/musl/lfs64.rs":"308c5b5c9b2f4b1ad17e5c2d02946f84ae83e8f5cb0e789d8d3e76c1923a5d31","src/unix/linux_like/linux/musl/mod.rs":"7fc0d475f397b64eb40c57bf5835a4612267d2a42c955e12f486032a8b54b8d9","src/unix/linux_like/linux/uclibc/arm/mod.rs":"32d3701fa086b2a98589b4ae4842ce62b295bc0bd9eaf1b5f9792e442b681090","src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs":"59493f1ab84ddbcf9dc5881c9cfc26e28d4fb5322d63f60eb7de5f9e8e329580","src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs":"a35532d5ae376f403873aa566f37bff99c6c323d334f3201667e5f7200b04643","src/unix/linux_like/linux/uclibc/mips/mod.rs":"ead3f9c05e3bdd5d5b52f25dd4a2d154471555a6bae2d4cbd5c07e976513dcea","src/unix/linux_like/linux/uclibc/mod.rs":"ed8bd29fc30319dfc149ccc5d150ca41e2d28ea5210fc26d9af91ad5903d0093","src/unix/linux_like/linux/uclibc/x86_64/l4re.rs":"059d1f15bf84e2226be6b842dc9466fc5f5bf55cdeed7a8742658ff25f05361c","src/unix/linux_like/linux/uclibc/x86_64/mod.rs":"c37752975c173aeb1641bae0e743ff2e7600976620bcb6e9ee8e74a40355d186","src/unix/linux_like/linux/uclibc/x86_64/other.rs":"12f8d4049862fc0c4d94b770f2d0341c1c7bf3da0619436169c12cadc4093def","src/unix/linux_like/mod.rs":"e04413e0d1c5207b58ab6c49f7995b9000be1f2fb1d4595c357a32df38951410","src/unix/mod.rs":"72b609e49e61591b3082cf674bb8df806f2ca5b755b9a052d94c6c8cb0f5e597","src/unix/newlib/aarch64/mod.rs":"ec594c54dc0e7784668d02ef737fd194dcc3f1e6ee23328d810fd2453bcb6f20","src/unix/newlib/arm/mod.rs":"a1fb6caa077c2ed69adf12da07c814ffab4c1311579f23bae2b26a40cf180665","src/unix/newlib/espidf/mod.rs":"77e8ad5b7db027b8b0b5aa5126f15bc0e35b6f3deb2339acf403c961f13df26f","src/unix/newlib/generic.rs":"182e584f14e0984934130425dd2be0781ca2c131449b3ae1734a07c72c3d43cd","src/unix/newlib/horizon/mod.rs":"ae4e76ef8c04fa8580578e33037bcf1888a8e4d688aa6f115713f644b8a11313","src/unix/newlib/mod.rs":"2f3e9c6217994ec34b0e3b49bf5ebe1335f3b12146f7f55a797ea7041cb1f44c","src/unix/newlib/powerpc/mod.rs":"4e5f804a13e907e17ebb66dcbf3b0fe6e1a611f91876aad8d8a0a69c7df0a7e8","src/unix/newlib/rtems/mod.rs":"239c90d1daf783ff95168a3fcbc5a0c3d1f9c4b5a0ef32a0e4a22b861f82713a","src/unix/newlib/vita/mod.rs":"66765c20482f03c3fcb57d57dd3f31eeeab9729e1bb188191ad53a8fc124fc5f","src/unix/nto/aarch64.rs":"73ad54ebca13454a75c7b0815e853175070a8ac2eefa338012a03e8b59f01e0c","src/unix/nto/mod.rs":"ded4a28f5b322446b0885290b917171d771b7897f39bf5616122283318b7a8e2","src/unix/nto/neutrino.rs":"039ab7b1ed702d515f3e06d7f3536709704715a49905024b6c520696a65086f9","src/unix/nto/x86_64.rs":"8da99138e210516a95d49c8c0265eada4c5f7b93d59be86224844410f5e7929b","src/unix/nuttx/mod.rs":"69beba3516f66d36c5b5e38130ff1fde8a8403d6d8ec79bebe437ac5d385176f","src/unix/redox/mod.rs":"a9a0005c8572ad5404cc9680a83a610d8aa82278fcb5d24a4b99ab32fcc6eb60","src/unix/solarish/compat.rs":"c02a88918852b7a9c60e45a34f7b003901000380f5c1b2832b8bd79f84936c8b","src/unix/solarish/illumos.rs":"7c5da4d4ea69ebfb83a59764eeafc74e234b2b9b021eed32572b8a28d991a398","src/unix/solarish/mod.rs":"ae04bf0fd7a30c0d0e22df180617c545428874c50a6ff815048a82124c2c6d75","src/unix/solarish/solaris.rs":"54bae4c960b65d849beea8f0beb79dc37afebc1e9d7664424df13e6082ccc2e8","src/unix/solarish/x86.rs":"44261c1f1b300dac9fa0dab93ec85d0c3b3c48b15bc4515b9820c9421cff7427","src/unix/solarish/x86_64.rs":"1601309baae50ccfd51b5d188668e6ac5dabc4e8d2ffde103592922ec15295ef","src/unix/solarish/x86_common.rs":"4ae02d88622f7f080f5e8cd328f13187edbc5e124fb3e05e4cf212597f6cce48","src/vxworks/aarch64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/arm.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/mod.rs":"b2857bf7695b4571ad7fba8f44ebcbdecbdd9ac26b38430b33b04f0c50addcc7","src/vxworks/powerpc.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/powerpc64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/riscv32.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/riscv64.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/x86.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/x86_64.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/wasi/mod.rs":"cac5127894b50bd1880e87b54ae0cbc9afe98f99ee739f74aec04172c14bcc1a","src/wasi/p2.rs":"feecc0485eabd2c32bc5d800df6ad1b9b4d282741342fb08792f2635204e1e08","src/windows/gnu/mod.rs":"320ddf761f731c24a27e061438ddbacb0630e3ad6f3bb39f6514c28dffd8ac9f","src/windows/mod.rs":"6be16eea8c7319c35e7efc6a70da8a04f9ab25d68173c51d561f37a0935de47c","src/windows/msvc/mod.rs":"7bc0f1e7e73815296cd6b63b2700e12624e9f47b5c4113a1a87fae8e64549c00","src/xous.rs":"1a83621c40248ad4d0c08e1fd4c1107d5efcbc2f4f0169538b7b4a885abedbfa","tests/const_fn.rs":"8ac3171d7bced3576a4e93f48570b3e00c553d7510ab85a7473ae3b716a812dc"},"package":"c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"} -\ No newline at end of file +{"files":{"CHANGELOG.md":"3da97ff39eff20f10d6780da7a8098c3cfb9eec2e3ac57196b773c7acbb6c3bd","CONTRIBUTING.md":"1cac4c47d46f83d06eeabfb7bf3a70b1a5405a913db1afa31c0e6387eb5bc189","Cargo.lock":"813b6f0cfc9e4e517d4ff41c8d7c75a683092460fab63d99b70b413d621dc6b1","Cargo.toml":"d2e93c20839094d50a36f1d283a037063415b3ae00fd45fc16b0872476f4fe2f","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"a8d47ff51ca256f56a8932dba07660672dbfe3004257ca8de708aac1415937a1","README.md":"a198be444453fe0b24d4fb6a8b732eb9e6dc77ebcfd119fca95b97b45c77c77a","build.rs":"f01c77e53ffb343d5c8885e097183589bb91d1fbab78b14bc0a658694616f95c","rustfmt.toml":"e9321ff995242e8cb0a4984254f0748ef11a89ca4618cab8f047ee59a88768e7","src/fuchsia/aarch64.rs":"9cd032304a54321a8926cf3157194c5d79a2491b1b974a05fe71729fa43b5738","src/fuchsia/mod.rs":"e0ed316a30662f2bd1cdf1c8013440c6f2688c48083326f58533565a588e00dd","src/fuchsia/riscv64.rs":"f2aba92cb88480bd72a9eb7a41aafc63c5db293b93113fa973fe5ab1fd819e29","src/fuchsia/x86_64.rs":"a6de0a3c9a45e7af2f0bac96d73da6a7cfb8c003335183016b08a25e2acab65b","src/hermit.rs":"f150c2882a4d8e510259697ff7685899e74bfabf84e5d37103c54b4387093775","src/lib.rs":"86c46729a494060c40a63f3732c5a4c1f3d757ba08d398c1ec3de2030c91a27b","src/macros.rs":"ba63c9018fe21b20dba1ceea97fb293860148d8bd8fbc7c0ab038ce2afcff1b2","src/new/bionic/mod.rs":"752e47b8a3c8cd3090e1af970f4c3e33e5fe5bb3f388bab8cfa66d99562dbfab","src/new/bionic/sys/mod.rs":"0fc3d4ff1c37a21f47c127e5b3818d6c115690e39082be9c3796b8ac2cc99478","src/new/bionic/sys/socket.rs":"c11b51f13897a7fff420f28e93bef74ee084fc08cc0a3ab15d5b286656a0043c","src/new/linux_uapi/linux/can.rs":"5684eccda3fe635c94927bfcc3cc33e357b18a16b19b72ee6b27e0f6df72079f","src/new/linux_uapi/linux/can/j1939.rs":"ab2a330c3d3cca3ac6a693b381661772036e10a6dc0004db3809a4f42cf724ba","src/new/linux_uapi/linux/can/raw.rs":"cc39efa823b9f4d13bc0978ce51186e91d484c2bcfce4c6b0cbfa28a3a256488","src/new/linux_uapi/linux/mod.rs":"e9135b549d9427b99f5978ee4096e5b7d613104cf1a91433488536ce0af3f74f","src/new/linux_uapi/mod.rs":"7497197e880a36e9276110947611d1911bc2375316cd5969a18c83ac6f9be78d","src/new/mod.rs":"143ce9cb8b1f50d08594ec8d305ad1a9d663b3dac139a1a4b758ac5c25e8a14c","src/primitives.rs":"ea7e28520f5f3991ab444f9262cb8497a8794ced2cf5e1754795fe82ebed5fb7","src/psp.rs":"081cf4e5127ba10ebb62a9a5f8f849dd92742693db443db429d446ee472b5d41","src/sgx.rs":"964d6af358f5c85f948275090e5a7854e0169c43b5c338070b6a4cd156ebc9e6","src/solid/aarch64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/solid/arm.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/solid/mod.rs":"0a89235e63d28a0e1a938243de862fe60bd3a3e9373c09c8c5cd42399b1c712e","src/switch.rs":"bfdcaf0268d79652ee52c1a2837959b8253e6a4124fd94dda82727ecc442a758","src/teeos/mod.rs":"d03cf399183ac40c6f74ce09787089007648d00b112c9fa8254723f0c2135c94","src/trusty.rs":"c5012aeefc4307c11374f062ad1d530e2ec556e7069e375de326a49c77f65e22","src/types.rs":"0d11841d8045deabf7bcded237a347978bd41e8e2fd227acc98400c383e221c6","src/unix/aix/mod.rs":"fec4d43917078c55debffe104e42d14dc66e039c7685566043a13ca42ebee072","src/unix/aix/powerpc64.rs":"45614bea9cf2732fca2a6d7f1bdc7d62eb2dcf2146993e1d726f677f6f4d3a47","src/unix/bsd/apple/b32/mod.rs":"56e90d43e36bcf0a4012072f92dc905dd40af386014b94c978f30b3bcbed8abf","src/unix/bsd/apple/b64/aarch64/mod.rs":"897be1845603876b2849a1fddf53ccd8a97b1156907f4833f7dfb0778e840d0f","src/unix/bsd/apple/b64/mod.rs":"75a313514fd3b9f21391ddb77f965386c36e99bbf4a4c952445e4e8d50bb16b5","src/unix/bsd/apple/b64/x86_64/mod.rs":"889efaf7baeca8ba2857fba1cba19c09dd1d27f3661b6687295f82caba716d9a","src/unix/bsd/apple/mod.rs":"d36675dfaf8e1f504142cc8e123aa3a272ae759e16d345aa8834ca85dfd72210","src/unix/bsd/freebsdlike/dragonfly/errno.rs":"07b19390b9ae8f541ac35fd4e14685d639b95152d6d7a33814bb749b8b927298","src/unix/bsd/freebsdlike/dragonfly/mod.rs":"7de7c1ac56ffd34d45e845cd6f8c83ad02355bc4cb441e5c45a3a682f5bbe0b6","src/unix/bsd/freebsdlike/freebsd/aarch64.rs":"246e20e9a143d4ac81d37d940e020ede283f8df5aecd5d149b297664c4293a84","src/unix/bsd/freebsdlike/freebsd/arm.rs":"6e938534090f85040f7228b781ba57020c412d4f8f99d65ca5ce2a0a0baf93a1","src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs":"951c9297ed31a13509716068bc04c202ace3cbca3cc485e3a7f6b2fefa06e396","src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs":"62ae6e372b644a4270c0bb325edaac4a9e553ad83ffdcf2f4d8608a2ec2bae9c","src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs":"16595db5aaf422e425ac9ba1e693aa0f176f743ca194a767f265e1b3cb1b3f22","src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs":"8467832d4b8a73e473371f49a2d7b56f632b8f44262c43b5f409c4094cbad26a","src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs":"64c4bd82eaf30a2681417f982fce28de7d1b0743bfaa14004692a56cee44be21","src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs":"2027bae85dac0ca1cfc97f4304023c06174231af3547f33c3f4fed0dcf8c5732","src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs":"64c4bd82eaf30a2681417f982fce28de7d1b0743bfaa14004692a56cee44be21","src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs":"d536725067b3a85fc57929d95a85dfdbe593c9fbe72c246f4ab855f602074fe5","src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs":"d6e66809e109dc779efe5584b79d34fcd6fdba91973a415d64ae66f481f45940","src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs":"9835c3374c2daea20de73ab7896044bc1de14f6cd0711df9d47d4e3a001c4ded","src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs":"d6e66809e109dc779efe5584b79d34fcd6fdba91973a415d64ae66f481f45940","src/unix/bsd/freebsdlike/freebsd/mod.rs":"69818c7db4f93d1a2e61f414d433fb9c1007dcde11260a69f808c8b7b92834be","src/unix/bsd/freebsdlike/freebsd/powerpc.rs":"809148c48a16cef7de40378c9322a5795b40fec8c7eeaccb20df44a3c1c77c1d","src/unix/bsd/freebsdlike/freebsd/powerpc64.rs":"8ec51f2eb1eae1504b743fc22b0c498c1a1c11bbf17f8199d9d3a6af2ab108ca","src/unix/bsd/freebsdlike/freebsd/riscv64.rs":"4e8e313c3a3736fbb663c26bc445684e89c91092870dc896848df13f8ef89cfe","src/unix/bsd/freebsdlike/freebsd/x86.rs":"a3a17037050ba9f2314574a2cec8ff1962d08561e60616a3f170ba256371ff0b","src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs":"b79601d4f5f297f2aafb17aa4ed69f128d1668eda5c59866c3eae498034403aa","src/unix/bsd/freebsdlike/mod.rs":"d2754ce7c91d0585fa1bcabb68d33a226491dc1f1a627f740385624e1e546334","src/unix/bsd/mod.rs":"e05f88aabb6ca6c3f388d314a4235894734f8a0a3c0ea87f748ea7de4132a70b","src/unix/bsd/netbsdlike/mod.rs":"fa5c797fb3f57b637284ed725c10f63827f0de008edd326341dc56c1638610c7","src/unix/bsd/netbsdlike/netbsd/aarch64.rs":"ba2425edbf025f13ab3c3534d1671d310392df3a7d237539817d9cfa675971c8","src/unix/bsd/netbsdlike/netbsd/arm.rs":"f498ac1c11d0ebf6ee2c23cddb573c2358dcb5191924bd96e1bbc86870a86407","src/unix/bsd/netbsdlike/netbsd/mips.rs":"20cdd8d1427c986ecc3fcf7960d337917a13cfd8386dd2d54f8693a23d60892f","src/unix/bsd/netbsdlike/netbsd/mod.rs":"14dc0173e4e8da439dab81c4321126cdb64ad2b741714002cc899598b5bbc8bd","src/unix/bsd/netbsdlike/netbsd/powerpc.rs":"c19c4edbc73b5a97b51e3e2ad39b9fee02ad15e80c70ceb3a1abfe977e5c0ead","src/unix/bsd/netbsdlike/netbsd/riscv64.rs":"efa1a156cff1ab2450439adbb3ab2113bed6b7de2205c99e9cba875aa2b1c153","src/unix/bsd/netbsdlike/netbsd/sparc64.rs":"d50816e830225779ac9e9a55a7e3e097882153d72987061d76a96ee736c8af9c","src/unix/bsd/netbsdlike/netbsd/x86.rs":"3006b6a086c0241f5383ca101e7b9357368d713f9c38400633491656d110798e","src/unix/bsd/netbsdlike/netbsd/x86_64.rs":"cb864e23a32eff1bf37563218cf6ce7dac8d028584c385107c84562cf1d87866","src/unix/bsd/netbsdlike/openbsd/aarch64.rs":"3960096fb915d2f75015e1706720d4cd0044938bcfe6727b097751b4c47df6a5","src/unix/bsd/netbsdlike/openbsd/arm.rs":"f064d935f416ca9f7e5e767b9b46da2250c997d667c0c7f4b4c7dfe02d0258c3","src/unix/bsd/netbsdlike/openbsd/mips64.rs":"bee7664d88f8451ae22552fc0721b6b6a6dee2493cc42bcb9829c1e47e4b05f5","src/unix/bsd/netbsdlike/openbsd/mod.rs":"f5f0177e1024bd3bdabdcf7fcb1802d79b565568243816ab7b7ca3e5051fb0ef","src/unix/bsd/netbsdlike/openbsd/powerpc.rs":"f064d935f416ca9f7e5e767b9b46da2250c997d667c0c7f4b4c7dfe02d0258c3","src/unix/bsd/netbsdlike/openbsd/powerpc64.rs":"1f62a42e2970c42de9e3492fbf3cd5b45410889f033743579266342d1a9e2a00","src/unix/bsd/netbsdlike/openbsd/riscv64.rs":"c93baaf8e3afa8c79a1acb03234b0bb85b148a706481de909528513f45afa136","src/unix/bsd/netbsdlike/openbsd/sparc64.rs":"8d4c5a4cae63e09e1c156164ddc82e0fc77926841d4d4e419dd2e7a7b7145f58","src/unix/bsd/netbsdlike/openbsd/x86.rs":"e6da2fdff7706fd3eac147d3aaf16afdd8542f231f502660d1d89c79b5eca21b","src/unix/bsd/netbsdlike/openbsd/x86_64.rs":"89be4988c6acca7ce411aa2907401b9fed1ffce6ad606cc150683f1e136cba94","src/unix/cygwin/mod.rs":"c98bb7c1118c249f2e7533c68b0d77bd778a1050ab52aab603a03151061e084f","src/unix/haiku/b32.rs":"c3f8678ceee65a3094d8133b0d1a94470860e0b1867977f0569c52c5a20e039f","src/unix/haiku/b64.rs":"f97ce9225f4710893dab03ab3e13bc62152cc84f90c597ec88f6dc1f4c27d242","src/unix/haiku/bsd.rs":"4d9af31fdac2561ee5f942dca97dd2f48139ca74660d40b854b307fa5679d1c8","src/unix/haiku/mod.rs":"a1e1ab46a354da23a8348331d014b184a3f3b9d7fec8ced4c6efede9f5c38a45","src/unix/haiku/native.rs":"8248c0491d62ed96b5c2707a998f8d13cf2a49f2d06fa724848863860cb40e69","src/unix/haiku/x86_64.rs":"09f2384474b2fcb7d0febb0e9e802610a627cadca29dc0e60eb4cfe15552f978","src/unix/hurd/b32.rs":"501f426f7aeb60acf4119064100dd94bbdfebff2cec785428708059d853dc123","src/unix/hurd/b64.rs":"b9b2082e721a5ec89ba55fd5a16bbffcc8a05ca7cef6dbfbd78aff0806cb931f","src/unix/hurd/mod.rs":"b09754b468b78b64463cbf6d5d50ffba76e27efe66bb1e5020054627d751d98a","src/unix/linux_like/android/b32/arm.rs":"e68f6a15870a22e0383770ed1a5bd443d4c2ed237d16fea338c5da1ab9bf1fe3","src/unix/linux_like/android/b32/mod.rs":"5b10ebe56435d868846ae720bb9081cf814486722b5c13520fd4ef50a7ecfb58","src/unix/linux_like/android/b32/x86/mod.rs":"52f402bc27e3ddc519cd2699205bc0f31ba9737f89772d26c07e9c28a7f35762","src/unix/linux_like/android/b64/aarch64/mod.rs":"6d4fcf287ee09d65cfd8d8d9e2b551185f1cf9d90072922b9f703d2871deb036","src/unix/linux_like/android/b64/mod.rs":"04346a4a75b7cf20992eed6a2cfb986d38daf539208c462c10a7ccf3cd516068","src/unix/linux_like/android/b64/riscv64/mod.rs":"10705a5608bc761718ed54ce6dcc2a83c8aa9300337c4f9a67152637dc8d3b11","src/unix/linux_like/android/b64/x86_64/mod.rs":"7243327f35f4f4e59642c9015ee65a13fbc61618fb8ca615580f7f84a3b72e45","src/unix/linux_like/android/mod.rs":"a75260c2c9951ab305559d249a9586167d609a473ecf1d568c876a428d866da1","src/unix/linux_like/emscripten/lfs64.rs":"3a1d1779bcf16525a578a68237f9854090eae4c9819e18ffb5a288f39be4afbe","src/unix/linux_like/emscripten/mod.rs":"fab8e539c9681b444e96cc46eed01fd2640347ff0499b82f238ccec796f15175","src/unix/linux_like/linux/arch/generic/mod.rs":"c8f4d88ba7ffe044c47fc84ca1e21751bfd2446806ccabbe8729958cbb5d1ccc","src/unix/linux_like/linux/arch/mips/mod.rs":"058ebf07f8b10358af9a7f66bd96ba14df1cc6a942203da9abe8d1abab00fcbb","src/unix/linux_like/linux/arch/mod.rs":"8bc5898b03760a95dd4f124ac76ad92e5ae36b2d0644203d752ef2b37e487c3a","src/unix/linux_like/linux/arch/powerpc/mod.rs":"0e20b7e63fe39a200cb4813eeb934bc25d91a2427cd1b1d81bc2cfa4e2368ed5","src/unix/linux_like/linux/arch/sparc/mod.rs":"96ed29a86c629657c521a5e12dece22e570ef7ceee9e8f4a58c2e0782d74e01d","src/unix/linux_like/linux/gnu/b32/arm/mod.rs":"0ab9b524f4e4182eb92ac40c7b5101ce73509aa2d483eab58eef212005c21497","src/unix/linux_like/linux/gnu/b32/csky/mod.rs":"8fdab3a121a111b9856f0de29fe75262d8aa5f1a3d75b273cc72c8c809e87c48","src/unix/linux_like/linux/gnu/b32/m68k/mod.rs":"4c79cca606495e3d98f386a0f8d447f3f281df5ade019380b9018f05999bf849","src/unix/linux_like/linux/gnu/b32/mips/mod.rs":"09e3e15f41d617a0d7f83d5346b318d6d4e7d6eb99fdb0d2603a59122140d7b9","src/unix/linux_like/linux/gnu/b32/mod.rs":"050fa9856b151b3e33214b570cf7527eca11eaa9145d40a1524824b5232b2500","src/unix/linux_like/linux/gnu/b32/powerpc.rs":"7c3b9aad8856408517e056bdcfde877ca9d4529b9c39ffada70b56cdf244c403","src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs":"4bdfd096759a489c0fcbfb1f38ff5c364bbe3fa3f6f3844a43486f5fb2e1eb24","src/unix/linux_like/linux/gnu/b32/sparc/mod.rs":"9a8e8ea56494fdb6421be801f6bfa0c878dac611aadcc66cef79e02e1c0604f5","src/unix/linux_like/linux/gnu/b32/x86/mod.rs":"ce42dc6c6b620f898d924fdb26895b7b832a4f38e838059f99f663bda2cb3e69","src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs":"638b2d717dcf5b59a0058c3dabab43edd84de9d1d7da6e16ad0c58e863000417","src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs":"28c11e70467b2f00735d3a04c369e96e04fd44d0587ee33359f38328b0677ee6","src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs":"9bfab4e70363d559f76600cbb38659f8e204bea14b165e0054118d34ad3f94ff","src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs":"f2d8b176c64d791a5a34b7753cab2f50e34cd450e6819bf0b180bd3c6a9d9771","src/unix/linux_like/linux/gnu/b64/mips64/mod.rs":"d34a56b36ac1b8b04a4468afeef76b78e5d50c794f697cfe481e9d44692d29b0","src/unix/linux_like/linux/gnu/b64/mod.rs":"30d1286c6b53a8c1cc090921a4192d5c05c7dbe0a7ff1aa4577774f9db934515","src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs":"285c465bd0cb1e66c2907306d560316b561732bca8ed2008eba370f48a0f957f","src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs":"cd5b8088ddb38bbee6cd8f293f4dd8e0970a5c04d25b4bb4f4c8a5da61a09029","src/unix/linux_like/linux/gnu/b64/s390x.rs":"64fba1b75736ef6e22c11751c9daa3abd61af47b27da641d655e9ebb04b0f507","src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs":"8e7af350479d61c31a5cd17585b3eb15c11acc95dd2d7ca37d229efe95a497cb","src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs":"deb7d1bb4639e0adaba2ad63636bc30df7d5318d934e514c0273fa08051eb5b2","src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs":"07240332eaf44996d86e37b12d71b519b499c9c9b57898441c58ac2e8c0cb6f7","src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs":"914898b781dfe6b2f755730d6000223d1beea177731e180ccbfdd84a0b8b3bd9","src/unix/linux_like/linux/gnu/mod.rs":"606d323e8aa2c14b22a54f9fc8720ae237df583ae1ba9e5bfe2249663ad02c5c","src/unix/linux_like/linux/mod.rs":"4ab0a27762842a59a5e59f9029d8a49527de4226c5d6e24156f316d7f52a4284","src/unix/linux_like/linux/musl/b32/arm/mod.rs":"8df7c7015240f62151363a0a545fb3be96e5d816b62ef673d84294e87e9bb9ea","src/unix/linux_like/linux/musl/b32/hexagon.rs":"1b0c68839dc46d00010d99e946f356d50dc4ad1c7468f99a8afe839f9542ebd0","src/unix/linux_like/linux/musl/b32/mips/mod.rs":"49a40760d4ac2b8ae50e2e4816bf09283828de5835daaf4ea616de2a23c66500","src/unix/linux_like/linux/musl/b32/mod.rs":"e0f53df7ca1dbe9b0b25ccecf1adf664227995e58d67a222a8d046d2a879dfc8","src/unix/linux_like/linux/musl/b32/powerpc.rs":"92089167ddbe1fde8663373699ee16c7b01c451c442c27ab1a392582c992dc32","src/unix/linux_like/linux/musl/b32/riscv32/mod.rs":"f13543de5c3b4f8c23d9c9f4f3ad90f514be122d2707f7f781c696261cb11f91","src/unix/linux_like/linux/musl/b32/x86/mod.rs":"264aafdd2d3dbbf57764a671797ca0ef53baee4737f7acf09db4f14a5d13831d","src/unix/linux_like/linux/musl/b64/aarch64/mod.rs":"5ba43a3198d9dff45bc411925353674f1e4cef29eace6b2b1cb6cad070680308","src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs":"294414bcb24a5b59335e49d00f6285b926bd352df20dcff4f935ae094d21495e","src/unix/linux_like/linux/musl/b64/mips64.rs":"63540cff731c8db41df7d3d3fc9291ece11a8c89b8e5ff30bbca9c784e306f9d","src/unix/linux_like/linux/musl/b64/mod.rs":"e3055a6690ed1dc63b865957be649bfa165852c693e2a387c2c627939157a773","src/unix/linux_like/linux/musl/b64/powerpc64.rs":"03552edded40fccc52c8259af289cbeb074482c1337ef0c32c3cfff81bd3d537","src/unix/linux_like/linux/musl/b64/riscv64/mod.rs":"e13c6430f950035f94989771122c733866651194e7218c7d0b243ae04ef7c864","src/unix/linux_like/linux/musl/b64/s390x.rs":"30f9ac1527e49a57f6d829e54a82ca48e7a1b74507904e6c89a13f933da30ff5","src/unix/linux_like/linux/musl/b64/wasm32/mod.rs":"2d2a01fd01b372ebf1ff63d23072ae548f8a392f443f41a455e0bfb6a8705b70","src/unix/linux_like/linux/musl/b64/wasm32/wali.rs":"69e0d06289f1c86898ef3ab505e397af2acce146accb62efff654fe458b6af02","src/unix/linux_like/linux/musl/b64/x86_64/mod.rs":"95b8adc3443988aa4908e8c1d8c8c0a1619a7636e8ea286edd95ec815d6cd5d2","src/unix/linux_like/linux/musl/lfs64.rs":"308c5b5c9b2f4b1ad17e5c2d02946f84ae83e8f5cb0e789d8d3e76c1923a5d31","src/unix/linux_like/linux/musl/mod.rs":"d8afb6167cab328d65ce2a755a5a4559de30173dd4d09bb90001734a15437730","src/unix/linux_like/linux/uclibc/arm/mod.rs":"a90c7811623714e168b676aa50b162931e66ce86f8c59b0acac131afde474b2c","src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs":"59493f1ab84ddbcf9dc5881c9cfc26e28d4fb5322d63f60eb7de5f9e8e329580","src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs":"a35532d5ae376f403873aa566f37bff99c6c323d334f3201667e5f7200b04643","src/unix/linux_like/linux/uclibc/mips/mod.rs":"af6323cebdeeeb4f0e86ddfddb9cf21cf251f27a98a8c02feb4f80e81d7a996a","src/unix/linux_like/linux/uclibc/mod.rs":"128d586702c6aa6f1d1c56342f855d62550063ea7df97c6c16abdb01fd6bf94e","src/unix/linux_like/linux/uclibc/x86_64/l4re.rs":"f29e4a969f0bf7359b984e17335cc957f980a70b49912c032fd762dd05743081","src/unix/linux_like/linux/uclibc/x86_64/mod.rs":"be62714a2ff04387093145a3d765585eaaac71e4fb53d1983546a57940fa2ce4","src/unix/linux_like/linux/uclibc/x86_64/other.rs":"12f8d4049862fc0c4d94b770f2d0341c1c7bf3da0619436169c12cadc4093def","src/unix/linux_like/mod.rs":"537ab6b4af3685a71487e31491d82cc2a08e8d4ce4a9dc88c6eeb29ae1daf5b7","src/unix/mod.rs":"4f6c804705ede5fa221cce2a9b23a69daaeccdbf390647a4d9f4e94aa462082d","src/unix/newlib/aarch64/mod.rs":"ec594c54dc0e7784668d02ef737fd194dcc3f1e6ee23328d810fd2453bcb6f20","src/unix/newlib/arm/mod.rs":"a1fb6caa077c2ed69adf12da07c814ffab4c1311579f23bae2b26a40cf180665","src/unix/newlib/espidf/mod.rs":"77e8ad5b7db027b8b0b5aa5126f15bc0e35b6f3deb2339acf403c961f13df26f","src/unix/newlib/generic.rs":"182e584f14e0984934130425dd2be0781ca2c131449b3ae1734a07c72c3d43cd","src/unix/newlib/horizon/mod.rs":"9ea04f90566fc14fcfd4ec5bd7c1ef467d6b26ce80bda73f4eec2fe7b652e816","src/unix/newlib/mod.rs":"18def44ab6d32cc50cb89242a1ef9edfa0ffe8010cafb27aaef8ebb970696dea","src/unix/newlib/powerpc/mod.rs":"4e5f804a13e907e17ebb66dcbf3b0fe6e1a611f91876aad8d8a0a69c7df0a7e8","src/unix/newlib/rtems/mod.rs":"6e26c8d4ce78557b3d0eef33f0057e46545c655612c7d86c38bb759f5e032788","src/unix/newlib/vita/mod.rs":"20fd016df6c8aa9097ab3410c5efd187a2f2a202b5e7c0e0ee67714036108329","src/unix/nto/aarch64.rs":"73ad54ebca13454a75c7b0815e853175070a8ac2eefa338012a03e8b59f01e0c","src/unix/nto/mod.rs":"a5219667280d9664a382b91dde8374f9959252a402d1b85dd3577957f4bf88b9","src/unix/nto/neutrino.rs":"2cef6af9943eec590b2b0af96a63bc3169e9d2af5c7713e3360eb09a807f248a","src/unix/nto/x86_64.rs":"8da99138e210516a95d49c8c0265eada4c5f7b93d59be86224844410f5e7929b","src/unix/nuttx/mod.rs":"137c69eca97ba9e0ca61baf6b9dafc11d68f07a1f5de527f9ff3fdc30e3f1ca9","src/unix/redox/mod.rs":"764d09bcdc670a821222d7b7d52799489ba21f140c3039fb60b6d3aa98e25acc","src/unix/solarish/compat.rs":"4346fbe9f8640868ac20b63bf3b52f883a37587e1df15ffe54fa0393a48a5588","src/unix/solarish/illumos.rs":"c6305f2555bc542dd63ac0edbc8e517f65a7a870ef9c406d0809d25c6c32276c","src/unix/solarish/mod.rs":"fd370036f3b0a198369104d426692ea4d1d4b9905ad3c15d61caec38e908dd02","src/unix/solarish/solaris.rs":"4045113ee68a9e29f6e2211dbfabe7fd423b21e7b882a982a589719d2c437657","src/unix/solarish/x86.rs":"44261c1f1b300dac9fa0dab93ec85d0c3b3c48b15bc4515b9820c9421cff7427","src/unix/solarish/x86_64.rs":"d888cd12da647f543df8cce7ae04e4a67f8647f71fd14cf7b4f968dbafcd4f5e","src/unix/solarish/x86_common.rs":"4ae02d88622f7f080f5e8cd328f13187edbc5e124fb3e05e4cf212597f6cce48","src/vxworks/aarch64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/arm.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/mod.rs":"29474e4025c3bcccc1aa63407928d58623ea7337aa74c325ca8fb01248d52256","src/vxworks/powerpc.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/powerpc64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/riscv32.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/riscv64.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/x86.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/x86_64.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/wasi/mod.rs":"bc84b5b6075e100f24f98ee4e131b4f9277c85675a1377e562b660c0798f171d","src/wasi/p2.rs":"feecc0485eabd2c32bc5d800df6ad1b9b4d282741342fb08792f2635204e1e08","src/windows/gnu/mod.rs":"f8c154637cd4b9b5b35b197373d67742d0678abb5f674905897a00029785c455","src/windows/mod.rs":"0231971b8fe96998d4a882f7be6aa92ba07615609a7fc4dc86172c0ad2b1992e","src/windows/msvc/mod.rs":"7bc0f1e7e73815296cd6b63b2700e12624e9f47b5c4113a1a87fae8e64549c00","src/xous.rs":"1a83621c40248ad4d0c08e1fd4c1107d5efcbc2f4f0169538b7b4a885abedbfa","tests/const_fn.rs":"8ac3171d7bced3576a4e93f48570b3e00c553d7510ab85a7473ae3b716a812dc"},"package":"58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174"} +\ No newline at end of file diff --git a/third_party/rust/libc/CHANGELOG.md b/third_party/rust/libc/CHANGELOG.md @@ -1,6 +1,238 @@ # Changelog -## [Unreleased] +## [0.2.176](https://github.com/rust-lang/libc/compare/0.2.175...0.2.176) - 2025-09-23 + +### Support + +- The default FreeBSD version has been raised from 11 to 12. This matches `rustc` since 1.78. ([#2406](https://github.com/rust-lang/libc/pull/2406)) +- `Debug` is now always implemented, rather than being gated behind the `extra_traits` feature. ([#4624](https://github.com/rust-lang/libc/pull/4624)) + +### Added + +- AIX: Restore some non-POSIX functions guarded by the `_KERNEL` macro. ([#4607](https://github.com/rust-lang/libc/pull/4607)) +- FreeBSD 14: Add `st_fileref` to `struct stat` ([#4642](https://github.com/rust-lang/libc/pull/4642)) +- Haiku: Add the `accept4` POSIX call ([#4586](https://github.com/rust-lang/libc/pull/4586)) +- Introduce a wrapper for representing padding ([#4632](https://github.com/rust-lang/libc/pull/4632)) +- Linux: Add `EM_RISCV` ([#4659](https://github.com/rust-lang/libc/pull/4659)) +- Linux: Add `MS_NOSYMFOLLOW` ([#4389](https://github.com/rust-lang/libc/pull/4389)) +- Linux: Add `backtrace_symbols(_fd)` ([#4668](https://github.com/rust-lang/libc/pull/4668)) +- Linux: Add missing `SOL_PACKET` optnames ([#4669](https://github.com/rust-lang/libc/pull/4669)) +- Musl s390x: Add `SYS_mseal` ([#4549](https://github.com/rust-lang/libc/pull/4549)) +- NuttX: Add `__errno` ([#4687](https://github.com/rust-lang/libc/pull/4687)) +- Redox: Add `dirfd`, `VDISABLE`, and resource consts ([#4660](https://github.com/rust-lang/libc/pull/4660)) +- Redox: Add more `resource.h`, `fcntl.h` constants ([#4666](https://github.com/rust-lang/libc/pull/4666)) +- Redox: Enable `strftime` and `mkostemp[s]` ([#4629](https://github.com/rust-lang/libc/pull/4629)) +- Unix, Windows: Add `qsort_r` (Unix), and `qsort(_s)` (Windows) ([#4677](https://github.com/rust-lang/libc/pull/4677)) +- Unix: Add `dlvsym` for Linux-gnu, FreeBSD, and NetBSD ([#4671](https://github.com/rust-lang/libc/pull/4671)) +- Unix: Add `sigqueue` ([#4620](https://github.com/rust-lang/libc/pull/4620)) + +### Changed + +- FreeBSD 15: Mark `kinfo_proc` as non-exhaustive ([#4553](https://github.com/rust-lang/libc/pull/4553)) +- FreeBSD: Set the ELF symbol version for `readdir_r` ([#4694](https://github.com/rust-lang/libc/pull/4694)) +- Linux: Correct the config for whether or not `epoll_event` is packed ([#4639](https://github.com/rust-lang/libc/pull/4639)) +- Tests: Replace the old `ctest` with the much more reliable new implementation ([#4655](https://github.com/rust-lang/libc/pull/4655) and many related PRs) + +### Fixed + +- AIX: Fix the type of the 4th arguement of `getgrnam_r` ([#4656](https://github.com/rust-lang/libc/pull/4656 +- FreeBSD: Limit `P_IDLEPROC` to FreeBSD 15 ([#4640](https://github.com/rust-lang/libc/pull/4640)) +- FreeBSD: Limit `mcontext_t::mc_tlsbase` to FreeBSD 15 ([#4640](https://github.com/rust-lang/libc/pull/464)) +- FreeBSD: Update gating of `mcontext_t.mc_tlsbase` ([#4703](https://github.com/rust-lang/libc/pull/4703)) +- Musl s390x: Correct the definition of `statfs[64]` ([#4549](https://github.com/rust-lang/libc/pull/4549)) +- Musl s390x: Make `fpreg_t` a union ([#4549](https://github.com/rust-lang/libc/pull/4549)) +- Redox: Fix the types of `gid_t` and `uid_t` ([#4689](https://github.com/rust-lang/libc/pull/4689)) +- Redox: Fix the value of `MAP_FIXED` ([#4684](https://github.com/rust-lang/libc/pull/4684)) + +### Deprecated + +- Apple: Correct the `deprecated` attribute for `iconv` ([`a97a0b53`](https://github.com/rust-lang/libc/commit/a97a0b53fb7faf5f99cd720ab12b1b8a5bf9f950)) +- FreeBSD: Deprecate `TIOCMGDTRWAIT` and `TIOCMSDTRWAIT` ([#4685](https://github.com/rust-lang/libc/pull/4685)) + +### Removed + +- FreeBSD: Remove `JAIL_{GET,SET}_MASK`, `_MC_FLAG_MASK` ([#4691](https://github.com/rust-lang/libc/pull/4691)) + +## [0.2.175](https://github.com/rust-lang/libc/compare/0.2.174...0.2.175) - 2025-08-10 + +### Added + +- AIX: Add `getpeereid` ([#4524](https://github.com/rust-lang/libc/pull/4524)) +- AIX: Add `struct ld_info` and friends ([#4578](https://github.com/rust-lang/libc/pull/4578)) +- AIX: Retore `struct winsize` ([#4577](https://github.com/rust-lang/libc/pull/4577)) +- Android: Add UDP socket option constants ([#4619](https://github.com/rust-lang/libc/pull/4619)) +- Android: Add `CLONE_CLEAR_SIGHAND` and `CLONE_INTO_CGROUP` ([#4502](https://github.com/rust-lang/libc/pull/4502)) +- Android: Add more `prctl` constants ([#4531](https://github.com/rust-lang/libc/pull/4531)) +- FreeBSD Add further TCP stack-related constants ([#4196](https://github.com/rust-lang/libc/pull/4196)) +- FreeBSD x86-64: Add `mcontext_t.mc_tlsbase ` ([#4503](https://github.com/rust-lang/libc/pull/4503)) +- FreeBSD15: Add `kinfo_proc.ki_uerrmsg` ([#4552](https://github.com/rust-lang/libc/pull/4552)) +- FreeBSD: Add `in_conninfo` ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- FreeBSD: Add `xinpgen` and related types ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- FreeBSD: Add `xktls_session` ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- Haiku: Add functionality from `libbsd` ([#4221](https://github.com/rust-lang/libc/pull/4221)) +- Linux: Add `SECBIT_*` ([#4480](https://github.com/rust-lang/libc/pull/4480)) +- NetBSD, OpenBSD: Export `ioctl` request generator macros ([#4460](https://github.com/rust-lang/libc/pull/4460)) +- NetBSD: Add `ptsname_r` ([#4608](https://github.com/rust-lang/libc/pull/4608)) +- RISCV32: Add time-related syscalls ([#4612](https://github.com/rust-lang/libc/pull/4612)) +- Solarish: Add `strftime*` ([#4453](https://github.com/rust-lang/libc/pull/4453)) +- linux: Add `EXEC_RESTRICT_*` and `EXEC_DENY_*` ([#4545](https://github.com/rust-lang/libc/pull/4545)) + +### Changed + +- AIX: Add `const` to signatures to be consistent with other platforms ([#4563](https://github.com/rust-lang/libc/pull/4563)) + +### Fixed + +- AIX: Fix the type of `struct statvfs.f_fsid` ([#4576](https://github.com/rust-lang/libc/pull/4576)) +- AIX: Fix the type of constants for the `ioctl` `request` argument ([#4582](https://github.com/rust-lang/libc/pull/4582)) +- AIX: Fix the types of `stat{,64}.st_*tim` ([#4597](https://github.com/rust-lang/libc/pull/4597)) +- AIX: Use unique `errno` values ([#4507](https://github.com/rust-lang/libc/pull/4507)) +- Build: Fix an incorrect `target_os` -> `target_arch` check ([#4550](https://github.com/rust-lang/libc/pull/4550)) +- FreeBSD: Fix the type of `xktls_session_onedir.ifnet` ([#4552](https://github.com/rust-lang/libc/pull/4552)) +- Mips64 musl: Fix the type of `nlink_t` ([#4509](https://github.com/rust-lang/libc/pull/4509)) +- Mips64 musl: Use a special MIPS definition of `stack_t` ([#4528](https://github.com/rust-lang/libc/pull/4528)) +- Mips64: Fix `SI_TIMER`, `SI_MESGQ` and `SI_ASYNCIO` definitions ([#4529](https://github.com/rust-lang/libc/pull/4529)) +- Musl Mips64: Swap the order of `si_errno` and `si_code` in `siginfo_t` ([#4530](https://github.com/rust-lang/libc/pull/4530)) +- Musl Mips64: Use a special MIPS definition of `statfs` ([#4527](https://github.com/rust-lang/libc/pull/4527)) +- Musl: Fix the definition of `fanotify_event_metadata` ([#4510](https://github.com/rust-lang/libc/pull/4510)) +- NetBSD: Correct `enum fae_action` to be `#[repr(C)]` ([#60a8cfd5](https://github.com/rust-lang/libc/commit/60a8cfd564f83164d45b9533ff7a0d7371878f2a)) +- PSP: Correct `char` -> `c_char` ([eaab4fc3](https://github.com/rust-lang/libc/commit/eaab4fc3f05dc646a953d4fd5ba46dfa1f8bd6f6)) +- PowerPC musl: Fix `termios` definitions ([#4518](https://github.com/rust-lang/libc/pull/4518)) +- PowerPC musl: Fix the definition of `EDEADLK` ([#4517](https://github.com/rust-lang/libc/pull/4517)) +- PowerPC musl: Fix the definition of `NCCS` ([#4513](https://github.com/rust-lang/libc/pull/4513)) +- PowerPC musl: Fix the definitions of `MAP_LOCKED` and `MAP_NORESERVE` ([#4516](https://github.com/rust-lang/libc/pull/4516)) +- PowerPC64 musl: Fix the definition of `shmid_ds` ([#4519](https://github.com/rust-lang/libc/pull/4519)) + +### Deprecated + +- Linux: `MAP_32BIT` is only defined on x86 on non-x86 architectures ([#4511](https://github.com/rust-lang/libc/pull/4511)) + +### Removed + +- AIX: Remove duplicate constant definitions `FIND` and `ENTER` ([#4588](https://github.com/rust-lang/libc/pull/4588)) +- s390x musl: Remove `O_FSYNC` ([#4515](https://github.com/rust-lang/libc/pull/4515)) +- s390x musl: Remove `RTLD_DEEPBIND` ([#4515](https://github.com/rust-lang/libc/pull/4515)) + + +## [0.2.174](https://github.com/rust-lang/libc/compare/0.2.173...0.2.174) - 2025-06-17 + +### Added + +- Linux: Make `pidfd_info` fields pub ([#4487](https://github.com/rust-lang/libc/pull/4487)) + +### Fixed + +- Gnu x32: Add missing `timespec.tv_nsec` ([#4497](https://github.com/rust-lang/libc/pull/4497)) +- NuttX: Use `nlink_t` type for `st_nlink` in `struct stat` definition ([#4483](https://github.com/rust-lang/libc/pull/4483)) + +### Other + +- Allow new `unpredictable_function_pointer_comparisons` lints ([#4489](https://github.com/rust-lang/libc/pull/4489)) +- OpenBSD: Fix some clippy warnings to use `pointer::cast`. ([#4490](https://github.com/rust-lang/libc/pull/4490)) +- Remove unessecary semicolons from definitions of `CMSG_NXTHDR`. ([#4492](https://github.com/rust-lang/libc/pull/4492)) + + +## [0.2.173](https://github.com/rust-lang/libc/compare/0.2.172...0.2.173) - 2025-06-09 + +### Added + +- AIX: Add an AIX triple to Cargo.toml for doc ([#4475](https://github.com/rust-lang/libc/pull/4475)) +- FreeBSD: Add the `SO_SPLICE` socket option support for FreeBSD >= 14.2 ([#4451](https://github.com/rust-lang/libc/pull/4451)) +- Linux GNU: Prepare for supporting `_TIME_BITS=64` ([#4433](https://github.com/rust-lang/libc/pull/4433)) +- Linux: Add constant PACKET_IGNORE_OUTGOING ([#4319](https://github.com/rust-lang/libc/pull/4319)) +- Linux: Add constants and types for `nsfs` ioctls ([#4436](https://github.com/rust-lang/libc/pull/4436)) +- Linux: Add constants for Memory-Deny-Write-Execute `prctls` ([#4400](https://github.com/rust-lang/libc/pull/4400)) +- Linux: Add constants from `linux/cn_proc.h` and `linux/connector.h` ([#4434](https://github.com/rust-lang/libc/pull/4434)) +- Linux: Add new flags for `pwritev2` and `preadv2` ([#4452](https://github.com/rust-lang/libc/pull/4452)) +- Linux: Add pid_type enum values ([#4403](https://github.com/rust-lang/libc/pull/4403)) +- Linux: Update pidfd constants and types (Linux 6.9-6.15) ([#4402](https://github.com/rust-lang/libc/pull/4402)) +- Loongarch64 musl: Define the `MADV_SOFT_OFFLINE` constant ([#4448](https://github.com/rust-lang/libc/pull/4448)) +- Musl: Add new fields since 1.2.0/1.2.2 to `struct tcp_info` ([#4443](https://github.com/rust-lang/libc/pull/4443)) +- Musl: Prepare for supporting v1.2.3 ([#4443](https://github.com/rust-lang/libc/pull/4443)) +- NuttX: Add `arc4random` and `arc4random_buf` ([#4464](https://github.com/rust-lang/libc/pull/4464)) +- RISC-V Musl: Add `MADV_SOFT_OFFLINE` definition ([#4447](https://github.com/rust-lang/libc/pull/4447)) +- Redox: Define SCM_RIGHTS ([#4440](https://github.com/rust-lang/libc/pull/4440)) +- VxWorks: Add missing UTIME defines and TASK_RENAME_LENGTH ([#4407](https://github.com/rust-lang/libc/pull/4407)) +- Windows: Add more `time.h` functions ([#4427](https://github.com/rust-lang/libc/pull/4427)) + +### Changed + +- Redox: Update `SA_` constants. ([#4426](https://github.com/rust-lang/libc/pull/4426)) +- Redox: make `CMSG_ALIGN`, `CMSG_LEN`, and `CMSG_SPACE` const functions ([#4441](https://github.com/rust-lang/libc/pull/4441)) + +### Fixed + +- AIX: Enable libc-test and fix definitions/declarations. ([#4450](https://github.com/rust-lang/libc/pull/4450)) +- Emscripten: Fix querying emcc on windows (use emcc.bat) ([#4248](https://github.com/rust-lang/libc/pull/4248)) +- Hurd: Fix build from missing `fpos_t` ([#4472](https://github.com/rust-lang/libc/pull/4472)) +- Loongarch64 Musl: Fix the `struct ipc_perm` bindings ([#4384](https://github.com/rust-lang/libc/pull/4384)) +- Musl: Fix the `O_LARGEFILE` constant value. ([#4443](https://github.com/rust-lang/libc/pull/4443)) + +## [0.2.172](https://github.com/rust-lang/libc/compare/0.2.171...0.2.172) - 2025-04-14 + +### Added + +- Android: Add `getauxval` for 32-bit targets ([#4338](https://github.com/rust-lang/libc/pull/4338)) +- Android: Add `if_tun.h` ioctls ([#4379](https://github.com/rust-lang/libc/pull/4379)) +- Android: Define `SO_BINDTOIFINDEX` ([#4391](https://github.com/rust-lang/libc/pull/4391)) +- Cygwin: Add `posix_spawn_file_actions_add[f]chdir[_np]` ([#4387](https://github.com/rust-lang/libc/pull/4387)) +- Cygwin: Add new socket options ([#4350](https://github.com/rust-lang/libc/pull/4350)) +- Cygwin: Add statfs & fcntl ([#4321](https://github.com/rust-lang/libc/pull/4321)) +- FreeBSD: Add `filedesc` and `fdescenttbl` ([#4327](https://github.com/rust-lang/libc/pull/4327)) +- Glibc: Add unstable support for _FILE_OFFSET_BITS=64 ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- Hermit: Add `AF_UNSPEC` ([#4344](https://github.com/rust-lang/libc/pull/4344)) +- Hermit: Add `AF_VSOCK` ([#4344](https://github.com/rust-lang/libc/pull/4344)) +- Illumos, NetBSD: Add `timerfd` APIs ([#4333](https://github.com/rust-lang/libc/pull/4333)) +- Linux: Add `_IO`, `_IOW`, `_IOR`, `_IOWR` to the exported API ([#4325](https://github.com/rust-lang/libc/pull/4325)) +- Linux: Add `tcp_info` to uClibc bindings ([#4347](https://github.com/rust-lang/libc/pull/4347)) +- Linux: Add further BPF program flags ([#4356](https://github.com/rust-lang/libc/pull/4356)) +- Linux: Add missing INPUT_PROP_XXX flags from `input-event-codes.h` ([#4326](https://github.com/rust-lang/libc/pull/4326)) +- Linux: Add missing TLS bindings ([#4296](https://github.com/rust-lang/libc/pull/4296)) +- Linux: Add more constants from `seccomp.h` ([#4330](https://github.com/rust-lang/libc/pull/4330)) +- Linux: Add more glibc `ptrace_sud_config` and related `PTRACE_*ET_SYSCALL_USER_DISPATCH_CONFIG`. ([#4386](https://github.com/rust-lang/libc/pull/4386)) +- Linux: Add new netlink flags ([#4288](https://github.com/rust-lang/libc/pull/4288)) +- Linux: Define ioctl codes on more architectures ([#4382](https://github.com/rust-lang/libc/pull/4382)) +- Linux: Add missing `pthread_attr_setstack` ([#4349](https://github.com/rust-lang/libc/pull/4349)) +- Musl: Add missing `utmpx` API ([#4332](https://github.com/rust-lang/libc/pull/4332)) +- Musl: Enable `getrandom` on all platforms ([#4346](https://github.com/rust-lang/libc/pull/4346)) +- NuttX: Add more signal constants ([#4353](https://github.com/rust-lang/libc/pull/4353)) +- QNX: Add QNX 7.1-iosock and 8.0 to list of additional cfgs ([#4169](https://github.com/rust-lang/libc/pull/4169)) +- QNX: Add support for alternative Neutrino network stack `io-sock` ([#4169](https://github.com/rust-lang/libc/pull/4169)) +- Redox: Add more `sys/socket.h` and `sys/uio.h` definitions ([#4388](https://github.com/rust-lang/libc/pull/4388)) +- Solaris: Temporarily define `O_DIRECT` and `SIGINFO` ([#4348](https://github.com/rust-lang/libc/pull/4348)) +- Solarish: Add `secure_getenv` ([#4342](https://github.com/rust-lang/libc/pull/4342)) +- VxWorks: Add missing `d_type` member to `dirent` ([#4352](https://github.com/rust-lang/libc/pull/4352)) +- VxWorks: Add missing signal-related constsants ([#4352](https://github.com/rust-lang/libc/pull/4352)) +- VxWorks: Add more error codes ([#4337](https://github.com/rust-lang/libc/pull/4337)) + +### Deprecated + +- FreeBSD: Deprecate `TCP_PCAP_OUT` and `TCP_PCAP_IN` ([#4381](https://github.com/rust-lang/libc/pull/4381)) + +### Fixed + +- Cygwin: Fix member types of `statfs` ([#4324](https://github.com/rust-lang/libc/pull/4324)) +- Cygwin: Fix tests ([#4357](https://github.com/rust-lang/libc/pull/4357)) +- Hermit: Make `AF_INET = 3` ([#4344](https://github.com/rust-lang/libc/pull/4344)) +- Musl: Fix the syscall table on RISC-V-32 ([#4335](https://github.com/rust-lang/libc/pull/4335)) +- Musl: Fix the value of `SA_ONSTACK` on RISC-V-32 ([#4335](https://github.com/rust-lang/libc/pull/4335)) +- VxWorks: Fix a typo in the `waitpid` parameter name ([#4334](https://github.com/rust-lang/libc/pull/4334)) + +### Removed + +- Musl: Remove `O_FSYNC` on RISC-V-32 (use `O_SYNC` instead) ([#4335](https://github.com/rust-lang/libc/pull/4335)) +- Musl: Remove `RTLD_DEEPBIND` on RISC-V-32 ([#4335](https://github.com/rust-lang/libc/pull/4335)) + +### Other + +- CI: Add matrix env variables to the environment ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- CI: Always deny warnings ([#4363](https://github.com/rust-lang/libc/pull/4363)) +- CI: Always upload successfully created artifacts ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- CI: Install musl from source for loongarch64 ([#4320](https://github.com/rust-lang/libc/pull/4320)) +- CI: Revert "Also skip `MFD_EXEC` and `MFD_NOEXEC_SEAL` on sparc64" ([#]()) +- CI: Use `$PWD` instead of `$(pwd)` in run-docker ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- Solarish: Restrict `openpty` and `forkpty` polyfills to Illumos, replace Solaris implementation with bindings ([#4329](https://github.com/rust-lang/libc/pull/4329)) +- Testing: Ensure the makedev test does not emit unused errors ([#4363](https://github.com/rust-lang/libc/pull/4363)) ## [0.2.171](https://github.com/rust-lang/libc/compare/0.2.170...0.2.171) - 2025-03-11 diff --git a/third_party/rust/libc/CONTRIBUTING.md b/third_party/rust/libc/CONTRIBUTING.md @@ -89,7 +89,7 @@ standard, it's just a list shared among all OSs that declare `#[cfg(unix)]`. We have two automated tests running on [GitHub Actions](https://github.com/rust-lang/libc/actions): -1. [`libc-test`](https://github.com/gnzlbg/ctest) +1. `libc-test` - `cd libc-test && cargo test` - Use the `skip_*()` functions in `build.rs` if you really need a workaround. 2. Style checker diff --git a/third_party/rust/libc/Cargo.lock b/third_party/rust/libc/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "libc" -version = "0.2.171" +version = "0.2.176" dependencies = [ "rustc-std-workspace-core", ] diff --git a/third_party/rust/libc/Cargo.toml b/third_party/rust/libc/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.63" name = "libc" -version = "0.2.171" +version = "0.2.176" authors = ["The Rust Project Developers"] build = "build.rs" exclude = [ @@ -27,11 +27,7 @@ autobins = false autoexamples = false autotests = false autobenches = false -description = """ -Raw FFI bindings to platform libraries like libc. -""" -homepage = "https://github.com/rust-lang/libc" -documentation = "https://docs.rs/libc/" +description = "Raw FFI bindings to platform libraries like libc." readme = "README.md" keywords = [ "libc", @@ -49,9 +45,8 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" [package.metadata.docs.rs] -cargo-args = ["-Zbuild-std=core"] -default-target = "x86_64-unknown-linux-gnu" features = ["extra_traits"] +default-target = "x86_64-unknown-linux-gnu" targets = [ "aarch64-apple-darwin", "aarch64-apple-ios", @@ -108,10 +103,12 @@ targets = [ "powerpc-unknown-netbsd", "powerpc-wrs-vxworks", "powerpc-wrs-vxworks-spe", + "powerpc64-ibm-aix", "powerpc64-unknown-freebsd", "powerpc64-unknown-linux-gnu", "powerpc64-wrs-vxworks", "powerpc64le-unknown-linux-gnu", + "powerpc64le-unknown-linux-musl", "riscv32gc-unknown-linux-gnu", "riscv32i-unknown-none-elf", "riscv32imac-unknown-none-elf", @@ -160,6 +157,7 @@ targets = [ "x86_64-unknown-redox", "x86_64-wrs-vxworks", ] +cargo-args = ["-Zbuild-std=core"] [features] align = [] @@ -182,5 +180,22 @@ name = "const_fn" path = "tests/const_fn.rs" [dependencies.rustc-std-workspace-core] -version = "1.0.0" +version = "1.0.1" optional = true + +[lints.clippy] +expl_impl_clone_on_copy = "allow" +explicit_iter_loop = "warn" +identity_op = "allow" +manual_assert = "warn" +map_unwrap_or = "warn" +missing_safety_doc = "allow" +non_minimal_cfg = "allow" +ptr_as_ptr = "warn" +uninlined_format_args = "allow" +unnecessary_cast = "allow" +unnecessary_semicolon = "warn" +used_underscore_binding = "allow" + +[lints.rust] +unused_qualifications = "allow" diff --git a/third_party/rust/libc/build.rs b/third_party/rust/libc/build.rs @@ -4,7 +4,7 @@ use std::{env, str}; // List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we // need to know all the possible cfgs that this script will set. If you need to set another cfg // make sure to add it to this list as well. -const ALLOWED_CFGS: &'static [&'static str] = &[ +const ALLOWED_CFGS: &[&str] = &[ "emscripten_old_stat_abi", "espidf_time32", "freebsd10", @@ -13,24 +13,29 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd13", "freebsd14", "freebsd15", - // FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn` - "libc_const_extern_fn", + // Corresponds to `_FILE_OFFSET_BITS=64` in glibc + "gnu_file_offset_bits64", + // Corresponds to `_TIME_BITS=64` in glibc + "gnu_time_bits64", "libc_deny_warnings", "libc_thread_local", - "libc_ctest", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", + "musl_v1_2_3", ]; // Extra values to allow for check-cfg. -const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[ +const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ( "target_os", &[ "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", ], ), - ("target_env", &["illumos", "wasi", "aix", "ohos"]), + ( + "target_env", + &["illumos", "wasi", "aix", "ohos", "nto71_iosock", "nto80"], + ), ( "target_arch", &["loongarch64", "mips32r6", "mips64r6", "csky"], @@ -44,9 +49,13 @@ fn main() { let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); + let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); // The ABI of libc used by std is backward compatible with FreeBSD 12. - // The ABI of libc from crates.io is backward compatible with FreeBSD 11. + // The ABI of libc from crates.io is backward compatible with FreeBSD 12. // // On CI, we detect the actual FreeBSD version and match its ABI exactly, // running tests to ensure that the ABI is correct. @@ -57,11 +66,9 @@ fn main() { println!("cargo:warning=setting FreeBSD version to {vers}"); vers } else if libc_ci { - which_freebsd().unwrap_or(11) - } else if rustc_dep_of_std { - 12 + which_freebsd().unwrap_or(12) } else { - 11 + 12 }; match which_freebsd { @@ -80,11 +87,56 @@ fn main() { _ => (), } + let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); + // loongarch64 and ohos have already updated + if musl_v1_2_3 || target_arch == "loongarch64" || target_env == "ohos" { + // FIXME(musl): enable time64 api as well + set_cfg("musl_v1_2_3"); + } let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); if linux_time_bits64 { set_cfg("linux_time_bits64"); } + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS"); + if target_env == "gnu" + && target_os == "linux" + && target_ptr_width == "32" + && target_arch != "riscv32" + && target_arch != "x86_64" + { + let defaultbits = "32".to_string(); + let (timebits, filebits) = match ( + env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), + env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + ) { + (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), + (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), + (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), + (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), + (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), + }; + let valid_bits = ["32", "64"]; + assert!( + valid_bits.contains(&filebits.as_str()) && valid_bits.contains(&timebits.as_str()), + "Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS or RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32, 64 or unset" + ); + assert!( + !(filebits == "32" && timebits == "64"), + "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS must be 64 or unset if RUST_LIBC_UNSTABLE_GNU_TIME_BITS is 64" + ); + if timebits == "64" { + set_cfg("linux_time_bits64"); + set_cfg("gnu_time_bits64"); + } + if filebits == "64" { + set_cfg("gnu_file_offset_bits64"); + } + } // On CI: deny all warnings if libc_ci { @@ -96,25 +148,22 @@ fn main() { set_cfg("libc_thread_local"); } - // Set unconditionally when ctest is not being invoked. - set_cfg("libc_const_extern_fn"); - // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to // avoid warnings. if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({})", cfg); + println!("cargo:rustc-check-cfg=cfg({cfg})"); } else { - println!("cargo:rustc-check-cfg=values({})", cfg); + println!("cargo:rustc-check-cfg=values({cfg})"); } } for &(name, values) in CHECK_CFG_EXTRA { let values = values.join("\",\""); if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({},values(\"{}\"))", name, values); + println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); } else { - println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values); + println!("cargo:rustc-check-cfg=values({name},\"{values}\")"); } } } @@ -143,12 +192,11 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output { let output = cmd.output().expect("Failed to get rustc version"); - if !output.status.success() { - panic!( - "failed to run rustc: {}", - String::from_utf8_lossy(output.stderr.as_slice()) - ); - } + assert!( + output.status.success(), + "failed to run rustc: {}", + String::from_utf8_lossy(output.stderr.as_slice()) + ); output } @@ -175,9 +223,11 @@ fn rustc_minor_nightly() -> (u32, bool) { let mut pieces = version.split('.'); - if pieces.next() != Some("rustc 1") { - panic!("Failed to get rustc version"); - } + assert_eq!( + pieces.next(), + Some("rustc 1"), + "Failed to get rustc version" + ); let minor = pieces.next(); @@ -187,9 +237,9 @@ fn rustc_minor_nightly() -> (u32, bool) { // since a nightly build should either come from CI // or a git checkout let nightly_raw = otry!(pieces.next()).split('-').nth(1); - let nightly = nightly_raw - .map(|raw| raw.starts_with("dev") || raw.starts_with("nightly")) - .unwrap_or(false); + let nightly = nightly_raw.map_or(false, |raw| { + raw.starts_with("dev") || raw.starts_with("nightly") + }); let minor = otry!(otry!(minor).parse().ok()); (minor, nightly) @@ -215,7 +265,13 @@ fn which_freebsd() -> Option<i32> { } fn emcc_version_code() -> Option<u64> { - let output = Command::new("emcc").arg("-dumpversion").output().ok()?; + let emcc = if cfg!(target_os = "windows") { + "emcc.bat" + } else { + "emcc" + }; + + let output = Command::new(emcc).arg("-dumpversion").output().ok()?; if !output.status.success() { return None; } @@ -234,8 +290,9 @@ fn emcc_version_code() -> Option<u64> { } fn set_cfg(cfg: &str) { - if !ALLOWED_CFGS.contains(&cfg) { - panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg); - } - println!("cargo:rustc-cfg={}", cfg); + assert!( + ALLOWED_CFGS.contains(&cfg), + "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS", + ); + println!("cargo:rustc-cfg={cfg}"); } diff --git a/third_party/rust/libc/src/fuchsia/mod.rs b/third_party/rust/libc/src/fuchsia/mod.rs @@ -80,7 +80,7 @@ pub type rlim_t = c_ulonglong; // FIXME(fuchsia): 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))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -88,7 +88,7 @@ impl Clone for timezone { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum DIR {} impl Copy for DIR {} impl Clone for DIR { @@ -97,7 +97,7 @@ impl Clone for DIR { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct impl Copy for fpos64_t {} impl Clone for fpos64_t { @@ -292,6 +292,8 @@ s! { __dummy4: [c_char; 16], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -1068,26 +1070,6 @@ cfg_if! { } } impl Eq for sysinfo {} - impl fmt::Debug for sysinfo { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("__reserved", &self.__reserved) - .finish() - } - } impl hash::Hash for sysinfo { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uptime.hash(state); @@ -1118,14 +1100,6 @@ cfg_if! { } } impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_family", &self.sun_family) - // FIXME(debug): .field("sun_path", &self.sun_path) - .finish() - } - } impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sun_family.hash(state); @@ -1145,15 +1119,6 @@ cfg_if! { } } impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_family", &self.ss_family) - .field("__ss_align", &self.__ss_align) - // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) - .finish() - } - } impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_family.hash(state); @@ -1191,17 +1156,6 @@ cfg_if! { } } impl Eq for utsname {} - impl fmt::Debug for utsname { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utsname") - // FIXME(debug): .field("sysname", &self.sysname) - // FIXME(debug): .field("nodename", &self.nodename) - // FIXME(debug): .field("release", &self.release) - // FIXME(debug): .field("version", &self.version) - // FIXME(debug): .field("machine", &self.machine) - .finish() - } - } impl hash::Hash for utsname { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sysname.hash(state); @@ -1226,17 +1180,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -1261,17 +1204,6 @@ cfg_if! { } } impl Eq for dirent64 {} - impl fmt::Debug for dirent64 { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } impl hash::Hash for dirent64 { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -1291,16 +1223,6 @@ cfg_if! { } } impl Eq for mq_attr {} - impl fmt::Debug for mq_attr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mq_attr") - .field("mq_flags", &self.mq_flags) - .field("mq_maxmsg", &self.mq_maxmsg) - .field("mq_msgsize", &self.mq_msgsize) - .field("mq_curmsgs", &self.mq_curmsgs) - .finish() - } - } impl hash::Hash for mq_attr { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mq_flags.hash(state); @@ -1318,15 +1240,6 @@ cfg_if! { } } impl Eq for sockaddr_nl {} - impl fmt::Debug for sockaddr_nl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_nl") - .field("nl_family", &self.nl_family) - .field("nl_pid", &self.nl_pid) - .field("nl_groups", &self.nl_groups) - .finish() - } - } impl hash::Hash for sockaddr_nl { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.nl_family.hash(state); @@ -1347,17 +1260,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_value", &self.sigev_value) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_notify", &self.sigev_notify) - .field("sigev_notify_function", &self.sigev_notify_function) - .field("sigev_notify_attributes", &self.sigev_notify_attributes) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_value.hash(state); @@ -1374,13 +1276,6 @@ cfg_if! { } } impl Eq for pthread_cond_t {} - impl fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_cond_t") - // FIXME(debug): .field("size", &self.size) - .finish() - } - } impl hash::Hash for pthread_cond_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -1393,13 +1288,6 @@ cfg_if! { } } impl Eq for pthread_mutex_t {} - impl fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_mutex_t") - // FIXME(debug): .field("size", &self.size) - .finish() - } - } impl hash::Hash for pthread_mutex_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -1412,13 +1300,6 @@ cfg_if! { } } impl Eq for pthread_rwlock_t {} - impl fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_rwlock_t") - // FIXME(debug): .field("size", &self.size) - .finish() - } - } impl hash::Hash for pthread_rwlock_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -1452,9 +1333,9 @@ pub const GRPQUOTA: c_int = 1; pub const SIGIOT: c_int = 6; -pub const S_ISUID: crate::mode_t = 0o4000; -pub const S_ISGID: crate::mode_t = 0o2000; -pub const S_ISVTX: crate::mode_t = 0o1000; +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; pub const IF_NAMESIZE: size_t = 16; pub const IFNAMSIZ: size_t = IF_NAMESIZE; @@ -1585,26 +1466,26 @@ pub const O_RDONLY: c_int = 0; pub const O_WRONLY: c_int = 1; pub const O_RDWR: c_int = 2; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IROTH: crate::mode_t = 0o0004; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; @@ -2427,7 +2308,7 @@ pub const ST_NOATIME: c_ulong = 1024; pub const ST_NODIRATIME: c_ulong = 2048; pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NODELETE: c_int = 0x1000; pub const RTLD_NOW: c_int = 0x2; @@ -2571,7 +2452,7 @@ pub const EFD_SEMAPHORE: c_int = 0x1; pub const LOG_NFACILITIES: c_int = 24; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32; pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32; @@ -3369,20 +3250,20 @@ cfg_if! { f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } @@ -3400,21 +3281,21 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } @@ -3428,74 +3309,74 @@ f! { } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { - if ((*cmsg).cmsg_len as size_t) < mem::size_of::<cmsghdr>() { - 0 as *mut cmsghdr - } else if __CMSG_NEXT(cmsg).add(mem::size_of::<cmsghdr>()) >= __MHDR_END(mhdr) { - 0 as *mut cmsghdr + if ((*cmsg).cmsg_len as size_t) < size_of::<cmsghdr>() { + core::ptr::null_mut::<cmsghdr>() + } else if __CMSG_NEXT(cmsg).add(size_of::<cmsghdr>()) >= __MHDR_END(mhdr) { + core::ptr::null_mut::<cmsghdr>() } else { __CMSG_NEXT(cmsg).cast() } } pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as size_t >= mem::size_of::<cmsghdr>() { + if (*mhdr).msg_controllen as size_t >= size_of::<cmsghdr>() { (*mhdr).msg_control.cast() } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } - pub {const} fn CMSG_ALIGN(len: size_t) -> size_t { - (len + mem::size_of::<size_t>() - 1) & !(mem::size_of::<size_t>() - 1) + pub const fn CMSG_ALIGN(len: size_t) -> size_t { + (len + size_of::<size_t>() - 1) & !(size_of::<size_t>() - 1) } - pub {const} fn CMSG_SPACE(len: c_uint) -> c_uint { - (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(mem::size_of::<cmsghdr>())) as c_uint + pub const fn CMSG_SPACE(len: c_uint) -> c_uint { + (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint } - pub {const} fn CMSG_LEN(len: c_uint) -> c_uint { - (CMSG_ALIGN(mem::size_of::<cmsghdr>()) + len as size_t) as c_uint + pub const fn CMSG_LEN(len: c_uint) -> c_uint { + (CMSG_ALIGN(size_of::<cmsghdr>()) + len as size_t) as c_uint } } safe_f! { - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0xffff } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0x7f) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } - pub {const} fn QCMD(cmd: c_int, type_: c_int) -> c_int { + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { (cmd << 8) | (type_ & 0x00ff) } - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -3506,14 +3387,14 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { let mut major = 0; major |= (dev & 0x00000000000fff00) >> 8; major |= (dev & 0xfffff00000000000) >> 32; major as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { let mut minor = 0; minor |= (dev & 0x00000000000000ff) >> 0; minor |= (dev & 0x00000ffffff00000) >> 12; @@ -3522,8 +3403,8 @@ safe_f! { } fn __CMSG_LEN(cmsg: *const cmsghdr) -> ssize_t { - ((unsafe { (*cmsg).cmsg_len as size_t } + mem::size_of::<c_long>() - 1) - & !(mem::size_of::<c_long>() - 1)) as ssize_t + ((unsafe { (*cmsg).cmsg_len as size_t } + size_of::<c_long>() - 1) & !(size_of::<c_long>() - 1)) + as ssize_t } fn __CMSG_NEXT(cmsg: *const cmsghdr) -> *mut c_uchar { @@ -3540,7 +3421,7 @@ fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar { #[link(name = "fdio")] extern "C" {} -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum FILE {} impl Copy for FILE {} impl Clone for FILE { @@ -3548,7 +3429,7 @@ impl Clone for FILE { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { @@ -3726,12 +3607,7 @@ extern "C" { pub fn rewinddir(dirp: *mut crate::DIR); pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; - pub fn fchmodat( - dirfd: c_int, - pathname: *const c_char, - mode: crate::mode_t, - flags: c_int, - ) -> c_int; + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; pub fn fchownat( dirfd: c_int, @@ -3748,7 +3624,7 @@ extern "C" { newpath: *const c_char, flags: c_int, ) -> c_int; - pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn readlinkat( dirfd: c_int, pathname: *const c_char, @@ -3966,7 +3842,7 @@ extern "C" { pub fn gmtime(time_p: *const time_t) -> *mut tm; pub fn localtime(time_p: *const time_t) -> *mut tm; - pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int; + pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; pub fn uname(buf: *mut crate::utsname) -> c_int; pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; @@ -4086,8 +3962,7 @@ extern "C" { pub fn fdopendir(fd: c_int) -> *mut crate::DIR; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, @@ -4214,7 +4089,7 @@ extern "C" { pub fn setfsuid(uid: crate::uid_t) -> c_int; // Not available now on Android - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; diff --git a/third_party/rust/libc/src/fuchsia/x86_64.rs b/third_party/rust/libc/src/fuchsia/x86_64.rs @@ -94,18 +94,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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) - // FIXME(debug): .field("__private", &self.__private) - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); diff --git a/third_party/rust/libc/src/hermit.rs b/third_party/rust/libc/src/hermit.rs @@ -114,8 +114,10 @@ s! { } } -pub const AF_INET: i32 = 0; +pub const AF_UNSPEC: i32 = 0; +pub const AF_INET: i32 = 3; pub const AF_INET6: i32 = 1; +pub const AF_VSOCK: i32 = 2; pub const CLOCK_REALTIME: clockid_t = 1; pub const CLOCK_MONOTONIC: clockid_t = 4; diff --git a/third_party/rust/libc/src/lib.rs b/third_party/rust/libc/src/lib.rs @@ -4,18 +4,24 @@ #![allow( renamed_and_removed_lints, // Keep this order. unknown_lints, // Keep this order. - bad_style, + nonstandard_style, overflowing_literals, - improper_ctypes, - // This lint is renamed but we run CI for old stable rustc so should be here. - redundant_semicolon, - redundant_semicolons, unused_macros, unused_macro_rules, - // FIXME(1.0): temporarily allow dead_code to fix CI: - // - https://github.com/rust-lang/libc/issues/3740 - // - https://github.com/rust-lang/rust/pull/126456 - dead_code, +)] +#![warn( + missing_copy_implementations, + missing_debug_implementations, + safe_packed_borrows +)] +// Prepare for a future upgrade +#![warn(rust_2024_compatibility)] +// Things missing for 2024 that are blocked on MSRV or breakage +#![allow( + missing_unsafe_on_extern, + edition_2024_expr_fragment_specifier, + // Allowed globally, the warning is enabled in individual modules as we work through them + unsafe_op_in_unsafe_fn )] #![cfg_attr(libc_deny_warnings, deny(warnings))] // Attributes needed when building as part of the standard library @@ -24,14 +30,12 @@ #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))] // DIFF(1.0): The thread local references that raise this lint were removed in 1.0 #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))] -// Enable extra lints: -#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] -#![deny(missing_copy_implementations, safe_packed_borrows)] #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #[macro_use] mod macros; +mod new; cfg_if! { if #[cfg(feature = "rustc-dep-of-std")] { @@ -41,6 +45,9 @@ cfg_if! { pub use core::ffi::c_void; +#[allow(unused_imports)] // needed while the module is empty on some platforms +pub use new::*; + cfg_if! { if #[cfg(windows)] { mod primitives; diff --git a/third_party/rust/libc/src/macros.rs b/third_party/rust/libc/src/macros.rs @@ -64,20 +64,33 @@ macro_rules! cfg_if { /// Create an internal crate prelude with `core` reexports and common types. macro_rules! prelude { () => { + mod types; + /// Frequently-used types that are available on all platforms /// /// We need to reexport the core types so this works with `rust-dep-of-std`. mod prelude { // Exports from `core` #[allow(unused_imports)] - pub(crate) use ::core::clone::Clone; + pub(crate) use core::clone::Clone; + #[allow(unused_imports)] + pub(crate) use core::default::Default; + #[allow(unused_imports)] + pub(crate) use core::marker::{Copy, Send, Sync}; + #[allow(unused_imports)] + pub(crate) use core::option::Option; #[allow(unused_imports)] - pub(crate) use ::core::marker::{Copy, Send, Sync}; + pub(crate) use core::prelude::v1::derive; #[allow(unused_imports)] - pub(crate) use ::core::option::Option; + pub(crate) use core::{fmt, hash, iter, mem, ptr}; + + #[allow(unused_imports)] + pub(crate) use fmt::Debug; #[allow(unused_imports)] - pub(crate) use ::core::{fmt, hash, iter, mem}; + pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; + #[allow(unused_imports)] + pub(crate) use crate::types::{CEnumRepr, Padding}; // Commonly used types defined in this crate #[allow(unused_imports)] pub(crate) use crate::{ @@ -110,9 +123,13 @@ macro_rules! s { #[repr(C)] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq) + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, )] - #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] #[allow(deprecated)] $(#[$attr])* pub struct $i { $($field)* } @@ -132,16 +149,21 @@ macro_rules! s_paren { __item! { #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq) + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, )] - #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] $(#[$attr])* pub struct $i ( $($field)* ); } )*); } -/// Implement `Clone` and `Copy` for a struct with no `extra_traits` feature. +/// Implement `Clone`, `Copy`, and `Debug` since those can be derived, but exclude `PartialEq`, +/// `Eq`, and `Hash`. /// /// Most items will prefer to use [`s`]. macro_rules! s_no_extra_traits { @@ -160,7 +182,6 @@ macro_rules! s_no_extra_traits { pub union $i { $($field)* } } - #[cfg(feature = "extra_traits")] impl ::core::fmt::Debug for $i { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { f.debug_struct(::core::stringify!($i)).finish_non_exhaustive() @@ -171,7 +192,11 @@ macro_rules! s_no_extra_traits { (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] - #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] $(#[$attr])* pub struct $i { $($field)* } } @@ -193,6 +218,7 @@ macro_rules! missing { /// Implement `Clone` and `Copy` for an enum, as well as `Debug`, `Eq`, `Hash`, and /// `PartialEq` if the `extra_traits` feature is enabled. +// FIXME(#4419): Replace all uses of `e!` with `c_enum!` macro_rules! e { ($( $(#[$attr:meta])* @@ -201,123 +227,107 @@ macro_rules! e { __item! { #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq) + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, )] - #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] $(#[$attr])* pub enum $i { $($field)* } } )*); } -// This is a pretty horrible hack to allow us to conditionally mark some functions as 'const', -// without requiring users of this macro to care "libc_const_extern_fn". -// -// When 'libc_const_extern_fn' is enabled, we emit the captured 'const' keyword in the expanded -// function. -// -// When 'libc_const_extern_fn' is disabled, we always emit a plain 'pub unsafe extern fn'. -// Note that the expression matched by the macro is exactly the same - this allows -// users of this macro to work whether or not 'libc_const_extern_fn' is enabled -// -// Unfortunately, we need to duplicate most of this macro between the 'cfg_if' blocks. -// This is because 'const unsafe extern fn' won't even parse on older compilers, -// so we need to avoid emitting it at all of 'libc_const_extern_fn'. -// -// Specifically, moving the 'cfg_if' into the macro body will *not* work. Doing so would cause the -// '#[cfg(libc_const_extern_fn)]' to be emitted into user code. The 'cfg' gate will not stop Rust -// from trying to parse the 'pub const unsafe extern fn', so users would get a compiler error even -// when the 'libc_const_extern_fn' feature is disabled. - -// FIXME(ctest): ctest can't handle `const extern` functions, we should be able to remove this -// cfg completely. -// FIXME(ctest): ctest can't handle `$(,)?` so we use `$(,)*` which isn't quite correct. -cfg_if! { - if #[cfg(libc_const_extern_fn)] { - /// Define an `unsafe` function that is const as long as `libc_const_extern_fn` is enabled. - macro_rules! f { - ($( - $(#[$attr:meta])* - pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty - $body:block - )*) => ($( - #[inline] - $(#[$attr])* - pub $($constness)* unsafe extern "C" fn $i($($arg: $argty),*) -> $ret - $body - )*) +/// Represent a C enum as Rust constants and a type. +/// +/// C enums can't soundly be mapped to Rust enums since C enums are allowed to have duplicates or +/// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main +/// purpose is to calculate the correct enum values. +/// +/// See <https://github.com/rust-lang/libc/issues/4419> for more. +macro_rules! c_enum { + ($( + $(#[repr($repr:ty)])? + pub enum $ty_name:ident { + $($variant:ident $(= $value:expr)?,)+ } + )+) => { + $(c_enum!(@expand; + $(#[repr($repr)])? + pub enum $ty_name { + $($variant $(= $value)?,)+ + } + );)+ + }; - /// Define a safe function that is const as long as `libc_const_extern_fn` is enabled. - macro_rules! safe_f { - ($( - $(#[$attr:meta])* - pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty - $body:block - )*) => ($( - #[inline] - $(#[$attr])* - pub $($constness)* extern "C" fn $i($($arg: $argty),*) -> $ret - $body - )*) + (@expand; + $(#[repr($repr:ty)])? + pub enum $ty_name:ident { + $($variant:ident $(= $value:expr)?,)+ } + ) => { + pub type $ty_name = c_enum!(@ty $($repr)?); + c_enum!(@one; $ty_name; 0; $($variant $(= $value)?,)+); + }; - /// A nonpublic function that is const as long as `libc_const_extern_fn` is enabled. - macro_rules! const_fn { - ($( - $(#[$attr:meta])* - $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty - $body:block - )*) => ($( - #[inline] - $(#[$attr])* - $($constness)* fn $i($($arg: $argty),*) -> $ret - $body - )*) - } - } else { - /// Define an `unsafe` function that is const as long as `libc_const_extern_fn` is enabled. - macro_rules! f { - ($( - $(#[$attr:meta])* - pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty - $body:block - )*) => ($( - #[inline] - $(#[$attr])* - pub unsafe extern "C" fn $i($($arg: $argty),*) -> $ret - $body - )*) - } + // Matcher for a single variant + (@one; $_ty_name:ident; $_idx:expr;) => {}; + ( + @one; $ty_name:ident; $default_val:expr; + $variant:ident $(= $value:expr)?, + $($tail:tt)* + ) => { + pub const $variant: $ty_name = { + #[allow(unused_variables)] + let r = $default_val; + $(let r = $value;)? + r + }; - /// Define a safe function that is const as long as `libc_const_extern_fn` is enabled. - macro_rules! safe_f { - ($( - $(#[$attr:meta])* - pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty - $body:block - )*) => ($( - #[inline] - $(#[$attr])* - pub extern "C" fn $i($($arg: $argty),*) -> $ret - $body - )*) - } + // The next value is always one more than the previous value, unless + // set explicitly. + c_enum!(@one; $ty_name; $variant + 1; $($tail)*); + }; - /// A nonpublic function that is const as long as `libc_const_extern_fn` is enabled. - macro_rules! const_fn { - ($( - $(#[$attr:meta])* - $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty - $body:block - )*) => ($( - #[inline] - $(#[$attr])* - fn $i($($arg: $argty),*) -> $ret - $body - )*) - } - } + // Use a specific type if provided, otherwise default to `CEnumRepr` + (@ty $repr:ty) => { $repr }; + (@ty) => { $crate::prelude::CEnumRepr }; +} + +/// Define a `unsafe` function. +macro_rules! f { + ($( + $(#[$attr:meta])* + // Less than ideal hack to match either `fn` or `const fn`. + pub $(fn $i:ident)? $(const fn $const_i:ident)? + ($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty + $body:block + )+) => {$( + #[inline] + $(#[$attr])* + pub $(unsafe extern "C" fn $i)? $(const unsafe extern "C" fn $const_i)? + ($($arg: $argty),*) -> $ret + $body + )+}; +} + +/// Define a safe function. +macro_rules! safe_f { + ($( + $(#[$attr:meta])* + // Less than ideal hack to match either `fn` or `const fn`. + pub $(fn $i:ident)? $(const fn $const_i:ident)? + ($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty + $body:block + )+) => {$( + #[inline] + $(#[$attr])* + pub $(extern "C" fn $i)? $(const extern "C" fn $const_i)? + ($($arg: $argty),*) -> $ret + $body + )+}; } macro_rules! __item { @@ -359,3 +369,78 @@ macro_rules! deprecated_mach { )* } } + +#[cfg(test)] +mod tests { + use crate::types::CEnumRepr; + + #[test] + fn c_enumbasic() { + // By default, variants get sequential values. + c_enum! { + pub enum e { + VAR0, + VAR1, + VAR2, + } + } + + assert_eq!(VAR0, 0 as CEnumRepr); + assert_eq!(VAR1, 1 as CEnumRepr); + assert_eq!(VAR2, 2 as CEnumRepr); + } + + #[test] + fn c_enumrepr() { + // By default, variants get sequential values. + c_enum! { + #[repr(u16)] + pub enum e { + VAR0, + } + } + + assert_eq!(VAR0, 0_u16); + } + + #[test] + fn c_enumset_value() { + // Setting an explicit value resets the count. + c_enum! { + pub enum e { + VAR2 = 2, + VAR3, + VAR4, + } + } + + assert_eq!(VAR2, 2 as CEnumRepr); + assert_eq!(VAR3, 3 as CEnumRepr); + assert_eq!(VAR4, 4 as CEnumRepr); + } + + #[test] + fn c_enummultiple_set_value() { + // C enums always take one more than the previous value, unless set to a specific + // value. Duplicates are allowed. + c_enum! { + pub enum e { + VAR0, + VAR2_0 = 2, + VAR3_0, + VAR4_0, + VAR2_1 = 2, + VAR3_1, + VAR4_1, + } + } + + assert_eq!(VAR0, 0 as CEnumRepr); + assert_eq!(VAR2_0, 2 as CEnumRepr); + assert_eq!(VAR3_0, 3 as CEnumRepr); + assert_eq!(VAR4_0, 4 as CEnumRepr); + assert_eq!(VAR2_1, 2 as CEnumRepr); + assert_eq!(VAR3_1, 3 as CEnumRepr); + assert_eq!(VAR4_1, 4 as CEnumRepr); + } +} diff --git a/third_party/rust/libc/src/new/bionic/mod.rs b/third_party/rust/libc/src/new/bionic/mod.rs @@ -0,0 +1,2 @@ +mod sys; +pub use sys::*; diff --git a/third_party/rust/libc/src/new/bionic/sys/mod.rs b/third_party/rust/libc/src/new/bionic/sys/mod.rs @@ -0,0 +1,2 @@ +mod socket; +pub use socket::*; diff --git a/third_party/rust/libc/src/new/bionic/sys/socket.rs b/third_party/rust/libc/src/new/bionic/sys/socket.rs @@ -0,0 +1,51 @@ +//! Header: `bionic/libc/include/sys/socket.h` + +use crate::prelude::*; + +s! { + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct ucred { + pub pid: crate::pid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } +} + +extern "C" { + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sendmmsg( + sockfd: c_int, + msgvec: *const crate::mmsghdr, + vlen: c_uint, + flags: c_int, + ) -> c_int; + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; +} diff --git a/third_party/rust/libc/src/new/linux_uapi/linux/can.rs b/third_party/rust/libc/src/new/linux_uapi/linux/can.rs @@ -0,0 +1,136 @@ +//! Header: `uapi/linux/can.h` + +pub(crate) mod j1939; +pub(crate) mod raw; + +pub use j1939::*; +pub use raw::*; + +use crate::prelude::*; + +pub const CAN_EFF_FLAG: canid_t = 0x80000000; +pub const CAN_RTR_FLAG: canid_t = 0x40000000; +pub const CAN_ERR_FLAG: canid_t = 0x20000000; + +pub const CAN_SFF_MASK: canid_t = 0x000007FF; +pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF; +pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF; +pub const CANXL_PRIO_MASK: crate::canid_t = CAN_SFF_MASK; + +pub type canid_t = u32; + +pub const CAN_SFF_ID_BITS: c_int = 11; +pub const CAN_EFF_ID_BITS: c_int = 29; +pub const CANXL_PRIO_BITS: c_int = CAN_SFF_ID_BITS; + +pub type can_err_mask_t = u32; + +pub const CAN_MAX_DLC: c_int = 8; +pub const CAN_MAX_DLEN: usize = 8; + +pub const CANFD_MAX_DLC: c_int = 15; +pub const CANFD_MAX_DLEN: usize = 64; + +pub const CANXL_MIN_DLC: c_int = 0; +pub const CANXL_MAX_DLC: c_int = 2047; +pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; +pub const CANXL_MIN_DLEN: usize = 1; +pub const CANXL_MAX_DLEN: usize = 2048; + +s! { + #[repr(align(8))] + pub struct can_frame { + pub can_id: canid_t, + // FIXME(1.0): this field was renamed to `len` in Linux 5.11 + pub can_dlc: u8, + __pad: u8, + __res0: u8, + pub len8_dlc: u8, + pub data: [u8; CAN_MAX_DLEN], + } +} + +pub const CANFD_BRS: c_int = 0x01; +pub const CANFD_ESI: c_int = 0x02; +pub const CANFD_FDF: c_int = 0x04; + +s! { + #[repr(align(8))] + pub struct canfd_frame { + pub can_id: canid_t, + pub len: u8, + pub flags: u8, + __res0: u8, + __res1: u8, + pub data: [u8; CANFD_MAX_DLEN], + } +} + +pub const CANXL_XLF: c_int = 0x80; +pub const CANXL_SEC: c_int = 0x01; + +s! { + #[repr(align(8))] + pub struct canxl_frame { + pub prio: canid_t, + pub flags: u8, + pub sdt: u8, + pub len: u16, + pub af: u32, + pub data: [u8; CANXL_MAX_DLEN], + } +} + +pub const CAN_MTU: usize = size_of::<can_frame>(); +pub const CANFD_MTU: usize = size_of::<canfd_frame>(); +pub const CANXL_MTU: usize = size_of::<canxl_frame>(); +// FIXME(offset_of): use `core::mem::offset_of!` once that is available +// https://github.com/rust-lang/rfcs/pull/3308 +// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); +pub const CANXL_HDR_SIZE: usize = 12; +pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; +pub const CANXL_MAX_MTU: usize = CANXL_MTU; + +pub const CAN_RAW: c_int = 1; +pub const CAN_BCM: c_int = 2; +pub const CAN_TP16: c_int = 3; +pub const CAN_TP20: c_int = 4; +pub const CAN_MCNET: c_int = 5; +pub const CAN_ISOTP: c_int = 6; +pub const CAN_J1939: c_int = 7; +pub const CAN_NPROTO: c_int = 8; + +pub const SOL_CAN_BASE: c_int = 100; + +s_no_extra_traits! { + pub struct sockaddr_can { + pub can_family: crate::sa_family_t, + pub can_ifindex: c_int, + pub can_addr: __c_anonymous_sockaddr_can_can_addr, + } + + pub union __c_anonymous_sockaddr_can_can_addr { + pub tp: __c_anonymous_sockaddr_can_tp, + pub j1939: __c_anonymous_sockaddr_can_j1939, + } +} + +s! { + pub struct __c_anonymous_sockaddr_can_tp { + pub rx_id: canid_t, + pub tx_id: canid_t, + } + + pub struct __c_anonymous_sockaddr_can_j1939 { + pub name: u64, + pub pgn: u32, + pub addr: u8, + } + + pub struct can_filter { + pub can_id: canid_t, + pub can_mask: canid_t, + } +} + +pub const CAN_INV_FILTER: canid_t = 0x20000000; diff --git a/third_party/rust/libc/src/new/linux_uapi/linux/can/j1939.rs b/third_party/rust/libc/src/new/linux_uapi/linux/can/j1939.rs @@ -0,0 +1,60 @@ +//! `linux/can/j1939.h` + +pub use crate::linux::can::*; + +pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd; +pub const J1939_IDLE_ADDR: c_uchar = 0xfe; +pub const J1939_NO_ADDR: c_uchar = 0xff; +pub const J1939_NO_NAME: c_ulong = 0; +pub const J1939_PGN_REQUEST: c_uint = 0x0ea00; +pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00; +pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8; +pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00; +pub const J1939_PGN_MAX: c_uint = 0x3ffff; +pub const J1939_NO_PGN: c_uint = 0x40000; + +pub type pgn_t = u32; +pub type priority_t = u8; +pub type name_t = u64; + +pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939; + +// FIXME(cleanup): these could use c_enum if it can accept anonymous enums. + +pub const SO_J1939_FILTER: c_int = 1; +pub const SO_J1939_PROMISC: c_int = 2; +pub const SO_J1939_SEND_PRIO: c_int = 3; +pub const SO_J1939_ERRQUEUE: c_int = 4; + +pub const SCM_J1939_DEST_ADDR: c_int = 1; +pub const SCM_J1939_DEST_NAME: c_int = 2; +pub const SCM_J1939_PRIO: c_int = 3; +pub const SCM_J1939_ERRQUEUE: c_int = 4; + +pub const J1939_NLA_PAD: c_int = 0; +pub const J1939_NLA_BYTES_ACKED: c_int = 1; +pub const J1939_NLA_TOTAL_SIZE: c_int = 2; +pub const J1939_NLA_PGN: c_int = 3; +pub const J1939_NLA_SRC_NAME: c_int = 4; +pub const J1939_NLA_DEST_NAME: c_int = 5; +pub const J1939_NLA_SRC_ADDR: c_int = 6; +pub const J1939_NLA_DEST_ADDR: c_int = 7; + +pub const J1939_EE_INFO_NONE: c_int = 0; +pub const J1939_EE_INFO_TX_ABORT: c_int = 1; +pub const J1939_EE_INFO_RX_RTS: c_int = 2; +pub const J1939_EE_INFO_RX_DPO: c_int = 3; +pub const J1939_EE_INFO_RX_ABORT: c_int = 4; + +s! { + pub struct j1939_filter { + pub name: name_t, + pub name_mask: name_t, + pub pgn: pgn_t, + pub pgn_mask: pgn_t, + pub addr: u8, + pub addr_mask: u8, + } +} + +pub const J1939_FILTER_MAX: c_int = 512; diff --git a/third_party/rust/libc/src/new/linux_uapi/linux/can/raw.rs b/third_party/rust/libc/src/new/linux_uapi/linux/can/raw.rs @@ -0,0 +1,15 @@ +//! `linux/can/raw.h` + +pub use crate::linux::can::*; + +pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW; +pub const CAN_RAW_FILTER_MAX: c_int = 512; + +// FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type. +pub const CAN_RAW_FILTER: c_int = 1; +pub const CAN_RAW_ERR_FILTER: c_int = 2; +pub const CAN_RAW_LOOPBACK: c_int = 3; +pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4; +pub const CAN_RAW_FD_FRAMES: c_int = 5; +pub const CAN_RAW_JOIN_FILTERS: c_int = 6; +pub const CAN_RAW_XL_FRAMES: c_int = 7; diff --git a/third_party/rust/libc/src/new/linux_uapi/linux/mod.rs b/third_party/rust/libc/src/new/linux_uapi/linux/mod.rs @@ -0,0 +1,4 @@ +//! The `linux` directory within `include/uapi` in the Linux source tree. + +pub(crate) mod can; +pub use can::*; diff --git a/third_party/rust/libc/src/new/linux_uapi/mod.rs b/third_party/rust/libc/src/new/linux_uapi/mod.rs @@ -0,0 +1,4 @@ +//! This directory maps to `include/uapi` in the Linux source tree. + +pub(crate) mod linux; +pub use linux::*; diff --git a/third_party/rust/libc/src/new/mod.rs b/third_party/rust/libc/src/new/mod.rs @@ -0,0 +1,15 @@ +//! This module contains the future directory structure. If possible, new definitions should +//! get added here. +//! +//! Eventually everything should be moved over, and we will move this directory to the top +//! level in `src`. + +cfg_if! { + if #[cfg(target_os = "linux")] { + mod linux_uapi; + pub use linux_uapi::*; + } else if #[cfg(target_os = "android")] { + mod bionic; + pub use bionic::*; + } +} diff --git a/third_party/rust/libc/src/primitives.rs b/third_party/rust/libc/src/primitives.rs @@ -20,14 +20,7 @@ pub type c_double = f64; cfg_if! { if #[cfg(all( not(windows), - // FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it - not(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", - )), + not(target_vendor = "apple"), not(target_os = "vita"), any( target_arch = "aarch64", @@ -90,35 +83,6 @@ pub type uint64_t = u64; cfg_if! { if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { - // This introduces partial support for FFI with __int128 and - // equivalent types on platforms where Rust's definition is validated - // to match the standard C ABI of that platform. - // - // Rust does not guarantee u128/i128 are sound for FFI, and its - // definitions are in fact known to be incompatible. [0] - // - // However these problems aren't fundamental, and are just platform - // inconsistencies. Specifically at the time of this writing: - // - // * For x64 SysV ABIs (everything but Windows), the types are underaligned. - // * For all Windows ABIs, Microsoft doesn't actually officially define __int128, - // and as a result different implementations don't actually agree on its ABI. - // - // But on the other major aarch64 platforms (android, linux, ios, macos) we have - // validated that rustc has the right ABI for these types. This is important because - // aarch64 uses these types in some fundamental OS types like user_fpsimd_struct, - // which represents saved simd registers. - // - // Any API which uses these types will need to `#[ignore(improper_ctypes)]` - // until the upstream rust issue is resolved, but this at least lets us make - // progress on platforms where this type is important. - // - // The list of supported architectures and OSes is intentionally very restricted, - // as careful work needs to be done to verify that a particular platform - // has a conformant ABI. - // - // [0]: https://github.com/rust-lang/rust/issues/54341 - /// C `__int128` (a GCC extension that's part of many ABIs) pub type __int128 = i128; /// C `unsigned __int128` (a GCC extension that's part of many ABIs) @@ -127,40 +91,5 @@ cfg_if! { pub type __int128_t = i128; /// C __uint128_t (alternate name for [__uint128][]) pub type __uint128_t = u128; - - // NOTE: if you add more platforms to here, you may need to cfg - // these consts. They should always match the platform's values - // for `sizeof(__int128)` and `_Alignof(__int128)`. - const _SIZE_128: usize = 16; - const _ALIGN_128: usize = 16; - - // FIXME(ctest): ctest doesn't handle `_` as an identifier so these tests are temporarily - // disabled. - // macro_rules! static_assert_eq { - // ($a:expr, $b:expr) => { - // const _: [(); $a] = [(); $b]; - // }; - // } - // - // // Since Rust doesn't officially guarantee that these types - // // have compatible ABIs, we const assert that these values have the - // // known size/align of the target platform's libc. If rustc ever - // // tries to regress things, it will cause a compilation error. - // // - // // This isn't a bullet-proof solution because e.g. it doesn't - // // catch the fact that llvm and gcc disagree on how x64 __int128 - // // is actually *passed* on the stack (clang underaligns it for - // // the same reason that rustc *never* properly aligns it). - // static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128); - - // static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128); - - // static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128); - - // static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); } } diff --git a/third_party/rust/libc/src/psp.rs b/third_party/rust/libc/src/psp.rs @@ -1415,6 +1415,8 @@ s! { pub stack: [u32; 8], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct GeCallbackData { pub signal_func: Option<extern "C" fn(id: i32, arg: *mut c_void)>, pub signal_arg: *mut c_void, @@ -1537,6 +1539,8 @@ s! { pub stack_mpid: SceUid, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct SceKernelThreadInfo { pub size: usize, pub name: [u8; 32], @@ -1611,6 +1615,8 @@ s! { pub first_message: *mut c_void, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct SceKernelVTimerInfo { pub size: usize, pub name: [u8; 32], @@ -1622,6 +1628,8 @@ s! { pub common: *mut c_void, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct SceKernelThreadEventHandlerInfo { pub size: usize, pub name: [u8; 32], @@ -1631,6 +1639,8 @@ s! { pub common: *mut c_void, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct SceKernelAlarmInfo { pub size: usize, pub schedule: SceKernelSysClock, @@ -1688,6 +1698,8 @@ s! { pub size: usize, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct SceKernelCallbackInfo { pub size: usize, pub name: [u8; 32usize], @@ -1787,6 +1799,8 @@ s! { pub type_: UmdType, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct SceMpegRingbuffer { pub packets: i32, pub unk0: u32, @@ -2115,12 +2129,10 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct GeContext { pub context: [u32; 512], } - #[allow(missing_debug_implementations)] pub struct SceKernelUtilsSha1Context { pub h: [u32; 5usize], pub us_remains: u16, @@ -2129,13 +2141,11 @@ s_no_extra_traits! { pub buf: [u8; 64usize], } - #[allow(missing_debug_implementations)] pub struct SceKernelUtilsMt19937Context { pub count: u32, pub state: [u32; 624usize], } - #[allow(missing_debug_implementations)] pub struct SceKernelUtilsMd5Context { pub h: [u32; 4usize], pub pad: u32, @@ -2145,7 +2155,6 @@ s_no_extra_traits! { pub buf: [u8; 64usize], } - #[allow(missing_debug_implementations)] pub struct SceIoDirent { pub d_stat: SceIoStat, pub d_name: [u8; 256usize], @@ -2153,7 +2162,6 @@ s_no_extra_traits! { pub dummy: i32, } - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct ScePspFRect { pub x: f32, pub y: f32, @@ -2162,7 +2170,6 @@ s_no_extra_traits! { } #[repr(align(16))] - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct ScePspFVector3 { pub x: f32, pub y: f32, @@ -2170,7 +2177,6 @@ s_no_extra_traits! { } #[repr(align(16))] - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct ScePspFVector4 { pub x: f32, pub y: f32, @@ -2178,7 +2184,6 @@ s_no_extra_traits! { pub w: f32, } - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct ScePspFVector4Unaligned { pub x: f32, pub y: f32, @@ -2186,26 +2191,22 @@ s_no_extra_traits! { pub w: f32, } - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct ScePspFVector2 { pub x: f32, pub y: f32, } - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct ScePspFMatrix2 { pub x: ScePspFVector2, pub y: ScePspFVector2, } - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct ScePspFMatrix3 { pub x: ScePspFVector3, pub y: ScePspFVector3, pub z: ScePspFVector3, } - #[cfg_attr(feature = "extra_traits", derive(Debug))] #[repr(align(16))] pub struct ScePspFMatrix4 { pub x: ScePspFVector4, @@ -2214,7 +2215,6 @@ s_no_extra_traits! { pub w: ScePspFVector4, } - #[allow(missing_debug_implementations)] pub struct ScePspFMatrix4Unaligned { pub x: ScePspFVector4, pub y: ScePspFVector4, @@ -2222,7 +2222,6 @@ s_no_extra_traits! { pub w: ScePspFVector4, } - #[allow(missing_debug_implementations)] pub union ScePspVector3 { pub fv: ScePspFVector3, pub iv: ScePspIVector3, @@ -2230,7 +2229,6 @@ s_no_extra_traits! { pub i: [i32; 3usize], } - #[allow(missing_debug_implementations)] pub union ScePspVector4 { pub fv: ScePspFVector4, pub iv: ScePspIVector4, @@ -2239,7 +2237,6 @@ s_no_extra_traits! { pub i: [i32; 4usize], } - #[allow(missing_debug_implementations)] pub union ScePspMatrix2 { pub fm: ScePspFMatrix2, pub im: ScePspIMatrix2, @@ -2250,7 +2247,6 @@ s_no_extra_traits! { pub i: [[i32; 2usize]; 2usize], } - #[allow(missing_debug_implementations)] pub union ScePspMatrix3 { pub fm: ScePspFMatrix3, pub im: ScePspIMatrix3, @@ -2261,7 +2257,6 @@ s_no_extra_traits! { pub i: [[i32; 3usize]; 3usize], } - #[allow(missing_debug_implementations)] pub union ScePspVector2 { pub fv: ScePspFVector2, pub iv: ScePspIVector2, @@ -2269,7 +2264,6 @@ s_no_extra_traits! { pub i: [i32; 2usize], } - #[allow(missing_debug_implementations)] pub union ScePspMatrix4 { pub fm: ScePspFMatrix4, pub im: ScePspIMatrix4, @@ -2280,7 +2274,6 @@ s_no_extra_traits! { pub i: [[i32; 4usize]; 4usize], } - #[allow(missing_debug_implementations)] pub struct Key { pub key_type: KeyType, pub name: [u8; 256usize], @@ -2289,7 +2282,6 @@ s_no_extra_traits! { pub unk3: u32, } - #[allow(missing_debug_implementations)] pub struct UtilityMsgDialogParams { pub base: UtilityDialogCommon, pub unknown: i32, @@ -2300,13 +2292,11 @@ s_no_extra_traits! { pub button_pressed: UtilityMsgDialogPressed, } - #[allow(missing_debug_implementations)] pub union UtilityNetData { pub as_uint: u32, pub as_string: [u8; 128usize], } - #[allow(missing_debug_implementations)] pub struct UtilitySavedataSFOParam { pub title: [u8; 128usize], pub savedata_title: [u8; 128usize], @@ -2315,7 +2305,6 @@ s_no_extra_traits! { pub unknown: [u8; 3usize], } - #[allow(missing_debug_implementations)] pub struct SceUtilitySavedataParam { pub base: UtilityDialogCommon, pub mode: UtilitySavedataMode, @@ -2342,7 +2331,6 @@ s_no_extra_traits! { pub unknown3: [u8; 20], } - #[allow(missing_debug_implementations)] pub struct SceNetAdhocctlPeerInfo { pub next: *mut SceNetAdhocctlPeerInfo, pub nickname: [u8; 128usize], @@ -2351,7 +2339,6 @@ s_no_extra_traits! { pub timestamp: u32, } - #[allow(missing_debug_implementations)] pub struct SceNetAdhocctlParams { pub channel: i32, pub name: [u8; 8usize], @@ -2359,7 +2346,6 @@ s_no_extra_traits! { pub nickname: [u8; 128usize], } - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub union SceNetApctlInfo { pub name: [u8; 64usize], pub bssid: [u8; 6usize], @@ -3285,18 +3271,18 @@ extern "C" { pub fn sceRtcGetWin32FileTime(date: *mut ScePspDateTime, time: *mut u64) -> i32; pub fn sceRtcParseDateTime(dest_tick: *mut u64, date_string: *const u8) -> i32; pub fn sceRtcFormatRFC3339( - psz_date_time: *mut char, + psz_date_time: *mut c_char, p_utc: *const u64, time_zone_minutes: i32, ) -> i32; - pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32; + pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; pub fn sceRtcParseRFC3339(p_utc: *mut u64, psz_date_time: *const u8) -> i32; pub fn sceRtcFormatRFC2822( - psz_date_time: *mut char, + psz_date_time: *mut c_char, p_utc: *const u64, time_zone_minutes: i32, ) -> i32; - pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32; + pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; pub fn sceIoOpen(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; pub fn sceIoOpenAsync(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; diff --git a/third_party/rust/libc/src/solid/mod.rs b/third_party/rust/libc/src/solid/mod.rs @@ -395,7 +395,7 @@ pub const SIGUSR1: c_int = 30; pub const SIGUSR2: c_int = 31; pub const SIGPWR: c_int = 32; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum FILE {} impl Copy for FILE {} impl Clone for FILE { @@ -403,7 +403,7 @@ impl Clone for FILE { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum fpos_t {} impl Copy for fpos_t {} impl Clone for fpos_t { diff --git a/third_party/rust/libc/src/teeos/mod.rs b/third_party/rust/libc/src/teeos/mod.rs @@ -99,7 +99,7 @@ pub struct pthread_attr_t { #[repr(C)] pub struct cpu_set_t { - bits: [c_ulong; 128 / core::mem::size_of::<c_ulong>()], + bits: [c_ulong; 128 / size_of::<c_ulong>()], } #[repr(C)] @@ -137,7 +137,7 @@ pub struct mbstate_t { #[repr(C)] pub struct sem_t { - pub __val: [c_int; 4 * core::mem::size_of::<c_long>() / core::mem::size_of::<c_int>()], + pub __val: [c_int; 4 * size_of::<c_long>() / size_of::<c_int>()], } #[repr(C)] @@ -1342,7 +1342,7 @@ pub fn errno() -> c_int { pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = core::mem::size_of_val(&cpuset.bits[0]); + let size_of_mask = size_of_val(&cpuset.bits[0]); for i in cpuset.bits[..(size / size_of_mask)].iter() { s += i.count_ones(); @@ -1351,5 +1351,5 @@ pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(core::mem::size_of::<cpu_set_t>(), cpuset) + CPU_COUNT_S(size_of::<cpu_set_t>(), cpuset) } diff --git a/third_party/rust/libc/src/types.rs b/third_party/rust/libc/src/types.rs @@ -0,0 +1,39 @@ +//! Platform-agnostic support types. + +use core::mem::MaybeUninit; + +use crate::prelude::*; + +/// A transparent wrapper over `MaybeUninit<T>` to represent uninitialized padding +/// while providing `Default`. +// This is restricted to `Copy` types since that's a loose indicator that zeros is actually +// a valid bitpattern. There is no technical reason this is required, though, so it could be +// lifted in the future if it becomes a problem. +#[allow(unused)] +#[repr(transparent)] +#[derive(Clone, Copy)] +pub(crate) struct Padding<T: Copy>(MaybeUninit<T>); + +impl<T: Copy> Default for Padding<T> { + fn default() -> Self { + Self(MaybeUninit::zeroed()) + } +} + +impl<T: Copy> fmt::Debug for Padding<T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Taken frmo `MaybeUninit`'s debug implementation + // NB: there is no `.pad_fmt` so we can't use a simpler `format_args!("Padding<{..}>"). + let full_name = core::any::type_name::<Self>(); + let prefix_len = full_name.find("Padding").unwrap(); + f.pad(&full_name[prefix_len..]) + } +} + +/// The default repr type used for C style enums in Rust. +#[cfg(target_env = "msvc")] +#[allow(unused)] +pub(crate) type CEnumRepr = c_int; +#[cfg(not(target_env = "msvc"))] +#[allow(unused)] +pub(crate) type CEnumRepr = c_uint; diff --git a/third_party/rust/libc/src/unix/aix/mod.rs b/third_party/rust/libc/src/unix/aix/mod.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use crate::{in_addr_t, in_port_t}; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; @@ -9,7 +10,6 @@ pub type dev_t = c_ulong; pub type fpos64_t = c_longlong; pub type fsblkcnt_t = c_ulong; pub type fsfilcnt_t = c_ulong; -pub type idtype_t = c_int; pub type ino_t = c_ulong; pub type key_t = c_int; pub type mode_t = c_uint; @@ -18,25 +18,23 @@ pub type rlim_t = c_ulong; pub type speed_t = c_uint; pub type tcflag_t = c_uint; pub type time_t = c_long; -pub type time64_t = crate::int64_t; +pub type time64_t = i64; pub type timer_t = c_long; pub type wchar_t = c_uint; -pub type nfds_t = c_int; +pub type nfds_t = c_uint; pub type projid_t = c_int; pub type id_t = c_uint; pub type blksize64_t = c_ulonglong; pub type blkcnt64_t = c_ulonglong; -pub type sctp_assoc_t = crate::uint32_t; - pub type suseconds_t = c_int; pub type useconds_t = c_uint; pub type off_t = c_long; +pub type offset_t = c_longlong; pub type off64_t = c_longlong; +pub type idtype_t = c_uint; pub type socklen_t = c_uint; pub type sa_family_t = c_uchar; -pub type in_port_t = c_ushort; -pub type in_addr_t = c_uint; pub type signal_t = c_int; pub type pthread_t = c_uint; @@ -51,6 +49,7 @@ pub type rlim64_t = c_ulonglong; pub type sem_t = c_int; pub type pollset_t = c_int; +pub type sctp_assoc_t = c_uint; pub type pthread_rwlockattr_t = *mut c_void; pub type pthread_condattr_t = *mut c_void; @@ -69,6 +68,11 @@ e! { UIO_WRITE_NO_MOVE, UIO_PWRITE, } + #[repr(u32)] + pub enum ACTION { + FIND = 0, + ENTER, + } } s! { @@ -228,7 +232,7 @@ s! { pub sin_family: sa_family_t, pub sin_port: in_port_t, pub sin_addr: in_addr, - pub sin_zero: [c_char; 8], + pub sin_zero: [c_uchar; 8], } pub struct sockaddr_in6 { @@ -318,19 +322,6 @@ s! { pub sigev_notify_attributes: *mut pthread_attr_t, } - // Should be union with another 'sival_int' - pub struct sigval64 { - pub sival_ptr: c_ulonglong, - } - - pub struct sigevent64 { - pub sigev_value: sigval64, - pub sigev_signo: c_int, - pub sigev_notify: c_int, - pub sigev_notify_function: c_ulonglong, - pub sigev_notify_attributes: c_ulonglong, - } - pub struct osigevent { pub sevt_value: *mut c_void, pub sevt_signo: signal_t, @@ -402,7 +393,7 @@ s! { pub keepcost: c_int, } - pub struct utmp_exit_status { + pub struct exit_status { pub e_termination: c_short, pub e_exit: c_short, } @@ -414,7 +405,7 @@ s! { pub ut_pid: crate::pid_t, pub ut_type: c_short, pub ut_time: time64_t, - pub ut_exit: utmp_exit_status, + pub ut_exit: exit_status, pub ut_host: [c_char; 256], pub __dbl_word_pad: c_int, pub __reservedA: [c_int; 2], @@ -459,7 +450,7 @@ s! { pub shm_extshm: c_int, pub shm_pagesize: crate::int64_t, pub shm_lba: crate::uint64_t, - pub shm_reserved: crate::int64_t, + pub shm_reserved0: crate::int64_t, pub shm_reserved1: crate::int64_t, } @@ -473,9 +464,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: dev_t, pub st_ssize: c_int, - pub st_atim: st_timespec, - pub st_mtim: st_timespec, - pub st_ctim: st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, pub st_vfstype: c_int, @@ -554,7 +545,7 @@ s_no_extra_traits! { pub events: c_short, pub fd: c_int, pub u: __poll_ctl_ext_u, - pub reversed64: [u64; 6], + pub reserved64: [u64; 6], } } @@ -586,23 +577,11 @@ cfg_if! { && self.command == other.command && self.events == other.events && self.fd == other.fd - && self.reversed64 == other.reversed64 + && self.reserved64 == other.reserved64 && self.u == other.u } } impl Eq for poll_ctl_ext {} - impl fmt::Debug for poll_ctl_ext { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("poll_ctl_ext") - .field("version", &self.version) - .field("command", &self.command) - .field("events", &self.events) - .field("fd", &self.fd) - .field("u", &self.u) - .field("reversed64", &self.reversed64) - .finish() - } - } impl hash::Hash for poll_ctl_ext { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.version.hash(state); @@ -610,7 +589,7 @@ cfg_if! { self.events.hash(state); self.fd.hash(state); self.u.hash(state); - self.reversed64.hash(state); + self.reserved64.hash(state); } } } @@ -643,33 +622,33 @@ pub const O_DIRECTORY: c_int = 0x80000; pub const O_SEARCH: c_int = 0x20; pub const O_EXEC: c_int = 0x20; pub const O_CLOEXEC: c_int = 0x800000; -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH; pub const O_DIRECT: c_int = 0x8000000; pub const O_TTY_INIT: c_int = 0; pub const O_RSYNC: c_int = 0x200000; pub const O_LARGEFILE: c_int = 0x4000000; -pub const F_CLOSEM: c_int = 10; +pub const F_DUPFD: c_int = 0; pub const F_DUPFD_CLOEXEC: c_int = 16; -pub const F_GETLK64: c_int = 11; -pub const F_SETLK64: c_int = 12; -pub const F_SETLKW64: c_int = 13; -pub const F_DUP2FD: c_int = 14; -pub const F_TSTLK: c_int = 15; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; pub const F_GETLK: c_int = F_GETLK64; pub const F_SETLK: c_int = F_SETLK64; pub const F_SETLKW: c_int = F_SETLKW64; pub const F_GETOWN: c_int = 8; pub const F_SETOWN: c_int = 9; +pub const F_CLOSEM: c_int = 10; +pub const F_GETLK64: c_int = 11; +pub const F_SETLK64: c_int = 12; +pub const F_SETLKW64: c_int = 13; +pub const F_DUP2FD: c_int = 14; +pub const F_TSTLK: c_int = 15; pub const AT_FDCWD: c_int = -2; pub const AT_SYMLINK_NOFOLLOW: c_int = 1; pub const AT_SYMLINK_FOLLOW: c_int = 2; pub const AT_REMOVEDIR: c_int = 1; pub const AT_EACCESS: c_int = 1; -pub const F_DUPFD: c_int = 0; -pub const F_GETFD: c_int = 1; -pub const F_SETFD: c_int = 2; -pub const F_GETFL: c_int = 3; -pub const F_SETFL: c_int = 4; pub const O_SYNC: c_int = 16; pub const O_NONBLOCK: c_int = 4; pub const FASYNC: c_int = 0x20000; @@ -754,25 +733,25 @@ pub const NOEXPR: crate::nl_item = 62; // locale.h pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t; +pub const LC_COLLATE: c_int = 0; pub const LC_CTYPE: c_int = 1; +pub const LC_MONETARY: c_int = 2; pub const LC_NUMERIC: c_int = 3; pub const LC_TIME: c_int = 4; -pub const LC_COLLATE: c_int = 0; -pub const LC_MONETARY: c_int = 2; -pub const LC_MESSAGES: c_int = 4; +pub const LC_MESSAGES: c_int = 5; pub const LC_ALL: c_int = -1; +pub const LC_COLLATE_MASK: c_int = 1; pub const LC_CTYPE_MASK: c_int = 2; +pub const LC_MESSAGES_MASK: c_int = 4; +pub const LC_MONETARY_MASK: c_int = 8; pub const LC_NUMERIC_MASK: c_int = 16; pub const LC_TIME_MASK: c_int = 32; -pub const LC_COLLATE_MASK: c_int = 1; -pub const LC_MONETARY_MASK: c_int = 8; -pub const LC_MESSAGES_MASK: c_int = 4; -pub const LC_ALL_MASK: c_int = LC_CTYPE_MASK - | LC_NUMERIC_MASK - | LC_TIME_MASK - | LC_COLLATE_MASK +pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK | LC_MONETARY_MASK - | LC_MESSAGES_MASK; + | LC_NUMERIC_MASK + | LC_TIME_MASK; // netdb.h pub const NI_MAXHOST: crate::socklen_t = 1025; @@ -808,8 +787,11 @@ pub const IPV6_ADDR_PREFERENCES: c_int = 74; pub const IPV6_CHECKSUM: c_int = 39; pub const IPV6_DONTFRAG: c_int = 45; pub const IPV6_DSTOPTS: c_int = 54; -pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 16777215; -pub const IPV6_FLOWINFO_PRIORITY: c_int = 251658240; +pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x00ffffff; +pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0f000000; +pub const IPV6_FLOWINFO_PRIFLOW: c_int = 0x0fffffff; +pub const IPV6_FLOWINFO_SRFLAG: c_int = 0x10000000; +pub const IPV6_FLOWINFO_VERSION: c_int = 0xf0000000; pub const IPV6_HOPLIMIT: c_int = 40; pub const IPV6_HOPOPTS: c_int = 52; pub const IPV6_NEXTHOP: c_int = 48; @@ -844,8 +826,8 @@ pub const DLT_PPP: c_int = 0x17; pub const DLT_FDDI: c_int = 0xf; pub const DLT_ATM: c_int = 0x25; pub const DLT_IPOIB: c_int = 0xc7; -pub const BIOCSETF: c_ulong = 0x80104267; -pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; +pub const BIOCSETF: c_int = 0x80104267; +pub const BIOCGRTIMEOUT: c_int = 0x4010426e; pub const BIOCGBLEN: c_int = 0x40044266; pub const BIOCSBLEN: c_int = 0xc0044266; pub const BIOCFLUSH: c_int = 0x20004268; @@ -856,8 +838,8 @@ pub const BIOCGSTATS: c_int = 0x4008426f; pub const BIOCIMMEDIATE: c_int = 0x80044270; pub const BIOCVERSION: c_int = 0x40044271; pub const BIOCSDEVNO: c_int = 0x20004272; -pub const BIOCGETIF: c_ulong = 0x4020426b; -pub const BIOCSETIF: c_ulong = 0xffffffff8020426c; +pub const BIOCGETIF: c_int = 0x4020426b; +pub const BIOCSETIF: c_int = 0x8020426c; pub const BPF_ABS: c_int = 32; pub const BPF_ADD: c_int = 0; pub const BPF_ALIGNMENT: c_ulong = 4; @@ -1024,7 +1006,6 @@ pub const IPPROTO_SCTP: c_int = 132; pub const IPPROTO_MH: c_int = 135; pub const IPPROTO_GIF: c_int = 140; pub const IPPROTO_RAW: c_int = 255; -pub const IPPROTO_MAX: c_int = 256; pub const IP_OPTIONS: c_int = 1; pub const IP_HDRINCL: c_int = 2; pub const IP_TOS: c_int = 3; @@ -1121,7 +1102,7 @@ pub const TCP_KEEPCNT: c_int = 0x13; pub const TCP_NODELAYACK: c_int = 0x14; // pthread.h -pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = 2; pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 1; pub const PTHREAD_PROCESS_SHARED: c_int = 0; @@ -1163,25 +1144,22 @@ pub const REG_EEOL: c_int = 16; pub const REG_ENOSYS: c_int = 17; // rpcsvc/mount.h -pub const NFSMNT_ACDIRMAX: c_int = 2048; -pub const NFSMNT_ACDIRMIN: c_int = 1024; -pub const NFSMNT_ACREGMAX: c_int = 512; -pub const NFSMNT_ACREGMIN: c_int = 256; -pub const NFSMNT_INT: c_int = 64; -pub const NFSMNT_NOAC: c_int = 128; -pub const NFSMNT_RETRANS: c_int = 16; -pub const NFSMNT_RSIZE: c_int = 4; -pub const NFSMNT_SOFT: c_int = 1; -pub const NFSMNT_TIMEO: c_int = 8; -pub const NFSMNT_WSIZE: c_int = 2; +pub const NFSMNT_SOFT: c_int = 0x001; +pub const NFSMNT_WSIZE: c_int = 0x002; +pub const NFSMNT_RSIZE: c_int = 0x004; +pub const NFSMNT_TIMEO: c_int = 0x008; +pub const NFSMNT_RETRANS: c_int = 0x010; +pub const NFSMNT_HOSTNAME: c_int = 0x020; +pub const NFSMNT_INT: c_int = 0x040; +pub const NFSMNT_NOAC: c_int = 0x080; +pub const NFSMNT_ACREGMIN: c_int = 0x0100; +pub const NFSMNT_ACREGMAX: c_int = 0x0200; +pub const NFSMNT_ACDIRMIN: c_int = 0x0400; +pub const NFSMNT_ACDIRMAX: c_int = 0x0800; // rpcsvc/rstat.h pub const CPUSTATES: c_int = 4; -// search.h -pub const FIND: c_int = 0; -pub const ENTER: c_int = 1; - // semaphore.h pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t; @@ -1276,33 +1254,16 @@ pub const EUNATCH: c_int = 42; pub const ENOCSI: c_int = 43; pub const EL2HLT: c_int = 44; pub const EDEADLK: c_int = 45; +pub const ENOTREADY: c_int = 46; +pub const EWRPROTECT: c_int = 47; +pub const EFORMAT: c_int = 48; pub const ENOLCK: c_int = 49; -pub const ECANCELED: c_int = 117; -pub const ENOTSUP: c_int = 124; -pub const EPROCLIM: c_int = 83; -pub const EDQUOT: c_int = 88; -pub const EOWNERDEAD: c_int = 95; -pub const ENOTRECOVERABLE: c_int = 94; -pub const ENOSTR: c_int = 123; -pub const ENODATA: c_int = 122; -pub const ETIME: c_int = 119; -pub const ENOSR: c_int = 118; -pub const EREMOTE: c_int = 93; -pub const ENOATTR: c_int = 112; -pub const ESAD: c_int = 113; -pub const ENOTRUST: c_int = 114; -pub const ENOLINK: c_int = 126; -pub const EPROTO: c_int = 121; -pub const EMULTIHOP: c_int = 125; -pub const EBADMSG: c_int = 120; -pub const ENAMETOOLONG: c_int = 86; -pub const EOVERFLOW: c_int = 127; -pub const EILSEQ: c_int = 116; -pub const ENOSYS: c_int = 109; -pub const ELOOP: c_int = 85; -pub const ERESTART: c_int = 82; -pub const ENOTEMPTY: c_int = 87; -pub const EUSERS: c_int = 84; +pub const ENOCONNECT: c_int = 50; +pub const ESTALE: c_int = 52; +pub const EDIST: c_int = 53; +pub const EWOULDBLOCK: c_int = 54; +pub const EINPROGRESS: c_int = 55; +pub const EALREADY: c_int = 56; pub const ENOTSOCK: c_int = 57; pub const EDESTADDRREQ: c_int = 58; pub const EMSGSIZE: c_int = 59; @@ -1324,15 +1285,42 @@ pub const ENOBUFS: c_int = 74; pub const EISCONN: c_int = 75; pub const ENOTCONN: c_int = 76; pub const ESHUTDOWN: c_int = 77; -pub const ETOOMANYREFS: c_int = 115; pub const ETIMEDOUT: c_int = 78; pub const ECONNREFUSED: c_int = 79; pub const EHOSTDOWN: c_int = 80; pub const EHOSTUNREACH: c_int = 81; -pub const EWOULDBLOCK: c_int = EAGAIN; -pub const EALREADY: c_int = 56; -pub const EINPROGRESS: c_int = 55; -pub const ESTALE: c_int = 52; +pub const ERESTART: c_int = 82; +pub const EPROCLIM: c_int = 83; +pub const EUSERS: c_int = 84; +pub const ELOOP: c_int = 85; +pub const ENAMETOOLONG: c_int = 86; +pub const ENOTEMPTY: c_int = 87; +pub const EDQUOT: c_int = 88; +pub const ECORRUPT: c_int = 89; +pub const ESYSERROR: c_int = 90; +pub const EREMOTE: c_int = 93; +pub const ENOTRECOVERABLE: c_int = 94; +pub const EOWNERDEAD: c_int = 95; +// errnos 96-108 reserved for future use compatible with AIX PS/2 +pub const ENOSYS: c_int = 109; +pub const EMEDIA: c_int = 110; +pub const ESOFT: c_int = 111; +pub const ENOATTR: c_int = 112; +pub const ESAD: c_int = 113; +pub const ENOTRUST: c_int = 114; +pub const ETOOMANYREFS: c_int = 115; +pub const EILSEQ: c_int = 116; +pub const ECANCELED: c_int = 117; +pub const ENOSR: c_int = 118; +pub const ETIME: c_int = 119; +pub const EBADMSG: c_int = 120; +pub const EPROTO: c_int = 121; +pub const ENODATA: c_int = 122; +pub const ENOSTR: c_int = 123; +pub const ENOTSUP: c_int = 124; +pub const EMULTIHOP: c_int = 125; +pub const ENOLINK: c_int = 126; +pub const EOVERFLOW: c_int = 127; // sys/dr.h pub const LPAR_INFO_FORMAT1: c_int = 1; @@ -1375,13 +1363,13 @@ pub const IOC_VOID: c_int = 0x20000000; pub const IOC_OUT: c_int = 0x40000000; pub const IOC_IN: c_int = 0x40000000 << 1; pub const IOC_INOUT: c_int = IOC_IN | IOC_OUT; -pub const FIOCLEX: c_int = 536897025; -pub const FIONCLEX: c_int = 536897026; -pub const FIONREAD: c_int = 1074030207; -pub const FIONBIO: c_int = -2147195266; -pub const FIOASYNC: c_int = -2147195267; -pub const FIOSETOWN: c_int = -2147195268; -pub const FIOGETOWN: c_int = 1074030203; +pub const FIOCLEX: c_int = 0x20006601; +pub const FIONCLEX: c_int = 0x20006602; +pub const FIONREAD: c_int = 0x4004667f; +pub const FIONBIO: c_int = 0x8004667e; +pub const FIOASYNC: c_int = 0x8004667d; +pub const FIOSETOWN: c_int = 0x8004667c; +pub const FIOGETOWN: c_int = 0x4004667b; pub const TIOCGETD: c_int = 0x40047400; pub const TIOCSETD: c_int = 0x80047401; pub const TIOCHPCL: c_int = 0x20007402; @@ -1411,33 +1399,33 @@ pub const CBREAK: c_int = 0x2; pub const LCASE: c_int = 0x4; pub const MDMBUF: c_int = 0x800000; pub const XTABS: c_int = 0xc00; -pub const SIOCADDMULTI: c_int = -2145359567; -pub const SIOCADDRT: c_int = -2143784438; -pub const SIOCDARP: c_int = -2142476000; -pub const SIOCDELMULTI: c_int = -2145359566; -pub const SIOCDELRT: c_int = -2143784437; -pub const SIOCDIFADDR: c_int = -2144835303; -pub const SIOCGARP: c_int = -1068734170; -pub const SIOCGIFADDR: c_int = -1071093471; -pub const SIOCGIFBRDADDR: c_int = -1071093469; -pub const SIOCGIFCONF: c_int = -1072666299; -pub const SIOCGIFDSTADDR: c_int = -1071093470; -pub const SIOCGIFFLAGS: c_int = -1071093487; -pub const SIOCGIFHWADDR: c_int = -1068209771; -pub const SIOCGIFMETRIC: c_int = -1071093481; -pub const SIOCGIFMTU: c_int = -1071093418; -pub const SIOCGIFNETMASK: c_int = -1071093467; -pub const SIOCSARP: c_int = -2142476002; -pub const SIOCSIFADDR: c_int = -2144835316; -pub const SIOCSIFBRDADDR: c_int = -2144835309; -pub const SIOCSIFDSTADDR: c_int = -2144835314; -pub const SIOCSIFFLAGS: c_int = -2144835312; -pub const SIOCSIFMETRIC: c_int = -2144835304; -pub const SIOCSIFMTU: c_int = -2144835240; -pub const SIOCSIFNETMASK: c_int = -2144835306; -pub const TIOCUCNTL: c_int = -2147191706; -pub const TIOCCONS: c_int = -2147191710; -pub const TIOCPKT: c_int = -2147191696; +pub const SIOCADDMULTI: c_int = 0x80206931; +pub const SIOCADDRT: c_int = 0x8038720a; +pub const SIOCDARP: c_int = 0x804c6920; +pub const SIOCDELMULTI: c_int = 0x80206932; +pub const SIOCDELRT: c_int = 0x8038720b; +pub const SIOCDIFADDR: c_int = 0x80286919; +pub const SIOCGARP: c_int = 0xc04c6926; +pub const SIOCGIFADDR: c_int = 0xc0286921; +pub const SIOCGIFBRDADDR: c_int = 0xc0286923; +pub const SIOCGIFCONF: c_int = 0xc0106945; +pub const SIOCGIFDSTADDR: c_int = 0xc0286922; +pub const SIOCGIFFLAGS: c_int = 0xc0286911; +pub const SIOCGIFHWADDR: c_int = 0xc0546995; +pub const SIOCGIFMETRIC: c_int = 0xc0286917; +pub const SIOCGIFMTU: c_int = 0xc0286956; +pub const SIOCGIFNETMASK: c_int = 0xc0286925; +pub const SIOCSARP: c_int = 0x804c691e; +pub const SIOCSIFADDR: c_int = 0x8028690c; +pub const SIOCSIFBRDADDR: c_int = 0x80286913; +pub const SIOCSIFDSTADDR: c_int = 0x8028690e; +pub const SIOCSIFFLAGS: c_int = 0x80286910; +pub const SIOCSIFMETRIC: c_int = 0x80286918; +pub const SIOCSIFMTU: c_int = 0x80286958; +pub const SIOCSIFNETMASK: c_int = 0x80286916; +pub const TIOCUCNTL: c_int = 0x80047466; +pub const TIOCCONS: c_int = 0x80047462; +pub const TIOCPKT: c_int = 0x80047470; pub const TIOCPKT_DATA: c_int = 0; pub const TIOCPKT_FLUSHREAD: c_int = 1; pub const TIOCPKT_FLUSHWRITE: c_int = 2; @@ -1463,9 +1451,13 @@ pub const SHM_LOCK: c_int = 201; pub const SHM_UNLOCK: c_int = 202; // sys/ldr.h +pub const L_GETMESSAGES: c_int = 1; pub const L_GETINFO: c_int = 2; -pub const L_GETMESSAGE: c_int = 1; pub const L_GETLIBPATH: c_int = 3; +pub const L_GETKERNINFO: c_int = 4; +pub const L_GETLIB32INFO: c_int = 5; +pub const L_GETLIB64INFO: c_int = 6; +pub const L_GETPROCINFO: c_int = 7; pub const L_GETXINFO: c_int = 8; // sys/limits.h @@ -2133,9 +2125,9 @@ pub const AT_GID: c_int = 8; pub const AT_UID: c_int = 4; // sys/wait.h -pub const P_ALL: c_int = 0; -pub const P_PID: c_int = 1; -pub const P_PGID: c_int = 2; +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; pub const WNOHANG: c_int = 0x1; pub const WUNTRACED: c_int = 0x2; pub const WEXITED: c_int = 0x04; @@ -2157,7 +2149,7 @@ pub const CS6: crate::tcflag_t = 0x00000010; pub const CS7: crate::tcflag_t = 0x00000020; pub const CS8: crate::tcflag_t = 0x00000030; pub const CSTOPB: crate::tcflag_t = 0x00000040; -pub const ECHO: crate::tcflag_t = 0x20000; +pub const ECHO: crate::tcflag_t = 0x00000008; pub const ECHOE: crate::tcflag_t = 0x00000010; pub const ECHOK: crate::tcflag_t = 0x00000020; pub const ECHONL: crate::tcflag_t = 0x00000040; @@ -2173,7 +2165,7 @@ pub const ISTRIP: crate::tcflag_t = 0x00000020; pub const INLCR: crate::tcflag_t = 0x00000040; pub const IGNCR: crate::tcflag_t = 0x00000080; pub const ICRNL: crate::tcflag_t = 0x00000100; -pub const IXON: crate::tcflag_t = 0x0001; +pub const IXON: crate::tcflag_t = 0x00000200; pub const IXOFF: crate::tcflag_t = 0x00000400; pub const IXANY: crate::tcflag_t = 0x00001000; pub const IMAXBEL: crate::tcflag_t = 0x00010000; @@ -2426,7 +2418,7 @@ pub const _SC_IPV6: c_int = 154; pub const _SC_RAW_SOCKETS: c_int = 155; // utmp.h -pub const EMPTY: c_short = -1; +pub const EMPTY: c_short = 0; pub const RUN_LVL: c_short = 1; pub const BOOT_TIME: c_short = 2; pub const OLD_TIME: c_short = 3; @@ -2439,10 +2431,10 @@ pub const ACCOUNTING: c_short = 9; f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { + if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } @@ -2450,10 +2442,10 @@ f! { if cmsg.is_null() { CMSG_FIRSTHDR(mhdr) } else { - if (cmsg as usize + (*cmsg).cmsg_len as usize + mem::size_of::<cmsghdr>()) + if (cmsg as usize + (*cmsg).cmsg_len as usize + size_of::<cmsghdr>()) > ((*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize) { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { // AIX does not have any alignment/padding for ancillary data, so we don't need _CMSG_ALIGN here. (cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr @@ -2462,15 +2454,15 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(mem::size_of::<cmsghdr>() as isize) + (cmsg as *mut c_uchar).offset(size_of::<cmsghdr>() as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - mem::size_of::<cmsghdr>() as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + size_of::<cmsghdr>() as c_uint + length } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - mem::size_of::<cmsghdr>() as c_uint + length + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + size_of::<cmsghdr>() as c_uint + length } pub fn FD_ZERO(set: *mut fd_set) -> () { @@ -2480,32 +2472,32 @@ f! { } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of::<c_long>() * 8; + let bits = size_of::<c_long>() * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of::<c_long>() * 8; + let bits = size_of::<c_long>() * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of::<c_long>() * 8; + let bits = size_of::<c_long>() * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } } safe_f! { - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & _W_STOPPED) != 0 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { if WIFSTOPPED(status) { (((status as c_uint) >> 8) & 0xff) as c_int } else { @@ -2513,11 +2505,11 @@ safe_f! { } } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xFF) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { if WIFEXITED(status) { (((status as c_uint) >> 8) & 0xff) as c_int } else { @@ -2525,11 +2517,11 @@ safe_f! { } } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { !WIFEXITED(status) && !WIFSTOPPED(status) } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { if WIFSIGNALED(status) { (((status as c_uint) >> 16) & 0xff) as c_int } else { @@ -2537,26 +2529,26 @@ safe_f! { } } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & WCONTINUED) != 0 } // AIX doesn't have native WCOREDUMP. - pub {const} fn WCOREDUMP(_status: c_int) -> bool { + pub const fn WCOREDUMP(_status: c_int) -> bool { false } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { let x = dev >> 16; x as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { let y = dev & 0xFFFF; y as c_uint } - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -2579,109 +2571,249 @@ extern "C" { parent: Option<unsafe extern "C" fn()>, child: Option<unsafe extern "C" fn()>, ) -> c_int; + + pub fn pthread_attr_getdetachstate( + attr: *const crate::pthread_attr_t, + detachstate: *mut c_int, + ) -> c_int; + pub fn pthread_attr_getguardsize( attr: *const crate::pthread_attr_t, guardsize: *mut size_t, ) -> c_int; - pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + + pub fn pthread_attr_getinheritsched( + attr: *const crate::pthread_attr_t, + inheritsched: *mut c_int, + ) -> c_int; + pub fn pthread_attr_getschedparam( attr: *const crate::pthread_attr_t, param: *mut sched_param, ) -> c_int; + + pub fn pthread_attr_getstackaddr( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + ) -> c_int; + + pub fn pthread_attr_getschedpolicy( + attr: *const crate::pthread_attr_t, + policy: *mut c_int, + ) -> c_int; + + pub fn pthread_attr_getscope( + attr: *const crate::pthread_attr_t, + contentionscope: *mut c_int, + ) -> c_int; + pub fn pthread_attr_getstack( attr: *const crate::pthread_attr_t, stackaddr: *mut *mut c_void, stacksize: *mut size_t, ) -> c_int; + + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + + pub fn pthread_attr_setinheritsched( + attr: *mut crate::pthread_attr_t, + inheritsched: c_int, + ) -> c_int; + pub fn pthread_attr_setschedparam( attr: *mut crate::pthread_attr_t, param: *const sched_param, ) -> c_int; - pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; - pub fn pthread_barrier_init( - barrier: *mut pthread_barrier_t, - attr: *const crate::pthread_barrierattr_t, - count: c_uint, + + pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; + + pub fn pthread_attr_setscope(attr: *mut crate::pthread_attr_t, contentionscope: c_int) + -> c_int; + + pub fn pthread_attr_setstack( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, ) -> c_int; - pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + + pub fn pthread_attr_setstackaddr( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + ) -> c_int; + pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_getpshared( attr: *const crate::pthread_barrierattr_t, - shared: *mut c_int, + pshared: *mut c_int, ) -> c_int; + pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_setpshared( attr: *mut crate::pthread_barrierattr_t, - shared: c_int, + pshared: c_int, + ) -> c_int; + + pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; + + pub fn pthread_barrier_init( + barrier: *mut pthread_barrier_t, + attr: *const crate::pthread_barrierattr_t, + count: c_uint, ) -> c_int; + + pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + + pub fn pthread_cleanup_pop(execute: c_int) -> c_void; + + pub fn pthread_cleanup_push( + routine: Option<unsafe extern "C" fn(*mut c_void)>, + arg: *mut c_void, + ) -> c_void; + pub fn pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, ) -> c_int; + pub fn pthread_condattr_getpshared( attr: *const pthread_condattr_t, pshared: *mut c_int, ) -> c_int; + pub fn pthread_condattr_setclock( attr: *mut pthread_condattr_t, clock_id: crate::clockid_t, ) -> c_int; + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + pub fn pthread_create( - native: *mut crate::pthread_t, + thread: *mut crate::pthread_t, attr: *const crate::pthread_attr_t, - f: extern "C" fn(*mut c_void) -> *mut c_void, - value: *mut c_void, + start_routine: extern "C" fn(*mut c_void) -> *mut c_void, + arg: *mut c_void, ) -> c_int; - pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; - pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; + + pub fn pthread_getconcurrency() -> c_int; + + pub fn pthread_getcpuclockid( + thread_id: crate::pthread_t, + clock_id: *mut crate::clockid_t, + ) -> c_int; + pub fn pthread_getschedparam( thread: crate::pthread_t, policy: *mut c_int, param: *mut sched_param, ) -> c_int; - pub fn pthread_kill(thread: crate::pthread_t, signal: c_int) -> c_int; - pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; - pub fn pthread_mutex_timedlock( - lock: *mut pthread_mutex_t, - abstime: *const crate::timespec, + + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + + pub fn pthread_mutexattr_getprioceiling( + attr: *const crate::pthread_mutexattr_t, + prioceiling: *mut c_int, ) -> c_int; + pub fn pthread_mutexattr_getprotocol( attr: *const pthread_mutexattr_t, protocol: *mut c_int, ) -> c_int; + pub fn pthread_mutexattr_getpshared( attr: *const pthread_mutexattr_t, pshared: *mut c_int, ) -> c_int; + pub fn pthread_mutexattr_getrobust( - attr: *mut crate::pthread_mutexattr_t, + attr: *const crate::pthread_mutexattr_t, robust: *mut c_int, ) -> c_int; + + pub fn pthread_mutexattr_gettype( + attr: *const crate::pthread_mutexattr_t, + _type: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_setprioceiling( + attr: *mut crate::pthread_mutexattr_t, + prioceiling: c_int, + ) -> c_int; + pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + pub fn pthread_mutexattr_setrobust( attr: *mut crate::pthread_mutexattr_t, robust: c_int, ) -> c_int; + + pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_getprioceiling( + mutex: *const crate::pthread_mutex_t, + prioceiling: *mut c_int, + ) -> c_int; + + pub fn pthread_mutex_setprioceiling( + mutex: *mut crate::pthread_mutex_t, + prioceiling: c_int, + old_ceiling: *mut c_int, + ) -> c_int; + + pub fn pthread_mutex_timedlock( + mutex: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_once( + once_control: *mut crate::pthread_once_t, + init_routine: Option<unsafe extern "C" fn()>, + ) -> c_int; + pub fn pthread_rwlockattr_getpshared( attr: *const pthread_rwlockattr_t, - val: *mut c_int, + pshared: *mut c_int, + ) -> c_int; + + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, pshared: c_int) -> c_int; + + pub fn pthread_rwlock_timedrdlock( + rwlock: *mut crate::pthread_rwlock_t, + abstime: *const crate::timespec, ) -> c_int; - pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; + + pub fn pthread_rwlock_timedwrlock( + rwlock: *mut crate::pthread_rwlock_t, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_setcancelstate(state: c_int, oldstate: *mut c_int) -> c_int; + pub fn pthread_setcanceltype(_type: c_int, oldtype: *mut c_int) -> c_int; + + pub fn pthread_setconcurrency(new_level: c_int) -> c_int; + pub fn pthread_setschedparam( thread: crate::pthread_t, policy: c_int, param: *const sched_param, ) -> c_int; - pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int; - pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + + pub fn pthread_setschedprio(thread: crate::pthread_t, prio: c_int) -> c_int; + + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int; + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_testcancel() -> c_void; } #[link(name = "iconv")] @@ -2698,14 +2830,25 @@ extern "C" { } extern "C" { - pub fn acct(filename: *const c_char) -> c_int; + pub fn acct(filename: *mut c_char) -> c_int; + #[link_name = "_posix_aio_cancel"] pub fn aio_cancel(fildes: c_int, aiocbp: *mut crate::aiocb) -> c_int; - pub fn aio_error(aiocbp: *mut crate::aiocb) -> c_int; + #[link_name = "_posix_aio_error"] + pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; #[link_name = "_posix_aio_fsync"] pub fn aio_fsync(op: c_int, aiocbp: *mut crate::aiocb) -> c_int; + #[link_name = "_posix_aio_read"] pub fn aio_read(aiocbp: *mut crate::aiocb) -> c_int; - // pub fn aio_suspend - // pub fn aio_write + #[link_name = "_posix_aio_return"] + pub fn aio_return(aiocbp: *mut crate::aiocb) -> ssize_t; + #[link_name = "_posix_aio_suspend"] + pub fn aio_suspend( + list: *const *const crate::aiocb, + nent: c_int, + timeout: *const crate::timespec, + ) -> c_int; + #[link_name = "_posix_aio_write"] + pub fn aio_write(aiocbp: *mut crate::aiocb) -> c_int; pub fn basename(path: *mut c_char) -> *mut c_char; pub fn bind( socket: c_int, @@ -2771,6 +2914,7 @@ extern "C" { pub fn getdtablesize() -> c_int; pub fn getgrent() -> *mut crate::group; pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + #[link_name = "_posix_getgrgid_r"] pub fn getgrgid_r( gid: crate::gid_t, grp: *mut crate::group, @@ -2779,6 +2923,7 @@ extern "C" { result: *mut *mut crate::group, ) -> c_int; pub fn getgrnam(name: *const c_char) -> *mut crate::group; + #[link_name = "_posix_getgrnam_r"] pub fn getgrnam_r( name: *const c_char, grp: *mut crate::group, @@ -2786,7 +2931,7 @@ extern "C" { buflen: size_t, result: *mut *mut crate::group, ) -> c_int; - pub fn getgrset(user: *mut c_char) -> *mut c_char; + pub fn getgrset(user: *const c_char) -> *mut c_char; pub fn gethostid() -> c_long; pub fn getmntent(stream: *mut crate::FILE) -> *mut crate::mntent; pub fn getnameinfo( @@ -2802,6 +2947,7 @@ extern "C" { pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn getpwent() -> *mut crate::passwd; + #[link_name = "_posix_getpwnam_r"] pub fn getpwnam_r( name: *const c_char, pwd: *mut passwd, @@ -2809,6 +2955,7 @@ extern "C" { buflen: size_t, result: *mut *mut passwd, ) -> c_int; + #[link_name = "_posix_getpwuid_r"] pub fn getpwuid_r( uid: crate::uid_t, pwd: *mut passwd, @@ -2836,7 +2983,7 @@ extern "C" { pub fn hasmntopt(mnt: *const crate::mntent, opt: *const c_char) -> *mut c_char; pub fn hcreate(nelt: size_t) -> c_int; pub fn hdestroy(); - pub fn hsearch(entry: entry, action: c_int) -> *mut entry; + pub fn hsearch(entry: entry, action: ACTION) -> *mut entry; pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn if_nameindex() -> *mut if_nameindex; pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; @@ -2850,13 +2997,14 @@ extern "C" { width: size_t, compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>, ) -> *mut c_void; + #[link_name = "_posix_lio_listio"] pub fn lio_listio( mode: c_int, aiocb_list: *const *mut aiocb, - nitems: c_int, + nent: c_int, sevp: *mut sigevent, ) -> c_int; - pub fn loadquery(flags: c_int, buf: *mut c_char, buflen: c_uint) -> c_int; + pub fn loadquery(flags: c_int, buf: *mut c_void, buflen: c_uint, ...) -> c_int; pub fn lpar_get_info(command: c_int, buf: *mut c_void, bufsize: size_t) -> c_int; pub fn lpar_set_resources(id: c_int, resource: *mut c_void) -> c_int; pub fn lrand48() -> c_long; @@ -2869,7 +3017,7 @@ extern "C" { ) -> *mut c_void; pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; - pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn madvise(addr: caddr_t, len: size_t, advice: c_int) -> c_int; pub fn makecontext(ucp: *mut crate::ucontext_t, func: extern "C" fn(), argc: c_int, ...); pub fn mallinfo() -> crate::mallinfo; pub fn mallopt(param: c_int, value: c_int) -> c_int; @@ -2880,10 +3028,9 @@ extern "C" { needlelen: size_t, ) -> *mut c_void; pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int; - pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mincore(addr: caddr_t, len: size_t, vec: *mut c_char) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int; pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; pub fn mq_close(mqd: crate::mqd_t) -> c_int; @@ -2977,7 +3124,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; @@ -3028,7 +3175,7 @@ extern "C" { envp: *const *mut c_char, ) -> c_int; pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; - pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) -> ssize_t; pub fn ptrace64( request: c_int, id: c_longlong, @@ -3039,11 +3186,13 @@ extern "C" { pub fn pututline(u: *const utmp) -> *mut utmp; pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: off64_t) -> ssize_t; - pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; - #[link_name = "__linux_quotactl"] - pub fn quotactl(cmd: c_int, special: *const c_char, id: c_int, data: *mut c_char) -> c_int; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) + -> ssize_t; + pub fn quotactl(cmd: *mut c_char, special: c_int, id: c_int, data: caddr_t) -> c_int; pub fn rand() -> c_int; pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + // AIX header socket.h maps recvfrom() to nrecvfrom() + #[link_name = "nrecvfrom"] pub fn recvfrom( socket: c_int, buf: *mut c_void, @@ -3059,6 +3208,8 @@ extern "C" { flags: c_int, timeout: *mut crate::timespec, ) -> c_int; + // AIX header socket.h maps recvmsg() to nrecvmsg(). + #[link_name = "nrecvmsg"] pub fn recvmsg(sockfd: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int; pub fn regerror( @@ -3094,7 +3245,7 @@ extern "C" { arg_size: *mut c_void, size: *mut size_t, ) -> c_int; - pub fn sctp_peeloff(s: c_int, id: crate::sctp_assoc_t) -> c_int; + pub fn sctp_peeloff(s: c_int, id: *mut c_uint) -> c_int; pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); pub fn sem_close(sem: *mut sem_t) -> c_int; @@ -3109,6 +3260,8 @@ extern "C" { pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int; pub fn send_file(socket: *mut c_int, iobuf: *mut sf_parms, flags: c_uint) -> ssize_t; pub fn sendmmsg(sockfd: c_int, msgvec: *mut mmsghdr, vlen: c_uint, flags: c_int) -> c_int; + // AIX header socket.h maps sendmsg() to nsendmsg(). + #[link_name = "nsendmsg"] pub fn sendmsg(sockfd: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; pub fn setcontext(ucp: *const ucontext_t) -> c_int; pub fn setdomainname(name: *const c_char, len: c_int) -> c_int; @@ -3142,7 +3295,7 @@ extern "C" { pub fn shmdt(shmaddr: *const c_void) -> c_int; pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int; pub fn srand(seed: c_uint); @@ -3174,7 +3327,7 @@ extern "C" { pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; pub fn strsep(string: *mut *mut c_char, delim: *const c_char) -> *mut c_char; pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; - pub fn swapoff(puath: *const c_char) -> c_int; + pub fn swapoff(path: *const c_char) -> c_int; pub fn swapon(path: *const c_char) -> c_int; pub fn sync(); pub fn telldir(dirp: *mut crate::DIR) -> c_long; @@ -3194,7 +3347,7 @@ extern "C" { ) -> c_int; pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; pub fn uname(buf: *mut crate::utsname) -> c_int; - pub fn updwtmp(file: *const c_char, u: *mut utmp); + pub fn updwtmp(file: *const c_char, u: *const utmp); pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; pub fn utmpname(file: *const c_char) -> c_int; pub fn utimensat( diff --git a/third_party/rust/libc/src/unix/aix/powerpc64.rs b/third_party/rust/libc/src/unix/aix/powerpc64.rs @@ -1,6 +1,12 @@ use crate::off_t; use crate::prelude::*; +// Define lock_data_instrumented as an empty enum +missing! { + #[derive(Debug)] + pub enum lock_data_instrumented {} +} + s! { pub struct sigset_t { pub ss_set: [c_ulong; 4], @@ -49,6 +55,10 @@ s! { __mt_word: [c_long; 8], } + pub struct pthread_once_t { + __on_word: [c_long; 9], + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -59,9 +69,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_ssize: c_int, - pub st_atime: crate::st_timespec, - pub st_mtime: crate::st_timespec, - pub st_ctime: crate::st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_vfstype: c_int, @@ -112,20 +122,47 @@ s! { pub aio_sigev_tid: c_long, } - pub struct ucontext_t { - pub __sc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub __sc_uerror: c_int, - pub uc_mcontext: crate::mcontext_t, - pub uc_link: *mut ucontext_t, - pub uc_stack: crate::stack_t, - // Should be pointer to __extctx_t - pub __extctx: *mut c_void, - pub __extctx_magic: c_int, - pub __pad: [c_int; 1], + pub struct __vmxreg_t { + __v: [c_uint; 4], } - pub struct mcontext_t { + pub struct __vmx_context_t { + pub __vr: [crate::__vmxreg_t; 32], + pub __pad1: [c_uint; 3], + pub __vscr: c_uint, + pub __vrsave: c_uint, + pub __pad2: [c_uint; 3], + } + + pub struct __vsx_context_t { + pub __vsr_dw1: [c_ulonglong; 32], + } + + pub struct __tm_context_t { + pub vmx: crate::__vmx_context_t, + pub vsx: crate::__vsx_context_t, + pub gpr: [c_ulonglong; 32], + pub lr: c_ulonglong, + pub ctr: c_ulonglong, + pub cr: c_uint, + pub xer: c_uint, + pub amr: c_ulonglong, + pub texasr: c_ulonglong, + pub tfiar: c_ulonglong, + pub tfhar: c_ulonglong, + pub ppr: c_ulonglong, + pub dscr: c_ulonglong, + pub tar: c_ulonglong, + pub fpscr: c_uint, + pub fpscrx: c_uint, + pub fpr: [fpreg_t; 32], + pub tmcontext: c_char, + pub tmstate: c_char, + pub prevowner: c_char, + pub pad: [c_char; 5], + } + + pub struct __context64 { pub gpr: [c_ulonglong; 32], pub msr: c_ulonglong, pub iar: c_ulonglong, @@ -136,8 +173,7 @@ s! { pub fpscr: c_uint, pub fpscrx: c_uint, pub except: [c_ulonglong; 1], - // Should be array of double type - pub fpr: [crate::uint64_t; 32], + pub fpr: [fpreg_t; 32], pub fpeu: c_char, pub fpinfo: c_char, pub fpscr24_31: c_char, @@ -145,6 +181,33 @@ s! { pub excp_type: c_int, } + pub struct mcontext_t { + pub jmp_context: __context64, + } + + pub struct __extctx_t { + pub __flags: c_uint, + pub __rsvd1: [c_uint; 3], + pub __vmx: crate::__vmx_context_t, + pub __ukeys: [c_uint; 2], + pub __vsx: crate::__vsx_context_t, + pub __tm: crate::__tm_context_t, + pub __reserved: [c_char; 1860], + pub __extctx_magic: c_int, + } + + pub struct ucontext_t { + pub __sc_onstack: c_int, + pub uc_sigmask: crate::sigset_t, + pub __sc_uerror: c_int, + pub uc_mcontext: crate::mcontext_t, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub __extctx: *mut crate::__extctx_t, + pub __extctx_magic: c_int, + pub __pad: [c_int; 1], + } + pub struct utmpx { pub ut_user: [c_char; 256], pub ut_id: [c_char; 14], @@ -201,29 +264,33 @@ s_no_extra_traits! { pub union _kernel_simple_lock { pub _slock: c_long, - // Should be pointer to 'lock_data_instrumented' - pub _slockp: *mut c_void, + pub _slockp: *mut lock_data_instrumented, } pub struct fileops_t { - pub fo_rw: extern "C" fn( - file: *mut file, - rw: crate::uio_rw, - io: *mut c_void, - ext: c_long, - secattr: *mut c_void, - ) -> c_int, - pub fo_ioctl: extern "C" fn( - file: *mut file, - a: c_long, - b: crate::caddr_t, - c: c_long, - d: c_long, - ) -> c_int, - pub fo_select: + pub fo_rw: Option< + extern "C" fn( + file: *mut file, + rw: crate::uio_rw, + io: *mut c_void, + ext: c_long, + secattr: *mut c_void, + ) -> c_int, + >, + pub fo_ioctl: Option< + extern "C" fn( + file: *mut file, + a: c_long, + b: crate::caddr_t, + c: c_long, + d: c_long, + ) -> c_int, + >, + pub fo_select: Option< extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int, - pub fo_close: extern "C" fn(file: *mut file) -> c_int, - pub fo_fstat: extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int, + >, + pub fo_close: Option<extern "C" fn(file: *mut file) -> c_int>, + pub fo_fstat: Option<extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int>, } pub struct file { @@ -271,10 +338,14 @@ s_no_extra_traits! { pub struct pollfd_ext { pub fd: c_int, - pub events: c_ushort, - pub revents: c_ushort, + pub events: c_short, + pub revents: c_short, pub data: __pollfd_ext_u, } + + pub struct fpreg_t { + pub d: c_double, + } } impl siginfo_t { @@ -316,22 +387,6 @@ cfg_if! { } } impl Eq for siginfo_t {} - impl fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> 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) - .field("si_pid", &self.si_pid) - .field("si_uid", &self.si_uid) - .field("si_status", &self.si_status) - .field("si_addr", &self.si_addr) - .field("si_band", &self.si_band) - .field("si_value", &self.si_value) - .field("__si_flags", &self.__si_flags) - .finish() - } - } impl hash::Hash for siginfo_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.si_signo.hash(state); @@ -347,173 +402,6 @@ cfg_if! { } } - impl PartialEq for _kernel_simple_lock { - fn eq(&self, other: &_kernel_simple_lock) -> bool { - unsafe { self._slock == other._slock && self._slockp == other._slockp } - } - } - impl Eq for _kernel_simple_lock {} - impl hash::Hash for _kernel_simple_lock { - fn hash<H: hash::Hasher>(&self, state: &mut H) { - unsafe { - self._slock.hash(state); - self._slockp.hash(state); - } - } - } - - impl PartialEq for fileops_t { - fn eq(&self, other: &fileops_t) -> bool { - self.fo_rw == other.fo_rw - && self.fo_ioctl == other.fo_ioctl - && self.fo_select == other.fo_select - && self.fo_close == other.fo_close - && self.fo_fstat == other.fo_fstat - } - } - impl Eq for fileops_t {} - impl fmt::Debug for fileops_t { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("fileops_t") - .field("fo_rw", &self.fo_rw) - .field("fo_ioctl", &self.fo_ioctl) - .field("fo_select", &self.fo_select) - .field("fo_close", &self.fo_close) - .field("fo_fstat", &self.fo_fstat) - .finish() - } - } - impl hash::Hash for fileops_t { - fn hash<H: hash::Hasher>(&self, state: &mut H) { - self.fo_rw.hash(state); - self.fo_ioctl.hash(state); - self.fo_select.hash(state); - self.fo_close.hash(state); - self.fo_fstat.hash(state); - } - } - - impl PartialEq for file { - fn eq(&self, other: &file) -> bool { - self.f_flag == other.f_flag - && self.f_count == other.f_count - && self.f_options == other.f_options - && self.f_type == other.f_type - && self.f_data == other.f_data - && self.f_offset == other.f_offset - && self.f_dir_off == other.f_dir_off - && self.f_cred == other.f_cred - && self.f_vinfo == other.f_vinfo - && self.f_ops == other.f_ops - && self.f_parentp == other.f_parentp - && self.f_fnamep == other.f_fnamep - && self.f_fdata == other.f_fdata - && self.f_lock == other.f_lock - && self.f_offset_lock == other.f_offset_lock - } - } - impl Eq for file {} - impl fmt::Debug for file { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("file") - .field("f_flag", &self.f_flag) - .field("f_count", &self.f_count) - .field("f_options", &self.f_options) - .field("f_type", &self.f_type) - .field("f_data", &self.f_data) - .field("f_offset", &self.f_offset) - .field("f_dir_off", &self.f_dir_off) - .field("f_cred", &self.f_cred) - .field("f_lock", &self.f_lock) - .field("f_offset_lock", &self.f_offset_lock) - .field("f_vinfo", &self.f_vinfo) - .field("f_ops", &self.f_ops) - .field("f_parentp", &self.f_parentp) - .field("f_fnamep", &self.f_fnamep) - .field("f_fdata", &self.f_fdata) - .finish() - } - } - impl hash::Hash for file { - fn hash<H: hash::Hasher>(&self, state: &mut H) { - self.f_flag.hash(state); - self.f_count.hash(state); - self.f_options.hash(state); - self.f_type.hash(state); - self.f_data.hash(state); - self.f_offset.hash(state); - self.f_dir_off.hash(state); - self.f_cred.hash(state); - self.f_lock.hash(state); - self.f_offset_lock.hash(state); - self.f_vinfo.hash(state); - self.f_ops.hash(state); - self.f_parentp.hash(state); - self.f_fnamep.hash(state); - self.f_fdata.hash(state); - } - } - - impl PartialEq for __ld_info_file { - fn eq(&self, other: &__ld_info_file) -> bool { - unsafe { - self._ldinfo_fd == other._ldinfo_fd - && self._ldinfo_fp == other._ldinfo_fp - && self._core_offset == other._core_offset - } - } - } - impl Eq for __ld_info_file {} - impl hash::Hash for __ld_info_file { - fn hash<H: hash::Hasher>(&self, state: &mut H) { - unsafe { - self._ldinfo_fd.hash(state); - self._ldinfo_fp.hash(state); - self._core_offset.hash(state); - } - } - } - - impl PartialEq for ld_info { - fn eq(&self, other: &ld_info) -> bool { - self.ldinfo_next == other.ldinfo_next - && self.ldinfo_flags == other.ldinfo_flags - && self.ldinfo_textorg == other.ldinfo_textorg - && self.ldinfo_textsize == other.ldinfo_textsize - && self.ldinfo_dataorg == other.ldinfo_dataorg - && self.ldinfo_datasize == other.ldinfo_datasize - && self.ldinfo_filename == other.ldinfo_filename - && self._file == other._file - } - } - impl Eq for ld_info {} - impl fmt::Debug for ld_info { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("ld_info") - .field("ldinfo_next", &self.ldinfo_next) - .field("ldinfo_flags", &self.ldinfo_flags) - .field("ldinfo_textorg", &self.ldinfo_textorg) - .field("ldinfo_textsize", &self.ldinfo_textsize) - .field("ldinfo_dataorg", &self.ldinfo_dataorg) - .field("ldinfo_datasize", &self.ldinfo_datasize) - .field("ldinfo_filename", &self.ldinfo_filename) - .field("_file", &self._file) - .finish() - } - } - impl hash::Hash for ld_info { - fn hash<H: hash::Hasher>(&self, state: &mut H) { - self.ldinfo_next.hash(state); - self.ldinfo_flags.hash(state); - self.ldinfo_textorg.hash(state); - self.ldinfo_textsize.hash(state); - self.ldinfo_dataorg.hash(state); - self.ldinfo_datasize.hash(state); - self.ldinfo_filename.hash(state); - self._file.hash(state); - } - } - impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { @@ -543,16 +431,6 @@ cfg_if! { } } impl Eq for pollfd_ext {} - impl fmt::Debug for pollfd_ext { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("pollfd_ext") - .field("fd", &self.fd) - .field("events", &self.events) - .field("revents", &self.revents) - .field("data", &self.data) - .finish() - } - } impl hash::Hash for pollfd_ext { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.fd.hash(state); @@ -561,6 +439,20 @@ cfg_if! { self.data.hash(state); } } + impl PartialEq for fpreg_t { + fn eq(&self, other: &fpreg_t) -> bool { + self.d == other.d + } + } + + impl Eq for fpreg_t {} + + impl hash::Hash for fpreg_t { + fn hash<H: hash::Hasher>(&self, state: &mut H) { + let d: u64 = unsafe { mem::transmute(self.d) }; + d.hash(state); + } + } } } @@ -573,6 +465,11 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __rw_word: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0], }; + +pub const PTHREAD_ONCE_INIT: pthread_once_t = pthread_once_t { + __on_word: [0, 0, 0, 0, 0, 2, 0, 0, 0], +}; + pub const RLIM_INFINITY: c_ulong = 0x7fffffffffffffff; extern "C" { diff --git a/third_party/rust/libc/src/unix/bsd/apple/b32/mod.rs b/third_party/rust/libc/src/unix/bsd/apple/b32/mod.rs @@ -60,7 +60,6 @@ s_no_extra_traits! { __opaque: [c_char; crate::__PTHREAD_ONCE_SIZE__], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], @@ -80,14 +79,6 @@ cfg_if! { } } impl Eq for pthread_attr_t {} - impl fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_attr_t") - .field("__sig", &self.__sig) - // FIXME(debug): .field("__opaque", &self.__opaque) - .finish() - } - } impl hash::Hash for pthread_attr_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__sig.hash(state); @@ -105,13 +96,6 @@ cfg_if! { } } impl Eq for pthread_once_t {} - impl fmt::Debug for pthread_once_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_once_t") - .field("__sig", &self.__sig) - .finish() - } - } impl hash::Hash for pthread_once_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__sig.hash(state); diff --git a/third_party/rust/libc/src/unix/bsd/apple/b64/aarch64/mod.rs b/third_party/rust/libc/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -47,7 +47,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct max_align_t { priv_: f64, } diff --git a/third_party/rust/libc/src/unix/bsd/apple/b64/mod.rs b/third_party/rust/libc/src/unix/bsd/apple/b64/mod.rs @@ -73,14 +73,6 @@ cfg_if! { } } impl Eq for pthread_attr_t {} - impl fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_attr_t") - .field("__sig", &self.__sig) - // FIXME(debug): .field("__opaque", &self.__opaque) - .finish() - } - } impl hash::Hash for pthread_attr_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__sig.hash(state); @@ -98,13 +90,6 @@ cfg_if! { } } impl Eq for pthread_once_t {} - impl fmt::Debug for pthread_once_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_once_t") - .field("__sig", &self.__sig) - .finish() - } - } impl hash::Hash for pthread_once_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__sig.hash(state); diff --git a/third_party/rust/libc/src/unix/bsd/apple/b64/x86_64/mod.rs b/third_party/rust/libc/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -109,6 +109,8 @@ s! { _private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct malloc_zone_t { _reserved1: *mut c_void, _reserved2: *mut c_void, @@ -170,7 +172,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], diff --git a/third_party/rust/libc/src/unix/bsd/apple/mod.rs b/third_party/rust/libc/src/unix/bsd/apple/mod.rs @@ -179,7 +179,7 @@ deprecated_mach! { pub type mach_timebase_info_data_t = mach_timebase_info; } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -188,7 +188,7 @@ impl Clone for timezone { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] #[repr(u32)] pub enum qos_class_t { QOS_CLASS_USER_INTERACTIVE = 0x21, @@ -205,7 +205,7 @@ impl Clone for qos_class_t { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] #[repr(u32)] pub enum sysdir_search_path_directory_t { SYSDIR_DIRECTORY_APPLICATION = 1, @@ -240,7 +240,7 @@ impl Clone for sysdir_search_path_directory_t { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] #[repr(u32)] pub enum sysdir_search_path_domain_mask_t { SYSDIR_DOMAIN_MASK_USER = (1 << 0), @@ -775,7 +775,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub _seq: c_ushort, pub _key: crate::key_t, } @@ -1691,7 +1691,7 @@ impl siginfo_t { si_value: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_timer)).si_value + (*(self as *const siginfo_t).cast::<siginfo_timer>()).si_value } pub unsafe fn si_pid(&self) -> crate::pid_t { @@ -1753,11 +1753,6 @@ cfg_if! { } } impl Eq for ifconf {} - impl fmt::Debug for ifconf { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifconf").finish_non_exhaustive() - } - } impl PartialEq for kevent { fn eq(&self, other: &kevent) -> bool { @@ -1770,24 +1765,6 @@ cfg_if! { } } impl Eq for kevent {} - impl fmt::Debug for kevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let ident = self.ident; - let filter = self.filter; - let flags = self.flags; - let fflags = self.fflags; - let data = self.data; - let udata = self.udata; - f.debug_struct("kevent") - .field("ident", &ident) - .field("filter", &filter) - .field("flags", &flags) - .field("fflags", &fflags) - .field("data", &data) - .field("udata", &udata) - .finish() - } - } impl hash::Hash for kevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { let ident = self.ident; @@ -1822,28 +1799,6 @@ cfg_if! { } } impl Eq for semid_ds {} - impl fmt::Debug for semid_ds { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let sem_perm = self.sem_perm; - let sem_base = self.sem_base; - let sem_nsems = self.sem_nsems; - let sem_otime = self.sem_otime; - let sem_pad1 = self.sem_pad1; - let sem_ctime = self.sem_ctime; - let sem_pad2 = self.sem_pad2; - let sem_pad3 = self.sem_pad3; - f.debug_struct("semid_ds") - .field("sem_perm", &sem_perm) - .field("sem_base", &sem_base) - .field("sem_nsems", &sem_nsems) - .field("sem_otime", &sem_otime) - .field("sem_pad1", &sem_pad1) - .field("sem_ctime", &sem_ctime) - .field("sem_pad2", &sem_pad2) - .field("sem_pad3", &sem_pad3) - .finish() - } - } impl hash::Hash for semid_ds { fn hash<H: hash::Hasher>(&self, state: &mut H) { let sem_perm = self.sem_perm; @@ -1881,30 +1836,6 @@ cfg_if! { } } impl Eq for shmid_ds {} - impl fmt::Debug for shmid_ds { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let shm_perm = self.shm_perm; - let shm_segsz = self.shm_segsz; - let shm_lpid = self.shm_lpid; - let shm_cpid = self.shm_cpid; - let shm_nattch = self.shm_nattch; - let shm_atime = self.shm_atime; - let shm_dtime = self.shm_dtime; - let shm_ctime = self.shm_ctime; - let shm_internal = self.shm_internal; - f.debug_struct("shmid_ds") - .field("shm_perm", &shm_perm) - .field("shm_segsz", &shm_segsz) - .field("shm_lpid", &shm_lpid) - .field("shm_cpid", &shm_cpid) - .field("shm_nattch", &shm_nattch) - .field("shm_atime", &shm_atime) - .field("shm_dtime", &shm_dtime) - .field("shm_ctime", &shm_ctime) - .field("shm_internal", &shm_internal) - .finish() - } - } impl hash::Hash for shmid_ds { fn hash<H: hash::Hasher>(&self, state: &mut H) { let shm_perm = self.shm_perm; @@ -1948,23 +1879,6 @@ cfg_if! { } } impl Eq for proc_threadinfo {} - impl fmt::Debug for proc_threadinfo { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("pth_name", &self.pth_name) - .finish() - } - } impl hash::Hash for proc_threadinfo { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.pth_user_time.hash(state); @@ -2011,28 +1925,6 @@ cfg_if! { } impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("f_mntonname", &self.f_mntonname) - // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) - .field("f_reserved", &self.f_reserved) - .finish() - } - } impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { @@ -2070,18 +1962,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -2103,14 +1983,6 @@ cfg_if! { } } impl Eq for pthread_rwlock_t {} - impl fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_rwlock_t") - .field("__sig", &self.__sig) - // FIXME(debug): .field("__opaque", &self.__opaque) - .finish() - } - } impl hash::Hash for pthread_rwlock_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__sig.hash(state); @@ -2131,15 +2003,6 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_mutex_t") - .field("__sig", &self.__sig) - // FIXME(debug): .field("__opaque", &self.__opaque) - .finish() - } - } - impl hash::Hash for pthread_mutex_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__sig.hash(state); @@ -2160,15 +2023,6 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_cond_t") - .field("__sig", &self.__sig) - // FIXME(debug): .field("__opaque", &self.__opaque) - .finish() - } - } - impl hash::Hash for pthread_cond_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__sig.hash(state); @@ -2196,18 +2050,6 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("__ss_pad2", &self.__ss_pad2) - .finish() - } - } - impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_len.hash(state); @@ -2240,21 +2082,6 @@ cfg_if! { impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - // FIXME(debug): .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(debug): .field("ut_host", &self.ut_host) - .field("ut_pad", &self.ut_pad) - .finish() - } - } - impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_user.hash(state); @@ -2279,17 +2106,6 @@ cfg_if! { impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_notify", &self.sigev_notify) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_value", &self.sigev_value) - .field("sigev_notify_attributes", &self.sigev_notify_attributes) - .finish() - } - } - impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_notify.hash(state); @@ -2305,13 +2121,6 @@ cfg_if! { } } impl Eq for processor_cpu_load_info {} - impl fmt::Debug for processor_cpu_load_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("processor_cpu_load_info") - .field("cpu_ticks", &self.cpu_ticks) - .finish() - } - } impl hash::Hash for processor_cpu_load_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cpu_ticks.hash(state); @@ -2328,17 +2137,6 @@ cfg_if! { } } impl Eq for processor_basic_info {} - impl fmt::Debug for processor_basic_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("processor_basic_info") - .field("cpu_type", &self.cpu_type) - .field("cpu_subtype", &self.cpu_subtype) - .field("running", &self.running) - .field("slot_num", &self.slot_num) - .field("is_master", &self.is_master) - .finish() - } - } impl hash::Hash for processor_basic_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cpu_type.hash(state); @@ -2356,14 +2154,6 @@ cfg_if! { } } impl Eq for processor_set_basic_info {} - impl fmt::Debug for processor_set_basic_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("processor_set_basic_info") - .field("processor_count", &self.processor_count) - .field("default_policy", &self.default_policy) - .finish() - } - } impl hash::Hash for processor_set_basic_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.processor_count.hash(state); @@ -2380,16 +2170,6 @@ cfg_if! { } } impl Eq for processor_set_load_info {} - impl fmt::Debug for processor_set_load_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("processor_set_load_info") - .field("task_count", &self.task_count) - .field("thread_count", &self.thread_count) - .field("load_average", &self.load_average) - .field("mach_factor", &self.mach_factor) - .finish() - } - } impl hash::Hash for processor_set_load_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.task_count.hash(state); @@ -2405,14 +2185,6 @@ cfg_if! { } } impl Eq for time_value_t {} - impl fmt::Debug for time_value_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("time_value_t") - .field("seconds", &self.seconds) - .field("microseconds", &self.microseconds) - .finish() - } - } impl hash::Hash for time_value_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.seconds.hash(state); @@ -2432,20 +2204,6 @@ cfg_if! { } } impl Eq for thread_basic_info {} - impl fmt::Debug for thread_basic_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("thread_basic_info") - .field("user_time", &self.user_time) - .field("system_time", &self.system_time) - .field("cpu_usage", &self.cpu_usage) - .field("policy", &self.policy) - .field("run_state", &self.run_state) - .field("flags", &self.flags) - .field("suspend_count", &self.suspend_count) - .field("sleep_time", &self.sleep_time) - .finish() - } - } impl hash::Hash for thread_basic_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.user_time.hash(state); @@ -2478,23 +2236,6 @@ cfg_if! { } } impl Eq for thread_extended_info {} - impl fmt::Debug for thread_extended_info { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("pth_name", &self.pth_name) - .finish() - } - } impl hash::Hash for thread_extended_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.pth_user_time.hash(state); @@ -2518,15 +2259,6 @@ cfg_if! { } } impl Eq for thread_identifier_info {} - impl fmt::Debug for thread_identifier_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("thread_identifier_info") - .field("thread_id", &self.thread_id) - .field("thread_handle", &self.thread_handle) - .field("dispatch_qaddr", &self.dispatch_qaddr) - .finish() - } - } impl hash::Hash for thread_identifier_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.thread_id.hash(state); @@ -2564,62 +2296,6 @@ cfg_if! { } } impl Eq for if_data64 {} - impl fmt::Debug for if_data64 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let ifi_type = self.ifi_type; - let ifi_typelen = self.ifi_typelen; - let ifi_physical = self.ifi_physical; - let ifi_addrlen = self.ifi_addrlen; - let ifi_hdrlen = self.ifi_hdrlen; - let ifi_recvquota = self.ifi_recvquota; - let ifi_xmitquota = self.ifi_xmitquota; - let ifi_unused1 = self.ifi_unused1; - let ifi_mtu = self.ifi_mtu; - let ifi_metric = self.ifi_metric; - let ifi_baudrate = self.ifi_baudrate; - let ifi_ipackets = self.ifi_ipackets; - let ifi_ierrors = self.ifi_ierrors; - let ifi_opackets = self.ifi_opackets; - let ifi_oerrors = self.ifi_oerrors; - let ifi_collisions = self.ifi_collisions; - let ifi_ibytes = self.ifi_ibytes; - let ifi_obytes = self.ifi_obytes; - let ifi_imcasts = self.ifi_imcasts; - let ifi_omcasts = self.ifi_omcasts; - let ifi_iqdrops = self.ifi_iqdrops; - let ifi_noproto = self.ifi_noproto; - let ifi_recvtiming = self.ifi_recvtiming; - let ifi_xmittiming = self.ifi_xmittiming; - let ifi_lastchange = self.ifi_lastchange; - f.debug_struct("if_data64") - .field("ifi_type", &ifi_type) - .field("ifi_typelen", &ifi_typelen) - .field("ifi_physical", &ifi_physical) - .field("ifi_addrlen", &ifi_addrlen) - .field("ifi_hdrlen", &ifi_hdrlen) - .field("ifi_recvquota", &ifi_recvquota) - .field("ifi_xmitquota", &ifi_xmitquota) - .field("ifi_unused1", &ifi_unused1) - .field("ifi_mtu", &ifi_mtu) - .field("ifi_metric", &ifi_metric) - .field("ifi_baudrate", &ifi_baudrate) - .field("ifi_ipackets", &ifi_ipackets) - .field("ifi_ierrors", &ifi_ierrors) - .field("ifi_opackets", &ifi_opackets) - .field("ifi_oerrors", &ifi_oerrors) - .field("ifi_collisions", &ifi_collisions) - .field("ifi_ibytes", &ifi_ibytes) - .field("ifi_obytes", &ifi_obytes) - .field("ifi_imcasts", &ifi_imcasts) - .field("ifi_omcasts", &ifi_omcasts) - .field("ifi_iqdrops", &ifi_iqdrops) - .field("ifi_noproto", &ifi_noproto) - .field("ifi_recvtiming", &ifi_recvtiming) - .field("ifi_xmittiming", &ifi_xmittiming) - .field("ifi_lastchange", &ifi_lastchange) - .finish() - } - } impl hash::Hash for if_data64 { fn hash<H: hash::Hasher>(&self, state: &mut H) { let ifi_type = self.ifi_type; @@ -2690,34 +2366,6 @@ cfg_if! { } } impl Eq for if_msghdr2 {} - impl fmt::Debug for if_msghdr2 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let ifm_msglen = self.ifm_msglen; - let ifm_version = self.ifm_version; - let ifm_type = self.ifm_type; - let ifm_addrs = self.ifm_addrs; - let ifm_flags = self.ifm_flags; - let ifm_index = self.ifm_index; - let ifm_snd_len = self.ifm_snd_len; - let ifm_snd_maxlen = self.ifm_snd_maxlen; - let ifm_snd_drops = self.ifm_snd_drops; - let ifm_timer = self.ifm_timer; - let ifm_data = self.ifm_data; - f.debug_struct("if_msghdr2") - .field("ifm_msglen", &ifm_msglen) - .field("ifm_version", &ifm_version) - .field("ifm_type", &ifm_type) - .field("ifm_addrs", &ifm_addrs) - .field("ifm_flags", &ifm_flags) - .field("ifm_index", &ifm_index) - .field("ifm_snd_len", &ifm_snd_len) - .field("ifm_snd_maxlen", &ifm_snd_maxlen) - .field("ifm_snd_drops", &ifm_snd_drops) - .field("ifm_timer", &ifm_timer) - .field("ifm_data", &ifm_data) - .finish() - } - } impl hash::Hash for if_msghdr2 { fn hash<H: hash::Hasher>(&self, state: &mut H) { let ifm_msglen = self.ifm_msglen; @@ -2775,64 +2423,6 @@ cfg_if! { } } impl Eq for vm_statistics64 {} - impl fmt::Debug for vm_statistics64 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let free_count = self.free_count; - let active_count = self.active_count; - let inactive_count = self.inactive_count; - let wire_count = self.wire_count; - let zero_fill_count = self.zero_fill_count; - let reactivations = self.reactivations; - let pageins = self.pageins; - let pageouts = self.pageouts; - let faults = self.faults; - let cow_faults = self.cow_faults; - let lookups = self.lookups; - let hits = self.hits; - let purges = self.purges; - let purgeable_count = self.purgeable_count; - let speculative_count = self.speculative_count; - let decompressions = self.decompressions; - let compressions = self.compressions; - let swapins = self.swapins; - let swapouts = self.swapouts; - let compressor_page_count = self.compressor_page_count; - let throttled_count = self.throttled_count; - let external_page_count = self.external_page_count; - let internal_page_count = self.internal_page_count; - // Otherwise rustfmt crashes... - let total_uncompressed = self.total_uncompressed_pages_in_compressor; - f.debug_struct("vm_statistics64") - .field("free_count", &free_count) - .field("active_count", &active_count) - .field("inactive_count", &inactive_count) - .field("wire_count", &wire_count) - .field("zero_fill_count", &zero_fill_count) - .field("reactivations", &reactivations) - .field("pageins", &pageins) - .field("pageouts", &pageouts) - .field("faults", &faults) - .field("cow_faults", &cow_faults) - .field("lookups", &lookups) - .field("hits", &hits) - .field("purges", &purges) - .field("purgeable_count", &purgeable_count) - .field("speculative_count", &speculative_count) - .field("decompressions", &decompressions) - .field("compressions", &compressions) - .field("swapins", &swapins) - .field("swapouts", &swapouts) - .field("compressor_page_count", &compressor_page_count) - .field("throttled_count", &throttled_count) - .field("external_page_count", &external_page_count) - .field("internal_page_count", &internal_page_count) - .field( - "total_uncompressed_pages_in_compressor", - &total_uncompressed, - ) - .finish() - } - } impl hash::Hash for vm_statistics64 { fn hash<H: hash::Hasher>(&self, state: &mut H) { let free_count = self.free_count; @@ -2899,26 +2489,6 @@ cfg_if! { } } impl Eq for mach_task_basic_info {} - impl fmt::Debug for mach_task_basic_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let virtual_size = self.virtual_size; - let resident_size = self.resident_size; - let resident_size_max = self.resident_size_max; - let user_time = self.user_time; - let system_time = self.system_time; - let policy = self.policy; - let suspend_count = self.suspend_count; - f.debug_struct("mach_task_basic_info") - .field("virtual_size", &virtual_size) - .field("resident_size", &resident_size) - .field("resident_size_max", &resident_size_max) - .field("user_time", &user_time) - .field("system_time", &system_time) - .field("policy", &policy) - .field("suspend_count", &suspend_count) - .finish() - } - } impl hash::Hash for mach_task_basic_info { fn hash<H: hash::Hasher>(&self, state: &mut H) { let virtual_size = self.virtual_size; @@ -2946,18 +2516,6 @@ cfg_if! { } } impl Eq for log2phys {} - impl fmt::Debug for log2phys { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let l2p_flags = self.l2p_flags; - let l2p_contigbytes = self.l2p_contigbytes; - let l2p_devoffset = self.l2p_devoffset; - f.debug_struct("log2phys") - .field("l2p_flags", &l2p_flags) - .field("l2p_contigbytes", &l2p_contigbytes) - .field("l2p_devoffset", &l2p_devoffset) - .finish() - } - } impl hash::Hash for log2phys { fn hash<H: hash::Hasher>(&self, state: &mut H) { let l2p_flags = self.l2p_flags; @@ -2976,14 +2534,6 @@ cfg_if! { impl Eq for os_unfair_lock {} - impl fmt::Debug for os_unfair_lock { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("os_unfair_lock") - .field("_os_unfair_lock_opaque", &self._os_unfair_lock_opaque) - .finish() - } - } - impl hash::Hash for os_unfair_lock { fn hash<H: hash::Hasher>(&self, state: &mut H) { self._os_unfair_lock_opaque.hash(state); @@ -3002,24 +2552,6 @@ cfg_if! { impl Eq for sockaddr_vm {} - impl fmt::Debug for sockaddr_vm { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let svm_len = self.svm_len; - let svm_family = self.svm_family; - let svm_reserved1 = self.svm_reserved1; - let svm_port = self.svm_port; - let svm_cid = self.svm_cid; - - f.debug_struct("sockaddr_vm") - .field("svm_len", &svm_len) - .field("svm_family", &svm_family) - .field("svm_reserved1", &svm_reserved1) - .field("svm_port", &svm_port) - .field("svm_cid", &svm_cid) - .finish() - } - } - impl hash::Hash for sockaddr_vm { fn hash<H: hash::Hasher>(&self, state: &mut H) { let svm_len = self.svm_len; @@ -3046,16 +2578,6 @@ cfg_if! { impl Eq for ifdevmtu {} - impl fmt::Debug for ifdevmtu { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifdevmtu") - .field("ifdm_current", &self.ifdm_current) - .field("ifdm_min", &self.ifdm_min) - .field("ifdm_max", &self.ifdm_max) - .finish() - } - } - impl hash::Hash for ifdevmtu { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifdm_current.hash(state); @@ -3088,15 +2610,6 @@ cfg_if! { impl Eq for ifkpi {} - impl fmt::Debug for ifkpi { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifkpi") - .field("ifk_module_id", &self.ifk_module_id) - .field("ifk_type", &self.ifk_type) - .finish() - } - } - impl hash::Hash for ifkpi { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifk_module_id.hash(state); @@ -3164,15 +2677,6 @@ cfg_if! { impl Eq for ifreq {} - impl fmt::Debug for ifreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifreq") - .field("ifr_name", &self.ifr_name) - .field("ifr_ifru", &self.ifr_ifru) - .finish() - } - } - impl hash::Hash for ifreq { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifr_name.hash(state); @@ -3238,15 +2742,6 @@ cfg_if! { } impl Eq for in6_ifreq {} - - impl fmt::Debug for in6_ifreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("in6_ifreq") - .field("ifr_name", &self.ifr_name) - .field("ifr_ifru", &self.ifr_ifru) - .finish() - } - } } } @@ -5147,7 +4642,7 @@ pub const PROC_PIDVNODEPATHINFO: c_int = 9; pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; pub const PROC_PIDLISTFDS: c_int = 1; -pub const PROC_PIDLISTFD_SIZE: c_int = mem::size_of::<proc_fdinfo>() as c_int; +pub const PROC_PIDLISTFD_SIZE: c_int = size_of::<proc_fdinfo>() as c_int; pub const PROX_FDTYPE_ATALK: c_int = 0; pub const PROX_FDTYPE_VNODE: c_int = 1; pub const PROX_FDTYPE_SOCKET: c_int = 2; @@ -5634,48 +5129,42 @@ pub const VMADDR_CID_HOST: c_uint = 2; pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; const fn __DARWIN_ALIGN32(p: usize) -> usize { - const __DARWIN_ALIGNBYTES32: usize = mem::size_of::<u32>() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 + const __DARWIN_ALIGNBYTES32: usize = size_of::<u32>() - 1; + (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32 } pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_extended_policy_data_t>() / mem::size_of::<integer_t>()) - as mach_msg_type_number_t; + (size_of::<thread_extended_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_time_constraint_policy_data_t>() / mem::size_of::<integer_t>()) + (size_of::<thread_time_constraint_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_precedence_policy_data_t>() / mem::size_of::<integer_t>()) + (size_of::<thread_precedence_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_affinity_policy_data_t>() / mem::size_of::<integer_t>()) - as mach_msg_type_number_t; + (size_of::<thread_affinity_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_background_policy_data_t>() / mem::size_of::<integer_t>()) + (size_of::<thread_background_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_latency_qos_policy_data_t>() / mem::size_of::<integer_t>()) + (size_of::<thread_latency_qos_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_throughput_qos_policy_data_t>() / mem::size_of::<integer_t>()) + (size_of::<thread_throughput_qos_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_basic_info_data_t>() / mem::size_of::<integer_t>()) - as mach_msg_type_number_t; + (size_of::<thread_basic_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_identifier_info_data_t>() / mem::size_of::<integer_t>()) - as mach_msg_type_number_t; + (size_of::<thread_identifier_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = - (mem::size_of::<thread_extended_info_data_t>() / mem::size_of::<integer_t>()) - as mach_msg_type_number_t; + (size_of::<thread_extended_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = - (mem::size_of::<task_thread_times_info_data_t>() / mem::size_of::<natural_t>()) as u32; + (size_of::<task_thread_times_info_data_t>() / size_of::<natural_t>()) as u32; pub const MACH_TASK_BASIC_INFO_COUNT: u32 = - (mem::size_of::<mach_task_basic_info_data_t>() / mem::size_of::<natural_t>()) as u32; -pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = (mem::size_of::<vm_statistics64_data_t>() - / mem::size_of::<integer_t>()) - as mach_msg_type_number_t; + (size_of::<mach_task_basic_info_data_t>() / size_of::<natural_t>()) as u32; +pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = + (size_of::<vm_statistics64_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t; // bsd/net/if_mib.h /// Non-interface-specific @@ -5710,11 +5199,11 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); - }; + } let cmsg_len = (*cmsg).cmsg_len as usize; let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; - if next + __DARWIN_ALIGN32(mem::size_of::<cmsghdr>()) > max { + if next + __DARWIN_ALIGN32(size_of::<cmsghdr>()) > max { core::ptr::null_mut() } else { next as *mut cmsghdr @@ -5722,52 +5211,52 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).add(__DARWIN_ALIGN32(mem::size_of::<cmsghdr>())) + (cmsg as *mut c_uchar).add(__DARWIN_ALIGN32(size_of::<cmsghdr>())) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (__DARWIN_ALIGN32(mem::size_of::<cmsghdr>()) + __DARWIN_ALIGN32(length as usize)) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (__DARWIN_ALIGN32(size_of::<cmsghdr>()) + __DARWIN_ALIGN32(length as usize)) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - (__DARWIN_ALIGN32(mem::size_of::<cmsghdr>()) + length as usize) as c_uint + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + (__DARWIN_ALIGN32(size_of::<cmsghdr>()) + length as usize) as c_uint } - pub {const} fn VM_MAKE_TAG(id: u8) -> u32 { + pub const fn VM_MAKE_TAG(id: u8) -> u32 { (id as u32) << 24u32 } } safe_f! { - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn _WSTATUS(status: c_int) -> c_int { + pub const fn _WSTATUS(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13 } - pub {const} fn makedev(major: i32, minor: i32) -> dev_t { + pub const fn makedev(major: i32, minor: i32) -> dev_t { (major << 24) | minor } - pub {const} fn major(dev: dev_t) -> i32 { + pub const fn major(dev: dev_t) -> i32 { (dev >> 24) & 0xff } - pub {const} fn minor(dev: dev_t) -> i32 { + pub const fn minor(dev: dev_t) -> i32 { dev & 0xffffff } } @@ -6341,7 +5830,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, @@ -6660,15 +6149,22 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int; pub fn execvP( file: *const c_char, search_path: *const c_char, argv: *const *mut c_char, ) -> c_int; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>, + ); } #[allow(deprecated)] @@ -6711,10 +6207,11 @@ cfg_if! { // These require a dependency on `libiconv`, and including this when built as // part of `std` means every Rust program gets it. Ideally we would have a link // modifier to only include these if they are used, but we do not. -#[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] #[cfg_attr(not(feature = "rustc-dep-of-std"), link(name = "iconv"))] extern "C" { + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] pub fn iconv( cd: iconv_t, inbuf: *mut *mut c_char, @@ -6722,6 +6219,7 @@ extern "C" { outbuf: *mut *mut c_char, outbytesleft: *mut size_t, ) -> size_t; + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] pub fn iconv_close(cd: iconv_t) -> c_int; } diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -45,7 +45,7 @@ pub type vm_map_entry_t = *mut vm_map_entry; pub type pmap = __c_anonymous_pmap; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum sem {} impl Copy for sem {} impl Clone for sem { @@ -520,6 +520,8 @@ s_no_extra_traits! { pub mc_fpregs: [[c_uint; 8]; 32], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct ucontext_t { pub uc_sigmask: crate::sigset_t, pub uc_mcontext: mcontext_t, @@ -554,24 +556,6 @@ cfg_if! { } } impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - .field("ut_name", &self.ut_name) - .field("ut_id", &self.ut_id) - .field("ut_line", &self.ut_line) - // FIXME(debug): .field("ut_host", &self.ut_host) - .field("ut_unused", &self.ut_unused) - .field("ut_session", &self.ut_session) - .field("ut_type", &self.ut_type) - .field("ut_pid", &self.ut_pid) - .field("ut_exit", &self.ut_exit) - .field("ut_ss", &self.ut_ss) - .field("ut_tv", &self.ut_tv) - .field("ut_unused2", &self.ut_unused2) - .finish() - } - } impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_name.hash(state); @@ -597,16 +581,6 @@ cfg_if! { } } impl Eq for lastlogx {} - impl fmt::Debug for lastlogx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("lastlogx") - .field("ll_tv", &self.ll_tv) - .field("ll_line", &self.ll_line) - .field("ll_host", &self.ll_host) - .field("ll_ss", &self.ll_ss) - .finish() - } - } impl hash::Hash for lastlogx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ll_tv.hash(state); @@ -631,18 +605,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_namlen", &self.d_namlen) - .field("d_type", &self.d_type) - // Ignore __unused1 - // Ignore __unused2 - // FIXME(debug): .field("d_name", &self.d_name) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -685,29 +647,6 @@ cfg_if! { } } impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_type", &self.f_type) - .field("f_flags", &self.f_flags) - .field("f_syncwrites", &self.f_syncwrites) - .field("f_asyncwrites", &self.f_asyncwrites) - // FIXME(debug): .field("f_mntonname", &self.f_mntonname) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncreads", &self.f_asyncreads) - // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) - .finish() - } - } impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_bsize.hash(state); @@ -739,15 +678,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_notify", &self.sigev_notify) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_value", &self.sigev_value) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_notify.hash(state); @@ -790,42 +720,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_onstack", &self.mc_onstack) - .field("mc_rdi", &self.mc_rdi) - .field("mc_rsi", &self.mc_rsi) - .field("mc_rdx", &self.mc_rdx) - .field("mc_rcx", &self.mc_rcx) - .field("mc_r8", &self.mc_r8) - .field("mc_r9", &self.mc_r9) - .field("mc_rax", &self.mc_rax) - .field("mc_rbx", &self.mc_rbx) - .field("mc_rbp", &self.mc_rbp) - .field("mc_r10", &self.mc_r10) - .field("mc_r11", &self.mc_r11) - .field("mc_r12", &self.mc_r12) - .field("mc_r13", &self.mc_r13) - .field("mc_r14", &self.mc_r14) - .field("mc_r15", &self.mc_r15) - .field("mc_xflags", &self.mc_xflags) - .field("mc_trapno", &self.mc_trapno) - .field("mc_addr", &self.mc_addr) - .field("mc_flags", &self.mc_flags) - .field("mc_err", &self.mc_err) - .field("mc_rip", &self.mc_rip) - .field("mc_cs", &self.mc_cs) - .field("mc_rflags", &self.mc_rflags) - .field("mc_rsp", &self.mc_rsp) - .field("mc_ss", &self.mc_ss) - .field("mc_len", &self.mc_len) - .field("mc_fpformat", &self.mc_fpformat) - .field("mc_ownedfp", &self.mc_ownedfp) - .field("mc_fpregs", &self.mc_fpregs) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mc_onstack.hash(state); @@ -875,18 +769,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_sigmask", &self.uc_sigmask) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_cofunc", &self.uc_cofunc) - .field("uc_arg", &self.uc_arg) - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_sigmask.hash(state); @@ -1067,7 +949,7 @@ pub const CPUCTL_MSRSBIT: c_int = 0xc0106305; pub const CPUCTL_MSRCBIT: c_int = 0xc0106306; pub const CPUCTL_CPUID_COUNT: c_int = 0xc0106307; -pub const CPU_SETSIZE: size_t = mem::size_of::<crate::cpumask_t>() * 8; +pub const CPU_SETSIZE: size_t = size_of::<crate::cpumask_t>() * 8; pub const EVFILT_READ: i16 = -1; pub const EVFILT_WRITE: i16 = -2; @@ -1537,35 +1419,33 @@ pub const RTAX_MPLS2: c_int = 9; pub const RTAX_MPLS3: c_int = 10; pub const RTAX_MAX: c_int = 11; -const_fn! { - {const} fn _CMSG_ALIGN(n: usize) -> usize { - (n + (mem::size_of::<c_long>() - 1)) & !(mem::size_of::<c_long>() - 1) - } +const fn _CMSG_ALIGN(n: usize) -> usize { + (n + (size_of::<c_long>() - 1)) & !(size_of::<c_long>() - 1) } f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::<cmsghdr>()) as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - (_CMSG_ALIGN(mem::size_of::<cmsghdr>()) + length as usize) as c_uint + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + (_CMSG_ALIGN(size_of::<cmsghdr>()) + length as usize) as c_uint } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize) - + _CMSG_ALIGN(mem::size_of::<cmsghdr>()); + + _CMSG_ALIGN(size_of::<cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next <= max { (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_CMSG_ALIGN(mem::size_of::<cmsghdr>()) + _CMSG_ALIGN(length as usize)) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_CMSG_ALIGN(size_of::<cmsghdr>()) + _CMSG_ALIGN(length as usize)) as c_uint } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { @@ -1593,11 +1473,11 @@ f! { } safe_f! { - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -1606,11 +1486,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { ((dev >> 8) & 0xff) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (dev & 0xffff00ff) as c_int } } diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -33,7 +33,7 @@ s_no_extra_traits! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1; cfg_if! { if #[cfg(feature = "extra_traits")] { @@ -48,18 +48,6 @@ cfg_if! { } } impl Eq for gpregs {} - impl fmt::Debug for gpregs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("gpregs") - .field("gp_x", &self.gp_x) - .field("gp_lr", &self.gp_lr) - .field("gp_sp", &self.gp_sp) - .field("gp_elr", &self.gp_elr) - .field("gp_spsr", &self.gp_spsr) - .field("gp_pad", &self.gp_pad) - .finish() - } - } impl hash::Hash for gpregs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.gp_x.hash(state); @@ -80,17 +68,6 @@ cfg_if! { } } impl Eq for fpregs {} - impl fmt::Debug for fpregs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpregs") - .field("fp_q", &self.fp_q) - .field("fp_sr", &self.fp_sr) - .field("fp_cr", &self.fp_cr) - .field("fp_flags", &self.fp_flags) - .field("fp_pad", &self.fp_pad) - .finish() - } - } impl hash::Hash for fpregs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.fp_q.hash(state); @@ -114,17 +91,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_gpregs", &self.mc_gpregs) - .field("mc_fpregs", &self.mc_fpregs) - .field("mc_flags", &self.mc_flags) - .field("mc_pad", &self.mc_pad) - .field("mc_spare", &self.mc_spare) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mc_gpregs.hash(state); diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -32,16 +32,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("__gregs", &self.__gregs) - .field("mc_vfp_size", &self.mc_vfp_size) - .field("mc_vfp_ptr", &self.mc_vfp_ptr) - .field("mc_spare", &self.mc_spare) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__gregs.hash(state); @@ -53,7 +43,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_int>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs @@ -2,7 +2,8 @@ use crate::off_t; use crate::prelude::*; #[repr(C)] -#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))] pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs @@ -2,7 +2,8 @@ use crate::off_t; use crate::prelude::*; #[repr(C)] -#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))] pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -51,9 +51,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, @@ -297,29 +296,6 @@ cfg_if! { } } impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_syncwrites", &self.f_syncwrites) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_fsid", &self.f_fsid) - .field("f_fstypename", &self.f_fstypename) - .field("f_mntfromname", &&self.f_mntfromname[..]) - .field("f_mntonname", &&self.f_mntonname[..]) - .finish() - } - } impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_version.hash(state); @@ -358,17 +334,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - .field("d_namlen", &self.d_namlen) - .field("d_name", &&self.d_name[..self.d_namlen as _]) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -395,22 +360,6 @@ cfg_if! { } } impl Eq for vnstat {} - impl fmt::Debug for vnstat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let self_vn_devname: &[c_char] = &self.vn_devname; - - f.debug_struct("vnstat") - .field("vn_fileid", &self.vn_fileid) - .field("vn_size", &self.vn_size) - .field("vn_mntdir", &self.vn_mntdir) - .field("vn_dev", &self.vn_dev) - .field("vn_fsid", &self.vn_fsid) - .field("vn_type", &self.vn_type) - .field("vn_mode", &self.vn_mode) - .field("vn_devname", &self_vn_devname) - .finish() - } - } impl hash::Hash for vnstat { fn hash<H: hash::Hasher>(&self, state: &mut H) { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -436,17 +385,17 @@ pub const MINCORE_SUPER: c_int = 0x20; pub const SPECNAMELEN: c_int = 63; safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; (major << 8) | minor } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { ((dev >> 8) & 0xff) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (dev & 0xffff00ff) as c_int } } @@ -475,6 +424,18 @@ extern "C" { // in FreeBSD 12 pub fn dirname(path: *const c_char) -> *mut c_char; pub fn basename(path: *const c_char) -> *mut c_char; + + // Argument order of the function pointer changed in FreeBSD 14. From 14 onwards the signature + // matches the POSIX specification by having the third argument be a mutable pointer, on + // earlier versions the first argument is the mutable pointer. + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>, + ); } cfg_if! { diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -59,9 +59,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, @@ -341,29 +340,6 @@ cfg_if! { } } impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_syncwrites", &self.f_syncwrites) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_fsid", &self.f_fsid) - .field("f_fstypename", &self.f_fstypename) - .field("f_mntfromname", &&self.f_mntfromname[..]) - .field("f_mntonname", &&self.f_mntonname[..]) - .finish() - } - } impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_version.hash(state); @@ -404,18 +380,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - .field("d_namlen", &self.d_namlen) - .field("d_name", &&self.d_name[..self.d_namlen as _]) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -443,22 +407,6 @@ cfg_if! { } } impl Eq for vnstat {} - impl fmt::Debug for vnstat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let self_vn_devname: &[c_char] = &self.vn_devname; - - f.debug_struct("vnstat") - .field("vn_fileid", &self.vn_fileid) - .field("vn_size", &self.vn_size) - .field("vn_dev", &self.vn_dev) - .field("vn_fsid", &self.vn_fsid) - .field("vn_mntdir", &self.vn_mntdir) - .field("vn_type", &self.vn_type) - .field("vn_mode", &self.vn_mode) - .field("vn_devname", &self_vn_devname) - .finish() - } - } impl hash::Hash for vnstat { fn hash<H: hash::Hasher>(&self, state: &mut H) { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -486,7 +434,7 @@ pub const KI_NSPARE_PTR: usize = 6; pub const MINCORE_SUPER: c_int = 0x20; safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -497,11 +445,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } @@ -520,6 +468,15 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>, + ); } cfg_if! { diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -69,9 +69,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, @@ -354,29 +353,6 @@ cfg_if! { } } impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_syncwrites", &self.f_syncwrites) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_fsid", &self.f_fsid) - .field("f_fstypename", &self.f_fstypename) - .field("f_mntfromname", &&self.f_mntfromname[..]) - .field("f_mntonname", &&self.f_mntonname[..]) - .finish() - } - } impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_version.hash(state); @@ -417,18 +393,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - .field("d_namlen", &self.d_namlen) - .field("d_name", &&self.d_name[..self.d_namlen as _]) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -456,22 +420,6 @@ cfg_if! { } } impl Eq for vnstat {} - impl fmt::Debug for vnstat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let self_vn_devname: &[c_char] = &self.vn_devname; - - f.debug_struct("vnstat") - .field("vn_fileid", &self.vn_fileid) - .field("vn_size", &self.vn_size) - .field("vn_dev", &self.vn_dev) - .field("vn_fsid", &self.vn_fsid) - .field("vn_mntdir", &self.vn_mntdir) - .field("vn_type", &self.vn_type) - .field("vn_mode", &self.vn_mode) - .field("vn_devname", &self_vn_devname) - .finish() - } - } impl hash::Hash for vnstat { fn hash<H: hash::Hasher>(&self, state: &mut H) { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -508,7 +456,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x20; safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -519,11 +467,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } @@ -559,6 +507,15 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>, + ); } #[link(name = "kvm")] diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -69,9 +69,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, @@ -235,6 +234,7 @@ s! { pub ki_tdflags: c_long, } + #[non_exhaustive] pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -266,7 +266,8 @@ s! { pub st_blksize: crate::blksize_t, pub st_flags: crate::fflags_t, pub st_gen: u64, - pub st_spare: [u64; 10], + pub st_filerev: u64, + pub st_spare: [u64; 9], } } @@ -354,29 +355,6 @@ cfg_if! { } } impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_syncwrites", &self.f_syncwrites) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_fsid", &self.f_fsid) - .field("f_fstypename", &self.f_fstypename) - .field("f_mntfromname", &&self.f_mntfromname[..]) - .field("f_mntonname", &&self.f_mntonname[..]) - .finish() - } - } impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_version.hash(state); @@ -417,18 +395,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - .field("d_namlen", &self.d_namlen) - .field("d_name", &&self.d_name[..self.d_namlen as _]) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -456,22 +422,6 @@ cfg_if! { } } impl Eq for vnstat {} - impl fmt::Debug for vnstat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let self_vn_devname: &[c_char] = &self.vn_devname; - - f.debug_struct("vnstat") - .field("vn_fileid", &self.vn_fileid) - .field("vn_size", &self.vn_size) - .field("vn_dev", &self.vn_dev) - .field("vn_fsid", &self.vn_fsid) - .field("vn_mntdir", &self.vn_mntdir) - .field("vn_type", &self.vn_type) - .field("vn_mode", &self.vn_mode) - .field("vn_devname", &self_vn_devname) - .finish() - } - } impl hash::Hash for vnstat { fn hash<H: hash::Hasher>(&self, state: &mut H) { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -508,7 +458,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x60; safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -519,11 +469,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } @@ -559,6 +509,14 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>, + arg: *mut c_void, + ); } #[link(name = "kvm")] diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -50,6 +50,7 @@ s! { _priv: [c_ulong; 8], } + #[non_exhaustive] pub struct kinfo_proc { /// Size of this structure. pub ki_structsize: c_int, @@ -69,9 +70,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, @@ -227,6 +227,8 @@ s! { // This is normally "struct pwddesc". /// Pointer to process paths info. pub ki_pd: *mut c_void, + /// Address of the ext err msg place + pub ki_uerrmsg: *mut c_void, pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], /// PS_* flags. @@ -355,29 +357,6 @@ cfg_if! { } } impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_syncwrites", &self.f_syncwrites) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_fsid", &self.f_fsid) - .field("f_fstypename", &self.f_fstypename) - .field("f_mntfromname", &&self.f_mntfromname[..]) - .field("f_mntonname", &&self.f_mntonname[..]) - .finish() - } - } impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_version.hash(state); @@ -418,18 +397,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - .field("d_namlen", &self.d_namlen) - .field("d_name", &&self.d_name[..self.d_namlen as _]) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -457,22 +424,6 @@ cfg_if! { } } impl Eq for vnstat {} - impl fmt::Debug for vnstat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let self_vn_devname: &[c_char] = &self.vn_devname; - - f.debug_struct("vnstat") - .field("vn_fileid", &self.vn_fileid) - .field("vn_size", &self.vn_size) - .field("vn_dev", &self.vn_dev) - .field("vn_fsid", &self.vn_fsid) - .field("vn_mntdir", &self.vn_mntdir) - .field("vn_type", &self.vn_type) - .field("vn_mode", &self.vn_mode) - .field("vn_devname", &self_vn_devname) - .finish() - } - } impl hash::Hash for vnstat { fn hash<H: hash::Hasher>(&self, state: &mut H) { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -497,7 +448,7 @@ pub const KF_TYPE_EVENTFD: c_int = 13; /// max length of devicename pub const SPECNAMELEN: c_int = 255; -pub const KI_NSPARE_PTR: usize = 5; +pub const KI_NSPARE_PTR: usize = 4; /// domainset policies pub const DOMAINSET_POLICY_INVALID: c_int = 0; @@ -509,7 +460,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x60; safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -520,11 +471,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } @@ -560,6 +511,14 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>, + arg: *mut c_void, + ); } #[link(name = "kvm")] diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -11,6 +11,9 @@ pub type fixpt_t = __fixpt_t; pub type __lwpid_t = i32; pub type lwpid_t = __lwpid_t; pub type blksize_t = i32; +pub type ksize_t = u64; +pub type inp_gen_t = u64; +pub type so_gen_t = u64; pub type clockid_t = c_int; pub type sem_t = _sem; pub type timer_t = *mut __c_anonymous__timer; @@ -50,7 +53,8 @@ pub type sctp_assoc_t = u32; pub type eventfd_t = u64; -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_support_flags { DEVSTAT_ALL_SUPPORTED = 0x00, @@ -65,7 +69,8 @@ impl Clone for devstat_support_flags { } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_trans_flags { DEVSTAT_NO_DATA = 0x00, @@ -81,7 +86,8 @@ impl Clone for devstat_trans_flags { } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_tag_type { DEVSTAT_TAG_SIMPLE = 0x00, @@ -96,7 +102,8 @@ impl Clone for devstat_tag_type { } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_match_flags { DEVSTAT_MATCH_NONE = 0x00, @@ -111,7 +118,8 @@ impl Clone for devstat_match_flags { } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_priority { DEVSTAT_PRIORITY_MIN = 0x000, @@ -132,7 +140,8 @@ impl Clone for devstat_priority { } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_type_flags { DEVSTAT_TYPE_DIRECT = 0x000, @@ -164,7 +173,8 @@ impl Clone for devstat_type_flags { } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_metric { DSM_NONE, @@ -221,7 +231,8 @@ impl Clone for devstat_metric { } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_select_mode { DS_SELECT_ADD, @@ -1357,6 +1368,53 @@ s! { pub strchange_instrms: u16, pub strchange_outstrms: u16, } + + pub struct filedesc { + pub fd_files: *mut fdescenttbl, + pub fd_map: *mut c_ulong, + pub fd_freefile: c_int, + pub fd_refcnt: c_int, + pub fd_holdcnt: c_int, + fd_sx: sx, + fd_kqlist: kqlist, + pub fd_holdleaderscount: c_int, + pub fd_holdleaderswakeup: c_int, + } + + pub struct fdescenttbl { + pub fdt_nfiles: c_int, + fdt_ofiles: [*mut c_void; 0], + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct sx { + lock_object: lock_object, + sx_lock: crate::uintptr_t, + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct lock_object { + lo_name: *const c_char, + lo_flags: c_uint, + lo_data: c_uint, + // This is normally `struct witness`. + lo_witness: *mut c_void, + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct kqlist { + tqh_first: *mut c_void, + tqh_last: *mut *mut c_void, + } + + pub struct splice { + pub sp_fd: c_int, + pub sp_max: off_t, + pub sp_idle: crate::timeval, + } } s_no_extra_traits! { @@ -1654,6 +1712,75 @@ s_no_extra_traits! { pub uc_flags: c_int, __spare__: [c_int; 4], } + + #[repr(align(8))] + pub struct xinpgen { + pub xig_len: ksize_t, + pub xig_count: u32, + _xig_spare32: u32, + pub xig_gen: inp_gen_t, + pub xig_sogen: so_gen_t, + _xig_spare64: [u64; 4], + } + + pub struct in_addr_4in6 { + _ia46_pad32: [u32; 3], + pub ia46_addr4: crate::in_addr, + } + + pub union in_dependaddr { + pub id46_addr: crate::in_addr_4in6, + pub id6_addr: crate::in6_addr, + } + + pub struct in_endpoints { + pub ie_fport: u16, + pub ie_lport: u16, + pub ie_dependfaddr: crate::in_dependaddr, + pub ie_dependladdr: crate::in_dependaddr, + pub ie6_zoneid: u32, + } + + pub struct in_conninfo { + pub inc_flags: u8, + pub inc_len: u8, + pub inc_fibnum: u16, + pub inc_ie: crate::in_endpoints, + } + + pub struct xktls_session_onedir { + // Note: this field is called `gen` in upstream FreeBSD, but `gen` is + // reserved keyword in Rust since the 2024 Edition, hence `gennum`. + pub gennum: u64, + _rsrv1: [u64; 8], + _rsrv2: [u32; 8], + pub iv: [u8; 32], + pub cipher_algorithm: i32, + pub auth_algorithm: i32, + pub cipher_key_len: u16, + pub iv_len: u16, + pub auth_key_len: u16, + pub max_frame_len: u16, + pub tls_vmajor: u8, + pub tls_vminor: u8, + pub tls_hlen: u8, + pub tls_tlen: u8, + pub tls_bs: u8, + pub flags: u8, + pub drv_st_len: u16, + pub ifnet: [c_char; 16], + } + + pub struct xktls_session { + pub tsz: u32, + pub fsz: u32, + pub inp_gencnt: u64, + pub so_pcb: kvaddr_t, + pub coninf: crate::in_conninfo, + pub rx_vlan_id: c_ushort, + pub rcv: crate::xktls_session_onedir, + pub snd: crate::xktls_session_onedir, + } } cfg_if! { @@ -1679,20 +1806,6 @@ cfg_if! { } } impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - .field("ut_type", &self.ut_type) - .field("ut_tv", &self.ut_tv) - .field("ut_id", &self.ut_id) - .field("ut_pid", &self.ut_pid) - .field("ut_user", &self.ut_user) - .field("ut_line", &self.ut_line) - // FIXME(debug): .field("ut_host", &self.ut_host) - // FIXME(debug): .field("__ut_spare", &self.__ut_spare) - .finish() - } - } impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_type.hash(state); @@ -1728,17 +1841,6 @@ cfg_if! { } } impl Eq for xucred {} - impl fmt::Debug for xucred { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("xucred") - .field("cr_version", &self.cr_version) - .field("cr_uid", &self.cr_uid) - .field("cr_ngroups", &self.cr_ngroups) - .field("cr_groups", &self.cr_groups) - .field("cr_pid__c_anonymous_union", &self.cr_pid__c_anonymous_union) - .finish() - } - } impl hash::Hash for xucred { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cr_version.hash(state); @@ -1766,20 +1868,6 @@ cfg_if! { } } impl Eq for sockaddr_dl {} - impl fmt::Debug for sockaddr_dl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_dl") - .field("sdl_len", &self.sdl_len) - .field("sdl_family", &self.sdl_family) - .field("sdl_index", &self.sdl_index) - .field("sdl_type", &self.sdl_type) - .field("sdl_nlen", &self.sdl_nlen) - .field("sdl_alen", &self.sdl_alen) - .field("sdl_slen", &self.sdl_slen) - // FIXME(debug): .field("sdl_data", &self.sdl_data) - .finish() - } - } impl hash::Hash for sockaddr_dl { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sdl_len.hash(state); @@ -1802,16 +1890,6 @@ cfg_if! { } } impl Eq for mq_attr {} - impl fmt::Debug for mq_attr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mq_attr") - .field("mq_flags", &self.mq_flags) - .field("mq_maxmsg", &self.mq_maxmsg) - .field("mq_msgsize", &self.mq_msgsize) - .field("mq_curmsgs", &self.mq_curmsgs) - .finish() - } - } impl hash::Hash for mq_attr { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mq_flags.hash(state); @@ -1830,16 +1908,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_notify", &self.sigev_notify) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_value", &self.sigev_value) - .field("sigev_notify_thread_id", &self.sigev_notify_thread_id) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_notify.hash(state); @@ -1858,16 +1926,6 @@ cfg_if! { } } impl Eq for ptsstat {} - impl fmt::Debug for ptsstat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let self_devname: &[c_char] = &self.devname; - - f.debug_struct("ptsstat") - .field("dev", &self.dev) - .field("devname", &self_devname) - .finish() - } - } impl hash::Hash for ptsstat { fn hash<H: hash::Hasher>(&self, state: &mut H) { let self_devname: &[c_char] = &self.devname; @@ -1889,14 +1947,6 @@ cfg_if! { } } impl Eq for Elf32_Auxinfo {} - impl fmt::Debug for Elf32_Auxinfo { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Elf32_Auxinfo") - .field("a_type", &self.a_type) - .field("a_un", &self.a_un) - .finish() - } - } impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { @@ -1946,14 +1996,6 @@ cfg_if! { } } impl Eq for ifreq {} - impl fmt::Debug for ifreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifreq") - .field("ifr_name", &self.ifr_name) - .field("ifr_ifru", &self.ifr_ifru) - .finish() - } - } impl hash::Hash for ifreq { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifr_name.hash(state); @@ -1985,16 +2027,6 @@ cfg_if! { } } impl Eq for ifstat {} - impl fmt::Debug for ifstat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let ascii: &[c_char] = &self.ascii; - - f.debug_struct("ifstat") - .field("ifs_name", &self.ifs_name) - .field("ascii", &ascii) - .finish() - } - } impl hash::Hash for ifstat { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifs_name.hash(state); @@ -2015,19 +2047,6 @@ cfg_if! { } } impl Eq for ifrsskey {} - impl fmt::Debug for ifrsskey { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let ifrk_key: &[u8] = &self.ifrk_key; - - f.debug_struct("ifrsskey") - .field("ifrk_name", &self.ifrk_name) - .field("ifrk_func", &self.ifrk_func) - .field("ifrk_spare0", &self.ifrk_spare0) - .field("ifrk_keylen", &self.ifrk_keylen) - .field("ifrk_key", &ifrk_key) - .finish() - } - } impl hash::Hash for ifrsskey { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifrk_name.hash(state); @@ -2050,18 +2069,6 @@ cfg_if! { } } impl Eq for ifdownreason {} - impl fmt::Debug for ifdownreason { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let ifdr_msg: &[c_char] = &self.ifdr_msg; - - f.debug_struct("ifdownreason") - .field("ifdr_name", &self.ifdr_name) - .field("ifdr_reason", &self.ifdr_reason) - .field("ifdr_vendor", &self.ifdr_vendor) - .field("ifdr_msg", &ifdr_msg) - .finish() - } - } impl hash::Hash for ifdownreason { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifdr_name.hash(state); @@ -2131,37 +2138,6 @@ cfg_if! { } } impl Eq for if_data {} - impl fmt::Debug for if_data { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("if_data") - .field("ifi_type", &self.ifi_type) - .field("ifi_physical", &self.ifi_physical) - .field("ifi_addrlen", &self.ifi_addrlen) - .field("ifi_hdrlen", &self.ifi_hdrlen) - .field("ifi_link_state", &self.ifi_link_state) - .field("ifi_vhid", &self.ifi_vhid) - .field("ifi_datalen", &self.ifi_datalen) - .field("ifi_mtu", &self.ifi_mtu) - .field("ifi_metric", &self.ifi_metric) - .field("ifi_baudrate", &self.ifi_baudrate) - .field("ifi_ipackets", &self.ifi_ipackets) - .field("ifi_ierrors", &self.ifi_ierrors) - .field("ifi_opackets", &self.ifi_opackets) - .field("ifi_oerrors", &self.ifi_oerrors) - .field("ifi_collisions", &self.ifi_collisions) - .field("ifi_ibytes", &self.ifi_ibytes) - .field("ifi_obytes", &self.ifi_obytes) - .field("ifi_imcasts", &self.ifi_imcasts) - .field("ifi_omcasts", &self.ifi_omcasts) - .field("ifi_iqdrops", &self.ifi_iqdrops) - .field("ifi_oqdrops", &self.ifi_oqdrops) - .field("ifi_noproto", &self.ifi_noproto) - .field("ifi_hwassist", &self.ifi_hwassist) - .field("__ifi_epoch", &self.__ifi_epoch) - .field("__ifi_lastchange", &self.__ifi_lastchange) - .finish() - } - } impl hash::Hash for if_data { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ifi_type.hash(state); @@ -2201,16 +2177,6 @@ cfg_if! { } } impl Eq for sctphdr {} - impl fmt::Debug for sctphdr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctphdr") - .field("src_port", &{ self.src_port }) - .field("dest_port", &{ self.dest_port }) - .field("v_tag", &{ self.v_tag }) - .field("checksum", &{ self.checksum }) - .finish() - } - } impl hash::Hash for sctphdr { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.src_port }.hash(state); @@ -2228,15 +2194,6 @@ cfg_if! { } } impl Eq for sctp_chunkhdr {} - impl fmt::Debug for sctp_chunkhdr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_chunkhdr") - .field("chunk_type", &{ self.chunk_type }) - .field("chunk_flags", &{ self.chunk_flags }) - .field("chunk_length", &{ self.chunk_length }) - .finish() - } - } impl hash::Hash for sctp_chunkhdr { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.chunk_type }.hash(state); @@ -2253,14 +2210,6 @@ cfg_if! { } } impl Eq for sctp_paramhdr {} - impl fmt::Debug for sctp_paramhdr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_paramhdr") - .field("param_type", &{ self.param_type }) - .field("param_length", &{ self.param_length }) - .finish() - } - } impl hash::Hash for sctp_paramhdr { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.param_type }.hash(state); @@ -2279,15 +2228,6 @@ cfg_if! { } } impl Eq for sctp_gen_error_cause {} - impl fmt::Debug for sctp_gen_error_cause { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_gen_error_cause") - .field("code", &{ self.code }) - .field("length", &{ self.length }) - // FIXME(debug): .field("info", &{self.info}) - .finish() - } - } impl hash::Hash for sctp_gen_error_cause { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.code }.hash(state); @@ -2302,14 +2242,6 @@ cfg_if! { } } impl Eq for sctp_error_cause {} - impl fmt::Debug for sctp_error_cause { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_cause") - .field("code", &{ self.code }) - .field("length", &{ self.length }) - .finish() - } - } impl hash::Hash for sctp_error_cause { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.code }.hash(state); @@ -2325,14 +2257,6 @@ cfg_if! { } } impl Eq for sctp_error_invalid_stream {} - impl fmt::Debug for sctp_error_invalid_stream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_invalid_stream") - .field("cause", &{ self.cause }) - .field("stream_id", &{ self.stream_id }) - .finish() - } - } impl hash::Hash for sctp_error_invalid_stream { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2351,15 +2275,6 @@ cfg_if! { } } impl Eq for sctp_error_missing_param {} - impl fmt::Debug for sctp_error_missing_param { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_missing_param") - .field("cause", &{ self.cause }) - .field("num_missing_params", &{ self.num_missing_params }) - // FIXME(debug): .field("tpe", &{self.tpe}) - .finish() - } - } impl hash::Hash for sctp_error_missing_param { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2376,14 +2291,6 @@ cfg_if! { } } impl Eq for sctp_error_stale_cookie {} - impl fmt::Debug for sctp_error_stale_cookie { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_stale_cookie") - .field("cause", &{ self.cause }) - .field("stale_time", &{ self.stale_time }) - .finish() - } - } impl hash::Hash for sctp_error_stale_cookie { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2397,13 +2304,6 @@ cfg_if! { } } impl Eq for sctp_error_out_of_resource {} - impl fmt::Debug for sctp_error_out_of_resource { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_out_of_resource") - .field("cause", &{ self.cause }) - .finish() - } - } impl hash::Hash for sctp_error_out_of_resource { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2416,13 +2316,6 @@ cfg_if! { } } impl Eq for sctp_error_unresolv_addr {} - impl fmt::Debug for sctp_error_unresolv_addr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_unresolv_addr") - .field("cause", &{ self.cause }) - .finish() - } - } impl hash::Hash for sctp_error_unresolv_addr { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2435,14 +2328,6 @@ cfg_if! { } } impl Eq for sctp_error_unrecognized_chunk {} - impl fmt::Debug for sctp_error_unrecognized_chunk { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_unrecognized_chunk") - .field("cause", &{ self.cause }) - .field("ch", &{ self.ch }) - .finish() - } - } impl hash::Hash for sctp_error_unrecognized_chunk { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2456,14 +2341,6 @@ cfg_if! { } } impl Eq for sctp_error_no_user_data {} - impl fmt::Debug for sctp_error_no_user_data { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_no_user_data") - .field("cause", &{ self.cause }) - .field("tsn", &{ self.tsn }) - .finish() - } - } impl hash::Hash for sctp_error_no_user_data { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2477,14 +2354,6 @@ cfg_if! { } } impl Eq for sctp_error_auth_invalid_hmac {} - impl fmt::Debug for sctp_error_auth_invalid_hmac { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sctp_error_invalid_hmac") - .field("cause", &{ self.cause }) - .field("hmac_id", &{ self.hmac_id }) - .finish() - } - } impl hash::Hash for sctp_error_auth_invalid_hmac { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.cause }.hash(state); @@ -2510,21 +2379,6 @@ cfg_if! { } } impl Eq for kinfo_file {} - impl fmt::Debug for kinfo_file { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("kinfo_file") - .field("kf_structsize", &self.kf_structsize) - .field("kf_type", &self.kf_type) - .field("kf_fd", &self.kf_fd) - .field("kf_ref_count", &self.kf_ref_count) - .field("kf_flags", &self.kf_flags) - .field("kf_offset", &self.kf_offset) - .field("kf_status", &self.kf_status) - .field("kf_cap_rights", &self.kf_cap_rights) - .field("kf_path", &&self.kf_path[..]) - .finish() - } - } impl hash::Hash for kinfo_file { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.kf_structsize.hash(state); @@ -2538,22 +2392,10 @@ cfg_if! { self.kf_path.hash(state); } } - - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_sigmask", &self.uc_sigmask) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_flags", &self.uc_flags) - .finish() - } - } } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] #[repr(u32)] pub enum dot3Vendors { dot3VendorAMD = 1, @@ -3116,8 +2958,6 @@ pub const JAIL_CREATE: c_int = 0x01; pub const JAIL_UPDATE: c_int = 0x02; pub const JAIL_ATTACH: c_int = 0x04; pub const JAIL_DYING: c_int = 0x08; -pub const JAIL_SET_MASK: c_int = 0x0f; -pub const JAIL_GET_MASK: c_int = 0x08; pub const JAIL_SYS_DISABLE: c_int = 0; pub const JAIL_SYS_NEW: c_int = 1; pub const JAIL_SYS_INHERIT: c_int = 2; @@ -3152,6 +2992,7 @@ pub const SO_PROTOCOL: c_int = 0x1016; pub const SO_PROTOTYPE: c_int = SO_PROTOCOL; pub const SO_TS_CLOCK: c_int = 0x1017; pub const SO_DOMAIN: c_int = 0x1019; +pub const SO_SPLICE: c_int = 0x1023; pub const SO_VENDOR: c_int = 0x80000000; pub const SO_TS_REALTIME_MICRO: c_int = 0; @@ -3771,7 +3612,9 @@ pub const TCP_PERF_INFO: c_int = 78; pub const TCP_LRD: c_int = 79; pub const TCP_KEEPINIT: c_int = 128; pub const TCP_FASTOPEN: c_int = 1025; +#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")] pub const TCP_PCAP_OUT: c_int = 2048; +#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")] pub const TCP_PCAP_IN: c_int = 4096; pub const TCP_FUNCTION_BLK: c_int = 8192; pub const TCP_FUNCTION_ALIAS: c_int = 8193; @@ -3801,6 +3644,26 @@ pub const TCP_BBR_USEDEL_RATE: c_int = 1079; pub const TCP_BBR_MIN_RTO: c_int = 1080; pub const TCP_BBR_MAX_RTO: c_int = 1081; pub const TCP_BBR_ALGORITHM: c_int = 1083; +pub const TCP_BBR_PACE_PER_SEC: c_int = 1086; +pub const TCP_BBR_PACE_DEL_TAR: c_int = 1087; +pub const TCP_BBR_PACE_SEG_MAX: c_int = 1088; +pub const TCP_BBR_PACE_SEG_MIN: c_int = 1089; +pub const TCP_BBR_PACE_CROSS: c_int = 1090; +pub const TCP_BBR_TMR_PACE_OH: c_int = 1096; +pub const TCP_BBR_RACK_RTT_USE: c_int = 1098; +pub const TCP_BBR_RETRAN_WTSO: c_int = 1099; +pub const TCP_BBR_PROBE_RTT_GAIN: c_int = 1101; +pub const TCP_BBR_PROBE_RTT_LEN: c_int = 1102; +pub const TCP_BBR_SEND_IWND_IN_TSO: c_int = 1103; +pub const TCP_BBR_USE_RACK_RR: c_int = 1104; +pub const TCP_BBR_HDWR_PACE: c_int = 1105; +pub const TCP_BBR_UTTER_MAX_TSO: c_int = 1106; +pub const TCP_BBR_EXTRA_STATE: c_int = 1107; +pub const TCP_BBR_FLOOR_MIN_TSO: c_int = 1108; +pub const TCP_BBR_MIN_TOPACEOUT: c_int = 1109; +pub const TCP_BBR_TSTMP_RAISES: c_int = 1110; +pub const TCP_BBR_POLICER_DETECT: c_int = 1111; +pub const TCP_BBR_RACK_INIT_RATE: c_int = 1112; pub const IP_BINDANY: c_int = 24; pub const IP_BINDMULTI: c_int = 25; @@ -4382,7 +4245,10 @@ pub const TDI_IWAIT: c_int = 0x0010; pub const P_ADVLOCK: c_int = 0x00000001; pub const P_CONTROLT: c_int = 0x00000002; pub const P_KPROC: c_int = 0x00000004; +#[deprecated(since = "1.0", note = "Replaced in FreeBSD 15 by P_IDLEPROC")] pub const P_UNUSED3: c_int = 0x00000008; +#[cfg(freebsd15)] +pub const P_IDLEPROC: c_int = 0x00000008; pub const P_PPWAIT: c_int = 0x00000010; pub const P_PROFIL: c_int = 0x00000020; pub const P_STOPPROF: c_int = 0x00000040; @@ -4853,6 +4719,10 @@ pub const RB_POWERCYCLE: c_int = 0x400000; pub const RB_PROBE: c_int = 0x10000000; pub const RB_MULTIPLE: c_int = 0x20000000; +// netinet/in_pcb.h +pub const INC_ISIPV6: c_uchar = 0x01; +pub const INC_IPV6MINMTU: c_uchar = 0x02; + // sys/time.h pub const CLOCK_BOOTTIME: crate::clockid_t = crate::CLOCK_UPTIME; pub const CLOCK_REALTIME_COARSE: crate::clockid_t = crate::CLOCK_REALTIME_FAST; @@ -4879,54 +4749,51 @@ pub const fn MAP_ALIGNED(a: c_int) -> c_int { a << 24 } -const_fn! { - {const} fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES - } +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES } f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).add(_ALIGN(size_of::<cmsghdr>())) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _ALIGN(size_of::<cmsghdr>()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); - }; - let next = - cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::<cmsghdr>()); + } + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::<cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_ALIGN(mem::size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_ALIGN(size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint } pub fn MALLOCX_ALIGN(lg: c_uint) -> c_int { ffsl(lg as c_long - 1) } - pub {const} fn MALLOCX_TCACHE(tc: c_int) -> c_int { + pub const fn MALLOCX_TCACHE(tc: c_int) -> c_int { (tc + 2) << 8 as c_int } - pub {const} fn MALLOCX_ARENA(a: c_int) -> c_int { + pub const fn MALLOCX_ARENA(a: c_int) -> c_int { (a + 1) << 20 as c_int } pub fn SOCKCREDSIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::<sockcred>() + mem::size_of::<crate::gid_t>() * ngrps + size_of::<sockcred>() + size_of::<crate::gid_t>() * ngrps } pub fn uname(buf: *mut crate::utsname) -> c_int { @@ -4946,29 +4813,27 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * mem::size_of::<c_long>(); + let bitset_bits = 8 * size_of::<c_long>(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * mem::size_of::<c_long>(); + let bitset_bits = 8 * size_of::<c_long>(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { - let bitset_bits = 8 * mem::size_of::<c_long>(); + let bitset_bits = 8 * size_of::<c_long>(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); 0 != cpuset.__bits[idx] & (1 << offset) } pub fn CPU_COUNT(cpuset: &cpuset_t) -> c_int { let mut s: u32 = 0; - let cpuset_size = mem::size_of::<cpuset_t>(); - let bitset_size = mem::size_of::<c_long>(); + let cpuset_size = size_of::<cpuset_t>(); + let bitset_size = size_of::<c_long>(); for i in cpuset.__bits[..(cpuset_size / bitset_size)].iter() { s += i.count_ones(); @@ -4978,7 +4843,7 @@ f! { pub fn SOCKCRED2SIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::<sockcred2>() + mem::size_of::<crate::gid_t>() * ngrps + size_of::<sockcred2>() + size_of::<crate::gid_t>() * ngrps } pub fn PROT_MAX(x: c_int) -> c_int { @@ -4991,11 +4856,11 @@ f! { } safe_f! { - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 && status != 0x13 } - pub {const} fn INVALID_SINFO_FLAG(x: c_int) -> bool { + pub const fn INVALID_SINFO_FLAG(x: c_int) -> bool { (x) & 0xfffffff0 & !(SCTP_EOF | SCTP_ABORT @@ -5007,31 +4872,31 @@ safe_f! { != 0 } - pub {const} fn PR_SCTP_POLICY(x: c_int) -> c_int { + pub const fn PR_SCTP_POLICY(x: c_int) -> c_int { x & 0x0f } - pub {const} fn PR_SCTP_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) != SCTP_PR_SCTP_NONE && PR_SCTP_POLICY(x) != SCTP_PR_SCTP_ALL } - pub {const} fn PR_SCTP_TTL_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_TTL_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL } - pub {const} fn PR_SCTP_BUF_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_BUF_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF } - pub {const} fn PR_SCTP_RTX_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_RTX_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX } - pub {const} fn PR_SCTP_INVALID_POLICY(x: c_int) -> bool { + pub const fn PR_SCTP_INVALID_POLICY(x: c_int) -> bool { PR_SCTP_POLICY(x) > SCTP_PR_SCTP_MAX } - pub {const} fn PR_SCTP_VALID_POLICY(x: c_int) -> bool { + pub const fn PR_SCTP_VALID_POLICY(x: c_int) -> bool { PR_SCTP_POLICY(x) <= SCTP_PR_SCTP_MAX } } @@ -5500,6 +5365,11 @@ extern "C" { idx1: c_ulong, idx2: c_ulong, ) -> c_int; + pub fn dlvsym( + handle: *mut c_void, + symbol: *const c_char, + version: *const c_char, + ) -> *mut c_void; } #[link(name = "memstat")] diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -37,21 +37,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_vers", &self.mc_vers) - .field("mc_flags", &self.mc_flags) - .field("mc_onstack", &self.mc_onstack) - .field("mc_len", &self.mc_len) - .field("mc_avec", &self.mc_avec) - .field("mc_av", &self.mc_av) - .field("mc_frame", &self.mc_frame) - .field("mc_fpreg", &self.mc_fpreg) - .field("mc_vsxfpreg", &self.mc_vsxfpreg) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mc_vers.hash(state); @@ -68,7 +53,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_int>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -37,21 +37,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_vers", &self.mc_vers) - .field("mc_flags", &self.mc_flags) - .field("mc_onstack", &self.mc_onstack) - .field("mc_len", &self.mc_len) - .field("mc_avec", &self.mc_avec) - .field("mc_av", &self.mc_av) - .field("mc_frame", &self.mc_frame) - .field("mc_fpreg", &self.mc_fpreg) - .field("mc_vsxfpreg", &self.mc_vsxfpreg) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mc_vers.hash(state); @@ -68,7 +53,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -51,21 +51,6 @@ cfg_if! { } } impl Eq for gpregs {} - impl fmt::Debug for gpregs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("gpregs") - .field("gp_ra", &self.gp_ra) - .field("gp_sp", &self.gp_sp) - .field("gp_gp", &self.gp_gp) - .field("gp_tp", &self.gp_tp) - .field("gp_t", &self.gp_t) - .field("gp_s", &self.gp_s) - .field("gp_a", &self.gp_a) - .field("gp_sepc", &self.gp_sepc) - .field("gp_sstatus", &self.gp_sstatus) - .finish() - } - } impl hash::Hash for gpregs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.gp_ra.hash(state); @@ -88,16 +73,6 @@ cfg_if! { } } impl Eq for fpregs {} - impl fmt::Debug for fpregs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpregs") - .field("fp_x", &self.fp_x) - .field("fp_fcsr", &self.fp_fcsr) - .field("fp_flags", &self.fp_flags) - .field("pad", &self.pad) - .finish() - } - } impl hash::Hash for fpregs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.fp_x.hash(state); @@ -120,17 +95,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_gpregs", &self.mc_gpregs) - .field("mc_fpregs", &self.mc_fpregs) - .field("mc_flags", &self.mc_flags) - .field("mc_pad", &self.mc_pad) - .field("mc_spare", &self.mc_spare) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mc_gpregs.hash(state); @@ -143,7 +107,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -87,42 +87,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_onstack", &self.mc_onstack) - .field("mc_gs", &self.mc_gs) - .field("mc_fs", &self.mc_fs) - .field("mc_es", &self.mc_es) - .field("mc_ds", &self.mc_ds) - .field("mc_edi", &self.mc_edi) - .field("mc_esi", &self.mc_esi) - .field("mc_ebp", &self.mc_ebp) - .field("mc_isp", &self.mc_isp) - .field("mc_ebx", &self.mc_ebx) - .field("mc_edx", &self.mc_edx) - .field("mc_ecx", &self.mc_ecx) - .field("mc_eax", &self.mc_eax) - .field("mc_trapno", &self.mc_trapno) - .field("mc_err", &self.mc_err) - .field("mc_eip", &self.mc_eip) - .field("mc_cs", &self.mc_cs) - .field("mc_eflags", &self.mc_eflags) - .field("mc_esp", &self.mc_esp) - .field("mc_ss", &self.mc_ss) - .field("mc_len", &self.mc_len) - .field("mc_fpformat", &self.mc_fpformat) - .field("mc_ownedfp", &self.mc_ownedfp) - .field("mc_flags", &self.mc_flags) - .field("mc_fpstate", &self.mc_fpstate) - .field("mc_fsbase", &self.mc_fsbase) - .field("mc_gsbase", &self.mc_gsbase) - .field("mc_xfpustate", &self.mc_xfpustate) - .field("mc_xfpustate_len", &self.mc_xfpustate_len) - .field("mc_spare2", &self.mc_spare2) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mc_onstack.hash(state); @@ -160,7 +124,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -92,13 +92,13 @@ s_no_extra_traits! { pub a_un: __c_anonymous_elf64_auxv_union, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], } #[repr(align(16))] + #[cfg_attr(not(any(freebsd11, freebsd12, freebsd13, freebsd14)), non_exhaustive)] pub struct mcontext_t { pub mc_onstack: register_t, pub mc_rdi: register_t, @@ -137,7 +137,14 @@ s_no_extra_traits! { pub mc_gsbase: register_t, pub mc_xfpustate: register_t, pub mc_xfpustate_len: register_t, + // freebsd < 15 + #[cfg(any(freebsd11, freebsd12, freebsd13, freebsd14))] pub mc_spare: [c_long; 4], + // freebsd >= 15 + #[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))] + pub mc_tlsbase: register_t, + #[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))] + pub mc_spare: [c_long; 3], } } @@ -156,16 +163,6 @@ cfg_if! { } } impl Eq for fpreg32 {} - impl fmt::Debug for fpreg32 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpreg32") - .field("fpr_env", &&self.fpr_env[..]) - .field("fpr_acc", &self.fpr_acc) - .field("fpr_ex_sw", &self.fpr_ex_sw) - .field("fpr_pad", &&self.fpr_pad[..]) - .finish() - } - } impl hash::Hash for fpreg32 { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.fpr_env.hash(state); @@ -184,16 +181,6 @@ cfg_if! { } } impl Eq for fpreg {} - impl fmt::Debug for fpreg { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpreg") - .field("fpr_env", &self.fpr_env) - .field("fpr_acc", &self.fpr_acc) - .field("fpr_xacc", &self.fpr_xacc) - .field("fpr_spare", &self.fpr_spare) - .finish() - } - } impl hash::Hash for fpreg { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.fpr_env.hash(state); @@ -216,16 +203,6 @@ cfg_if! { } } impl Eq for xmmreg {} - impl fmt::Debug for xmmreg { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("xmmreg") - .field("xmm_env", &self.xmm_env) - .field("xmm_acc", &self.xmm_acc) - .field("xmm_reg", &self.xmm_reg) - .field("xmm_pad", &&self.xmm_pad[..]) - .finish() - } - } impl hash::Hash for xmmreg { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.xmm_env.hash(state); @@ -253,14 +230,6 @@ cfg_if! { } } impl Eq for Elf64_Auxinfo {} - impl fmt::Debug for Elf64_Auxinfo { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Elf64_Auxinfo") - .field("a_type", &self.a_type) - .field("a_un", &self.a_un) - .finish() - } - } impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { @@ -309,50 +278,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("mc_onstack", &self.mc_onstack) - .field("mc_rdi", &self.mc_rdi) - .field("mc_rsi", &self.mc_rsi) - .field("mc_rdx", &self.mc_rdx) - .field("mc_rcx", &self.mc_rcx) - .field("mc_r8", &self.mc_r8) - .field("mc_r9", &self.mc_r9) - .field("mc_rax", &self.mc_rax) - .field("mc_rbx", &self.mc_rbx) - .field("mc_rbp", &self.mc_rbp) - .field("mc_r10", &self.mc_r10) - .field("mc_r11", &self.mc_r11) - .field("mc_r12", &self.mc_r12) - .field("mc_r13", &self.mc_r13) - .field("mc_r14", &self.mc_r14) - .field("mc_r15", &self.mc_r15) - .field("mc_trapno", &self.mc_trapno) - .field("mc_fs", &self.mc_fs) - .field("mc_gs", &self.mc_gs) - .field("mc_addr", &self.mc_addr) - .field("mc_flags", &self.mc_flags) - .field("mc_es", &self.mc_es) - .field("mc_ds", &self.mc_ds) - .field("mc_err", &self.mc_err) - .field("mc_rip", &self.mc_rip) - .field("mc_cs", &self.mc_cs) - .field("mc_rflags", &self.mc_rflags) - .field("mc_rsp", &self.mc_rsp) - .field("mc_ss", &self.mc_ss) - .field("mc_len", &self.mc_len) - .field("mc_fpformat", &self.mc_fpformat) - .field("mc_ownedfp", &self.mc_ownedfp) - // FIXME(debug): .field("mc_fpstate", &self.mc_fpstate) - .field("mc_fsbase", &self.mc_fsbase) - .field("mc_gsbase", &self.mc_gsbase) - .field("mc_xfpustate", &self.mc_xfpustate) - .field("mc_xfpustate_len", &self.mc_xfpustate_len) - .field("mc_spare", &self.mc_spare) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mc_onstack.hash(state); @@ -398,7 +323,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; @@ -409,7 +334,6 @@ pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 pub const _MC_HASSEGS: u32 = 0x1; pub const _MC_HASBASES: u32 = 0x2; pub const _MC_HASFPXSTATE: u32 = 0x4; -pub const _MC_FLAG_MASK: u32 = _MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE; pub const _MC_FPFMT_NODEV: c_long = 0x10000; pub const _MC_FPFMT_XMM: c_long = 0x10002; diff --git a/third_party/rust/libc/src/unix/bsd/freebsdlike/mod.rs b/third_party/rust/libc/src/unix/bsd/freebsdlike/mod.rs @@ -59,7 +59,7 @@ cfg_if! { // link.h -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -378,7 +378,7 @@ s! { pub cgid: crate::gid_t, pub uid: crate::uid_t, pub gid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub seq: c_ushort, pub key: crate::key_t, } @@ -414,17 +414,6 @@ cfg_if! { } } impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("__ss_pad2", &self.__ss_pad2) - .finish() - } - } impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_len.hash(state); @@ -438,7 +427,7 @@ cfg_if! { } // Non-public helper constant -const SIZEOF_LONG: usize = mem::size_of::<c_long>(); +const SIZEOF_LONG: usize = size_of::<c_long>(); #[deprecated( since = "0.2.64", @@ -1208,9 +1197,9 @@ pub const _SC_RAW_SOCKETS: c_int = 119; pub const _SC_SYMLOOP_MAX: c_int = 120; pub const _SC_PHYS_PAGES: c_int = 121; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; pub const PTHREAD_MUTEX_NORMAL: c_int = 3; @@ -1249,7 +1238,15 @@ pub const TIOCGETD: c_ulong = 0x4004741a; pub const TIOCSETD: c_ulong = 0x8004741b; pub const TIOCGDRAINWAIT: c_ulong = 0x40047456; pub const TIOCSDRAINWAIT: c_ulong = 0x80047457; +#[cfg_attr( + not(target_os = "dragonfly"), + deprecated = "unused since FreeBSD 8, removed in FreeBSD 15" +)] pub const TIOCMGDTRWAIT: c_ulong = 0x4004745a; +#[cfg_attr( + not(target_os = "dragonfly"), + deprecated = "unused since FreeBSD 8, removed in FreeBSD 15" +)] pub const TIOCMSDTRWAIT: c_ulong = 0x8004745b; pub const TIOCDRAIN: c_ulong = 0x2000745e; pub const TIOCEXT: c_ulong = 0x80047460; @@ -1342,7 +1339,7 @@ pub const B230400: speed_t = 230400; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); pub const CRTSCTS: crate::tcflag_t = 0x00030000; pub const CCTS_OFLOW: crate::tcflag_t = 0x00010000; @@ -1493,15 +1490,15 @@ pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; safe_f! { - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0x13 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0o177) == 0o177 } } @@ -1602,13 +1599,12 @@ extern "C" { pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int; pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; #[cfg_attr( all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "mknodat@FBSD_1.1" )] - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn malloc_usable_size(ptr: *const c_void) -> size_t; pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; @@ -1730,7 +1726,7 @@ extern "C" { pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; pub fn setutxent(); - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -1872,7 +1868,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, diff --git a/third_party/rust/libc/src/unix/bsd/mod.rs b/third_party/rust/libc/src/unix/bsd/mod.rs @@ -180,16 +180,6 @@ cfg_if! { impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_len", &self.sun_len) - .field("sun_family", &self.sun_family) - // FIXME(debug): .field("sun_path", &self.sun_path) - .finish() - } - } - impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sun_len.hash(state); @@ -229,18 +219,6 @@ cfg_if! { impl Eq for utsname {} - impl fmt::Debug for utsname { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utsname") - // FIXME(debug): .field("sysname", &self.sysname) - // FIXME(debug): .field("nodename", &self.nodename) - // FIXME(debug): .field("release", &self.release) - // FIXME(debug): .field("version", &self.version) - // FIXME(debug): .field("machine", &self.machine) - .finish() - } - } - impl hash::Hash for utsname { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sysname.hash(state); @@ -595,58 +573,58 @@ pub const RTAX_BRD: c_int = 7; f! { pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { - (*mhdr).msg_control as *mut cmsghdr + if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() { + (*mhdr).msg_control.cast::<cmsghdr>() } else { core::ptr::null_mut() } } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { + for slot in &mut (*set).fds_bits { *slot = 0; } } } safe_f! { - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0o177 } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0o177) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0x00ff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0o200) != 0 } - pub {const} fn QCMD(cmd: c_int, type_: c_int) -> c_int { + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { (cmd << 8) | (type_ & 0x00ff) } } diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/mod.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/mod.rs @@ -16,7 +16,7 @@ pub type id_t = u32; pub type sem_t = *mut sem; pub type key_t = c_long; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -24,7 +24,7 @@ impl Clone for timezone { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum sem {} impl Copy for sem {} impl Clone for sem { @@ -78,7 +78,7 @@ s! { pub cgid: crate::gid_t, pub uid: crate::uid_t, pub gid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, #[cfg(target_os = "openbsd")] pub seq: c_ushort, #[cfg(target_os = "netbsd")] @@ -440,6 +440,34 @@ pub const MNT_NODEV: c_int = 0x00000010; pub const MNT_LOCAL: c_int = 0x00001000; pub const MNT_QUOTA: c_int = 0x00002000; +// sys/ioccom.h in NetBSD and OpenBSD +pub const IOCPARM_MASK: u32 = 0x1fff; + +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + +pub const fn _IO(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_VOID, g, n, 0) +} + +/// Build an ioctl number for an read-only ioctl. +pub const fn _IOR<T>(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_OUT, g, n, mem::size_of::<T>() as c_ulong) +} + +/// Build an ioctl number for an write-only ioctl. +pub const fn _IOW<T>(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_IN, g, n, mem::size_of::<T>() as c_ulong) +} + +/// Build an ioctl number for a read-write ioctl. +pub const fn _IOWR<T>(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_INOUT, g, n, mem::size_of::<T>() as c_ulong) +} + pub const AF_UNSPEC: c_int = 0; pub const AF_LOCAL: c_int = 1; pub const AF_UNIX: c_int = AF_LOCAL; @@ -623,7 +651,7 @@ pub const B230400: speed_t = 230400; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); pub const CRTSCTS: crate::tcflag_t = 0x00010000; pub const CRTS_IFLOW: crate::tcflag_t = CRTSCTS; @@ -689,7 +717,7 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")] pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; pub fn __errno() -> *mut c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; @@ -707,9 +735,8 @@ extern "C" { pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; pub fn pthread_condattr_setclock( @@ -830,7 +857,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -65,7 +65,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_int>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -3,7 +3,7 @@ use crate::PT_FIRSTMACH; pub type __cpu_simple_lock_nv_t = c_int; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/mips.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -3,7 +3,7 @@ use crate::PT_FIRSTMACH; pub type __cpu_simple_lock_nv_t = c_int; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_longlong>() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -39,6 +39,7 @@ pub type Elf64_Xword = u64; pub type iconv_t = *mut c_void; e! { + #[repr(C)] pub enum fae_action { FAE_OPEN, FAE_DUP2, @@ -940,24 +941,6 @@ cfg_if! { impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - .field("ut_name", &self.ut_name) - .field("ut_id", &self.ut_id) - .field("ut_line", &self.ut_line) - // FIXME(debug) .field("ut_host", &self.ut_host) - .field("ut_session", &self.ut_session) - .field("ut_type", &self.ut_type) - .field("ut_pid", &self.ut_pid) - .field("ut_exit", &self.ut_exit) - .field("ut_ss", &self.ut_ss) - .field("ut_tv", &self.ut_tv) - // FIXME(debug) .field("ut_pad", &self.ut_pad) - .finish() - } - } - impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_name.hash(state); @@ -989,17 +972,6 @@ cfg_if! { impl Eq for lastlogx {} - impl fmt::Debug for lastlogx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("lastlogx") - .field("ll_tv", &self.ll_tv) - .field("ll_line", &self.ll_line) - // FIXME(debug).field("ll_host", &self.ll_host) - .field("ll_ss", &self.ll_ss) - .finish() - } - } - impl hash::Hash for lastlogx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ll_tv.hash(state); @@ -1015,14 +987,6 @@ cfg_if! { } } impl Eq for in_pktinfo {} - impl fmt::Debug for in_pktinfo { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("in_pktinfo") - .field("ipi_addr", &self.ipi_addr) - .field("ipi_ifindex", &self.ipi_ifindex) - .finish() - } - } impl hash::Hash for in_pktinfo { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ipi_addr.hash(state); @@ -1040,20 +1004,6 @@ cfg_if! { } } impl Eq for arphdr {} - impl fmt::Debug for arphdr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let ar_hrd = self.ar_hrd; - let ar_pro = self.ar_pro; - let ar_op = self.ar_op; - f.debug_struct("arphdr") - .field("ar_hrd", &ar_hrd) - .field("ar_pro", &ar_pro) - .field("ar_hln", &self.ar_hln) - .field("ar_pln", &self.ar_pln) - .field("ar_op", &ar_op) - .finish() - } - } impl hash::Hash for arphdr { fn hash<H: hash::Hasher>(&self, state: &mut H) { let ar_hrd = self.ar_hrd; @@ -1073,12 +1023,6 @@ cfg_if! { } } impl Eq for in_addr {} - impl fmt::Debug for in_addr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let s_addr = self.s_addr; - f.debug_struct("in_addr").field("s_addr", &s_addr).finish() - } - } impl hash::Hash for in_addr { fn hash<H: hash::Hasher>(&self, state: &mut H) { let s_addr = self.s_addr; @@ -1093,14 +1037,6 @@ cfg_if! { } } impl Eq for ip_mreq {} - impl fmt::Debug for ip_mreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ip_mreq") - .field("imr_multiaddr", &self.imr_multiaddr) - .field("imr_interface", &self.imr_interface) - .finish() - } - } impl hash::Hash for ip_mreq { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.imr_multiaddr.hash(state); @@ -1118,17 +1054,6 @@ cfg_if! { } } impl Eq for sockaddr_in {} - impl fmt::Debug for sockaddr_in { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_in") - .field("sin_len", &self.sin_len) - .field("sin_family", &self.sin_family) - .field("sin_port", &self.sin_port) - .field("sin_addr", &self.sin_addr) - .field("sin_zero", &self.sin_zero) - .finish() - } - } impl hash::Hash for sockaddr_in { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sin_len.hash(state); @@ -1153,17 +1078,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_reclen", &self.d_reclen) - .field("d_namlen", &self.d_namlen) - .field("d_type", &self.d_type) - // FIXME(debug): .field("d_name", &self.d_name) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -1211,36 +1125,6 @@ cfg_if! { } } impl Eq for statvfs {} - impl fmt::Debug for statvfs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("statvfs") - .field("f_flag", &self.f_flag) - .field("f_bsize", &self.f_bsize) - .field("f_frsize", &self.f_frsize) - .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_bresvd", &self.f_bresvd) - .field("f_files", &self.f_files) - .field("f_ffree", &self.f_ffree) - .field("f_favail", &self.f_favail) - .field("f_fresvd", &self.f_fresvd) - .field("f_syncreads", &self.f_syncreads) - .field("f_syncwrites", &self.f_syncwrites) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_fsidx", &self.f_fsidx) - .field("f_fsid", &self.f_fsid) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_spare", &self.f_spare) - .field("f_fstypename", &self.f_fstypename) - // FIXME(debug): .field("f_mntonname", &self.f_mntonname) - // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) - .finish() - } - } impl hash::Hash for statvfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_flag.hash(state); @@ -1284,17 +1168,6 @@ cfg_if! { } } impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_pad2", &self.__ss_pad2) - // FIXME(debug): .field("__ss_pad3", &self.__ss_pad3) - .finish() - } - } impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_len.hash(state); @@ -1314,16 +1187,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_notify", &self.sigev_notify) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_value", &self.sigev_value) - .field("sigev_notify_attributes", &self.sigev_notify_attributes) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_notify.hash(state); @@ -1850,6 +1713,29 @@ pub const MNT_WAIT: c_int = 1; pub const MNT_NOWAIT: c_int = 2; pub const MNT_LAZY: c_int = 3; +// sys/ioccom.h +pub const IOCPARM_SHIFT: u32 = 16; +pub const IOCGROUP_SHIFT: u32 = 8; + +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> IOCPARM_SHIFT) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << IOCPARM_SHIFT)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> IOCGROUP_SHIFT) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) + | (((len) & crate::IOCPARM_MASK as c_ulong) << IOCPARM_SHIFT) + | ((group) << IOCGROUP_SHIFT) + | (num) +} + //<sys/timex.h> pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; @@ -2409,37 +2295,40 @@ pub const RTA_TAG: c_int = 0x100; pub const RTAX_TAG: c_int = 8; pub const RTAX_MAX: c_int = 9; -const_fn! { - {const} fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES - } +// sys/timerfd.h +pub const TFD_CLOEXEC: i32 = crate::O_CLOEXEC; +pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK; +pub const TFD_TIMER_ABSTIME: i32 = crate::O_WRONLY; +pub const TFD_TIMER_CANCEL_ON_SET: i32 = crate::O_RDWR; + +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES } f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).add(_ALIGN(size_of::<cmsghdr>())) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _ALIGN(size_of::<cmsghdr>()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); - }; - let next = - cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::<cmsghdr>()); + } + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::<cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_ALIGN(mem::size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_ALIGN(size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint } // dirfd() is a macro on netbsd to access @@ -2451,7 +2340,7 @@ f! { pub fn SOCKCREDSIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::<sockcred>() + mem::size_of::<crate::gid_t>() * ngrps + size_of::<sockcred>() + size_of::<crate::gid_t>() * ngrps } pub fn PROT_MPROTECT(x: c_int) -> c_int { @@ -2464,23 +2353,23 @@ f! { } safe_f! { - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0o177) == 0o177 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0xffff } - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -2490,11 +2379,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev as u32) & 0x000fff00) >> 8) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { let mut res = 0; res |= ((dev as u32) & 0xfff00000) >> 12; res |= (dev as u32) & 0x000000ff; @@ -2606,6 +2495,8 @@ extern "C" { winp: *mut crate::winsize, ) -> crate::pid_t; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + #[link_name = "__lutimes50"] pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; #[link_name = "__gettimeofday50"] @@ -2794,6 +2685,11 @@ extern "C" { new_value: *const crate::itimerspec, old_value: *mut crate::itimerspec, ) -> c_int; + pub fn dlvsym( + handle: *mut c_void, + symbol: *const c_char, + version: *const c_char, + ) -> *mut c_void; // Added in `NetBSD` 7.0 pub fn explicit_memset(b: *mut c_void, c: c_int, len: size_t); @@ -2853,6 +2749,24 @@ extern "C" { #[link_name = "__getmntinfo13"] pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int; + + // Added in `NetBSD` 10.0 + pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const itimerspec, + old_value: *mut itimerspec, + ) -> c_int; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>, + arg: *mut c_void, + ); } #[link(name = "rt")] diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -3,7 +3,7 @@ use crate::PT_FIRSTMACH; pub type __cpu_simple_lock_nv_t = c_int; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_double>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_double>() - 1; pub const PT_STEP: c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -22,7 +22,7 @@ s_no_extra_traits! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -2,4 +2,4 @@ use crate::prelude::*; pub type __cpu_simple_lock_nv_t = c_uchar; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_int>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -20,7 +20,7 @@ s! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const PT_STEP: c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -15,6 +15,6 @@ s! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_double>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_double>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -630,7 +630,7 @@ impl siginfo_t { _pad: [c_int; SI_PAD], _pid: crate::pid_t, } - (*(self as *const siginfo_t as *const siginfo_timer))._pid + (*(self as *const siginfo_t).cast::<siginfo_timer>())._pid } pub unsafe fn si_uid(&self) -> crate::uid_t { @@ -643,7 +643,7 @@ impl siginfo_t { _pid: crate::pid_t, _uid: crate::uid_t, } - (*(self as *const siginfo_t as *const siginfo_timer))._uid + (*(self as *const siginfo_t).cast::<siginfo_timer>())._uid } pub unsafe fn si_value(&self) -> crate::sigval { @@ -657,7 +657,7 @@ impl siginfo_t { _uid: crate::uid_t, value: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_timer)).value + (*(self as *const siginfo_t).cast::<siginfo_timer>()).value } } @@ -773,19 +773,6 @@ cfg_if! { impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_fileno", &self.d_fileno) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - .field("d_namlen", &self.d_namlen) - // FIXME(debug): .field("d_name", &self.d_name) - .finish() - } - } - impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_fileno.hash(state); @@ -805,15 +792,6 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_len", &self.ss_len) - .field("ss_family", &self.ss_family) - .finish() - } - } - impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_len.hash(state); @@ -832,17 +810,6 @@ cfg_if! { impl Eq for siginfo_t {} - impl fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("siginfo_t") - .field("si_signo", &self.si_signo) - .field("si_code", &self.si_code) - .field("si_errno", &self.si_errno) - .field("si_addr", &self.si_addr) - .finish() - } - } - impl hash::Hash for siginfo_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.si_signo.hash(state); @@ -870,16 +837,6 @@ cfg_if! { impl Eq for lastlog {} - impl fmt::Debug for lastlog { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("lastlog") - .field("ll_time", &self.ll_time) - // FIXME(debug): .field("ll_line", &self.ll_line) - // FIXME(debug): .field("ll_host", &self.ll_host) - .finish() - } - } - impl hash::Hash for lastlog { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ll_time.hash(state); @@ -911,17 +868,6 @@ cfg_if! { impl Eq for utmp {} - impl fmt::Debug for utmp { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmp") - // FIXME(debug): .field("ut_line", &self.ut_line) - // FIXME(debug): .field("ut_name", &self.ut_name) - // FIXME(debug): .field("ut_host", &self.ut_host) - .field("ut_time", &self.ut_time) - .finish() - } - } - impl hash::Hash for utmp { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_line.hash(state); @@ -1029,35 +975,6 @@ cfg_if! { impl Eq for statfs {} - impl fmt::Debug for statfs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("statfs") - .field("f_flags", &self.f_flags) - .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_favail", &self.f_favail) - .field("f_syncwrites", &self.f_syncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_fsid", &self.f_fsid) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_ctime", &self.f_ctime) - // FIXME(debug): .field("f_fstypename", &self.f_fstypename) - // FIXME(debug): .field("f_mntonname", &self.f_mntonname) - // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) - // FIXME(debug): .field("f_mntfromspec", &self.f_mntfromspec) - .field("mount_info", &self.mount_info) - .finish() - } - } - impl hash::Hash for statfs { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.f_flags.hash(state); @@ -1411,9 +1328,9 @@ pub const SCHED_RR: c_int = 3; pub const ST_NOSUID: c_ulong = 2; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; @@ -1716,7 +1633,7 @@ pub const NTFS_MFLAG_ALLNAMES: c_int = 0x2; pub const TMPFS_ARGS_VERSION: c_int = 1; const SI_MAXSZ: size_t = 128; -const SI_PAD: size_t = (SI_MAXSZ / mem::size_of::<c_int>()) - 3; +const SI_PAD: size_t = (SI_MAXSZ / size_of::<c_int>()) - 3; pub const MAP_STACK: c_int = 0x4000; pub const MAP_CONCEAL: c_int = 0x8000; @@ -1821,6 +1738,23 @@ pub const PF_R: u32 = 0x4; pub const PF_MASKOS: u32 = 0x0ff00000; pub const PF_MASKPROC: u32 = 0xf0000000; +// sys/ioccom.h +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> 16) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << 16)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> 8) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) | (((len) & crate::IOCPARM_MASK as c_ulong) << 16) | ((group) << 8) | (num) +} + // sys/mount.h pub const MNT_NOPERM: c_int = 0x00000020; pub const MNT_WXALLOWED: c_int = 0x00000800; @@ -1934,58 +1868,55 @@ pub const RTAX_STATIC: c_int = 13; pub const RTAX_SEARCH: c_int = 14; pub const RTAX_MAX: c_int = 15; -const_fn! { - {const} fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES - } +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES } f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).offset(_ALIGN(size_of::<cmsghdr>()) as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _ALIGN(size_of::<cmsghdr>()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); - }; - let next = - cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::<cmsghdr>()); + } + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::<cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_ALIGN(mem::size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_ALIGN(size_of::<cmsghdr>()) + _ALIGN(length as usize)) as c_uint } } safe_f! { - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0o177 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0o177777) == 0o177777 } - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -1995,11 +1926,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { ((dev as c_uint) >> 8) & 0xff } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { let dev = dev as c_uint; let mut res = 0; res |= (dev) & 0xff; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_double>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_double>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -20,6 +20,6 @@ s! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_int>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_int>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/third_party/rust/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -81,22 +81,6 @@ cfg_if! { } } impl Eq for fxsave64 {} - impl fmt::Debug for fxsave64 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fxsave64") - .field("fx_fcw", &{ self.fx_fcw }) - .field("fx_fsw", &{ self.fx_fsw }) - .field("fx_ftw", &{ self.fx_ftw }) - .field("fx_fop", &{ self.fx_fop }) - .field("fx_rip", &{ self.fx_rip }) - .field("fx_rdp", &{ self.fx_rdp }) - .field("fx_mxcsr", &{ self.fx_mxcsr }) - .field("fx_mxcsr_mask", &{ self.fx_mxcsr_mask }) - // FIXME(debug): .field("fx_st", &{self.fx_st}) - // FIXME(debug): .field("fx_xmm", &{self.fx_xmm}) - .finish() - } - } impl hash::Hash for fxsave64 { fn hash<H: hash::Hasher>(&self, state: &mut H) { { self.fx_fcw }.hash(state); @@ -114,7 +98,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::<c_long>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/third_party/rust/libc/src/unix/cygwin/mod.rs b/third_party/rust/libc/src/unix/cygwin/mod.rs @@ -28,7 +28,7 @@ pub type nlink_t = c_ushort; pub type suseconds_t = c_long; pub type useconds_t = c_ulong; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -75,7 +75,7 @@ pub type nfds_t = c_uint; pub type sem_t = *mut sem; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum sem {} impl Copy for sem {} impl Clone for sem { @@ -272,7 +272,7 @@ s! { } pub struct fd_set { - fds_bits: [fd_mask; FD_SETSIZE / core::mem::size_of::<c_ulong>() / 8], + fds_bits: [fd_mask; FD_SETSIZE / size_of::<c_ulong>() / 8], } pub struct _uc_fpxreg { @@ -351,6 +351,8 @@ s! { pub cr2: u64, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigevent { pub sigev_value: sigval, pub sigev_signo: c_int, @@ -435,10 +437,22 @@ s! { pub f_flag: c_ulong, pub f_namemax: c_ulong, } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_blocks: c_long, + pub f_bfree: c_long, + pub f_bavail: c_long, + pub f_files: c_long, + pub f_ffree: c_long, + pub f_fsid: c_long, + pub f_namelen: c_long, + pub f_spare: [c_long; 6], + } } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], @@ -498,7 +512,7 @@ s_no_extra_traits! { } pub struct utsname { - pub sysname: [c_char; 65], + pub sysname: [c_char; 66], pub nodename: [c_char; 65], pub release: [c_char; 65], pub version: [c_char; 65], @@ -570,19 +584,6 @@ cfg_if! { impl Eq for siginfo_t {} - impl fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("siginfo_t") - .field("si_signo", &self.si_signo) - .field("si_code", &self.si_code) - .field("si_pid", &self.si_pid) - .field("si_uid", &self.si_uid) - .field("si_errno", &self.si_errno) - // Ignore __pad - .finish() - } - } - impl hash::Hash for siginfo_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.si_signo.hash(state); @@ -594,24 +595,6 @@ cfg_if! { } } - impl fmt::Debug for ifreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifreq") - .field("ifr_name", &self.ifr_name) - .field("ifr_ifru", &self.ifr_ifru) - .finish() - } - } - - impl fmt::Debug for ifconf { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifconf") - .field("ifc_len", &self.ifc_len) - .field("ifc_ifcu", &self.ifc_ifcu) - .finish() - } - } - impl PartialEq for dirent { fn eq(&self, other: &dirent) -> bool { self.d_ino == other.d_ino @@ -626,16 +609,6 @@ cfg_if! { impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) - .finish() - } - } - impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -657,15 +630,6 @@ cfg_if! { impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) - .finish() - } - } - impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sun_family.hash(state); @@ -709,19 +673,6 @@ cfg_if! { impl Eq for utsname {} - impl fmt::Debug for utsname { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for utsname { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sysname.hash(state); @@ -961,6 +912,8 @@ pub const SOL_UDP: c_int = 17; pub const IPTOS_LOWDELAY: u8 = 0x10; pub const IPTOS_THROUGHPUT: u8 = 0x08; pub const IPTOS_RELIABILITY: u8 = 0x04; +pub const IPTOS_LOWCOST: u8 = 0x02; +pub const IPTOS_MINCOST: u8 = IPTOS_LOWCOST; pub const IP_DEFAULT_MULTICAST_TTL: c_int = 1; pub const IP_DEFAULT_MULTICAST_LOOP: c_int = 1; pub const IP_OPTIONS: c_int = 1; @@ -977,8 +930,18 @@ pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 16; pub const IP_BLOCK_SOURCE: c_int = 17; pub const IP_UNBLOCK_SOURCE: c_int = 18; pub const IP_PKTINFO: c_int = 19; +pub const IP_RECVTTL: c_int = 21; pub const IP_UNICAST_IF: c_int = 31; +pub const IP_RECVTOS: c_int = 40; +pub const IP_MTU_DISCOVER: c_int = 71; +pub const IP_MTU: c_int = 73; +pub const IP_RECVERR: c_int = 75; +pub const IP_PMTUDISC_WANT: c_int = 0; +pub const IP_PMTUDISC_DO: c_int = 1; +pub const IP_PMTUDISC_DONT: c_int = 2; +pub const IP_PMTUDISC_PROBE: c_int = 3; pub const IPV6_HOPOPTS: c_int = 1; +pub const IPV6_HDRINCL: c_int = 2; pub const IPV6_UNICAST_HOPS: c_int = 4; pub const IPV6_MULTICAST_IF: c_int = 9; pub const IPV6_MULTICAST_HOPS: c_int = 10; @@ -997,6 +960,13 @@ pub const IPV6_RTHDR: c_int = 32; pub const IPV6_RECVRTHDR: c_int = 38; pub const IPV6_TCLASS: c_int = 39; pub const IPV6_RECVTCLASS: c_int = 40; +pub const IPV6_MTU_DISCOVER: c_int = 71; +pub const IPV6_MTU: c_int = 72; +pub const IPV6_RECVERR: c_int = 75; +pub const IPV6_PMTUDISC_WANT: c_int = 0; +pub const IPV6_PMTUDISC_DO: c_int = 1; +pub const IPV6_PMTUDISC_DONT: c_int = 2; +pub const IPV6_PMTUDISC_PROBE: c_int = 3; pub const MCAST_JOIN_GROUP: c_int = 41; pub const MCAST_LEAVE_GROUP: c_int = 42; pub const MCAST_BLOCK_SOURCE: c_int = 43; @@ -1048,7 +1018,7 @@ pub const NGROUPS_MAX: c_int = 1024; pub const FORK_RELOAD: c_int = 1; pub const FORK_NO_RELOAD: c_int = 0; -pub const RTLD_DEFAULT: *mut c_void = 0isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_LOCAL: c_int = 0; pub const RTLD_LAZY: c_int = 1; pub const RTLD_NOW: c_int = 2; @@ -1786,22 +1756,36 @@ pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x08; pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_SEQUENTIAL: c_int = 1; +pub const POSIX_FADV_RANDOM: c_int = 2; +pub const POSIX_FADV_WILLNEED: c_int = 3; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x0001; +pub const FALLOC_FL_ZERO_RANGE: c_int = 0x0002; +pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x0004; +pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x0008; +pub const FALLOC_FL_INSERT_RANGE: c_int = 0x0010; +pub const FALLOC_FL_KEEP_SIZE: c_int = 0x1000; + f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = core::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = core::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = core::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); } @@ -1813,13 +1797,13 @@ f! { pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = cpu_set_t { bits: [0; 16] }; - let size_in_bits = 8 * core::mem::size_of_val(&_dummy.bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = core::mem::size_of_val(&cpuset.bits[0]); + let size_of_mask = size_of_val(&cpuset.bits[0]); for i in cpuset.bits[..(size / size_of_mask)].iter() { s += i.count_ones(); } @@ -1832,7 +1816,7 @@ f! { } } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * core::mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); if cpu < size_in_bits { let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; @@ -1840,7 +1824,7 @@ f! { } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * core::mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); if cpu < size_in_bits { let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); @@ -1848,7 +1832,7 @@ f! { } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * core::mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); if cpu < size_in_bits { let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) @@ -1858,31 +1842,23 @@ f! { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(::core::mem::size_of::<cpu_set_t>(), cpuset) + CPU_COUNT_S(size_of::<cpu_set_t>(), cpuset) } pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { set1.bits == set2.bits } - pub fn major(dev: dev_t) -> c_uint { - ((dev >> 16) & 0xffff) as c_uint - } - - pub fn minor(dev: dev_t) -> c_uint { - (dev & 0xffff) as c_uint - } - pub fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(::core::mem::size_of::<cmsghdr>()) as c_uint + length + CMSG_ALIGN(size_of::<cmsghdr>()) as c_uint + length } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::core::mem::size_of::<cmsghdr>())) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint } pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= core::mem::size_of::<cmsghdr>() { + if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() { (*mhdr).msg_control.cast() } else { core::ptr::null_mut() @@ -1892,7 +1868,7 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; - if next as usize + CMSG_ALIGN(::core::mem::size_of::<cmsghdr>()) as usize > max { + if next as usize + CMSG_ALIGN(size_of::<cmsghdr>()) as usize > max { core::ptr::null_mut() } else { next @@ -1905,49 +1881,55 @@ f! { } safe_f! { - pub {const} fn makedev(ma: c_uint, mi: c_uint) -> dev_t { + pub const fn makedev(ma: c_uint, mi: c_uint) -> dev_t { let ma = ma as dev_t; let mi = mi as dev_t; (ma << 16) | (mi & 0xffff) } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn major(dev: dev_t) -> c_uint { + ((dev >> 16) & 0xffff) as c_uint + } + + pub const fn minor(dev: dev_t) -> c_uint { + (dev & 0xffff) as c_uint + } + + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xff) == 0 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0o177 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0o177777) == 0o177777 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0o177 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { WIFSIGNALED(status) && (status & 0x80) != 0 } } -const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { - len + core::mem::size_of::<usize>() - 1 & !(::core::mem::size_of::<usize>() - 1) - } +const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1) } extern "C" { @@ -2157,8 +2139,6 @@ extern "C" { pub fn timingsafe_bcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; pub fn timingsafe_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; - pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, count: size_t) -> *mut c_void; - pub fn memmem( haystack: *const c_void, haystacklen: size_t, @@ -2178,17 +2158,16 @@ extern "C" { pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int; pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int; pub fn euidaccess(pathname: *const c_char, mode: c_int) -> c_int; - // pub fn execlpe(path: *const c_char, arg0: *const c_char, ...) -> c_int; pub fn execvpe( file: *const c_char, - argv: *const *const c_char, - envp: *const *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, ) -> c_int; pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; - pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + pub fn fexecve(fd: c_int, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int; pub fn fdatasync(fd: c_int) -> c_int; pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; @@ -2349,7 +2328,7 @@ extern "C" { ) -> c_int; pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> c_int; - pub fn pthread_sigqueue(thread: *mut pthread_t, sig: c_int, value: sigval) -> c_int; + pub fn pthread_sigqueue(thread: pthread_t, sig: c_int, value: sigval) -> c_int; pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; @@ -2436,6 +2415,22 @@ extern "C" { fd: c_int, newfd: c_int, ) -> c_int; + pub fn posix_spawn_file_actions_addchdir( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; pub fn forkpty( amaster: *mut c_int, @@ -2472,4 +2467,11 @@ extern "C" { result: *mut *mut crate::group, ) -> c_int; pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; + + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; } diff --git a/third_party/rust/libc/src/unix/haiku/bsd.rs b/third_party/rust/libc/src/unix/haiku/bsd.rs @@ -0,0 +1,151 @@ +//! This file contains the BSD APIs available in Haiku. It corresponds to the +//! header files in `headers/compatibility/bsd`. +//! +//! Note that Haiku's BSD compatibility is a combination of system APIs and +//! utility libraries. There should only be system APIs in `libc`. When you are +//! trying to determine whether something should be included in this file, the +//! best indicator is whether it also exists in the BSD-specific definitions in +//! this libc crate. + +use crate::prelude::*; + +// stringlist.h (utility library) +// Note: this is kept because it was previously introduced +pub type StringList = _stringlist; + +s! { + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub struct _stringlist { + pub sl_str: *mut *mut c_char, + pub sl_max: size_t, + pub sl_cur: size_t, + } + + // sys/event.h + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + + // sys/link_elf.h + pub struct dl_phdr_info { + pub dlpi_addr: crate::Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const crate::Elf_Phdr, + pub dlpi_phnum: crate::Elf_Half, + } +} + +// sys/event.h +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_PROC: i16 = -5; +pub const EV_ADD: u16 = 0x0001; +pub const EV_DELETE: u16 = 0x0002; +pub const EV_ONESHOT: u16 = 0x0010; +pub const EV_CLEAR: u16 = 0x0020; +pub const EV_EOF: u16 = 0x8000; +pub const EV_ERROR: u16 = 0x4000; +pub const NOTE_EXIT: u32 = 0x80000000; + +// sys/ioccom.h +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + +#[link(name = "bsd")] +extern "C" { + // stdlib.h + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn getprogname() -> *const c_char; + pub fn setprogname(progname: *const c_char); + pub fn arc4random() -> u32; + pub fn arc4random_uniform(upper_bound: u32) -> u32; + pub fn arc4random_buf(buf: *mut c_void, n: size_t); + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn strtonum( + nptr: *const c_char, + minval: c_longlong, + maxval: c_longlong, + errstr: *mut *const c_char, + ) -> c_longlong; + + // pty.h + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn login_tty(_fd: c_int) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + + // string.h + pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; + pub fn explicit_bzero(buf: *mut c_void, len: size_t); + + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub fn sl_init() -> *mut StringList; + pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; + pub fn sl_free(sl: *mut StringList, i: c_int); + pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; + + // sys/event.h + pub fn kqueue() -> c_int; + pub fn kevent( + kq: c_int, + changelist: *const kevent, + nchanges: c_int, + eventlist: *mut kevent, + nevents: c_int, + timeout: *const crate::timespec, + ) -> c_int; + + // sys/link_elf.h + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + // sys/time.h + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + // sys/uov.h + pub fn preadv( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + pub fn pwritev( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + + // sys/wait.h + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; +} diff --git a/third_party/rust/libc/src/unix/haiku/mod.rs b/third_party/rust/libc/src/unix/haiku/mod.rs @@ -1,5 +1,29 @@ use crate::prelude::*; +// This module contains bindings to the native Haiku API. The Haiku API +// originates from BeOS, and it was the original way to perform low level +// system and IO operations. The POSIX API was in that era was like a +// compatibility layer. In current Haiku development, both the POSIX API and +// the Haiku API are considered to be co-equal status. However, they are not +// integrated like they are on other UNIX platforms, which means that for many +// low level concepts there are two versions, like processes (POSIX) and +// teams (Haiku), or pthreads and native threads. +// +// Both the POSIX API and the Haiku API live in libroot.so, the library that is +// linked to any binary by default. Additionally, Haiku supports several +// non-POSIX APIs from BSD and GNU, which live in libbsd.so and libgnu.so. These +// modules are also supported. +// +// The module is comprised of the following files: +// - `mod.rs` (this file) implements the C11 and POSIX API found in +// `headers/posix` +// - `b32.rs`, `b64.rs` and `x86_64.rs` contain platform-specific definitions +// of the C11 and POSIX APIs +// - `native.rs` defines the native Haiku API that is implemented in +// `libroot.so` and that are found in `headers/os`. +// - `bsd.rs` defines the BSD customizations available on Haiku found in +// `headers/compatibility/bsd` + pub type rlim_t = crate::uintptr_t; pub type sa_family_t = u8; pub type pthread_key_t = c_int; @@ -56,9 +80,7 @@ pub type ACTION = c_int; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -pub type StringList = _stringlist; - -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -420,7 +442,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, } pub struct sembuf { @@ -440,19 +462,6 @@ s! { pub flag: *mut c_int, pub val: c_int, } - - pub struct _stringlist { - pub sl_str: *mut *mut c_char, - pub sl_max: size_t, - pub sl_cur: size_t, - } - - pub struct dl_phdr_info { - pub dlpi_addr: crate::Elf_Addr, - pub dlpi_name: *const c_char, - pub dlpi_phdr: *const crate::Elf_Phdr, - pub dlpi_phnum: crate::Elf_Half, - } } s_no_extra_traits! { @@ -517,22 +526,6 @@ cfg_if! { } impl Eq for utmpx {} - - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - .field("ut_type", &self.ut_type) - .field("ut_tv", &self.ut_tv) - .field("ut_id", &self.ut_id) - .field("ut_pid", &self.ut_pid) - .field("ut_user", &self.ut_user) - .field("ut_line", &self.ut_line) - .field("ut_host", &self.ut_host) - .field("__ut_reserved", &self.__ut_reserved) - .finish() - } - } - impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_type.hash(state); @@ -557,15 +550,6 @@ cfg_if! { } } impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_len", &self.sun_len) - .field("sun_family", &self.sun_family) - // FIXME(debug): .field("sun_path", &self.sun_path) - .finish() - } - } impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sun_len.hash(state); @@ -592,17 +576,6 @@ cfg_if! { } } impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_pad2", &self.__ss_pad2) - // FIXME(debug): .field("__ss_pad3", &self.__ss_pad3) - .finish() - } - } impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_len.hash(state); @@ -628,18 +601,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_dev", &self.d_dev) - .field("d_pdev", &self.d_pdev) - .field("d_ino", &self.d_ino) - .field("d_pino", &self.d_pino) - .field("d_reclen", &self.d_reclen) - // FIXME(debug): .field("d_name", &self.d_name) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_dev.hash(state); @@ -660,16 +621,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_notify", &self.sigev_notify) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_value", &self.sigev_value) - .field("sigev_notify_attributes", &self.sigev_notify_attributes) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_notify.hash(state); @@ -774,27 +725,27 @@ pub const O_NOFOLLOW: c_int = 0x00080000; pub const O_NOCACHE: c_int = 0x00100000; pub const O_DIRECTORY: c_int = 0x00200000; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; - -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IXOTH: crate::mode_t = 0o0001; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; + +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; @@ -1109,7 +1060,7 @@ pub const FD_SETSIZE: usize = 1024; pub const RTLD_LOCAL: c_int = 0x0; pub const RTLD_NOW: c_int = 0x1; pub const RTLD_GLOBAL: c_int = 0x2; -pub const RTLD_DEFAULT: *mut c_void = 0isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const BUFSIZ: c_uint = 8192; pub const FILENAME_MAX: c_uint = 256; @@ -1310,6 +1261,8 @@ pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; pub const SOCK_RAW: c_int = 3; pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_NONBLOCK: c_int = 0x00040000; +pub const SOCK_CLOEXEC: c_int = 0x00080000; pub const SOL_SOCKET: c_int = -1; pub const SO_ACCEPTCONN: c_int = 0x00000001; @@ -1561,43 +1514,41 @@ pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; pub const POSIX_SPAWN_SETSID: c_int = 0x40; -const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1) - } +const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1) } f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { + if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::<cmsghdr>()) as isize) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::<cmsghdr>())) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::<cmsghdr>()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); - }; + } let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize) - + CMSG_ALIGN(mem::size_of::<cmsghdr>()); + + CMSG_ALIGN(size_of::<cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } @@ -1605,20 +1556,20 @@ f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } @@ -1631,36 +1582,36 @@ f! { } safe_f! { - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & !0xff) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { status & 0xff } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status >> 8) & 0xff) != 0 } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { ((status >> 16) & 0xff) != 0 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 16) & 0xff } // actually WIFCORED, but this is used everywhere else - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x10000) != 0 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0x20000) != 0 } } @@ -1733,9 +1684,8 @@ extern "C" { bufferSize: size_t, res: *mut *mut spwd, ) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn sem_destroy(sem: *mut sem_t) -> c_int; pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; @@ -1813,7 +1763,7 @@ extern "C" { pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); @@ -1831,7 +1781,6 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; - pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; pub fn bind( @@ -1840,6 +1789,13 @@ extern "C" { address_len: crate::socklen_t, ) -> c_int; + pub fn accept4( + socket: c_int, + address: *mut crate::sockaddr, + addressLength: *mut crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn writev(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t; pub fn readv(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t; @@ -2032,7 +1988,7 @@ extern "C" { fildes: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( file_actions: *mut posix_spawn_file_actions_t, @@ -2091,46 +2047,6 @@ extern "C" { pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; } -#[link(name = "bsd")] -extern "C" { - pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; - pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; - pub fn forkpty( - amaster: *mut c_int, - name: *mut c_char, - termp: *mut termios, - winp: *mut crate::winsize, - ) -> crate::pid_t; - pub fn openpty( - amaster: *mut c_int, - aslave: *mut c_int, - name: *mut c_char, - termp: *mut termios, - winp: *mut crate::winsize, - ) -> c_int; - pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; - pub fn explicit_bzero(buf: *mut c_void, len: size_t); - pub fn login_tty(_fd: c_int) -> c_int; - - pub fn sl_init() -> *mut StringList; - pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; - pub fn sl_free(sl: *mut StringList, i: c_int); - pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; - - pub fn getprogname() -> *const c_char; - pub fn setprogname(progname: *const c_char); - pub fn dl_iterate_phdr( - callback: Option< - unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, - >, - data: *mut c_void, - ) -> c_int; - - pub fn arc4random() -> u32; - pub fn arc4random_uniform(upper_bound: u32) -> u32; - pub fn arc4random_buf(buf: *mut c_void, n: size_t); -} - #[link(name = "gnu")] extern "C" { pub fn memmem( @@ -2174,5 +2090,8 @@ cfg_if! { } } +mod bsd; +pub use self::bsd::*; + mod native; pub use self::native::*; diff --git a/third_party/rust/libc/src/unix/haiku/native.rs b/third_party/rust/libc/src/unix/haiku/native.rs @@ -1,19 +1,7 @@ use crate::off_t; use crate::prelude::*; -// This module contains bindings to the native Haiku API. The Haiku API -// originates from BeOS, and it was the original way to perform low level -// system and IO operations. The POSIX API was in that era was like a -// compatibility layer. In current Haiku development, both the POSIX API and -// the Haiku API are considered to be co-equal status. However, they are not -// integrated like they are on other UNIX platforms, which means that for many -// low level concepts there are two versions, like processes (POSIX) and -// teams (Haiku), or pthreads and native threads. -// -// Both the POSIX API and the Haiku API live in libroot.so, the library that is -// linked to any binary by default. -// -// This file follows the Haiku API for Haiku R1 beta 2. It is organized by the +// This file follows the Haiku API for Haiku R1 beta 5. It is organized by the // C/C++ header files in which the concepts can be found, while adhering to the // style guide for this crate. @@ -46,7 +34,7 @@ pub type thread_func = extern "C" fn(*mut c_void) -> status_t; // kernel/image.h pub type image_id = i32; -e! { +c_enum! { // kernel/OS.h pub enum thread_state { B_THREAD_RUNNING = 1, @@ -403,11 +391,14 @@ s! { } // kernel/image.h + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct image_info { pub id: image_id, pub image_type: c_int, pub sequence: i32, pub init_order: i32, + // FIXME(1.0): these should be made optional pub init_routine: extern "C" fn(), pub term_routine: extern "C" fn(), pub device: crate::dev_t, @@ -520,15 +511,6 @@ cfg_if! { } impl Eq for cpu_topology_node_info {} - impl fmt::Debug for cpu_topology_node_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("cpu_topology_node_info") - .field("id", &self.id) - .field("type", &self.type_) - .field("level", &self.level) - .finish() - } - } } } @@ -1304,17 +1286,12 @@ extern "C" { // The following functions are defined as macros in C/C++ #[inline] pub unsafe fn get_cpu_info(firstCPU: u32, cpuCount: u32, info: *mut cpu_info) -> status_t { - _get_cpu_info_etc( - firstCPU, - cpuCount, - info, - core::mem::size_of::<cpu_info>() as size_t, - ) + _get_cpu_info_etc(firstCPU, cpuCount, info, size_of::<cpu_info>() as size_t) } #[inline] pub unsafe fn get_area_info(id: area_id, info: *mut area_info) -> status_t { - _get_area_info(id, info, core::mem::size_of::<area_info>() as usize) + _get_area_info(id, info, size_of::<area_info>() as usize) } #[inline] @@ -1323,17 +1300,12 @@ pub unsafe fn get_next_area_info( cookie: *mut isize, info: *mut area_info, ) -> status_t { - _get_next_area_info( - team, - cookie, - info, - core::mem::size_of::<area_info>() as usize, - ) + _get_next_area_info(team, cookie, info, size_of::<area_info>() as usize) } #[inline] pub unsafe fn get_port_info(port: port_id, buf: *mut port_info) -> status_t { - _get_port_info(port, buf, core::mem::size_of::<port_info>() as size_t) + _get_port_info(port, buf, size_of::<port_info>() as size_t) } #[inline] @@ -1342,12 +1314,7 @@ pub unsafe fn get_next_port_info( cookie: *mut i32, portInfo: *mut port_info, ) -> status_t { - _get_next_port_info( - port, - cookie, - portInfo, - core::mem::size_of::<port_info>() as size_t, - ) + _get_next_port_info(port, cookie, portInfo, size_of::<port_info>() as size_t) } #[inline] @@ -1360,7 +1327,7 @@ pub unsafe fn get_port_message_info_etc( _get_port_message_info_etc( port, info, - core::mem::size_of::<port_message_info>() as size_t, + size_of::<port_message_info>() as size_t, flags, timeout, ) @@ -1368,42 +1335,32 @@ pub unsafe fn get_port_message_info_etc( #[inline] pub unsafe fn get_sem_info(id: sem_id, info: *mut sem_info) -> status_t { - _get_sem_info(id, info, core::mem::size_of::<sem_info>() as size_t) + _get_sem_info(id, info, size_of::<sem_info>() as size_t) } #[inline] pub unsafe fn get_next_sem_info(team: team_id, cookie: *mut i32, info: *mut sem_info) -> status_t { - _get_next_sem_info( - team, - cookie, - info, - core::mem::size_of::<sem_info>() as size_t, - ) + _get_next_sem_info(team, cookie, info, size_of::<sem_info>() as size_t) } #[inline] pub unsafe fn get_team_info(team: team_id, info: *mut team_info) -> status_t { - _get_team_info(team, info, core::mem::size_of::<team_info>() as size_t) + _get_team_info(team, info, size_of::<team_info>() as size_t) } #[inline] pub unsafe fn get_next_team_info(cookie: *mut i32, info: *mut team_info) -> status_t { - _get_next_team_info(cookie, info, core::mem::size_of::<team_info>() as size_t) + _get_next_team_info(cookie, info, size_of::<team_info>() as size_t) } #[inline] pub unsafe fn get_team_usage_info(team: team_id, who: i32, info: *mut team_usage_info) -> status_t { - _get_team_usage_info( - team, - who, - info, - core::mem::size_of::<team_usage_info>() as size_t, - ) + _get_team_usage_info(team, who, info, size_of::<team_usage_info>() as size_t) } #[inline] pub unsafe fn get_thread_info(id: thread_id, info: *mut thread_info) -> status_t { - _get_thread_info(id, info, core::mem::size_of::<thread_info>() as size_t) + _get_thread_info(id, info, size_of::<thread_info>() as size_t) } #[inline] @@ -1412,18 +1369,13 @@ pub unsafe fn get_next_thread_info( cookie: *mut i32, info: *mut thread_info, ) -> status_t { - _get_next_thread_info( - team, - cookie, - info, - core::mem::size_of::<thread_info>() as size_t, - ) + _get_next_thread_info(team, cookie, info, size_of::<thread_info>() as size_t) } // kernel/image.h #[inline] pub unsafe fn get_image_info(image: image_id, info: *mut image_info) -> status_t { - _get_image_info(image, info, core::mem::size_of::<image_info>() as size_t) + _get_image_info(image, info, size_of::<image_info>() as size_t) } #[inline] @@ -1432,10 +1384,5 @@ pub unsafe fn get_next_image_info( cookie: *mut i32, info: *mut image_info, ) -> status_t { - _get_next_image_info( - team, - cookie, - info, - core::mem::size_of::<image_info>() as size_t, - ) + _get_next_image_info(team, cookie, info, size_of::<image_info>() as size_t) } diff --git a/third_party/rust/libc/src/unix/haiku/x86_64.rs b/third_party/rust/libc/src/unix/haiku/x86_64.rs @@ -83,23 +83,6 @@ cfg_if! { } } impl Eq for fpu_state {} - impl fmt::Debug for fpu_state { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpu_state") - .field("control", &self.control) - .field("status", &self.status) - .field("tag", &self.tag) - .field("opcode", &self.opcode) - .field("rip", &self.rip) - .field("rdp", &self.rdp) - .field("mxcsr", &self.mxcsr) - .field("mscsr_mask", &self.mscsr_mask) - // FIXME(debug): .field("_fpreg", &self._fpreg) - // FIXME(debug): .field("_xmm", &self._xmm) - // FIXME(debug): .field("_reserved_416_511", &self._reserved_416_511) - .finish() - } - } impl hash::Hash for fpu_state { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.control.hash(state); @@ -128,15 +111,6 @@ cfg_if! { } } impl Eq for xstate_hdr {} - impl fmt::Debug for xstate_hdr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("xstate_hdr") - .field("bv", &self.bv) - .field("xcomp_bv", &self.xcomp_bv) - // FIXME(debug): .field("_reserved", &field._reserved) - .finish() - } - } impl hash::Hash for xstate_hdr { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.bv.hash(state); @@ -157,15 +131,6 @@ cfg_if! { } } impl Eq for savefpu {} - impl fmt::Debug for savefpu { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("savefpu") - .field("fp_fxsave", &self.fp_fxsave) - .field("fp_xstate", &self.fp_xstate) - // FIXME(debug): .field("_fp_ymm", &field._fp_ymm) - .finish() - } - } impl hash::Hash for savefpu { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.fp_fxsave.hash(state); @@ -198,31 +163,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("rax", &self.rax) - .field("rbx", &self.rbx) - .field("rcx", &self.rcx) - .field("rdx", &self.rdx) - .field("rdi", &self.rdi) - .field("rsi", &self.rsi) - .field("rbp", &self.rbp) - .field("r8", &self.r8) - .field("r9", &self.r9) - .field("r10", &self.r10) - .field("r11", &self.r11) - .field("r12", &self.r12) - .field("r13", &self.r13) - .field("r14", &self.r14) - .field("r15", &self.r15) - .field("rsp", &self.rsp) - .field("rip", &self.rip) - .field("rflags", &self.rflags) - .field("fpu", &self.fpu) - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.rax.hash(state); @@ -256,16 +196,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_link", &self.uc_link) - .field("uc_sigmask", &self.uc_sigmask) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_link.hash(state); diff --git a/third_party/rust/libc/src/unix/hurd/mod.rs b/third_party/rust/libc/src/unix/hurd/mod.rs @@ -225,7 +225,7 @@ pub type nl_item = c_int; pub type iconv_t = *mut c_void; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct impl Copy for fpos64_t {} impl Clone for fpos64_t { @@ -234,7 +234,7 @@ impl Clone for fpos64_t { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -1084,24 +1084,6 @@ cfg_if! { impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .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() - } - } - impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_type.hash(state); @@ -1612,12 +1594,12 @@ pub const SEM_VALUE_MAX: c_int = 2147483647; pub const MAXNAMLEN: usize = 255; // netdb.h -pub const _PATH_HEQUIV: &'static [u8; 17usize] = b"/etc/hosts.equiv\0"; -pub const _PATH_HOSTS: &'static [u8; 11usize] = b"/etc/hosts\0"; -pub const _PATH_NETWORKS: &'static [u8; 14usize] = b"/etc/networks\0"; -pub const _PATH_NSSWITCH_CONF: &'static [u8; 19usize] = b"/etc/nsswitch.conf\0"; -pub const _PATH_PROTOCOLS: &'static [u8; 15usize] = b"/etc/protocols\0"; -pub const _PATH_SERVICES: &'static [u8; 14usize] = b"/etc/services\0"; +pub const _PATH_HEQUIV: &[u8; 17usize] = b"/etc/hosts.equiv\0"; +pub const _PATH_HOSTS: &[u8; 11usize] = b"/etc/hosts\0"; +pub const _PATH_NETWORKS: &[u8; 14usize] = b"/etc/networks\0"; +pub const _PATH_NSSWITCH_CONF: &[u8; 19usize] = b"/etc/nsswitch.conf\0"; +pub const _PATH_PROTOCOLS: &[u8; 15usize] = b"/etc/protocols\0"; +pub const _PATH_SERVICES: &[u8; 14usize] = b"/etc/services\0"; pub const HOST_NOT_FOUND: c_int = 1; pub const TRY_AGAIN: c_int = 2; pub const NO_RECOVERY: c_int = 3; @@ -1809,7 +1791,7 @@ pub const RB_DEBUGGER: c_int = 0x1000; // semaphore.h pub const __SIZEOF_SEM_T: usize = 20; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); // termios.h pub const IGNBRK: crate::tcflag_t = 1; @@ -1980,7 +1962,7 @@ pub const CTIME: u8 = 0; pub const CBRK: u8 = 0u8; // dlfcn.h -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; pub const RTLD_LAZY: c_int = 1; pub const RTLD_NOW: c_int = 2; @@ -2150,35 +2132,35 @@ pub const SF_NOUNLINK: c_uint = 1048576; pub const SF_SNAPSHOT: c_uint = 2097152; pub const UTIME_NOW: c_long = -1; pub const UTIME_OMIT: c_long = -2; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_ISUID: crate::mode_t = 0o4000; -pub const S_ISGID: crate::mode_t = 0o2000; -pub const S_ISVTX: crate::mode_t = 0o1000; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IREAD: crate::mode_t = 0o0400; -pub const S_IWRITE: crate::mode_t = 0o0200; -pub const S_IEXEC: crate::mode_t = 0o0100; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const ACCESSPERMS: crate::mode_t = 511; -pub const ALLPERMS: crate::mode_t = 4095; -pub const DEFFILEMODE: crate::mode_t = 438; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IRWXO: mode_t = 0o0007; +pub const ACCESSPERMS: mode_t = 511; +pub const ALLPERMS: mode_t = 4095; +pub const DEFFILEMODE: mode_t = 438; pub const S_BLKSIZE: usize = 512; pub const STATX_TYPE: c_uint = 1; pub const STATX_MODE: c_uint = 2; @@ -3432,52 +3414,50 @@ pub const PTHREAD_STACK_MIN: size_t = 0; // Non-public helper constants const _UTSNAME_LENGTH: usize = 1024; -const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1) - } +const fn CMSG_ALIGN(len: usize) -> usize { + (len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1) } // functions f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { - (*mhdr).msg_control as *mut cmsghdr + if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() { + (*mhdr).msg_control.cast::<cmsghdr>() } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::<cmsghdr>()) as isize) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::<cmsghdr>())) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::<cmsghdr>()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { - if ((*cmsg).cmsg_len as usize) < mem::size_of::<cmsghdr>() { - return 0 as *mut cmsghdr; - }; + if ((*cmsg).cmsg_len as usize) < size_of::<cmsghdr>() { + return core::ptr::null_mut::<cmsghdr>(); + } let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max || next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { - next as *mut cmsghdr + next.cast::<cmsghdr>() } } pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = mem::zeroed(); - let size_in_bits = 8 * mem::size_of_val(&_dummy.bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } @@ -3488,28 +3468,26 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = mem::size_of_val(&cpuset.bits[0]); + let size_of_mask = size_of_val(&cpuset.bits[0]); for i in cpuset.bits[..(size / size_of_mask)].iter() { s += i.count_ones(); } @@ -3517,7 +3495,7 @@ f! { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(mem::size_of::<cpu_set_t>(), cpuset) + CPU_COUNT_S(size_of::<cpu_set_t>(), cpuset) } pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { @@ -3534,20 +3512,20 @@ f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } @@ -3574,8 +3552,7 @@ extern "C" { pub fn mkfifoat(__fd: c_int, __path: *const c_char, __mode: __mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn __libc_current_sigrtmin() -> c_int; @@ -4248,7 +4225,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, @@ -4549,7 +4526,7 @@ extern "C" { } safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -4558,11 +4535,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { ((dev >> 8) & 0xff) as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { (dev & 0xffff00ff) as c_uint } @@ -4574,63 +4551,63 @@ safe_f! { unsafe { __libc_current_sigrtmin() } } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0xffff } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0x7f) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } - pub {const} fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { + pub const fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { (ret << 8) | sig } - pub {const} fn W_STOPCODE(sig: c_int) -> c_int { + pub const fn W_STOPCODE(sig: c_int) -> c_int { (sig << 8) | 0x7f } - pub {const} fn QCMD(cmd: c_int, type_: c_int) -> c_int { + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { (cmd << 8) | (type_ & 0x00ff) } - pub {const} fn IPOPT_COPIED(o: u8) -> u8 { + pub const fn IPOPT_COPIED(o: u8) -> u8 { o & IPOPT_COPY } - pub {const} fn IPOPT_CLASS(o: u8) -> u8 { + pub const fn IPOPT_CLASS(o: u8) -> u8 { o & IPOPT_CLASS_MASK } - pub {const} fn IPOPT_NUMBER(o: u8) -> u8 { + pub const fn IPOPT_NUMBER(o: u8) -> u8 { o & IPOPT_NUMBER_MASK } - pub {const} fn IPTOS_ECN(x: u8) -> u8 { + pub const fn IPTOS_ECN(x: u8) -> u8 { x & crate::IPTOS_ECN_MASK } } diff --git a/third_party/rust/libc/src/unix/linux_like/android/b32/arm.rs b/third_party/rust/libc/src/unix/linux_like/android/b32/arm.rs @@ -65,14 +65,6 @@ cfg_if! { } } impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl fmt::Debug for __c_anonymous_uc_sigmask_with_padding { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uc_sigmask_with_padding") - .field("uc_sigmask_with_padding", &self.uc_sigmask) - // Ignore padding - .finish() - } - } impl hash::Hash for __c_anonymous_uc_sigmask_with_padding { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_sigmask.hash(state) @@ -104,22 +96,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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__c_anonymous_union", - &self.uc_sigmask__c_anonymous_union, - ) - .field("uc_regspace", &&self.uc_regspace[..]) - // Ignore padding field - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); diff --git a/third_party/rust/libc/src/unix/linux_like/android/b32/mod.rs b/third_party/rust/libc/src/unix/linux_like/android/b32/mod.rs @@ -12,6 +12,8 @@ pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -181,18 +183,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl fmt::Debug for sigset64_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigset64_t") - .field("__bits", &self.__bits) - .finish() - } - } - } -} - // These constants must be of the same type of sigaction.sa_flags pub const SA_NOCLDSTOP: c_int = 0x00000001; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/third_party/rust/libc/src/unix/linux_like/android/b32/x86/mod.rs b/third_party/rust/libc/src/unix/linux_like/android/b32/x86/mod.rs @@ -51,7 +51,6 @@ s_no_extra_traits! { __fpregs_mem: _libc_fpstate, } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f64; 2], @@ -67,14 +66,6 @@ cfg_if! { } } impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl fmt::Debug for __c_anonymous_uc_sigmask_with_padding { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uc_sigmask_with_padding") - .field("uc_sigmask_with_padding", &self.uc_sigmask) - // Ignore padding - .finish() - } - } impl hash::Hash for __c_anonymous_uc_sigmask_with_padding { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_sigmask.hash(state) @@ -105,21 +96,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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__c_anonymous_union", - &self.uc_sigmask__c_anonymous_union, - ) - // Ignore padding field - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); diff --git a/third_party/rust/libc/src/unix/linux_like/android/b64/aarch64/mod.rs b/third_party/rust/libc/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -85,7 +85,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 8], diff --git a/third_party/rust/libc/src/unix/linux_like/android/b64/mod.rs b/third_party/rust/libc/src/unix/linux_like/android/b64/mod.rs @@ -12,6 +12,8 @@ s! { __val: [c_ulong; 1], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_flags: c_int, pub sa_sigaction: crate::sighandler_t, @@ -155,15 +157,6 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_mutex_t") - .field("value", &self.value) - // FIXME(debug): .field("__reserved", &self.__reserved) - .finish() - } - } - impl hash::Hash for pthread_mutex_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.value.hash(state); @@ -184,15 +177,6 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_cond_t") - .field("value", &self.value) - // FIXME(debug): .field("__reserved", &self.__reserved) - .finish() - } - } - impl hash::Hash for pthread_cond_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.value.hash(state); @@ -217,19 +201,6 @@ cfg_if! { impl Eq for pthread_rwlock_t {} - impl fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("__reserved", &self.__reserved) - .finish() - } - } - impl hash::Hash for pthread_rwlock_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.numLocks.hash(state); @@ -240,14 +211,6 @@ cfg_if! { self.__reserved.hash(state); } } - - impl fmt::Debug for sigset64_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigset64_t") - .field("__bits", &self.__bits) - .finish() - } - } } } @@ -262,7 +225,7 @@ pub const SA_SIGINFO: c_int = 0x00000004; 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; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, @@ -305,7 +268,6 @@ f! { } extern "C" { - pub fn getauxval(type_: c_ulong) -> c_ulong; pub fn __system_property_wait( pi: *const crate::prop_info, __old_serial: u32, diff --git a/third_party/rust/libc/src/unix/linux_like/android/b64/riscv64/mod.rs b/third_party/rust/libc/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -55,7 +55,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 8], diff --git a/third_party/rust/libc/src/unix/linux_like/android/b64/x86_64/mod.rs b/third_party/rust/libc/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -112,7 +112,6 @@ s_no_extra_traits! { uc_sigmask64: crate::sigset64_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], @@ -195,15 +194,6 @@ cfg_if! { } } impl Eq for _libc_fpxreg {} - impl fmt::Debug for _libc_fpxreg { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("_libc_fpxreg") - .field("significand", &self.significand) - .field("exponent", &self.exponent) - // Ignore padding field - .finish() - } - } impl hash::Hash for _libc_fpxreg { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.significand.hash(state); @@ -228,23 +218,6 @@ cfg_if! { } } impl Eq for _libc_fpstate {} - impl fmt::Debug for _libc_fpstate { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("_libc_fpstate") - .field("cwd", &self.cwd) - .field("swd", &self.swd) - .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", &self._st) - .field("_xmm", &self._xmm) - // Ignore padding field - .finish() - } - } impl hash::Hash for _libc_fpstate { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cwd.hash(state); @@ -268,15 +241,6 @@ cfg_if! { } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("gregs", &self.gregs) - .field("fpregs", &self.fpregs) - // Ignore padding field - .finish() - } - } impl hash::Hash for mcontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.gregs.hash(state); @@ -296,18 +260,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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_sigmask64", &self.uc_sigmask64) - // Ignore padding field - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); @@ -341,24 +293,6 @@ cfg_if! { impl Eq for user_fpregs_struct {} - impl fmt::Debug for user_fpregs_struct { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("user_fpregs_struct") - .field("cwd", &self.cwd) - .field("swd", &self.swd) - .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(debug): .field("xmm_space", &self.xmm_space) - // Ignore padding field - .finish() - } - } - impl hash::Hash for user_fpregs_struct { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cwd.hash(state); diff --git a/third_party/rust/libc/src/unix/linux_like/android/mod.rs b/third_party/rust/libc/src/unix/linux_like/android/mod.rs @@ -1,6 +1,16 @@ //! Android-specific definitions for linux-like values use crate::prelude::*; +use crate::{cmsghdr, msghdr}; + +cfg_if! { + if #[cfg(doc)] { + pub(crate) type Ioctl = c_int; + } else { + #[doc(hidden)] + pub type Ioctl = c_int; + } +} pub type clock_t = c_long; pub type time_t = c_long; @@ -65,22 +75,6 @@ s! { __val: [c_int; 2], } - pub struct msghdr { - pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, - pub msg_iov: *mut crate::iovec, - pub msg_iovlen: size_t, - pub msg_control: *mut c_void, - pub msg_controllen: size_t, - pub msg_flags: c_int, - } - - pub struct cmsghdr { - pub cmsg_len: size_t, - pub cmsg_level: c_int, - pub cmsg_type: c_int, - } - pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, @@ -194,12 +188,6 @@ s! { pub it_value: crate::timespec, } - pub struct ucred { - pub pid: crate::pid_t, - pub uid: crate::uid_t, - pub gid: crate::gid_t, - } - pub struct genlmsghdr { pub cmd: u8, pub version: u8, @@ -337,19 +325,6 @@ s! { pub dlpi_tls_data: *mut c_void, } - // linux/filter.h - pub struct sock_filter { - pub code: crate::__u16, - pub jt: crate::__u8, - pub jf: crate::__u8, - pub k: crate::__u32, - } - - pub struct sock_fprog { - pub len: c_ushort, - pub filter: *mut sock_filter, - } - // linux/seccomp.h pub struct seccomp_data { pub nr: c_int, @@ -664,15 +639,6 @@ cfg_if! { } } impl Eq for sockaddr_nl {} - impl fmt::Debug for sockaddr_nl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_nl") - .field("nl_family", &self.nl_family) - .field("nl_pid", &self.nl_pid) - .field("nl_groups", &self.nl_groups) - .finish() - } - } impl hash::Hash for sockaddr_nl { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.nl_family.hash(state); @@ -697,18 +663,6 @@ cfg_if! { impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } - impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -735,18 +689,6 @@ cfg_if! { impl Eq for dirent64 {} - impl fmt::Debug for dirent64 { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } - impl hash::Hash for dirent64 { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -769,18 +711,6 @@ cfg_if! { impl Eq for siginfo_t {} - impl fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for siginfo_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.si_signo.hash(state); @@ -809,16 +739,6 @@ cfg_if! { impl Eq for lastlog {} - impl fmt::Debug for lastlog { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("lastlog") - .field("ll_time", &self.ll_time) - .field("ll_line", &self.ll_line) - // FIXME(debug): .field("ll_host", &self.ll_host) - .finish() - } - } - impl hash::Hash for lastlog { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ll_time.hash(state); @@ -857,24 +777,6 @@ cfg_if! { impl Eq for utmp {} - impl fmt::Debug for utmp { - fn fmt(&self, f: &mut fmt::Formatter) -> 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) - // FIXME(debug): .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() - } - } - impl hash::Hash for utmp { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_type.hash(state); @@ -911,18 +813,6 @@ cfg_if! { impl Eq for sockaddr_alg {} - impl fmt::Debug for sockaddr_alg { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_alg") - .field("salg_family", &self.salg_family) - .field("salg_type", &self.salg_type) - .field("salg_feat", &self.salg_feat) - .field("salg_mask", &self.salg_mask) - .field("salg_name", &&self.salg_name[..]) - .finish() - } - } - impl hash::Hash for sockaddr_alg { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.salg_family.hash(state); @@ -942,16 +832,6 @@ cfg_if! { } impl Eq for uinput_setup {} - impl fmt::Debug for uinput_setup { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uinput_setup") - .field("id", &self.id) - .field("name", &&self.name[..]) - .field("ff_effects_max", &self.ff_effects_max) - .finish() - } - } - impl hash::Hash for uinput_setup { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.id.hash(state); @@ -973,20 +853,6 @@ cfg_if! { } impl Eq for uinput_user_dev {} - impl fmt::Debug for uinput_user_dev { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uinput_setup") - .field("name", &&self.name[..]) - .field("id", &self.id) - .field("ff_effects_max", &self.ff_effects_max) - .field("absmax", &&self.absmax[..]) - .field("absmin", &&self.absmin[..]) - .field("absfuzz", &&self.absfuzz[..]) - .field("absflat", &&self.absflat[..]) - .finish() - } - } - impl hash::Hash for uinput_user_dev { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.name.hash(state); @@ -999,24 +865,6 @@ cfg_if! { } } - impl fmt::Debug for ifreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifreq") - .field("ifr_name", &self.ifr_name) - .field("ifr_ifru", &self.ifr_ifru) - .finish() - } - } - - impl fmt::Debug for ifconf { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifconf") - .field("ifc_len", &self.ifc_len) - .field("ifc_ifcu", &self.ifc_ifcu) - .finish() - } - } - #[allow(deprecated)] impl af_alg_iv { fn as_slice(&self) -> &[u8] { @@ -1035,15 +883,6 @@ cfg_if! { impl Eq for af_alg_iv {} #[allow(deprecated)] - impl fmt::Debug for af_alg_iv { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("af_alg_iv") - .field("ivlen", &self.ivlen) - .finish() - } - } - - #[allow(deprecated)] impl hash::Hash for af_alg_iv { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.as_slice().hash(state); @@ -1058,15 +897,6 @@ cfg_if! { } } impl Eq for prop_info {} - impl fmt::Debug for prop_info { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("prop_info") - .field("__name", &self.__name) - .field("__serial", &self.__serial) - .field("__value", &self.__value) - .finish() - } - } } } @@ -1493,6 +1323,15 @@ pub const SOL_ATALK: c_int = 258; pub const SOL_NETROM: c_int = 259; pub const SOL_ROSE: c_int = 260; +/* UDP socket options */ +// include/uapi/linux/udp.h +pub const UDP_CORK: c_int = 1; +pub const UDP_ENCAP: c_int = 100; +pub const UDP_NO_CHECK6_TX: c_int = 101; +pub const UDP_NO_CHECK6_RX: c_int = 102; +pub const UDP_SEGMENT: c_int = 103; +pub const UDP_GRO: c_int = 104; + /* DCCP socket options */ pub const DCCP_SOCKOPT_PACKET_SIZE: c_int = 1; pub const DCCP_SOCKOPT_SERVICE: c_int = 2; @@ -1555,6 +1394,7 @@ pub const SO_PEEK_OFF: c_int = 42; pub const SO_BUSY_POLL: c_int = 46; pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; +pub const SO_BINDTOIFINDEX: c_int = 62; pub const SO_TIMESTAMP_NEW: c_int = 63; pub const SO_TIMESTAMPNS_NEW: c_int = 64; pub const SO_TIMESTAMPING_NEW: c_int = 65; @@ -1697,27 +1537,6 @@ pub const FIONREAD: c_int = 0x541B; pub const TIOCCONS: c_int = 0x541D; pub const TIOCSBRK: c_int = 0x5427; pub const TIOCCBRK: c_int = 0x5428; -cfg_if! { - if #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "riscv64", - target_arch = "s390x" - ))] { - pub const FICLONE: c_int = 0x40049409; - pub const FICLONERANGE: c_int = 0x4020940D; - } else if #[cfg(any( - target_arch = "mips", - target_arch = "mips64", - target_arch = "powerpc", - target_arch = "powerpc64" - ))] { - pub const FICLONE: c_int = 0x80049409; - pub const FICLONERANGE: c_int = 0x8020940D; - } -} pub const ST_RDONLY: c_ulong = 1; pub const ST_NOSUID: c_ulong = 2; @@ -1732,7 +1551,7 @@ pub const ST_RELATIME: c_ulong = 4096; pub const RTLD_NOLOAD: c_int = 0x4; pub const RTLD_NODELETE: c_int = 0x1000; -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); pub const AI_PASSIVE: c_int = 0x00000001; pub const AI_CANONNAME: c_int = 0x00000002; @@ -1899,38 +1718,6 @@ pub const BLKIOOPT: c_int = 0x1279; pub const BLKSSZGET: c_int = 0x1268; pub const BLKPBSZGET: c_int = 0x127B; -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { - pub const FS_IOC_GETFLAGS: c_int = 0x80046601; - pub const FS_IOC_SETFLAGS: c_int = 0x40046602; - pub const FS_IOC_GETVERSION: c_int = 0x80047601; - pub const FS_IOC_SETVERSION: c_int = 0x40047602; - pub const FS_IOC32_GETFLAGS: c_int = 0x80046601; - pub const FS_IOC32_SETFLAGS: c_int = 0x40046602; - pub const FS_IOC32_GETVERSION: c_int = 0x80047601; - pub const FS_IOC32_SETVERSION: c_int = 0x40047602; - } else if #[cfg(any( - target_arch = "x86_64", - target_arch = "riscv64", - target_arch = "aarch64" - ))] { - pub const FS_IOC_GETFLAGS: c_int = 0x80086601; - pub const FS_IOC_SETFLAGS: c_int = 0x40086602; - pub const FS_IOC_GETVERSION: c_int = 0x80087601; - pub const FS_IOC_SETVERSION: c_int = 0x40087602; - pub const FS_IOC32_GETFLAGS: c_int = 0x80046601; - pub const FS_IOC32_SETFLAGS: c_int = 0x40046602; - pub const FS_IOC32_GETVERSION: c_int = 0x80047601; - pub const FS_IOC32_SETVERSION: c_int = 0x40047602; - } -} - pub const EAI_AGAIN: c_int = 2; pub const EAI_BADFLAGS: c_int = 3; pub const EAI_FAIL: c_int = 4; @@ -1985,6 +1772,12 @@ pub const NLM_F_EXCL: c_int = 0x200; pub const NLM_F_CREATE: c_int = 0x400; pub const NLM_F_APPEND: c_int = 0x800; +pub const NLM_F_NONREC: c_int = 0x100; +pub const NLM_F_BULK: c_int = 0x200; + +pub const NLM_F_CAPPED: c_int = 0x100; +pub const NLM_F_ACK_TLVS: c_int = 0x200; + pub const NLMSG_NOOP: c_int = 0x1; pub const NLMSG_ERROR: c_int = 0x2; pub const NLMSG_DONE: c_int = 0x3; @@ -2194,18 +1987,22 @@ pub const GRND_NONBLOCK: c_uint = 0x0001; pub const GRND_RANDOM: c_uint = 0x0002; pub const GRND_INSECURE: c_uint = 0x0004; +// <linux/seccomp.h> pub const SECCOMP_MODE_DISABLED: c_uint = 0; pub const SECCOMP_MODE_STRICT: c_uint = 1; pub const SECCOMP_MODE_FILTER: c_uint = 2; -pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1; -pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 2; -pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 4; -pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 8; +pub const SECCOMP_SET_MODE_STRICT: c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: c_uint = 3; -pub const SECCOMP_RET_ACTION_FULL: c_uint = 0xffff0000; -pub const SECCOMP_RET_ACTION: c_uint = 0x7fff0000; -pub const SECCOMP_RET_DATA: c_uint = 0x0000ffff; +pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1 << 0; +pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 1 << 1; +pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 1 << 2; +pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 1 << 3; +pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: c_ulong = 1 << 4; +pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: c_ulong = 1 << 5; pub const SECCOMP_RET_KILL_PROCESS: c_uint = 0x80000000; pub const SECCOMP_RET_KILL_THREAD: c_uint = 0x00000000; @@ -2217,6 +2014,15 @@ pub const SECCOMP_RET_TRACE: c_uint = 0x7ff00000; pub const SECCOMP_RET_LOG: c_uint = 0x7ffc0000; pub const SECCOMP_RET_ALLOW: c_uint = 0x7fff0000; +pub const SECCOMP_RET_ACTION_FULL: c_uint = 0xffff0000; +pub const SECCOMP_RET_ACTION: c_uint = 0x7fff0000; +pub const SECCOMP_RET_DATA: c_uint = 0x0000ffff; + +pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: c_ulong = 1; + +pub const SECCOMP_ADDFD_FLAG_SETFD: c_ulong = 1; +pub const SECCOMP_ADDFD_FLAG_SEND: c_ulong = 2; + pub const NLA_F_NESTED: c_int = 1 << 15; pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14; pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); @@ -2646,30 +2452,6 @@ pub const SND_CNT: usize = SND_MAX as usize + 1; pub const UINPUT_VERSION: c_uint = 5; pub const UINPUT_MAX_NAME_SIZE: usize = 80; -// bionic/libc/kernel/uapi/linux/if_tun.h -pub const IFF_TUN: c_int = 0x0001; -pub const IFF_TAP: c_int = 0x0002; -pub const IFF_NAPI: c_int = 0x0010; -pub const IFF_NAPI_FRAGS: c_int = 0x0020; -pub const IFF_NO_CARRIER: c_int = 0x0040; -pub const IFF_NO_PI: c_int = 0x1000; -pub const IFF_ONE_QUEUE: c_int = 0x2000; -pub const IFF_VNET_HDR: c_int = 0x4000; -pub const IFF_TUN_EXCL: c_int = 0x8000; -pub const IFF_MULTI_QUEUE: c_int = 0x0100; -pub const IFF_ATTACH_QUEUE: c_int = 0x0200; -pub const IFF_DETACH_QUEUE: c_int = 0x0400; -pub const IFF_PERSIST: c_int = 0x0800; -pub const IFF_NOFILTER: c_int = 0x1000; -// Features for GSO (TUNSETOFFLOAD) -pub const TUN_F_CSUM: c_uint = 0x01; -pub const TUN_F_TSO4: c_uint = 0x02; -pub const TUN_F_TSO6: c_uint = 0x04; -pub const TUN_F_TSO_ECN: c_uint = 0x08; -pub const TUN_F_UFO: c_uint = 0x10; -pub const TUN_F_USO4: c_uint = 0x20; -pub const TUN_F_USO6: c_uint = 0x40; - // start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h // from https://android.googlesource.com/platform/bionic/+/HEAD/libc/kernel/uapi/linux/if_ether.h pub const ETH_ALEN: c_int = 6; @@ -3102,6 +2884,8 @@ pub const SCHED_DEADLINE: c_int = 6; pub const SCHED_RESET_ON_FORK: c_int = 0x40000000; pub const CLONE_PIDFD: c_int = 0x1000; +pub const CLONE_CLEAR_SIGHAND: c_ulonglong = 0x100000000; +pub const CLONE_INTO_CGROUP: c_ulonglong = 0x200000000; // linux/membarrier.h pub const MEMBARRIER_CMD_QUERY: c_int = 0; @@ -3137,29 +2921,178 @@ pub const PF_VSOCK: c_int = AF_VSOCK; pub const SOMAXCONN: c_int = 128; -// sys/prctl.h -pub const PR_SET_PDEATHSIG: c_int = 1; -pub const PR_GET_PDEATHSIG: c_int = 2; -pub const PR_GET_SECUREBITS: c_int = 27; -pub const PR_SET_SECUREBITS: c_int = 28; - // sys/system_properties.h pub const PROP_VALUE_MAX: c_int = 92; pub const PROP_NAME_MAX: c_int = 32; // sys/prctl.h -pub const PR_SET_VMA: c_int = 0x53564d41; -pub const PR_SET_VMA_ANON_NAME: c_int = 0; -pub const PR_SET_NO_NEW_PRIVS: c_int = 38; -pub const PR_GET_NO_NEW_PRIVS: c_int = 39; -pub const PR_GET_SECCOMP: c_int = 21; -pub const PR_SET_SECCOMP: c_int = 22; +pub const PR_SET_PDEATHSIG: c_int = 1; +pub const PR_GET_PDEATHSIG: c_int = 2; +pub const PR_GET_DUMPABLE: c_int = 3; +pub const PR_SET_DUMPABLE: c_int = 4; +pub const PR_GET_UNALIGN: c_int = 5; +pub const PR_SET_UNALIGN: c_int = 6; +pub const PR_UNALIGN_NOPRINT: c_int = 1; +pub const PR_UNALIGN_SIGBUS: c_int = 2; +pub const PR_GET_KEEPCAPS: c_int = 7; +pub const PR_SET_KEEPCAPS: c_int = 8; +pub const PR_GET_FPEMU: c_int = 9; +pub const PR_SET_FPEMU: c_int = 10; +pub const PR_FPEMU_NOPRINT: c_int = 1; +pub const PR_FPEMU_SIGFPE: c_int = 2; +pub const PR_GET_FPEXC: c_int = 11; +pub const PR_SET_FPEXC: c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: c_int = 0x80; +pub const PR_FP_EXC_DIV: c_int = 0x010000; +pub const PR_FP_EXC_OVF: c_int = 0x020000; +pub const PR_FP_EXC_UND: c_int = 0x040000; +pub const PR_FP_EXC_RES: c_int = 0x080000; +pub const PR_FP_EXC_INV: c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: c_int = 0; +pub const PR_FP_EXC_NONRECOV: c_int = 1; +pub const PR_FP_EXC_ASYNC: c_int = 2; +pub const PR_FP_EXC_PRECISE: c_int = 3; pub const PR_GET_TIMING: c_int = 13; pub const PR_SET_TIMING: c_int = 14; pub const PR_TIMING_STATISTICAL: c_int = 0; pub const PR_TIMING_TIMESTAMP: c_int = 1; pub const PR_SET_NAME: c_int = 15; pub const PR_GET_NAME: c_int = 16; +pub const PR_GET_ENDIAN: c_int = 19; +pub const PR_SET_ENDIAN: c_int = 20; +pub const PR_ENDIAN_BIG: c_int = 0; +pub const PR_ENDIAN_LITTLE: c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: c_int = 2; +pub const PR_GET_SECCOMP: c_int = 21; +pub const PR_SET_SECCOMP: c_int = 22; +pub const PR_CAPBSET_READ: c_int = 23; +pub const PR_CAPBSET_DROP: c_int = 24; +pub const PR_GET_TSC: c_int = 25; +pub const PR_SET_TSC: c_int = 26; +pub const PR_TSC_ENABLE: c_int = 1; +pub const PR_TSC_SIGSEGV: c_int = 2; +pub const PR_GET_SECUREBITS: c_int = 27; +pub const PR_SET_SECUREBITS: c_int = 28; +pub const PR_SET_TIMERSLACK: c_int = 29; +pub const PR_GET_TIMERSLACK: c_int = 30; +pub const PR_TASK_PERF_EVENTS_DISABLE: c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: c_int = 32; +pub const PR_MCE_KILL: c_int = 33; +pub const PR_MCE_KILL_CLEAR: c_int = 0; +pub const PR_MCE_KILL_SET: c_int = 1; +pub const PR_MCE_KILL_LATE: c_int = 0; +pub const PR_MCE_KILL_EARLY: c_int = 1; +pub const PR_MCE_KILL_DEFAULT: c_int = 2; +pub const PR_MCE_KILL_GET: c_int = 34; +pub const PR_SET_MM: c_int = 35; +pub const PR_SET_MM_START_CODE: c_int = 1; +pub const PR_SET_MM_END_CODE: c_int = 2; +pub const PR_SET_MM_START_DATA: c_int = 3; +pub const PR_SET_MM_END_DATA: c_int = 4; +pub const PR_SET_MM_START_STACK: c_int = 5; +pub const PR_SET_MM_START_BRK: c_int = 6; +pub const PR_SET_MM_BRK: c_int = 7; +pub const PR_SET_MM_ARG_START: c_int = 8; +pub const PR_SET_MM_ARG_END: c_int = 9; +pub const PR_SET_MM_ENV_START: c_int = 10; +pub const PR_SET_MM_ENV_END: c_int = 11; +pub const PR_SET_MM_AUXV: c_int = 12; +pub const PR_SET_MM_EXE_FILE: c_int = 13; +pub const PR_SET_MM_MAP: c_int = 14; +pub const PR_SET_MM_MAP_SIZE: c_int = 15; +pub const PR_SET_PTRACER: c_int = 0x59616d61; +pub const PR_SET_PTRACER_ANY: c_ulong = 0xffffffffffffffff; +pub const PR_SET_CHILD_SUBREAPER: c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: c_int = 37; +pub const PR_SET_NO_NEW_PRIVS: c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: c_int = 39; +pub const PR_GET_TID_ADDRESS: c_int = 40; +pub const PR_SET_THP_DISABLE: c_int = 41; +pub const PR_GET_THP_DISABLE: c_int = 42; +pub const PR_MPX_ENABLE_MANAGEMENT: c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: c_int = 44; +pub const PR_SET_FP_MODE: c_int = 45; +pub const PR_GET_FP_MODE: c_int = 46; +pub const PR_FP_MODE_FR: c_int = 1 << 0; +pub const PR_FP_MODE_FRE: c_int = 1 << 1; +pub const PR_CAP_AMBIENT: c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: c_int = 4; +pub const PR_SVE_SET_VL: c_int = 50; +pub const PR_SVE_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SVE_GET_VL: c_int = 51; +pub const PR_SVE_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SVE_VL_INHERIT: c_int = 1 << 17; +pub const PR_GET_SPECULATION_CTRL: c_int = 52; +pub const PR_SET_SPECULATION_CTRL: c_int = 53; +pub const PR_SPEC_STORE_BYPASS: c_int = 0; +pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1; +pub const PR_SPEC_L1D_FLUSH: c_int = 2; +pub const PR_SPEC_NOT_AFFECTED: c_int = 0; +pub const PR_SPEC_PRCTL: c_ulong = 1 << 0; +pub const PR_SPEC_ENABLE: c_ulong = 1 << 1; +pub const PR_SPEC_DISABLE: c_ulong = 1 << 2; +pub const PR_SPEC_FORCE_DISABLE: c_ulong = 1 << 3; +pub const PR_SPEC_DISABLE_NOEXEC: c_ulong = 1 << 4; +pub const PR_PAC_RESET_KEYS: c_int = 54; +pub const PR_PAC_APIAKEY: c_ulong = 1 << 0; +pub const PR_PAC_APIBKEY: c_ulong = 1 << 1; +pub const PR_PAC_APDAKEY: c_ulong = 1 << 2; +pub const PR_PAC_APDBKEY: c_ulong = 1 << 3; +pub const PR_PAC_APGAKEY: c_ulong = 1 << 4; +pub const PR_SET_TAGGED_ADDR_CTRL: c_int = 55; +pub const PR_GET_TAGGED_ADDR_CTRL: c_int = 56; +pub const PR_TAGGED_ADDR_ENABLE: c_ulong = 1 << 0; +pub const PR_MTE_TCF_NONE: c_ulong = 0; +pub const PR_MTE_TCF_SYNC: c_ulong = 1 << 1; +pub const PR_MTE_TCF_ASYNC: c_ulong = 1 << 2; +pub const PR_MTE_TCF_MASK: c_ulong = PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC; +pub const PR_MTE_TAG_SHIFT: c_ulong = 3; +pub const PR_MTE_TAG_MASK: c_ulong = 0xffff << PR_MTE_TAG_SHIFT; +pub const PR_MTE_TCF_SHIFT: c_ulong = 1; +pub const PR_SET_IO_FLUSHER: c_int = 57; +pub const PR_GET_IO_FLUSHER: c_int = 58; +pub const PR_SET_SYSCALL_USER_DISPATCH: c_int = 59; +pub const PR_SYS_DISPATCH_OFF: c_int = 0; +pub const PR_SYS_DISPATCH_ON: c_int = 1; +pub const SYSCALL_DISPATCH_FILTER_ALLOW: c_int = 0; +pub const SYSCALL_DISPATCH_FILTER_BLOCK: c_int = 1; +pub const PR_PAC_SET_ENABLED_KEYS: c_int = 60; +pub const PR_PAC_GET_ENABLED_KEYS: c_int = 61; +pub const PR_SCHED_CORE: c_int = 62; +pub const PR_SCHED_CORE_GET: c_int = 0; +pub const PR_SCHED_CORE_CREATE: c_int = 1; +pub const PR_SCHED_CORE_SHARE_TO: c_int = 2; +pub const PR_SCHED_CORE_SHARE_FROM: c_int = 3; +pub const PR_SCHED_CORE_MAX: c_int = 4; +pub const PR_SCHED_CORE_SCOPE_THREAD: c_int = 0; +pub const PR_SCHED_CORE_SCOPE_THREAD_GROUP: c_int = 1; +pub const PR_SCHED_CORE_SCOPE_PROCESS_GROUP: c_int = 2; +pub const PR_SME_SET_VL: c_int = 63; +pub const PR_SME_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SME_GET_VL: c_int = 64; +pub const PR_SME_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SME_VL_INHERIT: c_int = 1 << 17; +pub const PR_SET_MDWE: c_int = 65; +pub const PR_MDWE_REFUSE_EXEC_GAIN: c_ulong = 1 << 0; +pub const PR_MDWE_NO_INHERIT: c_ulong = 1 << 1; +pub const PR_GET_MDWE: c_int = 66; +pub const PR_SET_VMA: c_int = 0x53564d41; +pub const PR_SET_VMA_ANON_NAME: c_int = 0; +pub const PR_GET_AUXV: c_int = 0x41555856; +pub const PR_SET_MEMORY_MERGE: c_int = 67; +pub const PR_GET_MEMORY_MERGE: c_int = 68; +pub const PR_RISCV_V_SET_CONTROL: c_int = 69; +pub const PR_RISCV_V_GET_CONTROL: c_int = 70; +pub const PR_RISCV_V_VSTATE_CTRL_DEFAULT: c_int = 0; +pub const PR_RISCV_V_VSTATE_CTRL_OFF: c_int = 1; +pub const PR_RISCV_V_VSTATE_CTRL_ON: c_int = 2; +pub const PR_RISCV_V_VSTATE_CTRL_INHERIT: c_int = 1 << 4; +pub const PR_RISCV_V_VSTATE_CTRL_CUR_MASK: c_int = 0x3; +pub const PR_RISCV_V_VSTATE_CTRL_NEXT_MASK: c_int = 0xc; +pub const PR_RISCV_V_VSTATE_CTRL_MASK: c_int = 0x1f; // linux/if_addr.h pub const IFA_UNSPEC: c_ushort = 0; @@ -3598,7 +3531,7 @@ f! { let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { next as *mut cmsghdr } @@ -3606,7 +3539,7 @@ f! { pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = mem::zeroed(); - let size_in_bits = 8 * mem::size_of_val(&_dummy.__bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.__bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } @@ -3617,28 +3550,28 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] |= 1 << offset; () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] &= !(1 << offset); () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.__bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.__bits[idx] & (1 << offset)) } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = mem::size_of_val(&cpuset.__bits[0]); + let size_of_mask = size_of_val(&cpuset.__bits[0]); for i in cpuset.__bits[..(size / size_of_mask)].iter() { s += i.count_ones(); } @@ -3646,7 +3579,7 @@ f! { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(mem::size_of::<cpu_set_t>(), cpuset) + CPU_COUNT_S(size_of::<cpu_set_t>(), cpuset) } pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { @@ -3663,17 +3596,17 @@ f! { } safe_f! { - pub {const} fn makedev(ma: c_uint, mi: c_uint) -> crate::dev_t { + pub const fn makedev(ma: c_uint, mi: c_uint) -> crate::dev_t { let ma = ma as crate::dev_t; let mi = mi as crate::dev_t; ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12) } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { ((dev >> 8) & 0xfff) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as c_int } } @@ -3703,17 +3636,8 @@ extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn mlock2(addr: *const c_void, len: size_t, flags: c_int) -> c_int; pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; - pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn recvfrom( - socket: c_int, - buf: *mut c_void, - len: size_t, - flags: c_int, - addr: *mut crate::sockaddr, - addrlen: *mut crate::socklen_t, - ) -> ssize_t; pub fn getnameinfo( sa: *const crate::sockaddr, salen: crate::socklen_t, @@ -4026,19 +3950,6 @@ extern "C" { ) -> c_int; pub fn __errno() -> *mut c_int; pub fn inotify_rm_watch(fd: c_int, wd: u32) -> c_int; - pub fn sendmmsg( - sockfd: c_int, - msgvec: *const crate::mmsghdr, - vlen: c_uint, - flags: c_int, - ) -> c_int; - pub fn recvmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_int, - timeout: *const crate::timespec, - ) -> c_int; pub fn inotify_init() -> c_int; pub fn inotify_init1(flags: c_int) -> c_int; pub fn inotify_add_watch(fd: c_int, path: *const c_char, mask: u32) -> c_int; @@ -4066,6 +3977,8 @@ extern "C" { pub fn gettid() -> crate::pid_t; + pub fn getauxval(type_: c_ulong) -> c_ulong; + /// Only available in API Version 28+ pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; diff --git a/third_party/rust/libc/src/unix/linux_like/emscripten/mod.rs b/third_party/rust/libc/src/unix/linux_like/emscripten/mod.rs @@ -41,7 +41,7 @@ pub type statfs64 = crate::statfs; pub type statvfs64 = crate::statvfs; pub type dirent64 = crate::dirent; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct impl Copy for fpos64_t {} impl Clone for fpos64_t { @@ -158,6 +158,8 @@ s! { pub sem_flg: c_short, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -171,7 +173,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub __seq: c_int, __unused1: c_long, __unused2: c_long, @@ -229,7 +231,7 @@ s! { __st_dev_padding: c_int, #[cfg(emscripten_old_stat_abi)] __st_ino_truncated: c_long, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, @@ -313,7 +315,6 @@ s! { pub ha: [c_uchar; crate::MAX_ADDR_LEN], } - #[allow(missing_debug_implementations)] #[repr(align(4))] pub struct pthread_mutex_t { size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T], @@ -380,7 +381,6 @@ s_no_extra_traits! { size: [u8; crate::__SIZEOF_PTHREAD_COND_T], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], @@ -403,17 +403,6 @@ cfg_if! { } } impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -447,26 +436,6 @@ cfg_if! { } } impl Eq for sysinfo {} - impl fmt::Debug for sysinfo { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("__reserved", &self.__reserved) - .finish() - } - } impl hash::Hash for sysinfo { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uptime.hash(state); @@ -495,16 +464,6 @@ cfg_if! { } } impl Eq for mq_attr {} - impl fmt::Debug for mq_attr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mq_attr") - .field("mq_flags", &self.mq_flags) - .field("mq_maxmsg", &self.mq_maxmsg) - .field("mq_msgsize", &self.mq_msgsize) - .field("mq_curmsgs", &self.mq_curmsgs) - .finish() - } - } impl hash::Hash for mq_attr { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mq_flags.hash(state); @@ -520,13 +479,6 @@ cfg_if! { } } impl Eq for pthread_cond_t {} - impl fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_cond_t") - // FIXME(debug): .field("size", &self.size) - .finish() - } - } impl hash::Hash for pthread_cond_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -820,7 +772,7 @@ pub const ST_NOATIME: c_ulong = 1024; pub const ST_NODIRATIME: c_ulong = 2048; pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NODELETE: c_int = 0x1000; pub const RTLD_NOW: c_int = 0x2; @@ -890,7 +842,7 @@ pub const SHM_NORESERVE: c_int = 0o10000; pub const LOG_NFACILITIES: c_int = 24; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); pub const AI_PASSIVE: c_int = 0x0001; pub const AI_CANONNAME: c_int = 0x0002; @@ -1411,13 +1363,13 @@ pub const SOMAXCONN: c_int = 128; f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { - if ((*cmsg).cmsg_len as usize) < mem::size_of::<cmsghdr>() { - return 0 as *mut cmsghdr; - }; + if ((*cmsg).cmsg_len as usize) < size_of::<cmsghdr>() { + return core::ptr::null_mut::<cmsghdr>(); + } let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { next as *mut cmsghdr } @@ -1430,21 +1382,21 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } @@ -1455,7 +1407,7 @@ f! { } safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -1466,7 +1418,7 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ // main/system/lib/libc/musl/include/sys/sysmacros.h @@ -1476,7 +1428,7 @@ safe_f! { major as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ // main/system/lib/libc/musl/include/sys/sysmacros.h @@ -1530,7 +1482,7 @@ extern "C" { ) -> c_int; pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); diff --git a/third_party/rust/libc/src/unix/linux_like/linux/arch/generic/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/arch/generic/mod.rs @@ -40,8 +40,6 @@ pub const SO_PASSCRED: c_int = 16; pub const SO_PEERCRED: c_int = 17; pub const SO_RCVLOWAT: c_int = 18; pub const SO_SNDLOWAT: c_int = 19; -const SO_RCVTIMEO_OLD: c_int = 20; -const SO_SNDTIMEO_OLD: c_int = 21; pub const SO_SECURITY_AUTHENTICATION: c_int = 22; pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23; pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24; @@ -50,9 +48,6 @@ pub const SO_ATTACH_FILTER: c_int = 26; pub const SO_DETACH_FILTER: c_int = 27; pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; pub const SO_PEERNAME: c_int = 28; -const SO_TIMESTAMP_OLD: c_int = 29; -const SO_TIMESTAMPNS_OLD: c_int = 35; -const SO_TIMESTAMPING_OLD: c_int = 37; cfg_if! { if #[cfg(all( @@ -76,6 +71,12 @@ cfg_if! { pub const SO_RCVTIMEO: c_int = 66; pub const SO_SNDTIMEO: c_int = 67; } else { + const SO_TIMESTAMP_OLD: c_int = 29; + const SO_TIMESTAMPNS_OLD: c_int = 35; + const SO_TIMESTAMPING_OLD: c_int = 37; + const SO_RCVTIMEO_OLD: c_int = 20; + const SO_SNDTIMEO_OLD: c_int = 21; + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; @@ -158,22 +159,6 @@ pub const SO_DEVMEM_LINEAR: c_int = 78; pub const SO_DEVMEM_DMABUF: c_int = 79; pub const SO_DEVMEM_DONTNEED: c_int = 80; -cfg_if! { - if #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "riscv64", - target_arch = "s390x", - target_arch = "csky", - target_arch = "loongarch64" - ))] { - pub const FICLONE: c_ulong = 0x40049409; - pub const FICLONERANGE: c_ulong = 0x4020940D; - } -} - // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; @@ -264,79 +249,6 @@ pub const BLKIOMIN: Ioctl = 0x1278; pub const BLKIOOPT: Ioctl = 0x1279; pub const BLKSSZGET: Ioctl = 0x1268; pub const BLKPBSZGET: Ioctl = 0x127B; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x400454c8; -pub const TUNSETDEBUG: Ioctl = 0x400454c9; -pub const TUNSETIFF: Ioctl = 0x400454ca; -pub const TUNSETPERSIST: Ioctl = 0x400454cb; -pub const TUNSETOWNER: Ioctl = 0x400454cc; -pub const TUNSETLINK: Ioctl = 0x400454cd; -pub const TUNSETGROUP: Ioctl = 0x400454ce; -pub const TUNGETFEATURES: Ioctl = 0x800454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x400454d0; -pub const TUNSETTXFILTER: Ioctl = 0x400454d1; -pub const TUNGETIFF: Ioctl = 0x800454d2; -pub const TUNGETSNDBUF: Ioctl = 0x800454d3; -pub const TUNSETSNDBUF: Ioctl = 0x400454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x800454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x400454d8; -pub const TUNSETQUEUE: Ioctl = 0x400454d9; -pub const TUNSETIFINDEX: Ioctl = 0x400454da; -pub const TUNSETVNETLE: Ioctl = 0x400454dc; -pub const TUNGETVNETLE: Ioctl = 0x800454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x400454de; -pub const TUNGETVNETBE: Ioctl = 0x800454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x800454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x800454e1; - -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(any( - target_arch = "x86", - target_arch = "arm", - target_arch = "csky" - ))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x80046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x40046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x80047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x40047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x80046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x40046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x80047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x40047602; - pub const TUNATTACHFILTER: Ioctl = 0x400854d5; - pub const TUNDETACHFILTER: Ioctl = 0x400854d6; - pub const TUNGETFILTER: Ioctl = 0x800854db; - } else if #[cfg(any( - target_arch = "x86_64", - target_arch = "riscv64", - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - target_arch = "wasm32" - ))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x80086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x40086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x80087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x40087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x80046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x40046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x80047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x40047602; - pub const TUNATTACHFILTER: Ioctl = 0x401054d5; - pub const TUNDETACHFILTER: Ioctl = 0x401054d6; - pub const TUNGETFILTER: Ioctl = 0x801054db; - } -} cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] { @@ -402,9 +314,6 @@ cfg_if! { pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - #[cfg(not(target_arch = "loongarch64"))] - pub const RLIM_NLIMITS: c_int = 15; - #[cfg(target_arch = "loongarch64")] pub const RLIM_NLIMITS: c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] diff --git a/third_party/rust/libc/src/unix/linux_like/linux/arch/mips/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/arch/mips/mod.rs @@ -33,16 +33,17 @@ pub const SO_SNDBUF: c_int = 0x1001; pub const SO_RCVBUF: c_int = 0x1002; pub const SO_SNDLOWAT: c_int = 0x1003; pub const SO_RCVLOWAT: c_int = 0x1004; -// NOTE: These definitions are now being renamed with _OLD postfix, -// but CI haven't support them yet. -// Some related consts could be found in b32.rs and b64.rs -const SO_SNDTIMEO_OLD: c_int = 0x1005; -const SO_RCVTIMEO_OLD: c_int = 0x1006; cfg_if! { if #[cfg(linux_time_bits64)] { + const SO_RCVTIMEO_NEW: c_int = 66; + const SO_SNDTIMEO_NEW: c_int = 67; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; } else { + const SO_SNDTIMEO_OLD: c_int = 0x1005; + const SO_RCVTIMEO_OLD: c_int = 0x1006; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; } @@ -95,28 +96,27 @@ pub const SO_ZEROCOPY: c_int = 60; pub const SO_TXTIME: c_int = 61; pub const SCM_TXTIME: c_int = SO_TXTIME; pub const SO_BINDTOIFINDEX: c_int = 62; -// NOTE: These definitions are now being renamed with _OLD postfix, -// but CI haven't support them yet. -// Some related consts could be found in b32.rs and b64.rs -const SO_TIMESTAMP_OLD: c_int = 29; -const SO_RCVTIMEO_NEW: c_int = 66; -const SO_SNDTIMEO_NEW: c_int = 67; -const SO_TIMESTAMPNS_OLD: c_int = 35; -const SO_TIMESTAMPING_OLD: c_int = 37; -const SO_TIMESTAMP_NEW: c_int = 63; -const SO_TIMESTAMPNS_NEW: c_int = 64; -const SO_TIMESTAMPING_NEW: c_int = 65; + cfg_if! { if #[cfg(linux_time_bits64)] { + const SO_TIMESTAMP_NEW: c_int = 63; + const SO_TIMESTAMPNS_NEW: c_int = 64; + const SO_TIMESTAMPING_NEW: c_int = 65; + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; } else { + const SO_TIMESTAMP_OLD: c_int = 29; + const SO_TIMESTAMPNS_OLD: c_int = 35; + const SO_TIMESTAMPING_OLD: c_int = 37; + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; } } + // pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; pub const SO_PREFER_BUSY_POLL: c_int = 69; pub const SO_BUSY_POLL_BUDGET: c_int = 70; @@ -131,9 +131,6 @@ pub const SO_DEVMEM_LINEAR: c_int = 78; pub const SO_DEVMEM_DMABUF: c_int = 79; pub const SO_DEVMEM_DONTNEED: c_int = 80; -pub const FICLONE: c_ulong = 0x80049409; -pub const FICLONERANGE: c_ulong = 0x8020940D; - // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; @@ -223,68 +220,6 @@ pub const BLKIOMIN: Ioctl = 0x20001278; pub const BLKIOOPT: Ioctl = 0x20001279; pub const BLKSSZGET: Ioctl = 0x20001268; pub const BLKPBSZGET: Ioctl = 0x2000127B; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x800454c8; -pub const TUNSETDEBUG: Ioctl = 0x800454c9; -pub const TUNSETIFF: Ioctl = 0x800454ca; -pub const TUNSETPERSIST: Ioctl = 0x800454cb; -pub const TUNSETOWNER: Ioctl = 0x800454cc; -pub const TUNSETLINK: Ioctl = 0x800454cd; -pub const TUNSETGROUP: Ioctl = 0x800454ce; -pub const TUNGETFEATURES: Ioctl = 0x400454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x800454d0; -pub const TUNSETTXFILTER: Ioctl = 0x800454d1; -pub const TUNGETIFF: Ioctl = 0x400454d2; -pub const TUNGETSNDBUF: Ioctl = 0x400454d3; -pub const TUNSETSNDBUF: Ioctl = 0x800454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8; -pub const TUNSETQUEUE: Ioctl = 0x800454d9; -pub const TUNSETIFINDEX: Ioctl = 0x800454da; -pub const TUNSETVNETLE: Ioctl = 0x800454dc; -pub const TUNGETVNETLE: Ioctl = 0x400454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x800454de; -pub const TUNGETVNETBE: Ioctl = 0x400454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1; - -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x800854d5; - pub const TUNDETACHFILTER: Ioctl = 0x800854d6; - pub const TUNGETFILTER: Ioctl = 0x400854db; - } else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x801054d5; - pub const TUNDETACHFILTER: Ioctl = 0x801054d6; - pub const TUNGETFILTER: Ioctl = 0x401054db; - } -} cfg_if! { if #[cfg(target_env = "musl")] { @@ -349,7 +284,7 @@ cfg_if! { pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - pub const RLIM_NLIMITS: c_int = 15; + pub const RLIM_NLIMITS: c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; @@ -379,8 +314,13 @@ cfg_if! { cfg_if! { if #[cfg(all( any(target_arch = "mips", target_arch = "mips32r6"), - any(target_env = "uclibc", target_env = "gnu"), - linux_time_bits64 + any( + all(target_env = "uclibc", linux_time_bits64), + all( + target_env = "gnu", + any(linux_time_bits64, gnu_file_offset_bits64) + ) + ) ))] { pub const RLIM_INFINITY: crate::rlim_t = !0; } else if #[cfg(all( diff --git a/third_party/rust/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -24,17 +24,23 @@ pub const SO_REUSEPORT: c_int = 15; // powerpc only differs in these pub const SO_RCVLOWAT: c_int = 16; pub const SO_SNDLOWAT: c_int = 17; + cfg_if! { if #[cfg(linux_time_bits64)] { - pub const SO_SNDTIMEO: c_int = 67; - pub const SO_RCVTIMEO: c_int = 66; + const SO_RCVTIMEO_NEW: c_int = 66; + const SO_SNDTIMEO_NEW: c_int = 67; + + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; } else { - pub const SO_SNDTIMEO: c_int = 19; - pub const SO_RCVTIMEO: c_int = 18; + const SO_RCVTIMEO_OLD: c_int = 18; + const SO_SNDTIMEO_OLD: c_int = 19; + + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; } } -// pub const SO_RCVTIMEO_OLD: c_int = 18; -// pub const SO_SNDTIMEO_OLD: c_int = 19; + pub const SO_PASSCRED: c_int = 20; pub const SO_PEERCRED: c_int = 21; // end @@ -48,18 +54,23 @@ pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; pub const SO_PEERNAME: c_int = 28; cfg_if! { if #[cfg(linux_time_bits64)] { + const SO_TIMESTAMP_NEW: c_int = 63; + const SO_TIMESTAMPNS_NEW: c_int = 64; + const SO_TIMESTAMPING_NEW: c_int = 65; + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; } else { + const SO_TIMESTAMP_OLD: c_int = 29; + const SO_TIMESTAMPNS_OLD: c_int = 35; + const SO_TIMESTAMPING_OLD: c_int = 37; + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; } } -const SO_TIMESTAMP_OLD: c_int = 29; -const SO_TIMESTAMPNS_OLD: c_int = 35; -const SO_TIMESTAMPING_OLD: c_int = 37; pub const SO_ACCEPTCONN: c_int = 30; pub const SO_PEERSEC: c_int = 31; pub const SO_SNDBUFFORCE: c_int = 32; @@ -94,11 +105,6 @@ pub const SO_ZEROCOPY: c_int = 60; pub const SO_TXTIME: c_int = 61; pub const SCM_TXTIME: c_int = SO_TXTIME; pub const SO_BINDTOIFINDEX: c_int = 62; -const SO_TIMESTAMP_NEW: c_int = 63; -const SO_TIMESTAMPNS_NEW: c_int = 64; -const SO_TIMESTAMPING_NEW: c_int = 65; -const SO_RCVTIMEO_NEW: c_int = 66; -const SO_SNDTIMEO_NEW: c_int = 67; // pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; pub const SO_PREFER_BUSY_POLL: c_int = 69; pub const SO_BUSY_POLL_BUDGET: c_int = 70; @@ -113,9 +119,6 @@ pub const SO_DEVMEM_LINEAR: c_int = 78; pub const SO_DEVMEM_DMABUF: c_int = 79; pub const SO_DEVMEM_DONTNEED: c_int = 80; -pub const FICLONE: c_ulong = 0x80049409; -pub const FICLONERANGE: c_ulong = 0x8020940D; - // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; @@ -209,68 +212,6 @@ pub const BLKIOOPT: Ioctl = 0x20001279; pub const BLKSSZGET: Ioctl = 0x20001268; pub const BLKPBSZGET: Ioctl = 0x2000127B; //pub const FIOQSIZE: Ioctl = 0x40086680; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x800454c8; -pub const TUNSETDEBUG: Ioctl = 0x800454c9; -pub const TUNSETIFF: Ioctl = 0x800454ca; -pub const TUNSETPERSIST: Ioctl = 0x800454cb; -pub const TUNSETOWNER: Ioctl = 0x800454cc; -pub const TUNSETLINK: Ioctl = 0x800454cd; -pub const TUNSETGROUP: Ioctl = 0x800454ce; -pub const TUNGETFEATURES: Ioctl = 0x400454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x800454d0; -pub const TUNSETTXFILTER: Ioctl = 0x800454d1; -pub const TUNGETIFF: Ioctl = 0x400454d2; -pub const TUNGETSNDBUF: Ioctl = 0x400454d3; -pub const TUNSETSNDBUF: Ioctl = 0x800454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8; -pub const TUNSETQUEUE: Ioctl = 0x800454d9; -pub const TUNSETIFINDEX: Ioctl = 0x800454da; -pub const TUNSETVNETLE: Ioctl = 0x800454dc; -pub const TUNGETVNETLE: Ioctl = 0x400454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x800454de; -pub const TUNGETVNETBE: Ioctl = 0x400454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1; - -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(target_arch = "powerpc")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x800854d5; - pub const TUNDETACHFILTER: Ioctl = 0x800854d6; - pub const TUNGETFILTER: Ioctl = 0x400854db; - } else if #[cfg(target_arch = "powerpc64")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x801054d5; - pub const TUNDETACHFILTER: Ioctl = 0x801054d6; - pub const TUNGETFILTER: Ioctl = 0x401054db; - } -} pub const TIOCM_LE: c_int = 0x001; pub const TIOCM_DTR: c_int = 0x002; @@ -330,7 +271,7 @@ cfg_if! { pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - pub const RLIM_NLIMITS: c_int = 15; + pub const RLIM_NLIMITS: c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/arch/sparc/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/arch/sparc/mod.rs @@ -199,35 +199,6 @@ pub const BLKPBSZGET: Ioctl = 0x2000127B; //pub const TIOCGRS485: Ioctl = 0x40205441; //pub const TIOCSRS485: Ioctl = 0xc0205442; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x800454c8; -pub const TUNSETDEBUG: Ioctl = 0x800454c9; -pub const TUNSETIFF: Ioctl = 0x800454ca; -pub const TUNSETPERSIST: Ioctl = 0x800454cb; -pub const TUNSETOWNER: Ioctl = 0x800454cc; -pub const TUNSETLINK: Ioctl = 0x800454cd; -pub const TUNSETGROUP: Ioctl = 0x800454ce; -pub const TUNGETFEATURES: Ioctl = 0x400454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x800454d0; -pub const TUNSETTXFILTER: Ioctl = 0x800454d1; -pub const TUNGETIFF: Ioctl = 0x400454d2; -pub const TUNGETSNDBUF: Ioctl = 0x400454d3; -pub const TUNSETSNDBUF: Ioctl = 0x800454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8; -pub const TUNSETQUEUE: Ioctl = 0x800454d9; -pub const TUNSETIFINDEX: Ioctl = 0x800454da; -pub const TUNSETVNETLE: Ioctl = 0x800454dc; -pub const TUNGETVNETLE: Ioctl = 0x400454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x800454de; -pub const TUNGETVNETBE: Ioctl = 0x400454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1; - pub const TIOCM_LE: c_int = 0x001; pub const TIOCM_DTR: c_int = 0x002; pub const TIOCM_RTS: c_int = 0x004; @@ -274,37 +245,3 @@ cfg_if! { pub const RLIM_INFINITY: crate::rlim_t = 0x7fffffff; } } - -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(target_arch = "sparc")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x800854d5; - pub const TUNDETACHFILTER: Ioctl = 0x800854d6; - pub const TUNGETFILTER: Ioctl = 0x400854db; - } else if #[cfg(target_arch = "sparc64")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x801054d5; - pub const TUNDETACHFILTER: Ioctl = 0x801054d6; - pub const TUNGETFILTER: Ioctl = 0x401054db; - } -} diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -4,6 +4,8 @@ use crate::{off64_t, off_t}; pub type wchar_t = u32; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -60,23 +62,35 @@ s! { pub struct stat64 { pub st_dev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] __pad1: c_uint, - __st_ino: crate::ino_t, + #[cfg(not(gnu_time_bits64))] + __st_ino: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] __pad2: c_uint, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _atime_pad: c_int, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _mtime_pad: c_int, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _ctime_pad: c_int, + #[cfg(not(gnu_time_bits64))] pub st_ino: crate::ino64_t, } @@ -115,10 +129,13 @@ s! { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __unused1: c_ulong, pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __unused2: c_ulong, pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __unused3: c_ulong, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, @@ -130,10 +147,13 @@ s! { pub struct msqid_ds { pub msg_perm: crate::ipc_perm, pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved1: c_ulong, pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved2: c_ulong, pub msg_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved3: c_ulong, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, @@ -212,13 +232,11 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [i64; 2], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct ucontext_t { pub uc_flags: c_ulong, @@ -242,17 +260,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_link) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_sigmask", &self.uc_sigmask) - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); @@ -397,7 +404,13 @@ pub const MCL_ONFAULT: c_int = 0x0004; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const F_GETLK: c_int = 5; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -4,6 +4,8 @@ use crate::{off64_t, off_t}; pub type wchar_t = u32; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -166,7 +168,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [i64; 2], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -4,6 +4,8 @@ use crate::{off64_t, off_t}; pub type wchar_t = i32; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -159,7 +161,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(2))] pub struct max_align_t { priv_: [i8; 20], @@ -189,7 +190,6 @@ pub const O_NDELAY: c_int = 0x800; pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_LOCKED: c_int = 0x02000; pub const MAP_NORESERVE: c_int = 0x04000; -pub const MAP_32BIT: c_int = 0x0040; pub const MAP_ANON: c_int = 0x0020; pub const MAP_ANONYMOUS: c_int = 0x0020; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -5,49 +5,114 @@ pub type wchar_t = i32; s! { pub struct stat { + #[cfg(not(gnu_time_bits64))] pub st_dev: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_dev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] st_pad1: [c_long; 3], + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, + + #[cfg(not(gnu_time_bits64))] pub st_rdev: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_rdev: crate::dev_t, + + #[cfg(not(gnu_file_offset_bits64))] st_pad2: [c_long; 2], + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + st_pad2: [c_long; 3], + pub st_size: off_t, + + #[cfg(not(gnu_file_offset_bits64))] st_pad3: c_long, + + #[cfg(gnu_time_bits64)] + pub st_blksize: crate::blksize_t, + #[cfg(gnu_time_bits64)] + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: c_int, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: c_int, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: c_int, pub st_ctime_nsec: c_long, + + #[cfg(not(gnu_time_bits64))] pub st_blksize: crate::blksize_t, + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + st_pad4: c_long, + #[cfg(not(gnu_time_bits64))] pub st_blocks: crate::blkcnt_t, + #[cfg(not(gnu_time_bits64))] st_pad5: [c_long; 14], } pub struct stat64 { + #[cfg(not(gnu_time_bits64))] pub st_dev: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_dev: crate::dev_t, + + #[cfg(not(gnu_time_bits64))] st_pad1: [c_long; 3], + pub st_ino: crate::ino64_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, + + #[cfg(not(gnu_time_bits64))] pub st_rdev: c_ulong, - st_pad2: [c_long; 2], + #[cfg(gnu_time_bits64)] + pub st_rdev: crate::dev_t, + + #[cfg(not(gnu_time_bits64))] + st_pad2: [c_long; 3], + pub st_size: off64_t, + + #[cfg(gnu_time_bits64)] + pub st_blksize: crate::blksize_t, + #[cfg(gnu_time_bits64)] + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: c_int, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: c_int, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: c_int, pub st_ctime_nsec: c_long, + + #[cfg(not(gnu_time_bits64))] pub st_blksize: crate::blksize_t, + #[cfg(not(gnu_time_bits64))] st_pad3: c_long, + #[cfg(not(gnu_time_bits64))] pub st_blocks: crate::blkcnt64_t, + #[cfg(not(gnu_time_bits64))] st_pad5: [c_long; 14], } @@ -98,6 +163,8 @@ s! { __f_spare: [c_int; 6], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_flags: c_int, pub sa_sigaction: crate::sighandler_t, @@ -147,22 +214,22 @@ s! { pub struct msqid_ds { pub msg_perm: crate::ipc_perm, - #[cfg(target_endian = "big")] + #[cfg(all(not(gnu_time_bits64), target_endian = "big"))] __glibc_reserved1: c_ulong, pub msg_stime: crate::time_t, - #[cfg(target_endian = "little")] + #[cfg(all(not(gnu_time_bits64), target_endian = "little"))] __glibc_reserved1: c_ulong, - #[cfg(target_endian = "big")] + #[cfg(all(not(gnu_time_bits64), target_endian = "big"))] __glibc_reserved2: c_ulong, pub msg_rtime: crate::time_t, - #[cfg(target_endian = "little")] + #[cfg(all(not(gnu_time_bits64), target_endian = "little"))] __glibc_reserved2: c_ulong, - #[cfg(target_endian = "big")] + #[cfg(all(not(gnu_time_bits64), target_endian = "big"))] __glibc_reserved3: c_ulong, pub msg_ctime: crate::time_t, #[cfg(target_endian = "little")] __glibc_reserved3: c_ulong, - pub __msg_cbytes: c_ulong, + __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, @@ -176,14 +243,15 @@ s! { pub l_whence: c_short, pub l_start: off_t, pub l_len: off_t, + #[cfg(not(gnu_file_offset_bits64))] pub l_sysid: c_long, pub l_pid: crate::pid_t, - pad: [c_long; 4], + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved0: [c_long; 4], } } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f32; 4], @@ -745,7 +813,13 @@ pub const MAP_HUGETLB: c_int = 0x080000; pub const EFD_NONBLOCK: c_int = 0x80; -pub const F_GETLK: c_int = 14; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 33; + } else { + pub const F_GETLK: c_int = 14; + } +} pub const F_GETOWN: c_int = 23; pub const F_SETOWN: c_int = 24; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -15,22 +15,51 @@ pub type __fsword_t = i32; pub type fsblkcnt64_t = u64; pub type fsfilcnt64_t = u64; pub type __syscall_ulong_t = c_ulong; +pub type __suseconds64_t = i64; cfg_if! { if #[cfg(target_arch = "riscv32")] { pub type time_t = i64; pub type suseconds_t = i64; - pub type ino_t = u64; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; pub type off_t = i64; pub type blkcnt_t = i64; pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u64; pub type rlim_t = u64; pub type blksize_t = i64; + } else if #[cfg(gnu_time_bits64)] { + pub type time_t = i64; + pub type suseconds_t = i32; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; + pub type off_t = i64; + pub type blkcnt_t = i64; + pub type fsblkcnt_t = u64; + pub type fsfilcnt_t = u64; + pub type rlim_t = u64; + pub type blksize_t = i32; + } else if #[cfg(gnu_file_offset_bits64)] { + pub type time_t = i32; + pub type suseconds_t = i32; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; + pub type off_t = i64; + pub type blkcnt_t = i64; + pub type fsblkcnt_t = u64; + pub type fsfilcnt_t = u64; + pub type rlim_t = u64; + pub type blksize_t = i32; } else { pub type time_t = i32; pub type suseconds_t = i32; - pub type ino_t = u32; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino_t; pub type off_t = i32; pub type blkcnt_t = i32; pub type fsblkcnt_t = c_ulong; @@ -41,30 +70,58 @@ cfg_if! { } cfg_if! { - if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] { + if #[cfg(not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc", + target_arch = "sparc" + )))] { s! { pub struct stat { pub st_dev: crate::dev_t, - __pad1: c_short, + #[cfg(not(gnu_time_bits64))] + __pad1: c_uint, + + #[cfg(any(gnu_time_bits64, not(gnu_file_offset_bits64)))] pub st_ino: crate::ino_t, + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + __st_ino: __ino_t, + pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, - __pad2: c_short, + + #[cfg(not(gnu_time_bits64))] + __pad2: c_uint, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, pub st_atime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _atime_pad: c_int, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _mtime_pad: c_int, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __unused4: c_long, - __unused5: c_long, + #[cfg(gnu_time_bits64)] + _ctime_pad: c_int, + + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved4: c_long, + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved5: c_long, + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + pub st_ino: crate::ino_t, } } } @@ -118,28 +175,114 @@ s! { pub struct semid_ds { pub sem_perm: ipc_perm, - #[cfg(target_arch = "powerpc")] + #[cfg(all(not(gnu_time_bits64), target_arch = "powerpc"))] __reserved: crate::__syscall_ulong_t, pub sem_otime: crate::time_t, #[cfg(not(any( + gnu_time_bits64, target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc" )))] __reserved: crate::__syscall_ulong_t, - #[cfg(target_arch = "powerpc")] + #[cfg(all(not(gnu_time_bits64), target_arch = "powerpc"))] __reserved2: crate::__syscall_ulong_t, pub sem_ctime: crate::time_t, #[cfg(not(any( + gnu_time_bits64, target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc" )))] __reserved2: crate::__syscall_ulong_t, pub sem_nsems: crate::__syscall_ulong_t, + #[cfg(all( + gnu_time_bits64, + not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc", + target_arch = "arm", + target_arch = "x86" + )) + ))] + __reserved2: crate::__syscall_ulong_t, __glibc_reserved3: crate::__syscall_ulong_t, __glibc_reserved4: crate::__syscall_ulong_t, } + + #[cfg(gnu_time_bits64)] + pub struct timex { + pub modes: c_uint, + _pad1: c_int, + pub offset: c_longlong, + pub freq: c_longlong, + pub maxerror: c_longlong, + pub esterror: c_longlong, + pub status: c_int, + _pad2: c_int, + pub constant: c_longlong, + pub precision: c_longlong, + pub tolerance: c_longlong, + pub time: crate::timeval, + pub tick: c_longlong, + pub ppsfreq: c_longlong, + pub jitter: c_longlong, + pub shift: c_int, + _pad3: c_int, + pub stabil: c_longlong, + pub jitcnt: c_longlong, + pub calcnt: c_longlong, + pub errcnt: c_longlong, + pub stbcnt: c_longlong, + pub tai: c_int, + pub __unused1: i32, + pub __unused2: i32, + pub __unused3: i32, + pub __unused4: i32, + pub __unused5: i32, + pub __unused6: i32, + pub __unused7: i32, + pub __unused8: i32, + pub __unused9: i32, + pub __unused10: i32, + pub __unused11: i32, + } + + #[cfg(not(gnu_time_bits64))] + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub time: crate::timeval, + pub tick: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + pub tai: c_int, + pub __unused1: i32, + pub __unused2: i32, + pub __unused3: i32, + pub __unused4: i32, + pub __unused5: i32, + pub __unused6: i32, + pub __unused7: i32, + pub __unused8: i32, + pub __unused9: i32, + pub __unused10: i32, + pub __unused11: i32, + } } pub const POSIX_FADV_DONTNEED: c_int = 4; @@ -167,9 +310,6 @@ cfg_if! { pub const PTRACE_DETACH: c_uint = 11; - pub const F_SETLK: c_int = 8; - pub const F_SETLKW: c_int = 9; - pub const F_RDLCK: c_int = 1; pub const F_WRLCK: c_int = 2; pub const F_UNLCK: c_int = 3; @@ -213,9 +353,6 @@ cfg_if! { pub const PTRACE_DETACH: c_uint = 17; - pub const F_SETLK: c_int = 6; - pub const F_SETLKW: c_int = 7; - pub const F_RDLCK: c_int = 0; pub const F_WRLCK: c_int = 1; pub const F_UNLCK: c_int = 2; @@ -251,6 +388,24 @@ cfg_if! { pub const EFD_CLOEXEC: c_int = 0x80000; } } +cfg_if! { + if #[cfg(target_arch = "sparc")] { + pub const F_SETLK: c_int = 8; + pub const F_SETLKW: c_int = 9; + } else if #[cfg(all( + gnu_file_offset_bits64, + any(target_arch = "mips", target_arch = "mips32r6") + ))] { + pub const F_SETLK: c_int = 34; + pub const F_SETLKW: c_int = 35; + } else if #[cfg(gnu_file_offset_bits64)] { + pub const F_SETLK: c_int = 13; + pub const F_SETLKW: c_int = 14; + } else { + pub const F_SETLK: c_int = 6; + pub const F_SETLKW: c_int = 7; + } +} #[cfg(target_endian = "little")] pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -4,6 +4,8 @@ use crate::{off64_t, off_t}; pub type wchar_t = i32; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -57,6 +59,39 @@ s! { __glibc_reserved2: u64, } + pub struct stat { + pub st_dev: crate::dev_t, + #[cfg(not(gnu_file_offset_bits64))] + __pad1: c_ushort, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] + __pad2: c_ushort, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: c_int, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: c_int, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: c_int, + pub st_ctime_nsec: c_long, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved4: c_ulong, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved5: c_ulong, + } + pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino64_t, @@ -65,17 +100,26 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] __pad2: c_ushort, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: c_int, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: c_int, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: c_int, pub st_ctime_nsec: c_long, + #[cfg(not(gnu_time_bits64))] __glibc_reserved4: c_ulong, + #[cfg(not(gnu_time_bits64))] __glibc_reserved5: c_ulong, } @@ -112,13 +156,20 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, + #[cfg(gnu_time_bits64)] + pub shm_segsz: size_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved1: c_uint, pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved2: c_uint, pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved3: c_uint, pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved4: c_uint, + #[cfg(not(gnu_time_bits64))] pub shm_segsz: size_t, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, @@ -129,10 +180,13 @@ s! { pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + #[cfg(not(gnu_time_bits64))] __glibc_reserved1: c_uint, pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved2: c_uint, pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved3: c_uint, pub msg_ctime: crate::time_t, pub __msg_cbytes: c_ulong, @@ -301,7 +355,13 @@ pub const MCL_ONFAULT: c_int = 0x8000; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const F_GETLK: c_int = 5; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -108,6 +108,8 @@ s! { pub ss_size: size_t, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -195,7 +197,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub __uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -204,7 +205,6 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct mcontext_t { pub __gregs: [c_ulong; 32], @@ -217,19 +217,16 @@ s_no_extra_traits! { pub __q: __riscv_mc_q_ext_state, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_f_ext_state { pub __f: [c_uint; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_d_ext_state { pub __f: [c_ulonglong; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct __riscv_mc_q_ext_state { pub __f: [c_ulonglong; 64], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -6,6 +6,8 @@ use crate::{off64_t, off_t}; pub type wchar_t = i32; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -26,7 +28,8 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + pub f_flags: crate::__fsword_t, + f_spare: [crate::__fsword_t; 4], } pub struct siginfo_t { @@ -60,6 +63,30 @@ s! { pub ss_size: size_t, } + pub struct stat { + pub st_dev: crate::dev_t, + #[cfg(not(gnu_file_offset_bits64))] + __pad1: c_ushort, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: c_ushort, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __glibc_reserved4: c_ulong, + __glibc_reserved5: c_ulong, + } + pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino64_t, @@ -78,7 +105,8 @@ s! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - __reserved: [c_long; 2], + __glibc_reserved4: c_ulong, + __glibc_reserved5: c_ulong, } pub struct statfs64 { @@ -106,6 +134,7 @@ s! { pub f_ffree: u64, pub f_favail: u64, pub f_fsid: c_ulong, + __f_unused: c_int, pub f_flag: c_ulong, pub f_namemax: c_ulong, __f_spare: [c_int; 6], @@ -127,12 +156,18 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, + #[cfg(gnu_time_bits64)] + pub shm_segsz: size_t, + #[cfg(not(gnu_time_bits64))] __pad1: c_uint, pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __pad2: c_uint, pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __pad3: c_uint, pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] pub shm_segsz: size_t, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, @@ -143,24 +178,26 @@ s! { pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + #[cfg(not(gnu_time_bits64))] __pad1: c_uint, pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __pad2: c_uint, pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __pad3: c_uint, pub msg_ctime: crate::time_t, - pub __msg_cbytes: c_ushort, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __glibc_reserved1: c_ulong, - __glibc_reserved2: c_ulong, + __glibc_reserved4: c_ulong, + __glibc_reserved5: c_ulong, } } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [i64; 3], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -5,6 +5,8 @@ pub type wchar_t = i32; pub type greg_t = i32; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -134,23 +136,35 @@ s! { pub struct stat64 { pub st_dev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] __pad1: c_uint, - __st_ino: crate::ino_t, + #[cfg(not(gnu_time_bits64))] + __st_ino: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] __pad2: c_uint, pub st_size: off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _atime_pad: c_int, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _mtime_pad: c_int, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _ctime_pad: c_int, + #[cfg(not(gnu_time_bits64))] pub st_ino: crate::ino64_t, } @@ -189,10 +203,13 @@ s! { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __unused1: c_ulong, pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __unused2: c_ulong, pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __unused3: c_ulong, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, @@ -204,10 +221,13 @@ s! { pub struct msqid_ds { pub msg_perm: crate::ipc_perm, pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved1: c_ulong, pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved2: c_ulong, pub msg_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] __glibc_reserved3: c_ulong, pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, @@ -267,7 +287,6 @@ s_no_extra_traits! { __ssp: [c_ulong; 4], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 6], @@ -296,26 +315,6 @@ cfg_if! { impl Eq for user_fpxregs_struct {} - impl fmt::Debug for user_fpxregs_struct { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for user_fpxregs_struct { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cwd.hash(state); @@ -347,19 +346,6 @@ cfg_if! { impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); @@ -499,7 +485,13 @@ pub const SA_NOCLDWAIT: c_int = 0x00000002; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const F_GETLK: c_int = 5; +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -11,6 +11,8 @@ pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -240,7 +242,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 8], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -134,6 +134,8 @@ s! { __size: [c_ulong; 7], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -235,7 +237,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -136,6 +136,8 @@ s! { __size: [c_ulong; 7], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_flags: c_int, pub sa_sigaction: crate::sighandler_t, @@ -185,7 +187,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -97,6 +97,85 @@ s! { __glibc_reserved3: crate::__syscall_ulong_t, __glibc_reserved4: crate::__syscall_ulong_t, } + + pub struct timex { + pub modes: c_uint, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub offset: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub offset: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub freq: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub freq: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub maxerror: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub maxerror: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub esterror: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub esterror: c_long, + pub status: c_int, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub constant: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub constant: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub precision: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub precision: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tolerance: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tolerance: c_long, + pub time: crate::timeval, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tick: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tick: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub ppsfreq: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub ppsfreq: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub jitter: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub jitter: c_long, + pub shift: c_int, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub stabil: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub stabil: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub jitcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub jitcnt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub calcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub calcnt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub errcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub errcnt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub stbcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub stbcnt: c_long, + pub tai: c_int, + pub __unused1: i32, + pub __unused2: i32, + pub __unused3: i32, + pub __unused4: i32, + pub __unused5: i32, + pub __unused6: i32, + pub __unused7: i32, + pub __unused8: i32, + pub __unused9: i32, + pub __unused10: i32, + pub __unused11: i32, + } } pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; @@ -119,7 +198,7 @@ cfg_if! { } else if #[cfg(any(target_arch = "s390x"))] { mod s390x; pub use self::s390x::*; - } else if #[cfg(any(target_arch = "x86_64"))] { + } else if #[cfg(target_arch = "x86_64")] { mod x86_64; pub use self::x86_64::*; } else if #[cfg(any(target_arch = "riscv64"))] { diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -11,6 +11,8 @@ pub type __u64 = c_ulong; pub type __s64 = c_long; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -192,7 +194,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [i64; 4], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -143,6 +143,8 @@ s! { pub ss_size: size_t, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -245,7 +247,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub __uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -254,7 +255,6 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct mcontext_t { pub __gregs: [c_ulong; 32], @@ -267,19 +267,16 @@ s_no_extra_traits! { pub __q: __riscv_mc_q_ext_state, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_f_ext_state { pub __f: [c_uint; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_d_ext_state { pub __f: [c_ulonglong; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct __riscv_mc_q_ext_state { pub __f: [c_ulonglong; 64], @@ -601,6 +598,7 @@ pub const REG_NARGS: usize = 8; pub const COMPAT_HWCAP_ISA_I: c_ulong = 1 << (b'I' - b'A'); pub const COMPAT_HWCAP_ISA_M: c_ulong = 1 << (b'M' - b'A'); +#[allow(clippy::eq_op)] pub const COMPAT_HWCAP_ISA_A: c_ulong = 1 << (b'A' - b'A'); pub const COMPAT_HWCAP_ISA_F: c_ulong = 1 << (b'F' - b'A'); pub const COMPAT_HWCAP_ISA_D: c_ulong = 1 << (b'D' - b'A'); diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -12,6 +12,8 @@ pub type __u64 = u64; pub type __s64 = i64; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, __glibc_reserved0: c_int, @@ -227,15 +229,9 @@ cfg_if! { impl Eq for fpreg_t {} - impl fmt::Debug for fpreg_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpreg_t").field("d", &self.d).finish() - } - } - impl hash::Hash for fpreg_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { - let d: u64 = unsafe { mem::transmute(self.d) }; + let d: u64 = self.d.to_bits(); d.hash(state); } } diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -11,6 +11,8 @@ pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -195,7 +197,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [i64; 4], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -12,6 +12,8 @@ pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -315,7 +317,6 @@ s_no_extra_traits! { // __ssp: [c_ulonglong; 4], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], @@ -346,23 +347,6 @@ cfg_if! { impl Eq for user_fpregs_struct {} - impl fmt::Debug for user_fpregs_struct { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("xmm_space", &self.xmm_space) - // Ignore padding field - .finish() - } - } - impl hash::Hash for user_fpregs_struct { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cwd.hash(state); @@ -391,19 +375,6 @@ cfg_if! { impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); diff --git a/third_party/rust/libc/src/unix/linux_like/linux/gnu/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/gnu/mod.rs @@ -32,7 +32,11 @@ s! { __error_code: c_int, __return_value: ssize_t, pub aio_offset: off_t, - #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))] + #[cfg(all( + not(gnu_file_offset_bits64), + not(target_arch = "x86_64"), + target_pointer_width = "32" + ))] __unused1: [c_char; 4], __glibc_reserved: [c_char; 32], } @@ -170,85 +174,6 @@ s! { pub rt_irtt: c_ushort, } - pub struct timex { - pub modes: c_uint, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub offset: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub offset: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub freq: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub freq: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub maxerror: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub maxerror: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub esterror: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub esterror: c_long, - pub status: c_int, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub constant: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub constant: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub precision: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub precision: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub tolerance: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub tolerance: c_long, - pub time: crate::timeval, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub tick: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub tick: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub ppsfreq: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub ppsfreq: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub jitter: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub jitter: c_long, - pub shift: c_int, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub stabil: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub stabil: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub jitcnt: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub jitcnt: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub calcnt: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub calcnt: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub errcnt: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub errcnt: c_long, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub stbcnt: i64, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub stbcnt: c_long, - pub tai: c_int, - pub __unused1: i32, - pub __unused2: i32, - pub __unused3: i32, - pub __unused4: i32, - pub __unused5: i32, - pub __unused6: i32, - pub __unused7: i32, - pub __unused8: i32, - pub __unused9: i32, - pub __unused10: i32, - pub __unused11: i32, - } - pub struct ntptimeval { pub time: crate::timeval, pub maxerror: c_long, @@ -328,6 +253,13 @@ s! { pub u: __c_anonymous_ptrace_syscall_info_data, } + pub struct ptrace_sud_config { + pub mode: crate::__u64, + pub selector: crate::__u64, + pub offset: crate::__u64, + pub len: crate::__u64, + } + pub struct iocb { pub aio_data: crate::__u64, #[cfg(target_endian = "little")] @@ -407,6 +339,38 @@ s! { #[cfg(target_pointer_width = "64")] __size: [c_char; 32], } + + pub struct mbstate_t { + __count: c_int, + __wchb: [c_char; 4], + } + + pub struct fpos64_t { + __pos: off64_t, + __state: crate::mbstate_t, + } + + pub struct fpos_t { + #[cfg(not(gnu_file_offset_bits64))] + __pos: off_t, + #[cfg(gnu_file_offset_bits64)] + __pos: off64_t, + __state: crate::mbstate_t, + } + + // linux x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 + pub struct timespec { + pub tv_sec: time_t, + #[cfg(all(gnu_time_bits64, target_endian = "big"))] + __pad: i32, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tv_nsec: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tv_nsec: i64, + #[cfg(all(gnu_time_bits64, target_endian = "little"))] + __pad: i32, + } } impl siginfo_t { @@ -418,7 +382,7 @@ impl siginfo_t { _si_code: c_int, si_addr: *mut c_void, } - (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + (*(self as *const siginfo_t).cast::<siginfo_sigfault>()).si_addr } pub unsafe fn si_value(&self) -> crate::sigval { @@ -431,7 +395,7 @@ impl siginfo_t { _si_overrun: c_int, si_sigval: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval + (*(self as *const siginfo_t).cast::<siginfo_timer>()).si_sigval } } @@ -469,7 +433,7 @@ struct siginfo_f { impl siginfo_t { unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields + &(*(self as *const siginfo_t).cast::<siginfo_f>()).sifields } pub unsafe fn si_pid(&self) -> crate::pid_t { @@ -493,19 +457,13 @@ impl siginfo_t { } } -pub union __c_anonymous_ptrace_syscall_info_data { - pub entry: __c_anonymous_ptrace_syscall_info_entry, - pub exit: __c_anonymous_ptrace_syscall_info_exit, - pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, -} -impl Copy for __c_anonymous_ptrace_syscall_info_data {} -impl Clone for __c_anonymous_ptrace_syscall_info_data { - fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data { - *self +s_no_extra_traits! { + pub union __c_anonymous_ptrace_syscall_info_data { + pub entry: __c_anonymous_ptrace_syscall_info_entry, + pub exit: __c_anonymous_ptrace_syscall_info_exit, + pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, } -} -s_no_extra_traits! { pub struct utmpx { pub ut_type: c_short, pub ut_pid: crate::pid_t, @@ -575,24 +533,6 @@ cfg_if! { impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .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() - } - } - impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_type.hash(state); @@ -621,18 +561,6 @@ cfg_if! { impl Eq for __c_anonymous_ptrace_syscall_info_data {} - impl fmt::Debug for __c_anonymous_ptrace_syscall_info_data { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_ptrace_syscall_info_data") - .field("entry", &self.entry) - .field("exit", &self.exit) - .field("seccomp", &self.seccomp) - .finish() - } - } - } - impl hash::Hash for __c_anonymous_ptrace_syscall_info_data { fn hash<H: hash::Hasher>(&self, state: &mut H) { unsafe { @@ -722,7 +650,6 @@ pub const RTLD_DI_TLS_MODID: c_int = 9; pub const RTLD_DI_TLS_DATA: c_int = 10; pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; -pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; pub const SOL_RXRPC: c_int = 272; pub const SOL_PPPOL2TP: c_int = 273; @@ -911,15 +838,8 @@ pub const PTRACE_SYSCALL_INFO_NONE: crate::__u8 = 0; pub const PTRACE_SYSCALL_INFO_ENTRY: crate::__u8 = 1; pub const PTRACE_SYSCALL_INFO_EXIT: crate::__u8 = 2; pub const PTRACE_SYSCALL_INFO_SECCOMP: crate::__u8 = 3; - -// linux/fs.h - -// Flags for preadv2/pwritev2 -pub const RWF_HIPRI: c_int = 0x00000001; -pub const RWF_DSYNC: c_int = 0x00000002; -pub const RWF_SYNC: c_int = 0x00000004; -pub const RWF_NOWAIT: c_int = 0x00000008; -pub const RWF_APPEND: c_int = 0x00000010; +pub const PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4210; +pub const PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4211; // linux/rtnetlink.h pub const TCA_PAD: c_ushort = 9; @@ -1128,33 +1048,6 @@ pub const REG_EEND: c_int = 14; pub const REG_ESIZE: c_int = 15; pub const REG_ERPAREN: c_int = 16; -cfg_if! { - if #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "loongarch64", - target_arch = "riscv64", - target_arch = "s390x" - ))] { - pub const TUNSETCARRIER: Ioctl = 0x400454e2; - pub const TUNGETDEVNETNS: Ioctl = 0x54e3; - } else if #[cfg(any( - target_arch = "mips", - target_arch = "mips64", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "sparc", - target_arch = "sparc64" - ))] { - pub const TUNSETCARRIER: Ioctl = 0x800454e2; - pub const TUNGETDEVNETNS: Ioctl = 0x200054e3; - } else { - // Unknown target_arch - } -} - extern "C" { pub fn fgetspent_r( fp: *mut crate::FILE, @@ -1183,12 +1076,14 @@ extern "C" { compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>, arg: *mut c_void, ); + #[cfg_attr(gnu_time_bits64, link_name = "__sendmmsg64")] pub fn sendmmsg( sockfd: c_int, msgvec: *mut crate::mmsghdr, vlen: c_uint, flags: c_int, ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__recvmmsg64")] pub fn recvmmsg( sockfd: c_int, msgvec: *mut crate::mmsghdr, @@ -1200,8 +1095,11 @@ extern "C" { pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "getrlimit64")] pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "setrlimit64")] pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "prlimit64")] pub fn prlimit( pid: crate::pid_t, resource: crate::__rlimit_resource_t, @@ -1224,15 +1122,20 @@ extern "C" { pub fn endutxent(); pub fn getpt() -> c_int; pub fn mallopt(param: c_int, value: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__gettimeofday64")] pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; pub fn getauxval(type_: c_ulong) -> c_ulong; + #[cfg_attr(gnu_time_bits64, link_name = "___adjtimex64")] pub fn adjtimex(buf: *mut timex) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "___adjtimex64")] pub fn ntp_adjtime(buf: *mut timex) -> c_int; - #[link_name = "ntp_gettimex"] + #[cfg_attr(not(gnu_time_bits64), link_name = "ntp_gettimex")] + #[cfg_attr(gnu_time_bits64, link_name = "__ntp_gettime64")] pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__clock_adjtime64")] pub fn clock_adjtime(clk_id: crate::clockid_t, buf: *mut crate::timex) -> c_int; pub fn fanotify_mark( @@ -1242,6 +1145,7 @@ extern "C" { dirfd: c_int, path: *const c_char, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")] pub fn preadv2( fd: c_int, iov: *const crate::iovec, @@ -1249,6 +1153,7 @@ extern "C" { offset: off_t, flags: c_int, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")] pub fn pwritev2( fd: c_int, iov: *const crate::iovec, @@ -1285,12 +1190,16 @@ extern "C" { pub fn ctermid(s: *mut c_char) -> *mut c_char; pub fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int; + pub fn backtrace_symbols(buffer: *const *mut c_void, len: c_int) -> *mut *mut c_char; + pub fn backtrace_symbols_fd(buffer: *const *mut c_void, len: c_int, fd: c_int); + #[cfg_attr(gnu_time_bits64, link_name = "__glob64_time64")] pub fn glob64( pattern: *const c_char, flags: c_int, errfunc: Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>, pglob: *mut glob64_t, ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__globfree64_time64")] pub fn globfree64(pglob: *mut glob64_t); pub fn ptrace(request: c_uint, ...) -> c_long; pub fn pthread_attr_getaffinity_np( @@ -1358,6 +1267,7 @@ extern "C" { pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int; pub fn asctime_r(tm: *const crate::tm, buf: *mut c_char) -> *mut c_char; + #[cfg_attr(gnu_time_bits64, link_name = "__ctime64_r")] pub fn ctime_r(timep: *const time_t, buf: *mut c_char) -> *mut c_char; pub fn dirname(path: *mut c_char) -> *mut c_char; @@ -1375,6 +1285,11 @@ extern "C" { extra_info: *mut *mut c_void, flags: c_int, ) -> c_int; + pub fn dlvsym( + handle: *mut c_void, + symbol: *const c_char, + version: *const c_char, + ) -> *mut c_void; pub fn malloc_trim(__pad: size_t) -> c_int; pub fn gnu_get_libc_release() -> *const c_char; pub fn gnu_get_libc_version() -> *const c_char; @@ -1422,6 +1337,7 @@ extern "C" { pub fn mq_notify(mqdes: crate::mqd_t, sevp: *const crate::sigevent) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__epoll_pwait2_time64")] pub fn epoll_pwait2( epfd: c_int, events: *mut crate::epoll_event, diff --git a/third_party/rust/libc/src/unix/linux_like/linux/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/mod.rs @@ -1,8 +1,7 @@ //! Linux-specific definitions for linux-like values -use core::mem::size_of; - use crate::prelude::*; +use crate::{sock_filter, _IO, _IOR, _IOW, _IOWR}; pub type useconds_t = u32; pub type dev_t = u64; @@ -59,24 +58,20 @@ cfg_if! { } } -// linux/can.h -pub type canid_t = u32; - -// linux/can/j1939.h -pub type can_err_mask_t = u32; -pub type pgn_t = u32; -pub type priority_t = u8; -pub type name_t = u64; - pub type iconv_t = *mut c_void; // linux/sctp.h pub type sctp_assoc_t = __s32; pub type eventfd_t = u64; -missing! { - #[cfg_attr(feature = "extra_traits", derive(Debug))] - pub enum fpos64_t {} // FIXME(linux): fill this out with a struct + +cfg_if! { + if #[cfg(not(target_env = "gnu"))] { + missing! { + #[derive(Debug)] + pub enum fpos64_t {} // FIXME(linux): fill this out with a struct + } + } } e! { @@ -88,6 +83,16 @@ e! { } } +c_enum! { + pub enum pid_type { + PIDTYPE_PID, + PIDTYPE_TGID, + PIDTYPE_PGID, + PIDTYPE_SID, + PIDTYPE_MAX, + } +} + s! { pub struct glob_t { pub gl_pathc: size_t, @@ -716,46 +721,6 @@ s! { pub ee_data: u32, } - // linux/can.h - pub struct __c_anonymous_sockaddr_can_tp { - pub rx_id: canid_t, - pub tx_id: canid_t, - } - - pub struct __c_anonymous_sockaddr_can_j1939 { - pub name: u64, - pub pgn: u32, - pub addr: u8, - } - - pub struct can_filter { - pub can_id: canid_t, - pub can_mask: canid_t, - } - - // linux/can/j1939.h - pub struct j1939_filter { - pub name: name_t, - pub name_mask: name_t, - pub pgn: pgn_t, - pub pgn_mask: pgn_t, - pub addr: u8, - pub addr_mask: u8, - } - - // linux/filter.h - pub struct sock_filter { - pub code: __u16, - pub jt: __u8, - pub jf: __u8, - pub k: __u32, - } - - pub struct sock_fprog { - pub len: c_ushort, - pub filter: *mut sock_filter, - } - // linux/seccomp.h pub struct seccomp_data { pub nr: c_int, @@ -810,13 +775,6 @@ s! { pub nla_type: u16, } - pub struct file_clone_range { - pub src_fd: crate::__s64, - pub src_offset: crate::__u64, - pub src_length: crate::__u64, - pub dest_offset: crate::__u64, - } - pub struct __c_anonymous_ifru_map { pub mem_start: c_ulong, pub mem_end: c_ulong, @@ -966,6 +924,14 @@ s! { pub rec_seq: [c_uchar; TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE], } + pub struct tls12_crypto_info_aes_ccm_128 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_AES_CCM_128_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_AES_CCM_128_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_AES_CCM_128_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE], + } + pub struct tls12_crypto_info_chacha20_poly1305 { pub info: tls_crypto_info, pub iv: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE], @@ -974,6 +940,38 @@ s! { pub rec_seq: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE], } + pub struct tls12_crypto_info_sm4_gcm { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_SM4_GCM_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_SM4_GCM_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_SM4_GCM_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_sm4_ccm { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_SM4_CCM_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_SM4_CCM_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_SM4_CCM_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_aria_gcm_128 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_ARIA_GCM_128_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_ARIA_GCM_128_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_ARIA_GCM_128_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_aria_gcm_256 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_ARIA_GCM_256_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_ARIA_GCM_256_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_ARIA_GCM_256_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE], + } + // linux/wireless.h pub struct iw_param { @@ -1184,6 +1182,7 @@ s! { size: [u8; crate::__SIZEOF_PTHREAD_BARRIERATTR_T], } + #[cfg(not(target_env = "musl"))] #[repr(align(8))] pub struct fanotify_event_metadata { pub event_len: __u32, @@ -1321,6 +1320,33 @@ s! { pub userns_fd: crate::__u64, } + // linux/nsfs.h + pub struct mnt_ns_info { + pub size: crate::__u32, + pub nr_mounts: crate::__u32, + pub mnt_ns_id: crate::__u64, + } + + // linux/pidfd.h + + #[non_exhaustive] + pub struct pidfd_info { + pub mask: crate::__u64, + pub cgroupid: crate::__u64, + pub pid: crate::__u32, + pub tgid: crate::__u32, + pub ppid: crate::__u32, + pub ruid: crate::__u32, + pub rgid: crate::__u32, + pub euid: crate::__u32, + pub egid: crate::__u32, + pub suid: crate::__u32, + pub sgid: crate::__u32, + pub fsuid: crate::__u32, + pub fsgid: crate::__u32, + pub exit_code: crate::__s32, + } + // linux/uio.h pub struct dmabuf_cmsg { @@ -1512,18 +1538,15 @@ s_no_extra_traits! { pub sched_period: crate::__u64, } - #[allow(missing_debug_implementations)] pub union tpacket_req_u { pub req: crate::tpacket_req, pub req3: crate::tpacket_req3, } - #[allow(missing_debug_implementations)] pub union tpacket_bd_header_u { pub bh1: crate::tpacket_hdr_v1, } - #[allow(missing_debug_implementations)] pub struct tpacket_block_desc { pub version: __u32, pub offset_to_priv: __u32, @@ -1684,60 +1707,11 @@ s_no_extra_traits! { } // linux/net_tstamp.h - #[allow(missing_debug_implementations)] pub struct sock_txtime { pub clockid: crate::clockid_t, pub flags: __u32, } - // linux/can.h - #[repr(align(8))] - #[allow(missing_debug_implementations)] - pub struct can_frame { - pub can_id: canid_t, - // FIXME(1.0): this field was renamed to `len` in Linux 5.11 - pub can_dlc: u8, - __pad: u8, - __res0: u8, - pub len8_dlc: u8, - pub data: [u8; CAN_MAX_DLEN], - } - - #[repr(align(8))] - #[allow(missing_debug_implementations)] - pub struct canfd_frame { - pub can_id: canid_t, - pub len: u8, - pub flags: u8, - __res0: u8, - __res1: u8, - pub data: [u8; CANFD_MAX_DLEN], - } - - #[repr(align(8))] - #[allow(missing_debug_implementations)] - pub struct canxl_frame { - pub prio: canid_t, - pub flags: u8, - pub sdt: u8, - pub len: u16, - pub af: u32, - pub data: [u8; CANXL_MAX_DLEN], - } - - #[allow(missing_debug_implementations)] - pub union __c_anonymous_sockaddr_can_can_addr { - pub tp: __c_anonymous_sockaddr_can_tp, - pub j1939: __c_anonymous_sockaddr_can_j1939, - } - - #[allow(missing_debug_implementations)] - pub struct sockaddr_can { - pub can_family: crate::sa_family_t, - pub can_ifindex: c_int, - pub can_addr: __c_anonymous_sockaddr_can_can_addr, - } - // linux/wireless.h pub union iwreq_data { pub name: [c_char; crate::IFNAMSIZ], @@ -1786,7 +1760,6 @@ s_no_extra_traits! { pub rsv: [c_uint; 4], } - #[allow(missing_debug_implementations)] pub struct ptp_perout_request { pub anonymous_1: __c_anonymous_ptp_perout_request_1, pub period: ptp_clock_time, @@ -1796,7 +1769,6 @@ s_no_extra_traits! { } // linux/if_xdp.h - #[allow(missing_debug_implementations)] pub struct xsk_tx_metadata { pub flags: crate::__u64, pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union, @@ -1818,15 +1790,6 @@ cfg_if! { } } impl Eq for sockaddr_nl {} - impl fmt::Debug for sockaddr_nl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_nl") - .field("nl_family", &self.nl_family) - .field("nl_pid", &self.nl_pid) - .field("nl_groups", &self.nl_groups) - .finish() - } - } impl hash::Hash for sockaddr_nl { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.nl_family.hash(state); @@ -1851,18 +1814,6 @@ cfg_if! { impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } - impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -1889,18 +1840,6 @@ cfg_if! { impl Eq for dirent64 {} - impl fmt::Debug for dirent64 { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } - impl hash::Hash for dirent64 { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -1919,14 +1858,6 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_cond_t") - // FIXME(debug): .field("size", &self.size) - .finish() - } - } - impl hash::Hash for pthread_cond_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -1941,14 +1872,6 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_mutex_t") - // FIXME(debug): .field("size", &self.size) - .finish() - } - } - impl hash::Hash for pthread_mutex_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -1963,14 +1886,6 @@ cfg_if! { impl Eq for pthread_rwlock_t {} - impl fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_rwlock_t") - // FIXME(debug): .field("size", &self.size) - .finish() - } - } - impl hash::Hash for pthread_rwlock_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -1985,14 +1900,6 @@ cfg_if! { impl Eq for pthread_barrier_t {} - impl fmt::Debug for pthread_barrier_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_barrier_t") - .field("size", &self.size) - .finish() - } - } - impl hash::Hash for pthread_barrier_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.size.hash(state); @@ -2019,18 +1926,6 @@ cfg_if! { impl Eq for sockaddr_alg {} - impl fmt::Debug for sockaddr_alg { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_alg") - .field("salg_family", &self.salg_family) - .field("salg_type", &self.salg_type) - .field("salg_feat", &self.salg_feat) - .field("salg_mask", &self.salg_mask) - .field("salg_name", &&self.salg_name[..]) - .finish() - } - } - impl hash::Hash for sockaddr_alg { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.salg_family.hash(state); @@ -2050,16 +1945,6 @@ cfg_if! { } impl Eq for uinput_setup {} - impl fmt::Debug for uinput_setup { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uinput_setup") - .field("id", &self.id) - .field("name", &&self.name[..]) - .field("ff_effects_max", &self.ff_effects_max) - .finish() - } - } - impl hash::Hash for uinput_setup { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.id.hash(state); @@ -2081,20 +1966,6 @@ cfg_if! { } impl Eq for uinput_user_dev {} - impl fmt::Debug for uinput_user_dev { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("uinput_setup") - .field("name", &&self.name[..]) - .field("id", &self.id) - .field("ff_effects_max", &self.ff_effects_max) - .field("absmax", &&self.absmax[..]) - .field("absmin", &&self.absmin[..]) - .field("absfuzz", &&self.absfuzz[..]) - .field("absflat", &&self.absflat[..]) - .finish() - } - } - impl hash::Hash for uinput_user_dev { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.name.hash(state); @@ -2125,15 +1996,6 @@ cfg_if! { impl Eq for af_alg_iv {} #[allow(deprecated)] - impl fmt::Debug for af_alg_iv { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("af_alg_iv") - .field("ivlen", &self.ivlen) - .finish() - } - } - - #[allow(deprecated)] impl hash::Hash for af_alg_iv { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.as_slice().hash(state); @@ -2149,16 +2011,6 @@ cfg_if! { } } impl Eq for mq_attr {} - impl fmt::Debug for mq_attr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mq_attr") - .field("mq_flags", &self.mq_flags) - .field("mq_maxmsg", &self.mq_maxmsg) - .field("mq_msgsize", &self.mq_msgsize) - .field("mq_curmsgs", &self.mq_curmsgs) - .finish() - } - } impl hash::Hash for mq_attr { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mq_flags.hash(state); @@ -2167,31 +2019,6 @@ cfg_if! { self.mq_curmsgs.hash(state); } } - impl fmt::Debug for ifreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifreq") - .field("ifr_name", &self.ifr_name) - .field("ifr_ifru", &self.ifr_ifru) - .finish() - } - } - impl fmt::Debug for ifconf { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ifconf") - .field("ifc_len", &self.ifc_len) - .field("ifc_ifcu", &self.ifc_ifcu) - .finish() - } - } - impl fmt::Debug for hwtstamp_config { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("hwtstamp_config") - .field("flags", &self.flags) - .field("tx_type", &self.tx_type) - .field("rx_filter", &self.rx_filter) - .finish() - } - } impl PartialEq for hwtstamp_config { fn eq(&self, other: &hwtstamp_config) -> bool { self.flags == other.flags @@ -2208,20 +2035,6 @@ cfg_if! { } } - impl fmt::Debug for sched_attr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sched_attr") - .field("size", &self.size) - .field("sched_policy", &self.sched_policy) - .field("sched_flags", &self.sched_flags) - .field("sched_nice", &self.sched_nice) - .field("sched_priority", &self.sched_priority) - .field("sched_runtime", &self.sched_runtime) - .field("sched_deadline", &self.sched_deadline) - .field("sched_period", &self.sched_period) - .finish() - } - } impl PartialEq for sched_attr { fn eq(&self, other: &sched_attr) -> bool { self.size == other.size @@ -2247,25 +2060,6 @@ cfg_if! { self.sched_period.hash(state); } } - - impl fmt::Debug for iw_event { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("iw_event") - .field("len", &self.len) - .field("cmd", &self.cmd) - .field("u", &self.u) - .finish() - } - } - - impl fmt::Debug for iwreq { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("iwreq") - .field("ifr_ifrn", &self.ifr_ifrn) - .field("u", &self.u) - .finish() - } - } } } @@ -2688,6 +2482,7 @@ pub const EM_XTENSA: u16 = 94; pub const EM_AARCH64: u16 = 183; pub const EM_TILEPRO: u16 = 188; pub const EM_TILEGX: u16 = 191; +pub const EM_RISCV: u16 = 243; pub const EM_ALPHA: u16 = 0x9026; // elf.h - Legal values for e_version (version). @@ -2816,6 +2611,18 @@ pub const IFA_F_NOPREFIXROUTE: u32 = 0x200; pub const IFA_F_MCAUTOJOIN: u32 = 0x400; pub const IFA_F_STABLE_PRIVACY: u32 = 0x800; +// linux/fs.h + +// Flags for preadv2/pwritev2 +pub const RWF_HIPRI: c_int = 0x00000001; +pub const RWF_DSYNC: c_int = 0x00000002; +pub const RWF_SYNC: c_int = 0x00000004; +pub const RWF_NOWAIT: c_int = 0x00000008; +pub const RWF_APPEND: c_int = 0x00000010; +pub const RWF_NOAPPEND: c_int = 0x00000020; +pub const RWF_ATOMIC: c_int = 0x00000040; +pub const RWF_DONTCACHE: c_int = 0x00000080; + // linux/if_link.h pub const IFLA_UNSPEC: c_ushort = 0; pub const IFLA_ADDRESS: c_ushort = 1; @@ -2888,46 +2695,6 @@ pub const IFLA_INFO_XSTATS: c_ushort = 3; pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4; pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5; -// linux/if_tun.h -/* TUNSETIFF ifr flags */ -pub const IFF_TUN: c_int = 0x0001; -pub const IFF_TAP: c_int = 0x0002; -pub const IFF_NAPI: c_int = 0x0010; -pub const IFF_NAPI_FRAGS: c_int = 0x0020; -// Used in TUNSETIFF to bring up tun/tap without carrier -pub const IFF_NO_CARRIER: c_int = 0x0040; -pub const IFF_NO_PI: c_int = 0x1000; -// Read queue size -pub const TUN_READQ_SIZE: c_short = 500; -// TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. -pub const TUN_TUN_DEV: c_short = crate::IFF_TUN as c_short; -pub const TUN_TAP_DEV: c_short = crate::IFF_TAP as c_short; -pub const TUN_TYPE_MASK: c_short = 0x000f; -// This flag has no real effect -pub const IFF_ONE_QUEUE: c_int = 0x2000; -pub const IFF_VNET_HDR: c_int = 0x4000; -pub const IFF_TUN_EXCL: c_int = 0x8000; -pub const IFF_MULTI_QUEUE: c_int = 0x0100; -pub const IFF_ATTACH_QUEUE: c_int = 0x0200; -pub const IFF_DETACH_QUEUE: c_int = 0x0400; -// read-only flag -pub const IFF_PERSIST: c_int = 0x0800; -pub const IFF_NOFILTER: c_int = 0x1000; -// Socket options -pub const TUN_TX_TIMESTAMP: c_int = 1; -// Features for GSO (TUNSETOFFLOAD) -pub const TUN_F_CSUM: c_uint = 0x01; -pub const TUN_F_TSO4: c_uint = 0x02; -pub const TUN_F_TSO6: c_uint = 0x04; -pub const TUN_F_TSO_ECN: c_uint = 0x08; -pub const TUN_F_UFO: c_uint = 0x10; -pub const TUN_F_USO4: c_uint = 0x20; -pub const TUN_F_USO6: c_uint = 0x40; -// Protocol info prepended to the packets (when IFF_NO_PI is not set) -pub const TUN_PKT_STRIP: c_int = 0x0001; -// Accept all multicast packets -pub const TUN_FLT_ALLMULTI: c_int = 0x0001; - // Since Linux 3.1 pub const SEEK_DATA: c_int = 3; pub const SEEK_HOLE: c_int = 4; @@ -2945,7 +2712,7 @@ pub const ST_NOATIME: c_ulong = 1024; pub const ST_NODIRATIME: c_ulong = 2048; pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NODELETE: c_int = 0x1000; pub const RTLD_NOW: c_int = 0x2; @@ -3069,7 +2836,7 @@ pub const EFD_SEMAPHORE: c_int = 0x1; pub const LOG_NFACILITIES: c_int = 24; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32; pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32; @@ -3137,6 +2904,56 @@ pub const MREMAP_MAYMOVE: c_int = 1; pub const MREMAP_FIXED: c_int = 2; pub const MREMAP_DONTUNMAP: c_int = 4; +// linux/nsfs.h +const NSIO: c_uint = 0xb7; + +pub const NS_GET_USERNS: Ioctl = _IO(NSIO, 0x1); +pub const NS_GET_PARENT: Ioctl = _IO(NSIO, 0x2); +pub const NS_GET_NSTYPE: Ioctl = _IO(NSIO, 0x3); +pub const NS_GET_OWNER_UID: Ioctl = _IO(NSIO, 0x4); + +pub const NS_GET_MNTNS_ID: Ioctl = _IOR::<__u64>(NSIO, 0x5); + +pub const NS_GET_PID_FROM_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x6); +pub const NS_GET_TGID_FROM_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x7); +pub const NS_GET_PID_IN_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x8); +pub const NS_GET_TGID_IN_PIDNS: Ioctl = _IOR::<c_int>(NSIO, 0x9); + +pub const MNT_NS_INFO_SIZE_VER0: Ioctl = 16; + +pub const NS_MNT_GET_INFO: Ioctl = _IOR::<mnt_ns_info>(NSIO, 10); +pub const NS_MNT_GET_NEXT: Ioctl = _IOR::<mnt_ns_info>(NSIO, 11); +pub const NS_MNT_GET_PREV: Ioctl = _IOR::<mnt_ns_info>(NSIO, 12); + +// linux/pidfd.h +pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; +pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint; + +pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0; +pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1; +pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2; + +pub const PIDFD_INFO_PID: c_uint = 1 << 0; +pub const PIDFD_INFO_CREDS: c_uint = 1 << 1; +pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2; +pub const PIDFD_INFO_EXIT: c_uint = 1 << 3; + +pub const PIDFD_INFO_SIZE_VER0: c_uint = 64; + +const PIDFS_IOCTL_MAGIC: c_uint = 0xFF; +pub const PIDFD_GET_CGROUP_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 1); +pub const PIDFD_GET_IPC_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 2); +pub const PIDFD_GET_MNT_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 3); +pub const PIDFD_GET_NET_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 4); +pub const PIDFD_GET_PID_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 5); +pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 6); +pub const PIDFD_GET_TIME_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 7); +pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 8); +pub const PIDFD_GET_USER_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 9); +pub const PIDFD_GET_UTS_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 10); +pub const PIDFD_GET_INFO: Ioctl = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11); + +// linux/prctl.h pub const PR_SET_PDEATHSIG: c_int = 1; pub const PR_GET_PDEATHSIG: c_int = 2; @@ -3239,6 +3056,11 @@ pub const PR_GET_CHILD_SUBREAPER: c_int = 37; pub const PR_SET_NO_NEW_PRIVS: c_int = 38; pub const PR_GET_NO_NEW_PRIVS: c_int = 39; +pub const PR_SET_MDWE: c_int = 65; +pub const PR_GET_MDWE: c_int = 66; +pub const PR_MDWE_REFUSE_EXEC_GAIN: c_uint = 1 << 0; +pub const PR_MDWE_NO_INHERIT: c_uint = 1 << 1; + pub const PR_GET_TID_ADDRESS: c_int = 40; pub const PR_SET_THP_DISABLE: c_int = 41; @@ -3285,18 +3107,19 @@ pub const SECCOMP_SET_MODE_FILTER: c_uint = 1; pub const SECCOMP_GET_ACTION_AVAIL: c_uint = 2; pub const SECCOMP_GET_NOTIF_SIZES: c_uint = 3; -pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1; -pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 2; -pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 4; -pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 8; -pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: c_ulong = 16; -pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: c_ulong = 32; +pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1 << 0; +pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 1 << 1; +pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 1 << 2; +pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 1 << 3; +pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: c_ulong = 1 << 4; +pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: c_ulong = 1 << 5; pub const SECCOMP_RET_KILL_PROCESS: c_uint = 0x80000000; pub const SECCOMP_RET_KILL_THREAD: c_uint = 0x00000000; pub const SECCOMP_RET_KILL: c_uint = SECCOMP_RET_KILL_THREAD; pub const SECCOMP_RET_TRAP: c_uint = 0x00030000; pub const SECCOMP_RET_ERRNO: c_uint = 0x00050000; +pub const SECCOMP_RET_USER_NOTIF: c_uint = 0x7fc00000; pub const SECCOMP_RET_TRACE: c_uint = 0x7ff00000; pub const SECCOMP_RET_LOG: c_uint = 0x7ffc0000; pub const SECCOMP_RET_ALLOW: c_uint = 0x7fff0000; @@ -3451,6 +3274,12 @@ pub const BPF_JSET: __u32 = 0x40; pub const BPF_K: __u32 = 0x00; pub const BPF_X: __u32 = 0x08; +// linux/filter.h + +pub const BPF_A: __u32 = 0x10; +pub const BPF_TAX: __u32 = 0x00; +pub const BPF_TXA: __u32 = 0x80; + // linux/openat2.h pub const RESOLVE_NO_XDEV: crate::__u64 = 0x01; pub const RESOLVE_NO_MAGICLINKS: crate::__u64 = 0x02; @@ -3768,16 +3597,27 @@ pub const PACKET_KERNEL: c_uchar = 7; pub const PACKET_ADD_MEMBERSHIP: c_int = 1; pub const PACKET_DROP_MEMBERSHIP: c_int = 2; +pub const PACKET_RECV_OUTPUT: c_int = 3; pub const PACKET_RX_RING: c_int = 5; pub const PACKET_STATISTICS: c_int = 6; +pub const PACKET_COPY_THRESH: c_int = 7; pub const PACKET_AUXDATA: c_int = 8; +pub const PACKET_ORIGDEV: c_int = 9; pub const PACKET_VERSION: c_int = 10; +pub const PACKET_HDRLEN: c_int = 11; pub const PACKET_RESERVE: c_int = 12; pub const PACKET_TX_RING: c_int = 13; pub const PACKET_LOSS: c_int = 14; +pub const PACKET_VNET_HDR: c_int = 15; +pub const PACKET_TX_TIMESTAMP: c_int = 16; pub const PACKET_TIMESTAMP: c_int = 17; pub const PACKET_FANOUT: c_int = 18; +pub const PACKET_TX_HAS_OFF: c_int = 19; pub const PACKET_QDISC_BYPASS: c_int = 20; +pub const PACKET_ROLLOVER_STATS: c_int = 21; +pub const PACKET_FANOUT_DATA: c_int = 22; +pub const PACKET_IGNORE_OUTGOING: c_int = 23; +pub const PACKET_VNET_HDR_SZ: c_int = 24; pub const PACKET_FANOUT_HASH: c_uint = 0; pub const PACKET_FANOUT_LB: c_uint = 1; @@ -3789,6 +3629,7 @@ pub const PACKET_FANOUT_CBPF: c_uint = 6; pub const PACKET_FANOUT_EBPF: c_uint = 7; pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000; pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000; +pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000; pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000; pub const PACKET_MR_MULTICAST: c_int = 0; @@ -4419,6 +4260,12 @@ pub const NLM_F_EXCL: c_int = 0x200; pub const NLM_F_CREATE: c_int = 0x400; pub const NLM_F_APPEND: c_int = 0x800; +pub const NLM_F_NONREC: c_int = 0x100; +pub const NLM_F_BULK: c_int = 0x200; + +pub const NLM_F_CAPPED: c_int = 0x100; +pub const NLM_F_ACK_TLVS: c_int = 0x200; + pub const NETLINK_ADD_MEMBERSHIP: c_int = 1; pub const NETLINK_DROP_MEMBERSHIP: c_int = 2; pub const NETLINK_PKTINFO: c_int = 3; @@ -4631,6 +4478,49 @@ pub const RTNLGRP_MCTP_IFADDR: c_uint = 0x22; pub const RTNLGRP_TUNNEL: c_uint = 0x23; pub const RTNLGRP_STATS: c_uint = 0x24; +// linux/cn_proc.h +c_enum! { + pub enum proc_cn_mcast_op { + PROC_CN_MCAST_LISTEN = 1, + PROC_CN_MCAST_IGNORE = 2, + } + + pub enum proc_cn_event { + PROC_EVENT_NONE = 0x00000000, + PROC_EVENT_FORK = 0x00000001, + PROC_EVENT_EXEC = 0x00000002, + PROC_EVENT_UID = 0x00000004, + PROC_EVENT_GID = 0x00000040, + PROC_EVENT_SID = 0x00000080, + PROC_EVENT_PTRACE = 0x00000100, + PROC_EVENT_COMM = 0x00000200, + PROC_EVENT_NONZERO_EXIT = 0x20000000, + PROC_EVENT_COREDUMP = 0x40000000, + PROC_EVENT_EXIT = 0x80000000, + } +} + +// linux/connector.h +pub const CN_IDX_PROC: c_uint = 0x1; +pub const CN_VAL_PROC: c_uint = 0x1; +pub const CN_IDX_CIFS: c_uint = 0x2; +pub const CN_VAL_CIFS: c_uint = 0x1; +pub const CN_W1_IDX: c_uint = 0x3; +pub const CN_W1_VAL: c_uint = 0x1; +pub const CN_IDX_V86D: c_uint = 0x4; +pub const CN_VAL_V86D_UVESAFB: c_uint = 0x1; +pub const CN_IDX_BB: c_uint = 0x5; +pub const CN_DST_IDX: c_uint = 0x6; +pub const CN_DST_VAL: c_uint = 0x1; +pub const CN_IDX_DM: c_uint = 0x7; +pub const CN_VAL_DM_USERSPACE_LOG: c_uint = 0x1; +pub const CN_IDX_DRBD: c_uint = 0x8; +pub const CN_VAL_DRBD: c_uint = 0x1; +pub const CN_KVP_IDX: c_uint = 0x9; +pub const CN_KVP_VAL: c_uint = 0x1; +pub const CN_VSS_IDX: c_uint = 0xA; +pub const CN_VSS_VAL: c_uint = 0x1; + // linux/module.h pub const MODULE_INIT_IGNORE_MODVERSIONS: c_uint = 0x0001; pub const MODULE_INIT_IGNORE_VERMAGIC: c_uint = 0x0002; @@ -4684,25 +4574,25 @@ pub const PTP_MAX_SAMPLES: c_uint = 25; // Maximum allowed offset measurement sa const PTP_CLK_MAGIC: u32 = b'=' as u32; -pub const PTP_CLOCK_GETCAPS: c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1); -pub const PTP_EXTTS_REQUEST: c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 2); -pub const PTP_PEROUT_REQUEST: c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 3); -pub const PTP_ENABLE_PPS: c_uint = _IOW::<c_int>(PTP_CLK_MAGIC, 4); -pub const PTP_SYS_OFFSET: c_uint = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 5); -pub const PTP_PIN_GETFUNC: c_uint = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 6); -pub const PTP_PIN_SETFUNC: c_uint = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 7); -pub const PTP_SYS_OFFSET_PRECISE: c_uint = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 8); -pub const PTP_SYS_OFFSET_EXTENDED: c_uint = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 9); - -pub const PTP_CLOCK_GETCAPS2: c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10); -pub const PTP_EXTTS_REQUEST2: c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 11); -pub const PTP_PEROUT_REQUEST2: c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 12); -pub const PTP_ENABLE_PPS2: c_uint = _IOW::<c_int>(PTP_CLK_MAGIC, 13); -pub const PTP_SYS_OFFSET2: c_uint = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 14); -pub const PTP_PIN_GETFUNC2: c_uint = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 15); -pub const PTP_PIN_SETFUNC2: c_uint = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 16); -pub const PTP_SYS_OFFSET_PRECISE2: c_uint = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 17); -pub const PTP_SYS_OFFSET_EXTENDED2: c_uint = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 18); +pub const PTP_CLOCK_GETCAPS: Ioctl = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1); +pub const PTP_EXTTS_REQUEST: Ioctl = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 2); +pub const PTP_PEROUT_REQUEST: Ioctl = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 3); +pub const PTP_ENABLE_PPS: Ioctl = _IOW::<c_int>(PTP_CLK_MAGIC, 4); +pub const PTP_SYS_OFFSET: Ioctl = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 5); +pub const PTP_PIN_GETFUNC: Ioctl = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 6); +pub const PTP_PIN_SETFUNC: Ioctl = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 7); +pub const PTP_SYS_OFFSET_PRECISE: Ioctl = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 8); +pub const PTP_SYS_OFFSET_EXTENDED: Ioctl = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 9); + +pub const PTP_CLOCK_GETCAPS2: Ioctl = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10); +pub const PTP_EXTTS_REQUEST2: Ioctl = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 11); +pub const PTP_PEROUT_REQUEST2: Ioctl = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 12); +pub const PTP_ENABLE_PPS2: Ioctl = _IOW::<c_int>(PTP_CLK_MAGIC, 13); +pub const PTP_SYS_OFFSET2: Ioctl = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 14); +pub const PTP_PIN_GETFUNC2: Ioctl = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 15); +pub const PTP_PIN_SETFUNC2: Ioctl = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 16); +pub const PTP_SYS_OFFSET_PRECISE2: Ioctl = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 17); +pub const PTP_SYS_OFFSET_EXTENDED2: Ioctl = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 18); // enum ptp_pin_function pub const PTP_PF_NONE: c_uint = 0; @@ -4714,6 +4604,9 @@ pub const PTP_PF_PHYSYNC: c_uint = 3; pub const TLS_TX: c_int = 1; pub const TLS_RX: c_int = 2; +pub const TLS_TX_ZEROCOPY_RO: c_int = 3; +pub const TLS_RX_EXPECT_NO_PAD: c_int = 4; + pub const TLS_1_2_VERSION_MAJOR: __u8 = 0x3; pub const TLS_1_2_VERSION_MINOR: __u8 = 0x3; pub const TLS_1_2_VERSION: __u16 = @@ -4738,6 +4631,13 @@ pub const TLS_CIPHER_AES_GCM_256_SALT_SIZE: usize = 4; pub const TLS_CIPHER_AES_GCM_256_TAG_SIZE: usize = 16; pub const TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE: usize = 8; +pub const TLS_CIPHER_AES_CCM_128: __u16 = 53; +pub const TLS_CIPHER_AES_CCM_128_IV_SIZE: usize = 8; +pub const TLS_CIPHER_AES_CCM_128_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_AES_CCM_128_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_AES_CCM_128_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE: usize = 8; + pub const TLS_CIPHER_CHACHA20_POLY1305: __u16 = 54; pub const TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE: usize = 12; pub const TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE: usize = 32; @@ -4745,11 +4645,53 @@ pub const TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE: usize = 0; pub const TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE: usize = 16; pub const TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE: usize = 8; +pub const TLS_CIPHER_SM4_GCM: __u16 = 55; +pub const TLS_CIPHER_SM4_GCM_IV_SIZE: usize = 8; +pub const TLS_CIPHER_SM4_GCM_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_GCM_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_SM4_GCM_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_SM4_CCM: __u16 = 56; +pub const TLS_CIPHER_SM4_CCM_IV_SIZE: usize = 8; +pub const TLS_CIPHER_SM4_CCM_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_CCM_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_SM4_CCM_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_ARIA_GCM_128: __u16 = 57; +pub const TLS_CIPHER_ARIA_GCM_128_IV_SIZE: usize = 8; +pub const TLS_CIPHER_ARIA_GCM_128_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_ARIA_GCM_128_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_ARIA_GCM_128_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_ARIA_GCM_256: __u16 = 58; +pub const TLS_CIPHER_ARIA_GCM_256_IV_SIZE: usize = 8; +pub const TLS_CIPHER_ARIA_GCM_256_KEY_SIZE: usize = 32; +pub const TLS_CIPHER_ARIA_GCM_256_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_ARIA_GCM_256_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE: usize = 8; + pub const TLS_SET_RECORD_TYPE: c_int = 1; pub const TLS_GET_RECORD_TYPE: c_int = 2; pub const SOL_TLS: c_int = 282; +// enum +pub const TLS_INFO_UNSPEC: c_int = 0x00; +pub const TLS_INFO_VERSION: c_int = 0x01; +pub const TLS_INFO_CIPHER: c_int = 0x02; +pub const TLS_INFO_TXCONF: c_int = 0x03; +pub const TLS_INFO_RXCONF: c_int = 0x04; +pub const TLS_INFO_ZC_RO_TX: c_int = 0x05; +pub const TLS_INFO_RX_NO_PAD: c_int = 0x06; + +pub const TLS_CONF_BASE: c_int = 1; +pub const TLS_CONF_SW: c_int = 2; +pub const TLS_CONF_HW: c_int = 3; +pub const TLS_CONF_HW_RECORD: c_int = 4; + // linux/if_alg.h pub const ALG_SET_KEY: c_int = 1; pub const ALG_SET_IV: c_int = 2; @@ -4824,6 +4766,61 @@ pub const IN_ONLYDIR: u32 = 0x0100_0000; pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; +// uapi/linux/securebits.h +const SECURE_NOROOT: c_int = 0; +const SECURE_NOROOT_LOCKED: c_int = 1; + +pub const SECBIT_NOROOT: c_int = issecure_mask(SECURE_NOROOT); +pub const SECBIT_NOROOT_LOCKED: c_int = issecure_mask(SECURE_NOROOT_LOCKED); + +const SECURE_NO_SETUID_FIXUP: c_int = 2; +const SECURE_NO_SETUID_FIXUP_LOCKED: c_int = 3; + +pub const SECBIT_NO_SETUID_FIXUP: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP); +pub const SECBIT_NO_SETUID_FIXUP_LOCKED: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED); + +const SECURE_KEEP_CAPS: c_int = 4; +const SECURE_KEEP_CAPS_LOCKED: c_int = 5; + +pub const SECBIT_KEEP_CAPS: c_int = issecure_mask(SECURE_KEEP_CAPS); +pub const SECBIT_KEEP_CAPS_LOCKED: c_int = issecure_mask(SECURE_KEEP_CAPS_LOCKED); + +const SECURE_NO_CAP_AMBIENT_RAISE: c_int = 6; +const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = 7; + +pub const SECBIT_NO_CAP_AMBIENT_RAISE: c_int = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); +pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = + issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED); + +const SECURE_EXEC_RESTRICT_FILE: c_int = 8; +const SECURE_EXEC_RESTRICT_FILE_LOCKED: c_int = 9; + +pub const SECBIT_EXEC_RESTRICT_FILE: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE); +pub const SECBIT_EXEC_RESTRICT_FILE_LOCKED: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE_LOCKED); + +const SECURE_EXEC_DENY_INTERACTIVE: c_int = 10; +const SECURE_EXEC_DENY_INTERACTIVE_LOCKED: c_int = 11; + +pub const SECBIT_EXEC_DENY_INTERACTIVE: c_int = issecure_mask(SECURE_EXEC_DENY_INTERACTIVE); +pub const SECBIT_EXEC_DENY_INTERACTIVE_LOCKED: c_int = + issecure_mask(SECURE_EXEC_DENY_INTERACTIVE_LOCKED); + +pub const SECUREBITS_DEFAULT: c_int = 0x00000000; +pub const SECURE_ALL_BITS: c_int = SECBIT_NOROOT + | SECBIT_NO_SETUID_FIXUP + | SECBIT_KEEP_CAPS + | SECBIT_NO_CAP_AMBIENT_RAISE + | SECBIT_EXEC_RESTRICT_FILE + | SECBIT_EXEC_DENY_INTERACTIVE; +pub const SECURE_ALL_LOCKS: c_int = SECURE_ALL_BITS << 1; + +pub const SECURE_ALL_UNPRIVILEGED: c_int = + issecure_mask(SECURE_EXEC_RESTRICT_FILE) | issecure_mask(SECURE_EXEC_DENY_INTERACTIVE); + +const fn issecure_mask(x: c_int) -> c_int { + 1 << x +} + // linux/keyctl.h pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; @@ -5092,6 +5089,13 @@ pub const FF_MAX: __u16 = 0x7f; pub const FF_CNT: usize = FF_MAX as usize + 1; // linux/input-event-codes.h +pub const INPUT_PROP_POINTER: __u16 = 0x00; +pub const INPUT_PROP_DIRECT: __u16 = 0x01; +pub const INPUT_PROP_BUTTONPAD: __u16 = 0x02; +pub const INPUT_PROP_SEMI_MT: __u16 = 0x03; +pub const INPUT_PROP_TOPBUTTONPAD: __u16 = 0x04; +pub const INPUT_PROP_POINTING_STICK: __u16 = 0x05; +pub const INPUT_PROP_ACCELEROMETER: __u16 = 0x06; pub const INPUT_PROP_MAX: __u16 = 0x1f; pub const INPUT_PROP_CNT: usize = INPUT_PROP_MAX as usize + 1; pub const EV_MAX: __u16 = 0x1f; @@ -5348,112 +5352,6 @@ pub const EDOM: c_int = 33; pub const ERANGE: c_int = 34; pub const EWOULDBLOCK: c_int = EAGAIN; -// linux/can.h -pub const CAN_EFF_FLAG: canid_t = 0x80000000; -pub const CAN_RTR_FLAG: canid_t = 0x40000000; -pub const CAN_ERR_FLAG: canid_t = 0x20000000; -pub const CAN_SFF_MASK: canid_t = 0x000007FF; -pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF; -pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF; -pub const CANXL_PRIO_MASK: crate::canid_t = CAN_SFF_MASK; - -pub const CAN_SFF_ID_BITS: c_int = 11; -pub const CAN_EFF_ID_BITS: c_int = 29; -pub const CANXL_PRIO_BITS: c_int = CAN_SFF_ID_BITS; - -pub const CAN_MAX_DLC: c_int = 8; -pub const CAN_MAX_DLEN: usize = 8; -pub const CANFD_MAX_DLC: c_int = 15; -pub const CANFD_MAX_DLEN: usize = 64; - -pub const CANFD_BRS: c_int = 0x01; -pub const CANFD_ESI: c_int = 0x02; -pub const CANFD_FDF: c_int = 0x04; - -pub const CANXL_MIN_DLC: c_int = 0; -pub const CANXL_MAX_DLC: c_int = 2047; -pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; -pub const CANXL_MIN_DLEN: usize = 1; -pub const CANXL_MAX_DLEN: usize = 2048; - -pub const CANXL_XLF: c_int = 0x80; -pub const CANXL_SEC: c_int = 0x01; - -pub const CAN_MTU: usize = size_of::<can_frame>(); -pub const CANFD_MTU: usize = size_of::<canfd_frame>(); -pub const CANXL_MTU: usize = size_of::<canxl_frame>(); -// FIXME(offset_of): use `core::mem::offset_of!` once that is available -// https://github.com/rust-lang/rfcs/pull/3308 -// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); -pub const CANXL_HDR_SIZE: usize = 12; -pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; -pub const CANXL_MAX_MTU: usize = CANXL_MTU; - -pub const CAN_RAW: c_int = 1; -pub const CAN_BCM: c_int = 2; -pub const CAN_TP16: c_int = 3; -pub const CAN_TP20: c_int = 4; -pub const CAN_MCNET: c_int = 5; -pub const CAN_ISOTP: c_int = 6; -pub const CAN_J1939: c_int = 7; -pub const CAN_NPROTO: c_int = 8; - -pub const SOL_CAN_BASE: c_int = 100; - -pub const CAN_INV_FILTER: canid_t = 0x20000000; -pub const CAN_RAW_FILTER_MAX: c_int = 512; - -// linux/can/raw.h -pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW; -pub const CAN_RAW_FILTER: c_int = 1; -pub const CAN_RAW_ERR_FILTER: c_int = 2; -pub const CAN_RAW_LOOPBACK: c_int = 3; -pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4; -pub const CAN_RAW_FD_FRAMES: c_int = 5; -pub const CAN_RAW_JOIN_FILTERS: c_int = 6; -pub const CAN_RAW_XL_FRAMES: c_int = 7; - -// linux/can/j1939.h -pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939; - -pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd; -pub const J1939_IDLE_ADDR: c_uchar = 0xfe; -pub const J1939_NO_ADDR: c_uchar = 0xff; -pub const J1939_NO_NAME: c_ulong = 0; -pub const J1939_PGN_REQUEST: c_uint = 0x0ea00; -pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00; -pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8; -pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00; -pub const J1939_PGN_MAX: c_uint = 0x3ffff; -pub const J1939_NO_PGN: c_uint = 0x40000; - -pub const SO_J1939_FILTER: c_int = 1; -pub const SO_J1939_PROMISC: c_int = 2; -pub const SO_J1939_SEND_PRIO: c_int = 3; -pub const SO_J1939_ERRQUEUE: c_int = 4; - -pub const SCM_J1939_DEST_ADDR: c_int = 1; -pub const SCM_J1939_DEST_NAME: c_int = 2; -pub const SCM_J1939_PRIO: c_int = 3; -pub const SCM_J1939_ERRQUEUE: c_int = 4; - -pub const J1939_NLA_PAD: c_int = 0; -pub const J1939_NLA_BYTES_ACKED: c_int = 1; -pub const J1939_NLA_TOTAL_SIZE: c_int = 2; -pub const J1939_NLA_PGN: c_int = 3; -pub const J1939_NLA_SRC_NAME: c_int = 4; -pub const J1939_NLA_DEST_NAME: c_int = 5; -pub const J1939_NLA_SRC_ADDR: c_int = 6; -pub const J1939_NLA_DEST_ADDR: c_int = 7; - -pub const J1939_EE_INFO_NONE: c_int = 0; -pub const J1939_EE_INFO_TX_ABORT: c_int = 1; -pub const J1939_EE_INFO_RX_RTS: c_int = 2; -pub const J1939_EE_INFO_RX_DPO: c_int = 3; -pub const J1939_EE_INFO_RX_ABORT: c_int = 4; - -pub const J1939_FILTER_MAX: c_int = 512; - // linux/sctp.h pub const SCTP_FUTURE_ASSOC: c_int = 0; pub const SCTP_CURRENT_ASSOC: c_int = 1; @@ -5868,90 +5766,10 @@ pub const SCHED_FLAG_ALL: c_int = SCHED_FLAG_RESET_ON_FORK pub const EPIOCSPARAMS: Ioctl = 0x40088a01; pub const EPIOCGPARAMS: Ioctl = 0x80088a02; -const _IOC_NRBITS: u32 = 8; -const _IOC_TYPEBITS: u32 = 8; - // siginfo.h pub const SI_DETHREAD: c_int = -7; pub const TRAP_PERF: c_int = 6; -// https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code -cfg_if! { - if #[cfg(any( - any(target_arch = "powerpc", target_arch = "powerpc64"), - any(target_arch = "sparc", target_arch = "sparc64"), - any(target_arch = "mips", target_arch = "mips64"), - ))] { - // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/powerpc/include/uapi/asm/ioctl.h - // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/sparc/include/uapi/asm/ioctl.h - // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/mips/include/uapi/asm/ioctl.h - - const _IOC_SIZEBITS: u32 = 13; - const _IOC_DIRBITS: u32 = 3; - - const _IOC_NONE: u32 = 1; - const _IOC_READ: u32 = 2; - const _IOC_WRITE: u32 = 4; - } else { - // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/include/uapi/asm-generic/ioctl.h - - const _IOC_SIZEBITS: u32 = 14; - const _IOC_DIRBITS: u32 = 2; - - const _IOC_NONE: u32 = 0; - const _IOC_WRITE: u32 = 1; - const _IOC_READ: u32 = 2; - } -} - -const _IOC_NRMASK: u32 = (1 << _IOC_NRBITS) - 1; -const _IOC_TYPEMASK: u32 = (1 << _IOC_TYPEBITS) - 1; -const _IOC_SIZEMASK: u32 = (1 << _IOC_SIZEBITS) - 1; -const _IOC_DIRMASK: u32 = (1 << _IOC_DIRBITS) - 1; - -const _IOC_NRSHIFT: u32 = 0; -const _IOC_TYPESHIFT: u32 = _IOC_NRSHIFT + _IOC_NRBITS; -const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT + _IOC_TYPEBITS; -const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT + _IOC_SIZEBITS; - -// adapted from https://github.com/torvalds/linux/blob/8a696a29c6905594e4abf78eaafcb62165ac61f1/rust/kernel/ioctl.rs - -/// Build an ioctl number, analogous to the C macro of the same name. -const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> u32 { - // FIXME(ctest) the `garando_syntax` crate (used by ctest2 in the CI test suite) - // cannot currently parse these `debug_assert!`s - // - // debug_assert!(dir <= _IOC_DIRMASK); - // debug_assert!(ty <= _IOC_TYPEMASK); - // debug_assert!(nr <= _IOC_NRMASK); - // debug_assert!(size <= (_IOC_SIZEMASK as usize)); - - (dir << _IOC_DIRSHIFT) - | (ty << _IOC_TYPESHIFT) - | (nr << _IOC_NRSHIFT) - | ((size as u32) << _IOC_SIZESHIFT) -} - -/// Build an ioctl number for an argumentless ioctl. -pub(crate) const fn _IO(ty: u32, nr: u32) -> u32 { - _IOC(_IOC_NONE, ty, nr, 0) -} - -/// Build an ioctl number for an read-only ioctl. -pub(crate) const fn _IOR<T>(ty: u32, nr: u32) -> u32 { - _IOC(_IOC_READ, ty, nr, size_of::<T>()) -} - -/// Build an ioctl number for an write-only ioctl. -pub(crate) const fn _IOW<T>(ty: u32, nr: u32) -> u32 { - _IOC(_IOC_WRITE, ty, nr, size_of::<T>()) -} - -/// Build an ioctl number for a read-write ioctl. -pub(crate) const fn _IOWR<T>(ty: u32, nr: u32) -> u32 { - _IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::<T>()) -} - f! { pub fn NLA_ALIGN(len: c_int) -> c_int { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); @@ -5959,55 +5777,53 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::<cmsghdr>() { - return 0 as *mut cmsghdr; - }; + return core::ptr::null_mut::<cmsghdr>(); + } let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.wrapping_offset(1)) as usize > max || next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { - next as *mut cmsghdr + next } } pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = mem::zeroed(); - let size_in_bits = 8 * mem::size_of_val(&_dummy.bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.bits.iter_mut() { + for slot in &mut cpuset.bits { *slot = 0; } } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = mem::size_of_val(&cpuset.bits[0]); - for i in cpuset.bits[..(size / size_of_mask)].iter() { + let size_of_mask = size_of_val(&cpuset.bits[0]); + for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int @@ -6022,7 +5838,7 @@ f! { } pub fn SCTP_PR_INDEX(policy: c_int) -> c_int { - policy >> 4 - 1 + policy >> (4 - 1) } pub fn SCTP_PR_POLICY(policy: c_int) -> c_int { @@ -6032,7 +5848,6 @@ f! { pub fn SCTP_PR_SET_POLICY(flags: &mut c_int, policy: c_int) -> () { *flags &= !SCTP_PR_SCTP_MASK; *flags |= policy; - () } pub fn IPTOS_TOS(tos: u8) -> u8 { @@ -6063,6 +5878,26 @@ f! { (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1) } + pub fn BPF_CLASS(code: __u32) -> __u32 { + code & 0x07 + } + + pub fn BPF_SIZE(code: __u32) -> __u32 { + code & 0x18 + } + + pub fn BPF_MODE(code: __u32) -> __u32 { + code & 0xe0 + } + + pub fn BPF_OP(code: __u32) -> __u32 { + code & 0xf0 + } + + pub fn BPF_SRC(code: __u32) -> __u32 { + code & 0x08 + } + pub fn BPF_RVAL(code: __u32) -> __u32 { code & 0x18 } @@ -6073,20 +5908,15 @@ f! { pub fn BPF_STMT(code: __u16, k: __u32) -> sock_filter { sock_filter { - code: code, + code, jt: 0, jf: 0, - k: k, + k, } } pub fn BPF_JUMP(code: __u16, k: __u32, jt: __u8, jf: __u8) -> sock_filter { - sock_filter { - code: code, - jt: jt, - jf: jf, - k: k, - } + sock_filter { code, jt, jf, k } } pub fn ELF32_R_SYM(val: Elf32_Word) -> Elf32_Word { @@ -6098,7 +5928,7 @@ f! { } pub fn ELF32_R_INFO(sym: Elf32_Word, t: Elf32_Word) -> Elf32_Word { - sym << 8 + t & 0xff + sym << (8 + t) & 0xff } pub fn ELF64_R_SYM(val: Elf64_Xword) -> Elf64_Xword { @@ -6110,12 +5940,12 @@ f! { } pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword { - sym << 32 + t + sym << (32 + t) } } safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; @@ -6126,29 +5956,29 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { let mut major = 0; major |= (dev & 0x00000000000fff00) >> 8; major |= (dev & 0xfffff00000000000) >> 32; major as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { let mut minor = 0; minor |= (dev & 0x00000000000000ff) >> 0; minor |= (dev & 0x00000ffffff00000) >> 12; minor as c_uint } - pub {const} fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool { + pub const fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_TTL } - pub {const} fn SCTP_PR_RTX_ENABLED(policy: c_int) -> bool { + pub const fn SCTP_PR_RTX_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_RTX } - pub {const} fn SCTP_PR_PRIO_ENABLED(policy: c_int) -> bool { + pub const fn SCTP_PR_PRIO_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_PRIO } } @@ -6168,17 +5998,24 @@ cfg_if! { cfg_if! { if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] { extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_read64")] pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_write64")] pub fn aio_write(aiocbp: *mut aiocb) -> c_int; pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_error64")] pub fn aio_error(aiocbp: *const aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_return64")] pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; + #[cfg_attr(gnu_time_bits64, link_name = "__aio_suspend_time64")] pub fn aio_suspend( aiocb_list: *const *const aiocb, nitems: c_int, timeout: *const crate::timespec, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_cancel64")] pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lio_listio64")] pub fn lio_listio( mode: c_int, aiocb_list: *const *mut aiocb, @@ -6192,12 +6029,14 @@ cfg_if! { cfg_if! { if #[cfg(not(target_env = "uclibc"))] { extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64")] pub fn pwritev( fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64")] pub fn preadv( fd: c_int, iov: *const crate::iovec, @@ -6230,6 +6069,7 @@ cfg_if! { riovcnt: c_ulong, flags: c_ulong, ) -> isize; + #[cfg_attr(gnu_time_bits64, link_name = "__futimes64")] pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; } } @@ -6259,6 +6099,7 @@ cfg_if! { msg_len: size_t, msg_prio: *mut c_uint, ) -> ssize_t; + #[cfg_attr(gnu_time_bits64, link_name = "__mq_timedreceive_time64")] pub fn mq_timedreceive( mqd: crate::mqd_t, msg_ptr: *mut c_char, @@ -6272,6 +6113,7 @@ cfg_if! { msg_len: size_t, msg_prio: c_uint, ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__mq_timedsend_time64")] pub fn mq_timedsend( mqd: crate::mqd_t, msg_ptr: *const c_char, @@ -6322,6 +6164,7 @@ extern "C" { pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; pub fn lcong48(p: *mut c_ushort); + #[cfg_attr(gnu_time_bits64, link_name = "__lutimes64")] pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; pub fn setpwent(); @@ -6343,11 +6186,14 @@ extern "C" { pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmdt(shmaddr: *const c_void) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__shmctl64")] pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t; pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int; pub fn semop(semid: c_int, sops: *mut crate::sembuf, nsops: size_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__semctl64")] pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__msgctl64")] pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int; pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; pub fn msgrcv( @@ -6362,7 +6208,9 @@ extern "C" { pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; pub fn __errno_location() -> *mut c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fallocate64")] pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fallocate64")] pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t; pub fn getxattr( @@ -6412,7 +6260,9 @@ extern "C" { pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int; pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__timerfd_gettime64")] pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__timerfd_settime64")] pub fn timerfd_settime( fd: c_int, flags: c_int, @@ -6428,6 +6278,7 @@ extern "C" { sigmask: *const crate::sigset_t, ) -> c_int; pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__sigtimedwait64")] pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -6457,7 +6308,7 @@ extern "C" { pub fn setfsuid(uid: crate::uid_t) -> c_int; // Not available now on Android - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; @@ -6469,12 +6320,22 @@ extern "C" { ... ) -> *mut c_void; + #[cfg_attr(gnu_time_bits64, link_name = "__glob64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "glob64" + )] pub fn glob( pattern: *const c_char, flags: c_int, errfunc: Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>, pglob: *mut crate::glob_t, ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__globfree64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "globfree64" + )] pub fn globfree(pglob: *mut crate::glob_t); pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; @@ -6500,6 +6361,7 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemps64")] pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; @@ -6536,6 +6398,7 @@ extern "C" { pub fn umount(target: *const c_char) -> c_int; pub fn sched_get_priority_max(policy: c_int) -> c_int; pub fn tee(fd_in: c_int, fd_out: c_int, len: size_t, flags: c_uint) -> ssize_t; + #[cfg_attr(gnu_time_bits64, link_name = "__settimeofday64")] pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; pub fn splice( fd_in: c_int, @@ -6549,7 +6412,9 @@ extern "C" { pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__sched_rr_get_interval64")] pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__sem_timedwait64")] pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; @@ -6565,8 +6430,10 @@ extern "C" { data: *const c_void, ) -> c_int; pub fn personality(persona: c_ulong) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__prctl_time64")] pub fn prctl(option: c_int, ...) -> c_int; pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__ppoll64")] pub fn ppoll( fds: *mut crate::pollfd, nfds: nfds_t, @@ -6579,6 +6446,7 @@ extern "C" { ) -> c_int; pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] pub fn pthread_mutex_timedlock( lock: *mut pthread_mutex_t, abstime: *const crate::timespec, @@ -6613,6 +6481,7 @@ extern "C" { ... ) -> c_int; pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__clock_nanosleep_time64")] pub fn clock_nanosleep( clk_id: crate::clockid_t, flags: c_int, @@ -6664,6 +6533,7 @@ extern "C" { policy: c_int, param: *const crate::sched_param, ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "sendfile64")] pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; pub fn getgrgid_r( @@ -6808,7 +6678,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, @@ -6869,7 +6739,9 @@ extern "C" { ) -> c_int; pub fn timer_delete(timerid: crate::timer_t) -> c_int; pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__timer_gettime64")] pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__timer_settime64")] pub fn timer_settime( timerid: crate::timer_t, flags: c_int, @@ -6910,8 +6782,6 @@ extern "C" { ) -> ssize_t; pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int; - - pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int; } // LFS64 extensions diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -55,6 +55,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -125,7 +133,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -135,7 +142,6 @@ s_no_extra_traits! { pub uc_regspace: [c_ulonglong; 64], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: (i64, i64), @@ -154,17 +160,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_link) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_sigmask", &self.uc_sigmask) - .finish() - } - } impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); @@ -795,7 +790,3 @@ pub const SYS_process_mrelease: c_long = 448; pub const SYS_futex_waitv: c_long = 449; pub const SYS_set_mempolicy_home_node: c_long = 450; pub const SYS_mseal: c_long = 462; - -extern "C" { - pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; -} diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -34,6 +34,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release" + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -57,6 +57,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -139,7 +147,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f32; 4], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -4,6 +4,17 @@ use crate::prelude::*; pub type wchar_t = i32; s! { + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_line: crate::cc_t, + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -53,6 +64,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -745,7 +764,3 @@ pub const SYS_process_mrelease: c_long = 448; pub const SYS_futex_waitv: c_long = 449; pub const SYS_set_mempolicy_home_node: c_long = 450; pub const SYS_mseal: c_long = 462; - -extern "C" { - pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; -} diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -102,7 +102,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: (i64, f64), @@ -111,7 +110,6 @@ s_no_extra_traits! { //pub const RLIM_INFINITY: crate::rlim_t = !0; pub const VEOF: usize = 4; -pub const RTLD_DEEPBIND: c_int = 0x8; //pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5; //pub const RLIMIT_AS: crate::__rlimit_resource_t = 9; //pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8; @@ -125,7 +123,6 @@ pub const O_NONBLOCK: c_int = 2048; pub const O_SYNC: c_int = 1052672; pub const O_RSYNC: c_int = 1052672; pub const O_DSYNC: c_int = 4096; -pub const O_FSYNC: c_int = 1052672; pub const MAP_GROWSDOWN: c_int = 256; pub const EDEADLK: c_int = 35; pub const ENAMETOOLONG: c_int = 36; @@ -209,7 +206,7 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 8; +pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 4; pub const SA_NOCLDWAIT: c_int = 2; pub const SIGTTIN: c_int = 21; @@ -248,6 +245,7 @@ pub const O_DIRECT: c_int = 16384; pub const O_DIRECTORY: c_int = 65536; pub const O_LARGEFILE: c_int = 0o0100000; pub const O_NOFOLLOW: c_int = 131072; +pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_HUGETLB: c_int = 262144; pub const MAP_LOCKED: c_int = 8192; pub const MAP_NORESERVE: c_int = 16384; @@ -346,7 +344,7 @@ pub const EXTPROC: crate::tcflag_t = 65536; pub const SYS_read: c_long = 63; pub const SYS_write: c_long = 64; pub const SYS_close: c_long = 57; -pub const SYS_fstat: c_long = 80; +// RISC-V don't have SYS_fstat, use statx instead. pub const SYS_lseek: c_long = 62; pub const SYS_mmap: c_long = 222; pub const SYS_mprotect: c_long = 226; @@ -369,7 +367,6 @@ pub const SYS_shmget: c_long = 194; pub const SYS_shmat: c_long = 196; pub const SYS_shmctl: c_long = 195; pub const SYS_dup: c_long = 23; -pub const SYS_nanosleep: c_long = 101; pub const SYS_getitimer: c_long = 102; pub const SYS_setitimer: c_long = 103; pub const SYS_getpid: c_long = 172; @@ -392,7 +389,7 @@ pub const SYS_getsockopt: c_long = 209; pub const SYS_clone: c_long = 220; pub const SYS_execve: c_long = 221; pub const SYS_exit: c_long = 93; -pub const SYS_wait4: c_long = 260; +// RISC-V don't have wait4, use waitid instead. pub const SYS_kill: c_long = 129; pub const SYS_uname: c_long = 160; pub const SYS_semget: c_long = 190; @@ -415,8 +412,8 @@ pub const SYS_fchdir: c_long = 50; pub const SYS_fchmod: c_long = 52; pub const SYS_fchown: c_long = 55; pub const SYS_umask: c_long = 166; -pub const SYS_gettimeofday: c_long = 169; -pub const SYS_getrlimit: c_long = 163; +// RISC-V don't have gettimeofday, use clock_gettime64 instead. +// RISC-V don't have getrlimit, use prlimit64 instead. pub const SYS_getrusage: c_long = 165; pub const SYS_sysinfo: c_long = 179; pub const SYS_times: c_long = 153; @@ -446,7 +443,7 @@ pub const SYS_getsid: c_long = 156; pub const SYS_capget: c_long = 90; pub const SYS_capset: c_long = 91; pub const SYS_rt_sigpending: c_long = 136; -pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigtimedwait_time64: c_long = 421; pub const SYS_rt_sigqueueinfo: c_long = 138; pub const SYS_rt_sigsuspend: c_long = 133; pub const SYS_sigaltstack: c_long = 132; @@ -461,7 +458,7 @@ pub const SYS_sched_setscheduler: c_long = 119; pub const SYS_sched_getscheduler: c_long = 120; pub const SYS_sched_get_priority_max: c_long = 125; pub const SYS_sched_get_priority_min: c_long = 126; -pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_sched_rr_get_interval_time64: c_long = 423; pub const SYS_mlock: c_long = 228; pub const SYS_munlock: c_long = 229; pub const SYS_mlockall: c_long = 230; @@ -469,12 +466,11 @@ pub const SYS_munlockall: c_long = 231; pub const SYS_vhangup: c_long = 58; pub const SYS_pivot_root: c_long = 41; pub const SYS_prctl: c_long = 167; -pub const SYS_adjtimex: c_long = 171; -pub const SYS_setrlimit: c_long = 164; +// RISC-V don't have setrlimit, use prlimit64 instead. pub const SYS_chroot: c_long = 51; pub const SYS_sync: c_long = 81; pub const SYS_acct: c_long = 89; -pub const SYS_settimeofday: c_long = 170; +// RISC-V don't have settimeofday, use clock_settime64 instead. pub const SYS_mount: c_long = 40; pub const SYS_umount2: c_long = 39; pub const SYS_swapon: c_long = 224; @@ -501,12 +497,12 @@ pub const SYS_removexattr: c_long = 14; pub const SYS_lremovexattr: c_long = 15; pub const SYS_fremovexattr: c_long = 16; pub const SYS_tkill: c_long = 130; -pub const SYS_futex: c_long = 98; +pub const SYS_futex_time64: c_long = 422; pub const SYS_sched_setaffinity: c_long = 122; pub const SYS_sched_getaffinity: c_long = 123; pub const SYS_io_setup: c_long = 0; pub const SYS_io_destroy: c_long = 1; -pub const SYS_io_getevents: c_long = 4; +pub const SYS_io_pgetevents_time64: c_long = 416; pub const SYS_io_submit: c_long = 2; pub const SYS_io_cancel: c_long = 3; pub const SYS_lookup_dcookie: c_long = 18; @@ -514,17 +510,17 @@ pub const SYS_remap_file_pages: c_long = 234; pub const SYS_getdents64: c_long = 61; pub const SYS_set_tid_address: c_long = 96; pub const SYS_restart_syscall: c_long = 128; -pub const SYS_semtimedop: c_long = 192; +pub const SYS_semtimedop_time64: c_long = 420; pub const SYS_fadvise64: c_long = 223; pub const SYS_timer_create: c_long = 107; -pub const SYS_timer_settime: c_long = 110; -pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_settime64: c_long = 409; +pub const SYS_timer_gettime64: c_long = 408; pub const SYS_timer_getoverrun: c_long = 109; pub const SYS_timer_delete: c_long = 111; -pub const SYS_clock_settime: c_long = 112; -pub const SYS_clock_gettime: c_long = 113; -pub const SYS_clock_getres: c_long = 114; -pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_clock_settime64: c_long = 404; +pub const SYS_clock_gettime64: c_long = 403; +pub const SYS_clock_getres_time64: c_long = 406; +pub const SYS_clock_nanosleep_time64: c_long = 407; pub const SYS_exit_group: c_long = 94; pub const SYS_epoll_ctl: c_long = 21; pub const SYS_tgkill: c_long = 131; @@ -533,8 +529,8 @@ pub const SYS_set_mempolicy: c_long = 237; pub const SYS_get_mempolicy: c_long = 236; pub const SYS_mq_open: c_long = 180; pub const SYS_mq_unlink: c_long = 181; -pub const SYS_mq_timedsend: c_long = 182; -pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_timedsend_time64: c_long = 418; +pub const SYS_mq_timedreceive_time64: c_long = 419; pub const SYS_mq_notify: c_long = 184; pub const SYS_mq_getsetattr: c_long = 185; pub const SYS_kexec_load: c_long = 104; @@ -551,15 +547,15 @@ pub const SYS_openat: c_long = 56; pub const SYS_mkdirat: c_long = 34; pub const SYS_mknodat: c_long = 33; pub const SYS_fchownat: c_long = 54; -pub const SYS_newfstatat: c_long = 79; +// RISC-V don't have newfstatat, use statx instead. pub const SYS_unlinkat: c_long = 35; pub const SYS_linkat: c_long = 37; pub const SYS_symlinkat: c_long = 36; pub const SYS_readlinkat: c_long = 78; pub const SYS_fchmodat: c_long = 53; pub const SYS_faccessat: c_long = 48; -pub const SYS_pselect6: c_long = 72; -pub const SYS_ppoll: c_long = 73; +pub const SYS_pselect6_time64: c_long = 413; +pub const SYS_ppoll_time64: c_long = 414; pub const SYS_unshare: c_long = 97; pub const SYS_set_robust_list: c_long = 99; pub const SYS_get_robust_list: c_long = 100; @@ -568,12 +564,12 @@ pub const SYS_tee: c_long = 77; pub const SYS_sync_file_range: c_long = 84; pub const SYS_vmsplice: c_long = 75; pub const SYS_move_pages: c_long = 239; -pub const SYS_utimensat: c_long = 88; +pub const SYS_utimensat_time64: c_long = 412; pub const SYS_epoll_pwait: c_long = 22; pub const SYS_timerfd_create: c_long = 85; pub const SYS_fallocate: c_long = 47; -pub const SYS_timerfd_settime: c_long = 86; -pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_timerfd_settime64: c_long = 411; +pub const SYS_timerfd_gettime64: c_long = 410; pub const SYS_accept4: c_long = 242; pub const SYS_signalfd4: c_long = 74; pub const SYS_eventfd2: c_long = 19; @@ -585,13 +581,13 @@ pub const SYS_preadv: c_long = 69; pub const SYS_pwritev: c_long = 70; pub const SYS_rt_tgsigqueueinfo: c_long = 240; pub const SYS_perf_event_open: c_long = 241; -pub const SYS_recvmmsg: c_long = 243; +pub const SYS_recvmmsg_time64: c_long = 417; pub const SYS_fanotify_init: c_long = 262; pub const SYS_fanotify_mark: c_long = 263; pub const SYS_prlimit64: c_long = 261; pub const SYS_name_to_handle_at: c_long = 264; pub const SYS_open_by_handle_at: c_long = 265; -pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_clock_adjtime64: c_long = 405; pub const SYS_syncfs: c_long = 267; pub const SYS_sendmmsg: c_long = 269; pub const SYS_setns: c_long = 268; @@ -637,3 +633,23 @@ pub const SYS_faccessat2: c_long = 439; pub const SYS_process_madvise: c_long = 440; pub const SYS_epoll_pwait2: c_long = 441; pub const SYS_mount_setattr: c_long = 442; + +// Plain syscalls aliased to their time64 variants +pub const SYS_clock_gettime: c_long = SYS_clock_gettime64; +pub const SYS_clock_settime: c_long = SYS_clock_settime64; +pub const SYS_clock_adjtime: c_long = SYS_clock_adjtime64; +pub const SYS_clock_getres: c_long = SYS_clock_getres_time64; +pub const SYS_clock_nanosleep: c_long = SYS_clock_nanosleep_time64; +pub const SYS_timer_gettime: c_long = SYS_timer_gettime64; +pub const SYS_timer_settime: c_long = SYS_timer_settime64; +pub const SYS_timerfd_gettime: c_long = SYS_timerfd_gettime64; +pub const SYS_timerfd_settime: c_long = SYS_timerfd_settime64; +pub const SYS_utimensat: c_long = SYS_utimensat_time64; +pub const SYS_pselect6: c_long = SYS_pselect6_time64; +pub const SYS_ppoll: c_long = SYS_ppoll_time64; +pub const SYS_recvmmsg: c_long = SYS_recvmmsg_time64; +pub const SYS_mq_timedsend: c_long = SYS_mq_timedsend_time64; +pub const SYS_mq_timedreceive: c_long = SYS_mq_timedreceive_time64; +pub const SYS_rt_sigtimedwait: c_long = SYS_rt_sigtimedwait_time64; +pub const SYS_futex: c_long = SYS_futex_time64; +pub const SYS_sched_rr_get_interval: c_long = SYS_sched_rr_get_interval_time64; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -59,6 +59,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -130,7 +138,6 @@ s_no_extra_traits! { __private: [u8; 112], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], @@ -159,26 +166,6 @@ cfg_if! { impl Eq for user_fpxregs_struct {} - impl fmt::Debug for user_fpxregs_struct { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for user_fpxregs_struct { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cwd.hash(state); @@ -214,19 +201,6 @@ cfg_if! { impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); @@ -913,7 +887,3 @@ pub const CS: c_int = 13; pub const EFL: c_int = 14; pub const UESP: c_int = 15; pub const SS: c_int = 16; - -extern "C" { - pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; -} diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -60,15 +60,32 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: crate::mode_t, + + #[cfg(musl_v1_2_3)] + pub __seq: c_int, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "The type of this field has changed from c_ushort to c_int, + we'll follow that change in the future release." + )] pub __seq: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __unused1: c_long, + __unused2: c_long, } pub struct ucontext_t { @@ -112,7 +129,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 8], diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -7,8 +7,6 @@ pub type wchar_t = c_int; pub type nlink_t = c_uint; pub type blksize_t = c_int; -pub type fsblkcnt64_t = c_ulong; -pub type fsfilcnt64_t = c_ulong; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; @@ -65,7 +63,6 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_int, - __pad2: c_ushort, __unused1: c_ulong, __unused2: c_ulong, } @@ -117,7 +114,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], @@ -533,6 +529,8 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; +pub const MADV_SOFT_OFFLINE: c_int = 101; + pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000004; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/mips64.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -4,7 +4,7 @@ use crate::prelude::*; pub type wchar_t = i32; pub type __u64 = c_ulong; pub type __s64 = c_long; -pub type nlink_t = u64; +pub type nlink_t = c_uint; pub type blksize_t = i64; s! { @@ -56,7 +56,21 @@ s! { __pad5: [c_int; 14], } + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -68,6 +82,36 @@ s! { __unused1: c_ulong, __unused2: c_ulong, } + + pub struct statfs { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } + + pub struct statfs64 { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } } pub const SIGSTKSZ: size_t = 8192; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type regoff_t = c_long; s! { + // MIPS implementation is special, see the subfolder. + #[cfg(not(target_arch = "mips64"))] pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -17,6 +19,8 @@ s! { __val: [c_ulong; 16], } + // PowerPC implementation is special, see the subfolder. + #[cfg(not(target_arch = "powerpc64"))] pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, @@ -81,10 +85,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -extern "C" { - pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; -} - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -8,6 +8,17 @@ pub type nlink_t = u64; pub type blksize_t = c_long; s! { + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_line: crate::cc_t, + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -50,7 +61,27 @@ s! { __reserved: [c_long; 3], } + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __unused: [c_ulong; 2], + } + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -64,6 +95,11 @@ s! { } pub const MADV_SOFT_OFFLINE: c_int = 101; +#[deprecated( + since = "0.2.175", + note = "Linux does not define MAP_32BIT on any architectures \ + other than x86 and x86_64, this constant will be removed in the future" +)] pub const MAP_32BIT: c_int = 0x0040; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x20000; @@ -167,8 +203,8 @@ pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; pub const MAP_EXECUTABLE: c_int = 0x01000; -pub const MAP_LOCKED: c_int = 0x02000; -pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_LOCKED: c_int = 0x80; +pub const MAP_NORESERVE: c_int = 0x40; pub const MAP_POPULATE: c_int = 0x08000; pub const MAP_NONBLOCK: c_int = 0x010000; pub const MAP_STACK: c_int = 0x020000; @@ -631,8 +667,8 @@ pub const SYS_process_mrelease: c_long = 448; pub const SYS_futex_waitv: c_long = 449; pub const SYS_set_mempolicy_home_node: c_long = 450; -pub const EDEADLK: c_int = 58; -pub const EDEADLOCK: c_int = EDEADLK; +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = 58; pub const EXTPROC: crate::tcflag_t = 0x10000000; pub const VEOL: usize = 6; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -86,7 +86,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub __uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -95,7 +94,6 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct mcontext_t { pub __gregs: [c_ulong; 32], @@ -108,19 +106,16 @@ s_no_extra_traits! { pub __q: __riscv_mc_q_ext_state, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_f_ext_state { pub __f: [c_uint; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_d_ext_state { pub __f: [c_ulonglong; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct __riscv_mc_q_ext_state { pub __f: [c_ulonglong; 64], @@ -432,7 +427,7 @@ pub const SYS_landlock_restrict_self: c_long = 446; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; -pub const O_LARGEFILE: c_int = 0; +pub const O_LARGEFILE: c_int = 0o100000; pub const O_NOFOLLOW: c_int = 0x20000; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; @@ -572,6 +567,7 @@ pub const POLLWRBAND: c_short = 0x200; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; +pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/s390x.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -7,9 +7,18 @@ pub type wchar_t = i32; pub type greg_t = u64; pub type __u64 = u64; pub type __s64 = i64; +pub type statfs64 = statfs; s! { pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -60,43 +69,49 @@ s! { pub st_blocks: crate::blkcnt64_t, __unused: [c_long; 3], } + + pub struct statfs { + pub f_type: c_uint, + pub f_bsize: c_uint, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_uint, + pub f_frsize: c_uint, + pub f_flags: c_uint, + pub f_spare: [c_uint; 4], + } } s_no_extra_traits! { - // FIXME(union): This is actually a union. - pub struct fpreg_t { + pub union fpreg_t { pub d: c_double, - // f: c_float, + pub f: c_float, } } cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for fpreg_t { - fn eq(&self, other: &fpreg_t) -> bool { - self.d == other.d + fn eq(&self, _other: &fpreg_t) -> bool { + unimplemented!("traits") } } impl Eq for fpreg_t {} - impl fmt::Debug for fpreg_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpreg_t").field("d", &self.d).finish() - } - } - impl hash::Hash for fpreg_t { - fn hash<H: hash::Hasher>(&self, state: &mut H) { - let d: u64 = unsafe { mem::transmute(self.d) }; - d.hash(state); + fn hash<H: hash::Hasher>(&self, _state: &mut H) { + unimplemented!("traits") } } } } pub const VEOF: usize = 4; -pub const RTLD_DEEPBIND: c_int = 0x8; pub const EUCLEAN: c_int = 117; pub const ENOTNAM: c_int = 118; @@ -132,7 +147,6 @@ pub const O_NOCTTY: c_int = 256; pub const O_SYNC: c_int = 1052672; pub const O_RSYNC: c_int = 1052672; pub const O_DSYNC: c_int = 4096; -pub const O_FSYNC: c_int = 0x101000; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; pub const O_NOFOLLOW: c_int = 0x20000; @@ -715,3 +729,4 @@ pub const SYS_futex_waitv: c_long = 449; pub const SYS_set_mempolicy_home_node: c_long = 450; pub const SYS_cachestat: c_long = 451; pub const SYS_fchmodat2: c_long = 452; +pub const SYS_mseal: c_long = 462; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -53,6 +53,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -433,7 +441,6 @@ pub const SYS_set_mempolicy_home_node: c_long = 450; pub const SYS_fadvise: c_long = SYS_fadvise64; pub const MADV_SOFT_OFFLINE: c_int = 101; -pub const MAP_32BIT: c_int = 0x0040; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -112,6 +112,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -163,7 +171,6 @@ s_no_extra_traits! { __private: [u8; 512], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], @@ -194,23 +201,6 @@ cfg_if! { impl Eq for user_fpregs_struct {} - impl fmt::Debug for user_fpregs_struct { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("xmm_space", &self.xmm_space) - // Ignore padding field - .finish() - } - } - impl hash::Hash for user_fpregs_struct { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.cwd.hash(state); @@ -243,19 +233,6 @@ cfg_if! { impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> 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() - } - } - impl hash::Hash for ucontext_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uc_flags.hash(state); @@ -701,7 +678,7 @@ pub const MAP_32BIT: c_int = 0x0040; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; -pub const O_LARGEFILE: c_int = 0; +pub const O_LARGEFILE: c_int = 0o0100000; pub const O_NOFOLLOW: c_int = 0x20000; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/musl/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/musl/mod.rs @@ -136,12 +136,22 @@ s! { pub aio_offset: off_t, __next: *mut c_void, __prev: *mut c_void, - #[cfg(target_pointer_width = "32")] - __dummy4: [c_char; 24], - #[cfg(target_pointer_width = "64")] - __dummy4: [c_char; 16], + __dummy4: [c_char; 32 - 2 * size_of::<*const ()>()], + } + + #[repr(align(8))] + pub struct fanotify_event_metadata { + pub event_len: c_uint, + pub vers: c_uchar, + pub reserved: c_uchar, + pub metadata_len: c_ushort, + pub mask: c_ulonglong, + pub fd: c_int, + pub pid: c_int, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, @@ -155,10 +165,10 @@ s! { // FIXME(union): C implementation uses unions pub struct siginfo_t { pub si_signo: c_int, - #[cfg(not(target_arch = "mips"))] + #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] pub si_errno: c_int, pub si_code: c_int, - #[cfg(target_arch = "mips")] + #[cfg(any(target_arch = "mips", target_arch = "mips64"))] pub si_errno: c_int, #[doc(hidden)] #[deprecated( @@ -210,6 +220,8 @@ s! { __f_reserved: [c_int; 6], } + // PowerPC implementations are special, see the subfolders + #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, @@ -323,16 +335,11 @@ s! { pub tcpi_probes: u8, pub tcpi_backoff: u8, pub tcpi_options: u8, - /* - * FIXME(musl): enable on all targets once musl headers are more up to date - */ /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. /// Each is 4 bits. - #[cfg(target_arch = "loongarch64")] pub tcpi_snd_rcv_wscale: u8, /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and /// `tcpi_fastopen_client_fail` (2 bits). - #[cfg(target_arch = "loongarch64")] pub tcpi_delivery_fastopen_bitfields: u8, pub tcpi_rto: u32, pub tcpi_ato: u32, @@ -378,15 +385,12 @@ s! { pub tcpi_bytes_retrans: u64, pub tcpi_dsack_dups: u32, pub tcpi_reord_seen: u32, - // FIXME(musl): enable on all targets once CI musl is updated - #[cfg(target_arch = "loongarch64")] pub tcpi_rcv_ooopack: u32, - #[cfg(target_arch = "loongarch64")] pub tcpi_snd_wnd: u32, } - // MIPS implementation is special (see mips arch folders) - #[cfg(not(target_arch = "mips"))] + // MIPS/s390x implementation is special (see arch folders) + #[cfg(not(any(target_arch = "mips", target_arch = "mips64", target_arch = "s390x")))] pub struct statfs { pub f_type: c_ulong, pub f_bsize: c_ulong, @@ -402,8 +406,8 @@ s! { pub f_spare: [c_ulong; 4], } - // MIPS implementation is special (see mips arch folders) - #[cfg(not(target_arch = "mips"))] + // MIPS/s390x implementation is special (see arch folders) + #[cfg(not(any(target_arch = "mips", target_arch = "mips64", target_arch = "s390x")))] pub struct statfs64 { pub f_type: c_ulong, pub f_bsize: c_ulong, @@ -438,13 +442,6 @@ s_no_extra_traits! { pub __reserved: [c_char; 256], } - // FIXME(musl): musl added paddings and adjusted - // layout in 1.2.0 but our CI is still 1.1.24. - // So, I'm leaving some fields as cfg for now. - // ref. https://github.com/bminor/musl/commit/ - // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 - // - // OpenHarmony uses the musl 1.2 layout. pub struct utmpx { pub ut_type: c_short, __ut_pad1: c_short, @@ -455,31 +452,24 @@ s_no_extra_traits! { pub ut_host: [c_char; 256], pub ut_exit: __exit_status, - #[cfg(target_env = "musl")] - #[cfg(not(target_arch = "loongarch64"))] + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "The ABI of this field has changed from c_long to c_int with padding, \ + we'll follow that change in the future release. See #4443 for more info." + )] pub ut_session: c_long, - #[cfg(target_env = "musl")] - #[cfg(target_arch = "loongarch64")] - pub ut_session: c_int, - - #[cfg(target_env = "musl")] - #[cfg(target_arch = "loongarch64")] + #[cfg(musl_v1_2_3)] + #[cfg(not(target_endian = "little"))] __ut_pad2: c_int, - #[cfg(target_env = "ohos")] - #[cfg(target_endian = "little")] + #[cfg(musl_v1_2_3)] pub ut_session: c_int, - #[cfg(target_env = "ohos")] - #[cfg(target_endian = "little")] - __ut_pad2: c_int, - #[cfg(target_env = "ohos")] - #[cfg(not(target_endian = "little"))] + #[cfg(musl_v1_2_3)] + #[cfg(target_endian = "little")] __ut_pad2: c_int, - #[cfg(target_env = "ohos")] - #[cfg(not(target_endian = "little"))] - pub ut_session: c_int, pub ut_tv: crate::timeval, pub ut_addr_v6: [c_uint; 4], @@ -514,27 +504,6 @@ cfg_if! { impl Eq for sysinfo {} - impl fmt::Debug for sysinfo { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("__reserved", &self.__reserved) - .finish() - } - } - impl hash::Hash for sysinfo { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.uptime.hash(state); @@ -555,6 +524,7 @@ cfg_if! { } impl PartialEq for utmpx { + #[allow(deprecated)] fn eq(&self, other: &utmpx) -> bool { self.ut_type == other.ut_type //&& self.__ut_pad1 == other.__ut_pad1 @@ -578,27 +548,8 @@ cfg_if! { impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - .field("ut_type", &self.ut_type) - //.field("__ut_pad1", &self.__ut_pad1) - .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(debug): .field("ut_host", &self.ut_host) - .field("ut_exit", &self.ut_exit) - .field("ut_session", &self.ut_session) - //.field("__ut_pad2", &self.__ut_pad2) - .field("ut_tv", &self.ut_tv) - .field("ut_addr_v6", &self.ut_addr_v6) - .field("__unused", &self.__unused) - .finish() - } - } - impl hash::Hash for utmpx { + #[allow(deprecated)] fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_type.hash(state); //self.__ut_pad1.hash(state); @@ -654,11 +605,14 @@ pub const INIT_PROCESS: c_short = 5; pub const LOGIN_PROCESS: c_short = 6; pub const USER_PROCESS: c_short = 7; pub const DEAD_PROCESS: c_short = 8; -// musl does not define ACCOUNTING +pub const ACCOUNTING: c_short = 9; pub const SFD_CLOEXEC: c_int = 0x080000; +#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] pub const NCCS: usize = 32; +#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] +pub const NCCS: usize = 19; pub const O_TRUNC: c_int = 512; pub const O_NOATIME: c_int = 0o1000000; @@ -729,6 +683,7 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +// FIXME(musl): Value is 1024 for all architectures since 1.2.4 #[cfg(not(target_arch = "loongarch64"))] pub const CPU_SETSIZE: c_int = 128; #[cfg(target_arch = "loongarch64")] @@ -766,12 +721,6 @@ pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; pub const PTRACE_GETSIGMASK: c_uint = 0x420a; pub const PTRACE_SETSIGMASK: c_uint = 0x420b; -pub const RWF_HIPRI: c_int = 0x00000001; -pub const RWF_DSYNC: c_int = 0x00000002; -pub const RWF_SYNC: c_int = 0x00000004; -pub const RWF_NOWAIT: c_int = 0x00000008; -pub const RWF_APPEND: c_int = 0x00000010; - pub const AF_IB: c_int = 27; pub const AF_MPLS: c_int = 28; pub const AF_NFC: c_int = 39; @@ -787,8 +736,6 @@ pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK; -pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; - pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; @@ -886,6 +833,10 @@ pub const _CS_V7_ENV: c_int = 1149; pub const CLONE_NEWTIME: c_int = 0x80; +pub const UT_HOSTSIZE: usize = 256; +pub const UT_LINESIZE: usize = 32; +pub const UT_NAMESIZE: usize = 32; + cfg_if! { if #[cfg(target_arch = "s390x")] { pub const POSIX_FADV_DONTNEED: c_int = 6; @@ -971,6 +922,9 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + // Added in `musl` 1.1.20 + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + // Added in `musl` 1.1.24 pub fn posix_spawn_file_actions_addchdir_np( actions: *mut crate::posix_spawn_file_actions_t, @@ -982,12 +936,41 @@ extern "C" { fd: c_int, ) -> c_int; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn getutxent() -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn setutxent(); + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn endutxent(); + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn utmpxname(file: *const c_char) -> c_int; } // Alias <foo> to <foo>64 to mimic glibc's LFS64 support diff --git a/third_party/rust/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -163,6 +163,8 @@ s! { __val: [c_ulong; 2], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_flags: c_ulong, @@ -475,7 +477,6 @@ pub const POLLWRBAND: c_short = 0x200; pub const POLLWRNORM: c_short = 0x100; pub const PTHREAD_STACK_MIN: size_t = 16384; pub const RTLD_GLOBAL: c_int = 0x00100; -pub const PIDFD_NONBLOCK: c_int = 0x800; // These are typed unsigned to match sigaction pub const SA_NOCLDSTOP: c_ulong = 0x1; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -57,7 +57,6 @@ pub const O_LARGEFILE: c_int = 0x2000; pub const O_NDELAY: c_int = 0x80; pub const SOCK_NONBLOCK: c_int = 128; -pub const PIDFD_NONBLOCK: c_int = 128; pub const EDEADLK: c_int = 45; pub const ENAMETOOLONG: c_int = 78; diff --git a/third_party/rust/libc/src/unix/linux_like/linux/uclibc/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/uclibc/mod.rs @@ -1,3 +1,6 @@ +// FIXME(ulibc): this module has definitions that are redundant with the parent +#![allow(dead_code)] + use crate::off64_t; use crate::prelude::*; @@ -114,6 +117,42 @@ s! { pub struct pthread_condattr_t { size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], } + + pub struct tcp_info { + pub tcpi_state: u8, + pub tcpi_ca_state: u8, + pub tcpi_retransmits: u8, + pub tcpi_probes: u8, + pub tcpi_backoff: u8, + pub tcpi_options: u8, + /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. + /// Each is 4 bits. + pub tcpi_snd_rcv_wscale: u8, + pub tcpi_rto: u32, + pub tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub tcpi_unacked: u32, + pub tcpi_sacked: u32, + pub tcpi_lost: u32, + pub tcpi_retrans: u32, + pub tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub tcpi_pmtu: u32, + pub tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_advmss: u32, + pub tcpi_reordering: u32, + pub tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_total_retrans: u32, + } } impl siginfo_t { diff --git a/third_party/rust/libc/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/third_party/rust/libc/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -26,22 +26,21 @@ s! { /// Bitmap of CPUs. map: l4_umword_t, } -} -#[allow(missing_debug_implementations)] -pub struct pthread_attr_t { - pub __detachstate: c_int, - pub __schedpolicy: c_int, - pub __schedparam: super::__sched_param, - pub __inheritsched: c_int, - pub __scope: c_int, - pub __guardsize: size_t, - pub __stackaddr_set: c_int, - pub __stackaddr: *mut c_void, // better don't use it - pub __stacksize: size_t, - // L4Re specifics - pub affinity: l4_sched_cpu_set_t, - pub create_flags: c_uint, + pub struct pthread_attr_t { + pub __detachstate: c_int, + pub __schedpolicy: c_int, + pub __schedparam: super::__sched_param, + pub __inheritsched: c_int, + pub __scope: c_int, + pub __guardsize: size_t, + pub __stackaddr_set: c_int, + pub __stackaddr: *mut c_void, // better don't use it + pub __stacksize: size_t, + // L4Re specifics + pub affinity: l4_sched_cpu_set_t, + pub create_flags: c_uint, + } } // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but diff --git a/third_party/rust/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/third_party/rust/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -144,6 +144,8 @@ s! { st_pad4: [c_long; 3], } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_handler: crate::sighandler_t, pub sa_flags: c_ulong, @@ -291,7 +293,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct dirent { pub d_ino: crate::ino64_t, pub d_off: off64_t, @@ -342,7 +343,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; -pub const PIDFD_NONBLOCK: c_int = 0o4000; cfg_if! { if #[cfg(target_os = "l4re")] { diff --git a/third_party/rust/libc/src/unix/linux_like/mod.rs b/third_party/rust/libc/src/unix/linux_like/mod.rs @@ -9,7 +9,7 @@ pub type key_t = c_int; pub type id_t = c_uint; missing! { - #[cfg_attr(feature = "extra_traits", derive(Debug))] + #[derive(Debug)] pub enum timezone {} } @@ -208,7 +208,37 @@ s! { } cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(not(target_os = "emscripten"))] { + s! { + pub struct file_clone_range { + pub src_fd: crate::__s64, + pub src_offset: crate::__u64, + pub src_length: crate::__u64, + pub dest_offset: crate::__u64, + } + + // linux/filter.h + pub struct sock_filter { + pub code: __u16, + pub jt: __u8, + pub jf: __u8, + pub k: __u32, + } + + pub struct sock_fprog { + pub len: c_ushort, + pub filter: *mut sock_filter, + } + } + } +} + +cfg_if! { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { s! { pub struct statx { pub stx_mask: crate::__u32, @@ -248,14 +278,7 @@ cfg_if! { s_no_extra_traits! { #[cfg_attr( - any( - all( - target_arch = "x86", - not(target_env = "musl"), - not(target_os = "android") - ), - target_arch = "x86_64" - ), + any(target_arch = "x86_64", all(target_arch = "x86", target_env = "gnu")), repr(packed) )] pub struct epoll_event { @@ -308,16 +331,6 @@ cfg_if! { } } impl Eq for epoll_event {} - impl fmt::Debug for epoll_event { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let events = self.events; - let u64 = self.u64; - f.debug_struct("epoll_event") - .field("events", &events) - .field("u64", &u64) - .finish() - } - } impl hash::Hash for epoll_event { fn hash<H: hash::Hasher>(&self, state: &mut H) { let events = self.events; @@ -338,14 +351,6 @@ cfg_if! { } } impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_family", &self.sun_family) - // FIXME(debug): .field("sun_path", &self.sun_path) - .finish() - } - } impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sun_family.hash(state); @@ -366,16 +371,6 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_family", &self.ss_family) - .field("__ss_align", &self.__ss_align) - // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) - .finish() - } - } - impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_family.hash(state); @@ -419,19 +414,6 @@ cfg_if! { impl Eq for utsname {} - impl fmt::Debug for utsname { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utsname") - // FIXME(debug): .field("sysname", &self.sysname) - // FIXME(debug): .field("nodename", &self.nodename) - // FIXME(debug): .field("release", &self.release) - // FIXME(debug): .field("version", &self.version) - // FIXME(debug): .field("machine", &self.machine) - // FIXME(debug): .field("domainname", &self.domainname) - .finish() - } - } - impl hash::Hash for utsname { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sysname.hash(state); @@ -452,16 +434,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_value", &self.sigev_value) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_notify", &self.sigev_notify) - .field("sigev_notify_thread_id", &self.sigev_notify_thread_id) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_value.hash(state); @@ -545,26 +517,26 @@ pub const O_RDWR: c_int = 2; pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IROTH: crate::mode_t = 0o0004; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; @@ -655,6 +627,7 @@ pub const MS_SYNCHRONOUS: c_ulong = 0x10; pub const MS_REMOUNT: c_ulong = 0x20; pub const MS_MANDLOCK: c_ulong = 0x40; pub const MS_DIRSYNC: c_ulong = 0x80; +pub const MS_NOSYMFOLLOW: c_ulong = 0x100; pub const MS_NOATIME: c_ulong = 0x0400; pub const MS_NODIRATIME: c_ulong = 0x0800; pub const MS_BIND: c_ulong = 0x1000; @@ -1294,7 +1267,11 @@ pub const SI_USER: c_int = 0; pub const SI_KERNEL: c_int = 0x80; pub const SI_QUEUE: c_int = -1; cfg_if! { - if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] { + if #[cfg(not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64" + )))] { pub const SI_TIMER: c_int = -2; pub const SI_MESGQ: c_int = -3; pub const SI_ASYNCIO: c_int = -4; @@ -1483,6 +1460,93 @@ pub const ARPHRD_VOID: u16 = 0xFFFF; pub const ARPHRD_NONE: u16 = 0xFFFE; cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + // linux/if_tun.h + /* TUNSETIFF ifr flags */ + pub const IFF_TUN: c_int = 0x0001; + pub const IFF_TAP: c_int = 0x0002; + pub const IFF_NAPI: c_int = 0x0010; + pub const IFF_NAPI_FRAGS: c_int = 0x0020; + // Used in TUNSETIFF to bring up tun/tap without carrier + pub const IFF_NO_CARRIER: c_int = 0x0040; + pub const IFF_NO_PI: c_int = 0x1000; + // Read queue size + pub const TUN_READQ_SIZE: c_short = 500; + // TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. + pub const TUN_TUN_DEV: c_short = crate::IFF_TUN as c_short; + pub const TUN_TAP_DEV: c_short = crate::IFF_TAP as c_short; + pub const TUN_TYPE_MASK: c_short = 0x000f; + // This flag has no real effect + pub const IFF_ONE_QUEUE: c_int = 0x2000; + pub const IFF_VNET_HDR: c_int = 0x4000; + pub const IFF_TUN_EXCL: c_int = 0x8000; + pub const IFF_MULTI_QUEUE: c_int = 0x0100; + pub const IFF_ATTACH_QUEUE: c_int = 0x0200; + pub const IFF_DETACH_QUEUE: c_int = 0x0400; + // read-only flag + pub const IFF_PERSIST: c_int = 0x0800; + pub const IFF_NOFILTER: c_int = 0x1000; + // Socket options + pub const TUN_TX_TIMESTAMP: c_int = 1; + // Features for GSO (TUNSETOFFLOAD) + pub const TUN_F_CSUM: c_uint = 0x01; + pub const TUN_F_TSO4: c_uint = 0x02; + pub const TUN_F_TSO6: c_uint = 0x04; + pub const TUN_F_TSO_ECN: c_uint = 0x08; + pub const TUN_F_UFO: c_uint = 0x10; + pub const TUN_F_USO4: c_uint = 0x20; + pub const TUN_F_USO6: c_uint = 0x40; + // Protocol info prepended to the packets (when IFF_NO_PI is not set) + pub const TUN_PKT_STRIP: c_int = 0x0001; + // Accept all multicast packets + pub const TUN_FLT_ALLMULTI: c_int = 0x0001; + // Ioctl operation codes + const T_TYPE: u32 = b'T' as u32; + pub const TUNSETNOCSUM: Ioctl = _IOW::<c_int>(T_TYPE, 200); + pub const TUNSETDEBUG: Ioctl = _IOW::<c_int>(T_TYPE, 201); + pub const TUNSETIFF: Ioctl = _IOW::<c_int>(T_TYPE, 202); + pub const TUNSETPERSIST: Ioctl = _IOW::<c_int>(T_TYPE, 203); + pub const TUNSETOWNER: Ioctl = _IOW::<c_int>(T_TYPE, 204); + pub const TUNSETLINK: Ioctl = _IOW::<c_int>(T_TYPE, 205); + pub const TUNSETGROUP: Ioctl = _IOW::<c_int>(T_TYPE, 206); + pub const TUNGETFEATURES: Ioctl = _IOR::<c_int>(T_TYPE, 207); + pub const TUNSETOFFLOAD: Ioctl = _IOW::<c_int>(T_TYPE, 208); + pub const TUNSETTXFILTER: Ioctl = _IOW::<c_int>(T_TYPE, 209); + pub const TUNGETIFF: Ioctl = _IOR::<c_int>(T_TYPE, 210); + pub const TUNGETSNDBUF: Ioctl = _IOR::<c_int>(T_TYPE, 211); + pub const TUNSETSNDBUF: Ioctl = _IOW::<c_int>(T_TYPE, 212); + pub const TUNATTACHFILTER: Ioctl = _IOW::<sock_fprog>(T_TYPE, 213); + pub const TUNDETACHFILTER: Ioctl = _IOW::<sock_fprog>(T_TYPE, 214); + pub const TUNGETVNETHDRSZ: Ioctl = _IOR::<c_int>(T_TYPE, 215); + pub const TUNSETVNETHDRSZ: Ioctl = _IOW::<c_int>(T_TYPE, 216); + pub const TUNSETQUEUE: Ioctl = _IOW::<c_int>(T_TYPE, 217); + pub const TUNSETIFINDEX: Ioctl = _IOW::<c_int>(T_TYPE, 218); + pub const TUNGETFILTER: Ioctl = _IOR::<sock_fprog>(T_TYPE, 219); + pub const TUNSETVNETLE: Ioctl = _IOW::<c_int>(T_TYPE, 220); + pub const TUNGETVNETLE: Ioctl = _IOR::<c_int>(T_TYPE, 221); + pub const TUNSETVNETBE: Ioctl = _IOW::<c_int>(T_TYPE, 222); + pub const TUNGETVNETBE: Ioctl = _IOR::<c_int>(T_TYPE, 223); + pub const TUNSETSTEERINGEBPF: Ioctl = _IOR::<c_int>(T_TYPE, 224); + pub const TUNSETFILTEREBPF: Ioctl = _IOR::<c_int>(T_TYPE, 225); + pub const TUNSETCARRIER: Ioctl = _IOW::<c_int>(T_TYPE, 226); + pub const TUNGETDEVNETNS: Ioctl = _IO(T_TYPE, 227); + + // linux/fs.h + pub const FS_IOC_GETFLAGS: Ioctl = _IOR::<c_long>('f' as u32, 1); + pub const FS_IOC_SETFLAGS: Ioctl = _IOW::<c_long>('f' as u32, 2); + pub const FS_IOC_GETVERSION: Ioctl = _IOR::<c_long>('v' as u32, 1); + pub const FS_IOC_SETVERSION: Ioctl = _IOW::<c_long>('v' as u32, 2); + pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::<c_int>('f' as u32, 1); + pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::<c_int>('f' as u32, 2); + pub const FS_IOC32_GETVERSION: Ioctl = _IOR::<c_int>('v' as u32, 1); + pub const FS_IOC32_SETVERSION: Ioctl = _IOW::<c_int>('v' as u32, 2); + + pub const FICLONE: Ioctl = _IOW::<c_int>(0x94, 9); + pub const FICLONERANGE: Ioctl = _IOW::<crate::file_clone_range>(0x94, 13); + } +} + +cfg_if! { if #[cfg(target_os = "emscripten")] { // Emscripten does not define any `*_SUPER_MAGIC` constants. } else if #[cfg(not(target_arch = "s390x"))] { @@ -1597,7 +1661,11 @@ cfg_if! { } cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; pub const AT_STATX_SYNC_AS_STAT: c_int = 0x0000; pub const AT_STATX_FORCE_SYNC: c_int = 0x2000; @@ -1631,55 +1699,138 @@ cfg_if! { } } -const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1) +// https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + const _IOC_NRBITS: u32 = 8; + const _IOC_TYPEBITS: u32 = 8; + + cfg_if! { + if #[cfg(any( + any(target_arch = "powerpc", target_arch = "powerpc64"), + any(target_arch = "sparc", target_arch = "sparc64"), + any(target_arch = "mips", target_arch = "mips64"), + ))] { + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/powerpc/include/uapi/asm/ioctl.h + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/sparc/include/uapi/asm/ioctl.h + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/mips/include/uapi/asm/ioctl.h + + const _IOC_SIZEBITS: u32 = 13; + const _IOC_DIRBITS: u32 = 3; + + const _IOC_NONE: u32 = 1; + const _IOC_READ: u32 = 2; + const _IOC_WRITE: u32 = 4; + } else { + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/include/uapi/asm-generic/ioctl.h + + const _IOC_SIZEBITS: u32 = 14; + const _IOC_DIRBITS: u32 = 2; + + const _IOC_NONE: u32 = 0; + const _IOC_WRITE: u32 = 1; + const _IOC_READ: u32 = 2; + } + } + const _IOC_NRMASK: u32 = (1 << _IOC_NRBITS) - 1; + const _IOC_TYPEMASK: u32 = (1 << _IOC_TYPEBITS) - 1; + const _IOC_SIZEMASK: u32 = (1 << _IOC_SIZEBITS) - 1; + const _IOC_DIRMASK: u32 = (1 << _IOC_DIRBITS) - 1; + + const _IOC_NRSHIFT: u32 = 0; + const _IOC_TYPESHIFT: u32 = _IOC_NRSHIFT + _IOC_NRBITS; + const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT + _IOC_TYPEBITS; + const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT + _IOC_SIZEBITS; + + // adapted from https://github.com/torvalds/linux/blob/8a696a29c6905594e4abf78eaafcb62165ac61f1/rust/kernel/ioctl.rs + + /// Build an ioctl number, analogous to the C macro of the same name. + const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> Ioctl { + core::debug_assert!(dir <= _IOC_DIRMASK); + core::debug_assert!(ty <= _IOC_TYPEMASK); + core::debug_assert!(nr <= _IOC_NRMASK); + core::debug_assert!(size <= (_IOC_SIZEMASK as usize)); + + ((dir << _IOC_DIRSHIFT) + | (ty << _IOC_TYPESHIFT) + | (nr << _IOC_NRSHIFT) + | ((size as u32) << _IOC_SIZESHIFT)) as Ioctl + } + + /// Build an ioctl number for an argumentless ioctl. + pub const fn _IO(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_NONE, ty, nr, 0) + } + + /// Build an ioctl number for an read-only ioctl. + pub const fn _IOR<T>(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_READ, ty, nr, size_of::<T>()) + } + + /// Build an ioctl number for an write-only ioctl. + pub const fn _IOW<T>(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_WRITE, ty, nr, size_of::<T>()) + } + + /// Build an ioctl number for a read-write ioctl. + pub const fn _IOWR<T>(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::<T>()) + } + + extern "C" { + #[cfg_attr(gnu_time_bits64, link_name = "__ioctl_time64")] + pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int; + } } } +const fn CMSG_ALIGN(len: usize) -> usize { + (len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1) +} + f! { - pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { - (*mhdr).msg_control as *mut cmsghdr + pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut crate::cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::<crate::cmsghdr>() { + (*mhdr).msg_control.cast::<crate::cmsghdr>() } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<crate::cmsghdr>() } } - pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + pub fn CMSG_DATA(cmsg: *const crate::cmsghdr) -> *mut c_uchar { cmsg.offset(1) as *mut c_uchar } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::<cmsghdr>())) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::<crate::cmsghdr>())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::<crate::cmsghdr>()) as c_uint + length } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { + for slot in &mut (*set).fds_bits { *slot = 0; } } @@ -1694,68 +1845,68 @@ safe_f! { unsafe { __libc_current_sigrtmin() } } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0xffff } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0x7f) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } - pub {const} fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { + pub const fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { (ret << 8) | sig } - pub {const} fn W_STOPCODE(sig: c_int) -> c_int { + pub const fn W_STOPCODE(sig: c_int) -> c_int { (sig << 8) | 0x7f } - pub {const} fn QCMD(cmd: c_int, type_: c_int) -> c_int { + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { (cmd << 8) | (type_ & 0x00ff) } - pub {const} fn IPOPT_COPIED(o: u8) -> u8 { + pub const fn IPOPT_COPIED(o: u8) -> u8 { o & IPOPT_COPY } - pub {const} fn IPOPT_CLASS(o: u8) -> u8 { + pub const fn IPOPT_CLASS(o: u8) -> u8 { o & IPOPT_CLASS_MASK } - pub {const} fn IPOPT_NUMBER(o: u8) -> u8 { + pub const fn IPOPT_NUMBER(o: u8) -> u8 { o & IPOPT_NUMBER_MASK } - pub {const} fn IPTOS_ECN(x: u8) -> u8 { + pub const fn IPTOS_ECN(x: u8) -> u8 { x & crate::IPTOS_ECN_MASK } #[allow(ellipsis_inclusive_range_patterns)] - pub {const} fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 { + pub const fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 { ((a << 16) + (b << 8)) + if c > 255 { 255 } else { c } } } @@ -1771,8 +1922,11 @@ extern "C" { pub fn fdatasync(fd: c_int) -> c_int; pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__clock_getres64")] pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__clock_gettime64")] pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__clock_settime64")] pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; @@ -1784,14 +1938,24 @@ extern "C" { stackaddr: *mut *mut c_void, stacksize: *mut size_t, ) -> c_int; + pub fn pthread_attr_setstack( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; pub fn memalign(align: size_t, size: size_t) -> *mut c_void; pub fn setgroups(ngroups: size_t, ptr: *const crate::gid_t) -> c_int; pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "statfs64")] pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatfs64")] pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fadvise64")] pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__futimens64")] pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__utimensat64")] pub fn utimensat( dirfd: c_int, path: *const c_char, @@ -1802,8 +1966,7 @@ extern "C" { pub fn freelocale(loc: crate::locale_t); pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, @@ -1847,6 +2010,7 @@ extern "C" { pub fn vfork() -> crate::pid_t; pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__wait4_time64")] pub fn wait4( pid: crate::pid_t, status: *mut c_int, @@ -1874,7 +2038,9 @@ extern "C" { pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + #[cfg_attr(gnu_time_bits64, link_name = "__sendmsg64")] pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + #[cfg_attr(gnu_time_bits64, link_name = "__recvmsg64")] pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; pub fn uname(buf: *mut crate::utsname) -> c_int; @@ -1895,7 +2061,9 @@ extern "C" { ) -> size_t; pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemp64")] pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemps64")] pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; @@ -1914,7 +2082,9 @@ cfg_if! { pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] pub fn fstatat64( dirfd: c_int, pathname: *const c_char, @@ -1923,6 +2093,7 @@ cfg_if! { ) -> c_int; pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; + #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn mmap64( addr: *mut c_void, @@ -1953,6 +2124,7 @@ cfg_if! { entry: *mut crate::dirent64, result: *mut *mut crate::dirent64, ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; } @@ -2006,7 +2178,11 @@ cfg_if! { // The statx syscall, available on some libcs. cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { extern "C" { pub fn statx( dirfd: c_int, diff --git a/third_party/rust/libc/src/unix/mod.rs b/third_party/rust/libc/src/unix/mod.rs @@ -38,7 +38,7 @@ cfg_if! { } missing! { - #[cfg_attr(feature = "extra_traits", derive(Debug))] + #[derive(Debug)] pub enum DIR {} } pub type locale_t = *mut c_void; @@ -56,14 +56,19 @@ s! { pub modtime: time_t, } - // FIXME(time): Needs updates at least for glibc _TIME_BITS=64 pub struct timeval { pub tv_sec: time_t, + #[cfg(not(gnu_time_bits64))] pub tv_usec: suseconds_t, + // For 64 bit time on 32 bit linux glibc, suseconds_t is still + // a 32 bit type. Use __suseconds64_t instead + #[cfg(gnu_time_bits64)] + pub tv_usec: __suseconds64_t, } // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 + #[cfg(not(target_env = "gnu"))] pub struct timespec { pub tv_sec: time_t, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] @@ -220,7 +225,7 @@ pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; cfg_if! { - if #[cfg(not(target_os = "nto"))] { + if #[cfg(all(not(target_os = "nto"), not(target_os = "aix")))] { pub const DT_UNKNOWN: u8 = 0; pub const DT_FIFO: u8 = 1; pub const DT_CHR: u8 = 2; @@ -245,9 +250,9 @@ cfg_if! { } pub const SIGIOT: c_int = 6; -pub const S_ISUID: crate::mode_t = 0o4000; -pub const S_ISGID: crate::mode_t = 0o2000; -pub const S_ISVTX: crate::mode_t = 0o1000; +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; cfg_if! { if #[cfg(not(any( @@ -334,13 +339,19 @@ pub const ATF_PERM: c_int = 0x04; pub const ATF_PUBL: c_int = 0x08; pub const ATF_USETRAILERS: c_int = 0x10; -pub const FNM_PERIOD: c_int = 1 << 2; +cfg_if! { + if #[cfg(any(target_os = "nto", target_os = "aix"))] { + pub const FNM_PERIOD: c_int = 1 << 1; + } else { + pub const FNM_PERIOD: c_int = 1 << 2; + } +} pub const FNM_NOMATCH: c_int = 1; cfg_if! { if #[cfg(any(target_os = "illumos", target_os = "solaris",))] { pub const FNM_CASEFOLD: c_int = 1 << 3; - } else { + } else if #[cfg(not(target_os = "aix"))] { pub const FNM_CASEFOLD: c_int = 1 << 4; } } @@ -351,11 +362,27 @@ cfg_if! { target_os = "freebsd", target_os = "android", target_os = "openbsd", + target_os = "cygwin", ))] { pub const FNM_PATHNAME: c_int = 1 << 1; - pub const FNM_NOESCAPE: c_int = 1 << 0; } else { pub const FNM_PATHNAME: c_int = 1 << 0; + } +} + +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "freebsd", + target_os = "android", + target_os = "openbsd", + ))] { + pub const FNM_NOESCAPE: c_int = 1 << 0; + } else if #[cfg(target_os = "nto")] { + pub const FNM_NOESCAPE: c_int = 1 << 2; + } else if #[cfg(target_os = "aix")] { + pub const FNM_NOESCAPE: c_int = 1 << 3; + } else { pub const FNM_NOESCAPE: c_int = 1 << 1; } } @@ -538,11 +565,18 @@ cfg_if! { } } +cfg_if! { + if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { + missing! { + #[derive(Debug)] + pub enum fpos_t {} // FIXME(unix): fill this out with a struct + } + } +} + missing! { - #[cfg_attr(feature = "extra_traits", derive(Debug))] + #[derive(Debug)] pub enum FILE {} - #[cfg_attr(feature = "extra_traits", derive(Debug))] - pub enum fpos_t {} // FIXME(unix): fill this out with a struct } extern "C" { @@ -577,17 +611,20 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "fopen$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fopen64")] pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "freopen$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "freopen64")] pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; pub fn fflush(file: *mut FILE) -> c_int; pub fn fclose(file: *mut FILE) -> c_int; pub fn remove(filename: *const c_char) -> c_int; pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "tmpfile64")] pub fn tmpfile() -> *mut FILE; pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; pub fn setbuf(stream: *mut FILE, buf: *mut c_char); @@ -613,8 +650,10 @@ extern "C" { pub fn ftell(stream: *mut FILE) -> c_long; pub fn rewind(stream: *mut FILE); #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fgetpos64")] pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fsetpos64")] pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; @@ -634,7 +673,9 @@ extern "C" { pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; + #[cfg_attr(target_os = "aix", link_name = "vec_calloc")] pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + #[cfg_attr(target_os = "aix", link_name = "vec_malloc")] pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; pub fn free(p: *mut c_void); @@ -746,6 +787,7 @@ extern "C" { link_name = "accept$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")] + #[cfg_attr(target_os = "aix", link_name = "naccept")] pub fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( @@ -753,6 +795,7 @@ extern "C" { link_name = "getpeername$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_getpeername")] + #[cfg_attr(target_os = "aix", link_name = "ngetpeername")] pub fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] @@ -761,9 +804,11 @@ extern "C" { link_name = "getsockname$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockname")] + #[cfg_attr(target_os = "aix", link_name = "ngetsockname")] pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")] + #[cfg_attr(gnu_time_bits64, link_name = "__setsockopt64")] pub fn setsockopt( socket: c_int, level: c_int, @@ -826,6 +871,11 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "fstat@FBSD_1.0" )] + #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "fstat64" + )] pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; @@ -839,6 +889,11 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "stat@FBSD_1.0" )] + #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "stat64" + )] pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; pub fn pclose(stream: *mut crate::FILE) -> c_int; @@ -853,16 +908,23 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "open$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "open64")] pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "creat$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "creat64")] pub fn creat(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "fcntl$UNIX2003" )] + #[cfg_attr(gnu_time_bits64, link_name = "__fcntl_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "__fcntl_time64" + )] pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; #[cfg_attr( @@ -885,6 +947,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "readdir@FBSD_1.0" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64")] pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), @@ -901,12 +964,7 @@ extern "C" { )] pub fn rewinddir(dirp: *mut crate::DIR); - pub fn fchmodat( - dirfd: c_int, - pathname: *const c_char, - mode: crate::mode_t, - flags: c_int, - ) -> c_int; + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; pub fn fchownat( dirfd: c_int, @@ -923,6 +981,11 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "fstatat@FBSD_1.1" )] + #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "fstatat64" + )] pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; pub fn linkat( olddirfd: c_int, @@ -997,6 +1060,7 @@ extern "C" { pub fn isatty(fd: c_int) -> c_int; #[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")] pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lseek64")] pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; pub fn pathconf(path: *const c_char, name: c_int) -> c_long; pub fn pipe(fds: *mut c_int) -> c_int; @@ -1026,6 +1090,7 @@ extern "C" { link_name = "nanosleep$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] + #[cfg_attr(gnu_time_bits64, link_name = "__nanosleep64")] pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int; pub fn tcgetpgrp(fd: c_int) -> pid_t; pub fn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int; @@ -1059,15 +1124,18 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "pread$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "pread64")] pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "pwrite$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwrite64")] pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t; pub fn umask(mask: mode_t) -> mode_t; #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] + #[cfg_attr(gnu_time_bits64, link_name = "__utime64")] pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; #[cfg_attr( @@ -1090,6 +1158,7 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "mmap$UNIX2003" )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "mmap64")] pub fn mmap( addr: *mut c_void, len: size_t, @@ -1116,6 +1185,11 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "lstat@FBSD_1.0" )] + #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "lstat64" + )] pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg_attr( @@ -1138,12 +1212,15 @@ extern "C" { pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "truncate64")] pub fn truncate(path: *const c_char, length: off_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "ftruncate64")] pub fn ftruncate(fd: c_int, length: off_t) -> c_int; pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] + #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")] pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; #[cfg_attr( @@ -1219,6 +1296,7 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "pthread_cond_timedwait$UNIX2003" )] + #[cfg_attr(gnu_time_bits64, link_name = "__pthread_cond_timedwait64")] pub fn pthread_cond_timedwait( cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t, @@ -1275,6 +1353,7 @@ extern "C" { link_name = "__xnet_getsockopt" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")] + #[cfg_attr(gnu_time_bits64, link_name = "__getsockopt64")] pub fn getsockopt( sockfd: c_int, level: c_int, @@ -1285,6 +1364,7 @@ extern "C" { pub fn raise(signum: c_int) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] + #[cfg_attr(gnu_time_bits64, link_name = "__utimes64")] pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; pub fn dlerror() -> *mut c_char; @@ -1331,15 +1411,18 @@ extern "C" { ), link_name = "res_9_init" )] + #[cfg_attr(target_os = "aix", link_name = "_res_init")] pub fn res_init() -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64_r")] pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__localtime64_r")] pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), @@ -1348,26 +1431,33 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__mktime64")] pub fn mktime(tm: *mut tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__time50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__time64")] pub fn time(time: *mut time_t) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64")] pub fn gmtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__localtime64")] pub fn localtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__difftime64")] pub fn difftime(time1: time_t, time0: time_t) -> c_double; + #[cfg(not(target_os = "aix"))] #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` + #[cfg_attr(gnu_time_bits64, link_name = "__timegm64")] pub fn timegm(tm: *mut crate::tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] @@ -1375,7 +1465,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "mknod@FBSD_1.0" )] - pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int; + pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn endservent(); pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; @@ -1425,6 +1515,8 @@ extern "C" { link_name = "select$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__select50")] + #[cfg_attr(target_os = "aix", link_name = "__fd_select")] + #[cfg_attr(gnu_time_bits64, link_name = "__select64")] pub fn select( nfds: c_int, readfds: *mut fd_set, @@ -1443,7 +1535,9 @@ extern "C" { pub fn sem_wait(sem: *mut sem_t) -> c_int; pub fn sem_trywait(sem: *mut sem_t) -> c_int; pub fn sem_post(sem: *mut sem_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] @@ -1467,7 +1561,9 @@ extern "C" { pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fseeko64")] pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "ftello64")] pub fn ftello(stream: *mut crate::FILE) -> off_t; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), @@ -1484,6 +1580,7 @@ extern "C" { pub fn tcflush(fd: c_int, action: c_int) -> c_int; pub fn tcgetsid(fd: c_int) -> crate::pid_t; pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemp64")] pub fn mkstemp(template: *mut c_char) -> c_int; pub fn mkdtemp(template: *mut c_char) -> *mut c_char; @@ -1505,9 +1602,11 @@ extern "C" { pub fn ptsname(fd: c_int) -> *mut c_char; pub fn unlockpt(fd: c_int) -> c_int; + #[cfg(not(target_os = "aix"))] pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lockf64")] pub fn lockf(fd: c_int, cmd: c_int, len: off_t) -> c_int; } @@ -1515,16 +1614,16 @@ extern "C" { safe_f! { // It seems htonl, etc are macros on macOS. So we have to reimplement them. So let's // reimplement them for all UNIX platforms - pub {const} fn htonl(hostlong: u32) -> u32 { + pub const fn htonl(hostlong: u32) -> u32 { u32::to_be(hostlong) } - pub {const} fn htons(hostshort: u16) -> u16 { + pub const fn htons(hostshort: u16) -> u16 { u16::to_be(hostshort) } - pub {const} fn ntohl(netlong: u32) -> u32 { + pub const fn ntohl(netlong: u32) -> u32 { u32::from_be(netlong) } - pub {const} fn ntohs(netshort: u16) -> u16 { + pub const fn ntohs(netshort: u16) -> u16 { u16::from_be(netshort) } } @@ -1536,9 +1635,11 @@ cfg_if! { target_os = "haiku", target_os = "nto", target_os = "solaris", - target_os = "cygwin" + target_os = "cygwin", + target_os = "aix", )))] { extern "C" { + #[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")] pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; } } else if #[cfg(target_os = "solaris")] { @@ -1561,6 +1662,20 @@ cfg_if! { } cfg_if! { + if #[cfg(not(any( + target_os = "dragonfly", + target_os = "emscripten", + target_os = "hurd", + target_os = "macos", + target_os = "openbsd", + )))] { + extern "C" { + pub fn sigqueue(pid: pid_t, sig: c_int, value: crate::sigval) -> c_int; + } + } +} + +cfg_if! { if #[cfg(not(target_os = "android"))] { extern "C" { #[cfg_attr( @@ -1607,7 +1722,8 @@ cfg_if! { )] pub fn pause() -> c_int; - pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; #[cfg_attr( @@ -1629,6 +1745,10 @@ cfg_if! { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "readdir_r@FBSD_1.0" )] + #[cfg_attr( + all(target_os = "freebsd", not(any(freebsd11, freebsd10))), + link_name = "readdir_r@FBSD_1.5" + )] #[allow(non_autolinks)] // FIXME(docs): `<>` breaks line length limit. /// The 64-bit libc on Solaris and illumos only has readdir_r. If a /// 32-bit Solaris or illumos target is ever created, it should use @@ -1636,6 +1756,7 @@ cfg_if! { /// https://illumos.org/man/3lib/libc /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html /// https://www.unix.com/man-page/opensolaris/3LIB/libc/ + #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64_r")] pub fn readdir_r( dirp: *mut crate::DIR, entry: *mut crate::dirent, @@ -1690,6 +1811,7 @@ cfg_if! { link_name = "pselect$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] + #[cfg_attr(gnu_time_bits64, link_name = "__pselect64")] pub fn pselect( nfds: c_int, readfds: *mut fd_set, @@ -1703,7 +1825,12 @@ cfg_if! { } cfg_if! { - if #[cfg(not(any( + if #[cfg(target_os = "aix")] { + extern "C" { + pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + } + } else if #[cfg(not(any( target_os = "solaris", target_os = "illumos", target_os = "nto", diff --git a/third_party/rust/libc/src/unix/newlib/horizon/mod.rs b/third_party/rust/libc/src/unix/newlib/horizon/mod.rs @@ -173,7 +173,7 @@ pub const AF_INET6: c_int = 23; pub const FIONBIO: c_ulong = 1; -pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // For pthread get/setschedparam pub const SCHED_FIFO: c_int = 1; @@ -185,35 +185,35 @@ pub const GRND_RANDOM: c_uint = 0x2; // Horizon OS works doesn't or can't hold any of this information safe_f! { - pub {const} fn WIFSTOPPED(_status: c_int) -> bool { + pub const fn WIFSTOPPED(_status: c_int) -> bool { false } - pub {const} fn WSTOPSIG(_status: c_int) -> c_int { + pub const fn WSTOPSIG(_status: c_int) -> c_int { 0 } - pub {const} fn WIFCONTINUED(_status: c_int) -> bool { + pub const fn WIFCONTINUED(_status: c_int) -> bool { true } - pub {const} fn WIFSIGNALED(_status: c_int) -> bool { + pub const fn WIFSIGNALED(_status: c_int) -> bool { false } - pub {const} fn WTERMSIG(_status: c_int) -> c_int { + pub const fn WTERMSIG(_status: c_int) -> c_int { 0 } - pub {const} fn WIFEXITED(_status: c_int) -> bool { + pub const fn WIFEXITED(_status: c_int) -> bool { true } - pub {const} fn WEXITSTATUS(_status: c_int) -> c_int { + pub const fn WEXITSTATUS(_status: c_int) -> c_int { 0 } - pub {const} fn WCOREDUMP(_status: c_int) -> bool { + pub const fn WCOREDUMP(_status: c_int) -> bool { false } } diff --git a/third_party/rust/libc/src/unix/newlib/mod.rs b/third_party/rust/libc/src/unix/newlib/mod.rs @@ -568,28 +568,28 @@ pub const SEEK_END: c_int = 2; pub const FIOCLEX: c_ulong = 0x20006601; pub const FIONCLEX: c_ulong = 0x20006602; -pub const S_BLKSIZE: crate::mode_t = 1024; -pub const S_IREAD: crate::mode_t = 0o0400; -pub const S_IWRITE: crate::mode_t = 0o0200; -pub const S_IEXEC: crate::mode_t = 0o0100; -pub const S_ENFMT: crate::mode_t = 0o2000; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IXOTH: crate::mode_t = 0o0001; +pub const S_BLKSIZE: mode_t = 1024; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_ENFMT: mode_t = 0o2000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; pub const SOL_TCP: c_int = 6; @@ -837,20 +837,20 @@ pub const PRIO_USER: c_int = 2; f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; diff --git a/third_party/rust/libc/src/unix/newlib/rtems/mod.rs b/third_party/rust/libc/src/unix/newlib/rtems/mod.rs @@ -85,38 +85,38 @@ pub const WUNTRACED: c_int = 2; pub const SOMAXCONN: c_int = 128; safe_f! { - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { // (status >> 8) & 0xff WEXITSTATUS(status) } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0x7f) > 0) && ((status & 0x7f) < 0x7f) } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xff) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } // RTEMS doesn't have native WIFCONTINUED. - pub {const} fn WIFCONTINUED(_status: c_int) -> bool { + pub const fn WIFCONTINUED(_status: c_int) -> bool { true } // RTEMS doesn't have native WCOREDUMP. - pub {const} fn WCOREDUMP(_status: c_int) -> bool { + pub const fn WCOREDUMP(_status: c_int) -> bool { false } } diff --git a/third_party/rust/libc/src/unix/newlib/vita/mod.rs b/third_party/rust/libc/src/unix/newlib/vita/mod.rs @@ -108,7 +108,7 @@ pub const POLLERR: c_short = 0x0008; pub const POLLHUP: c_short = 0x0010; pub const POLLNVAL: c_short = 0x0020; -pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const SOL_SOCKET: c_int = 0xffff; pub const SO_NONBLOCK: c_int = 0x1100; diff --git a/third_party/rust/libc/src/unix/nto/mod.rs b/third_party/rust/libc/src/unix/nto/mod.rs @@ -72,7 +72,7 @@ pub type sem_t = sync_t; pub type nl_item = c_int; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -98,7 +98,7 @@ s! { pub __old_st_mtime: crate::_Time32t, pub __old_st_atime: crate::_Time32t, pub __old_st_ctime: crate::_Time32t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_blocksize: crate::blksize_t, pub st_nblocks: i32, @@ -114,7 +114,7 @@ s! { pub imr_interface: in_addr, } - #[repr(packed)] + #[cfg_attr(any(target_env = "nto71", target_env = "nto70"), repr(packed))] pub struct in_addr { pub s_addr: crate::in_addr_t, } @@ -125,6 +125,7 @@ s! { pub sa_data: [c_char; 14], } + #[cfg(not(target_env = "nto71_iosock"))] pub struct sockaddr_in { pub sin_len: u8, pub sin_family: sa_family_t, @@ -133,6 +134,15 @@ s! { pub sin_zero: [i8; 8], } + #[cfg(target_env = "nto71_iosock")] + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, @@ -234,6 +244,8 @@ s! { pub _Reserved: [*mut c_char; 8], } + // Does not exist in io-sock + #[cfg(not(target_env = "nto71_iosock"))] pub struct in_pktinfo { pub ipi_addr: crate::in_addr, pub ipi_ifindex: c_uint, @@ -255,7 +267,7 @@ s! { pub arp_flags: c_int, } - #[repr(packed)] + #[cfg_attr(any(target_env = "nto71", target_env = "nto70"), repr(packed))] pub struct arphdr { pub ar_hrd: u16, pub ar_pro: u16, @@ -264,11 +276,18 @@ s! { pub ar_op: u16, } + #[cfg(not(target_env = "nto71_iosock"))] pub struct mmsghdr { pub msg_hdr: crate::msghdr, pub msg_len: c_uint, } + #[cfg(target_env = "nto71_iosock")] + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: ssize_t, + } + #[repr(align(8))] pub struct siginfo_t { pub si_signo: c_int, @@ -544,7 +563,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub seq: c_uint, pub key: crate::key_t, _reserved: [c_int; 4], @@ -557,6 +576,8 @@ s! { re_g: *mut c_void, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct _thread_attr { pub __flags: c_int, pub __stacksize: size_t, @@ -592,6 +613,7 @@ s! { pub bf_insns: *mut crate::bpf_insn, } + #[cfg(not(target_env = "nto71_iosock"))] pub struct bpf_stat { pub bs_recv: u64, pub bs_drop: u64, @@ -599,6 +621,12 @@ s! { bs_padding: [u64; 13], } + #[cfg(target_env = "nto71_iosock")] + pub struct bpf_stat { + pub bs_recv: c_uint, + pub bs_drop: c_uint, + } + pub struct bpf_version { pub bv_major: c_ushort, pub bv_minor: c_ushort, @@ -623,6 +651,8 @@ s! { pub bfl_list: *mut c_uint, } + // Does not exist in io-sock + #[cfg(not(target_env = "nto71_iosock"))] pub struct unpcbid { pub unp_pid: crate::pid_t, pub unp_euid: crate::uid_t, @@ -723,6 +753,7 @@ s_no_extra_traits! { msg_pad4: [c_long; 4], } + #[cfg(not(target_env = "nto71_iosock"))] pub struct sockaddr_dl { pub sdl_len: c_uchar, pub sdl_family: crate::sa_family_t, @@ -734,6 +765,18 @@ s_no_extra_traits! { pub sdl_data: [c_char; 12], } + #[cfg(target_env = "nto71_iosock")] + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 46], + } + pub struct sync_t { __u: c_uint, // union pub __owner: c_uint, @@ -770,16 +813,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_notify", &self.sigev_notify) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_value", &self.sigev_value) - .field("__sigev_un2", &self.__sigev_un2) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_notify.hash(state); @@ -801,15 +834,6 @@ cfg_if! { } } impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_len", &self.sun_len) - .field("sun_family", &self.sun_family) - // FIXME(debug): .field("sun_path", &self.sun_path) - .finish() - } - } impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { @@ -826,13 +850,6 @@ cfg_if! { } } impl Eq for sigset_t {} - impl fmt::Debug for sigset_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigset_t") - .field("__val", &self.__val) - .finish() - } - } impl hash::Hash for sigset_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.__val.hash(state); @@ -840,50 +857,10 @@ cfg_if! { } // msg - impl fmt::Debug for msg { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("msg") - .field("msg_next", &self.msg_next) - .field("msg_type", &self.msg_type) - .field("msg_ts", &self.msg_ts) - .field("msg_spot", &self.msg_spot) - .finish() - } - } // msqid_ds - impl fmt::Debug for msqid_ds { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("msqid_ds") - .field("msg_perm", &self.msg_perm) - .field("msg_first", &self.msg_first) - .field("msg_cbytes", &self.msg_cbytes) - .field("msg_qnum", &self.msg_qnum) - .field("msg_qbytes", &self.msg_qbytes) - .field("msg_lspid", &self.msg_lspid) - .field("msg_lrpid", &self.msg_lrpid) - .field("msg_stime", &self.msg_stime) - .field("msg_rtime", &self.msg_rtime) - .field("msg_ctime", &self.msg_ctime) - .finish() - } - } // sockaddr_dl - impl fmt::Debug for sockaddr_dl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_dl") - .field("sdl_len", &self.sdl_len) - .field("sdl_family", &self.sdl_family) - .field("sdl_index", &self.sdl_index) - .field("sdl_type", &self.sdl_type) - .field("sdl_nlen", &self.sdl_nlen) - .field("sdl_alen", &self.sdl_alen) - .field("sdl_slen", &self.sdl_slen) - .field("sdl_data", &self.sdl_data) - .finish() - } - } impl PartialEq for sockaddr_dl { fn eq(&self, other: &sockaddr_dl) -> bool { self.sdl_len == other.sdl_len @@ -914,73 +891,6 @@ cfg_if! { } } - // sync_t - impl fmt::Debug for sync_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sync_t") - .field("__owner", &self.__owner) - .field("__u", &self.__u) - .finish() - } - } - - // pthread_barrier_t - impl fmt::Debug for pthread_barrier_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_barrier_t") - .field("__pad", &self.__pad) - .finish() - } - } - - // pthread_rwlock_t - impl fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("pthread_rwlock_t") - .field("__active", &self.__active) - .field("__blockedwriters", &self.__blockedwriters) - .field("__blockedreaders", &self.__blockedreaders) - .field("__heavy", &self.__heavy) - .field("__lock", &self.__lock) - .field("__rcond", &self.__rcond) - .field("__wcond", &self.__wcond) - .field("__owner", &self.__owner) - .field("__spare", &self.__spare) - .finish() - } - } - - // syspage_entry - impl fmt::Debug for syspage_entry { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("syspage_entry") - .field("size", &self.size) - .field("total_size", &self.total_size) - .field("type_", &self.type_) - .field("num_cpu", &self.num_cpu) - .field("system_private", &self.system_private) - .field("old_asinfo", &self.old_asinfo) - .field("hwinfo", &self.hwinfo) - .field("old_cpuinfo", &self.old_cpuinfo) - .field("old_cacheattr", &self.old_cacheattr) - .field("qtime", &self.qtime) - .field("callout", &self.callout) - .field("callin", &self.callin) - .field("typed_strings", &self.typed_strings) - .field("strings", &self.strings) - .field("old_intrinfo", &self.old_intrinfo) - .field("smp", &self.smp) - .field("pminfo", &self.pminfo) - .field("old_mdriver", &self.old_mdriver) - .field("new_asinfo", &self.new_asinfo) - .field("new_cpuinfo", &self.new_cpuinfo) - .field("new_cacheattr", &self.new_cacheattr) - .field("new_intrinfo", &self.new_intrinfo) - .field("new_mdriver", &self.new_mdriver) - .finish() - } - } - impl PartialEq for utsname { fn eq(&self, other: &utsname) -> bool { self.sysname @@ -1012,18 +922,6 @@ cfg_if! { impl Eq for utsname {} - impl fmt::Debug for utsname { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utsname") - // FIXME(debug): .field("sysname", &self.sysname) - // FIXME(debug): .field("nodename", &self.nodename) - // FIXME(debug): .field("release", &self.release) - // FIXME(debug): .field("version", &self.version) - // FIXME(debug): .field("machine", &self.machine) - .finish() - } - } - impl hash::Hash for utsname { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sysname.hash(state); @@ -1048,19 +946,6 @@ cfg_if! { impl Eq for mq_attr {} - impl fmt::Debug for mq_attr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mq_attr") - .field("mq_maxmsg", &self.mq_maxmsg) - .field("mq_msgsize", &self.mq_msgsize) - .field("mq_flags", &self.mq_flags) - .field("mq_curmsgs", &self.mq_curmsgs) - .field("mq_msgsize", &self.mq_msgsize) - .field("mq_sendwait", &self.mq_sendwait) - .field("mq_recvwait", &self.mq_recvwait) - .finish() - } - } impl hash::Hash for mq_attr { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.mq_maxmsg.hash(state); @@ -1088,18 +973,6 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("__ss_pad2", &self.__ss_pad2) - .finish() - } - } - impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_len.hash(state); @@ -1125,18 +998,6 @@ cfg_if! { impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_offset", &self.d_offset) - .field("d_reclen", &self.d_reclen) - .field("d_namelen", &self.d_namelen) - .field("d_name", &&self.d_name[..self.d_namelen as _]) - .finish() - } - } - impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -1232,7 +1093,122 @@ pub const MS_SYNC: c_int = 2; pub const SCM_RIGHTS: c_int = 0x01; pub const SCM_TIMESTAMP: c_int = 0x02; -pub const SCM_CREDS: c_int = 0x04; +cfg_if! { + if #[cfg(not(target_env = "nto71_iosock"))] { + pub const SCM_CREDS: c_int = 0x04; + pub const IFF_NOTRAILERS: c_int = 0x00000020; + pub const AF_INET6: c_int = 24; + pub const AF_BLUETOOTH: c_int = 31; + pub const pseudo_AF_KEY: c_int = 29; + pub const MSG_NOSIGNAL: c_int = 0x0800; + pub const MSG_WAITFORONE: c_int = 0x2000; + pub const IP_IPSEC_POLICY_COMPAT: c_int = 22; + pub const IP_PKTINFO: c_int = 25; + pub const IPPROTO_DIVERT: c_int = 259; + pub const IPV6_IPSEC_POLICY_COMPAT: c_int = 28; + pub const TCP_KEEPALIVE: c_int = 0x04; + pub const ARPHRD_ARCNET: u16 = 7; + pub const SO_BINDTODEVICE: c_int = 0x0800; + pub const EAI_NODATA: c_int = 7; + pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; + pub const RTF_BROADCAST: u32 = 0x80000; + pub const UDP_ENCAP: c_int = 100; + pub const HW_IOSTATS: c_int = 9; + pub const HW_MACHINE_ARCH: c_int = 10; + pub const HW_ALIGNBYTES: c_int = 11; + pub const HW_CNMAGIC: c_int = 12; + pub const HW_PHYSMEM64: c_int = 13; + pub const HW_USERMEM64: c_int = 14; + pub const HW_IOSTATNAMES: c_int = 15; + pub const HW_MAXID: c_int = 15; + pub const CTL_UNSPEC: c_int = 0; + pub const CTL_QNX: c_int = 9; + pub const CTL_PROC: c_int = 10; + pub const CTL_VENDOR: c_int = 11; + pub const CTL_EMUL: c_int = 12; + pub const CTL_SECURITY: c_int = 13; + pub const CTL_MAXID: c_int = 14; + pub const AF_ARP: c_int = 28; + pub const AF_IEEE80211: c_int = 32; + pub const AF_NATM: c_int = 27; + pub const AF_NS: c_int = 6; + pub const BIOCGDLTLIST: c_int = -1072676233; + pub const BIOCGETIF: c_int = 1083196011; + pub const BIOCGSEESENT: c_int = 1074020984; + pub const BIOCGSTATS: c_int = 1082147439; + pub const BIOCSDLT: c_int = -2147204490; + pub const BIOCSETIF: c_int = -2138029460; + pub const BIOCSSEESENT: c_int = -2147204487; + pub const FIONSPACE: c_int = 1074030200; + pub const FIONWRITE: c_int = 1074030201; + pub const IFF_ACCEPTRTADV: c_int = 0x40000000; + pub const IFF_IP6FORWARDING: c_int = 0x20000000; + pub const IFF_SHIM: c_int = 0x80000000; + pub const KERN_ARND: c_int = 81; + pub const KERN_IOV_MAX: c_int = 38; + pub const KERN_LOGSIGEXIT: c_int = 46; + pub const KERN_MAXID: c_int = 83; + pub const KERN_PROC_ARGS: c_int = 48; + pub const KERN_PROC_ENV: c_int = 3; + pub const KERN_PROC_GID: c_int = 7; + pub const KERN_PROC_RGID: c_int = 8; + pub const LOCAL_CONNWAIT: c_int = 0x0002; + pub const LOCAL_CREDS: c_int = 0x0001; + pub const LOCAL_PEEREID: c_int = 0x0003; + pub const MSG_NOTIFICATION: c_int = 0x0400; + pub const NET_RT_IFLIST: c_int = 4; + pub const NI_NUMERICSCOPE: c_int = 0x00000040; + pub const PF_ARP: c_int = 28; + pub const PF_NATM: c_int = 27; + pub const pseudo_AF_HDRCMPLT: c_int = 30; + pub const SIOCGIFADDR: c_int = -1064277727; + pub const SO_FIB: c_int = 0x100a; + pub const SO_TXPRIO: c_int = 0x100b; + pub const SO_SETFIB: c_int = 0x100a; + pub const SO_VLANPRIO: c_int = 0x100c; + pub const USER_ATEXIT_MAX: c_int = 21; + pub const USER_MAXID: c_int = 22; + pub const SO_OVERFLOWED: c_int = 0x1009; + } else { + pub const SCM_CREDS: c_int = 0x03; + pub const AF_INET6: c_int = 28; + pub const AF_BLUETOOTH: c_int = 36; + pub const pseudo_AF_KEY: c_int = 27; + pub const MSG_NOSIGNAL: c_int = 0x20000; + pub const MSG_WAITFORONE: c_int = 0x00080000; + pub const IPPROTO_DIVERT: c_int = 258; + pub const RTF_BROADCAST: u32 = 0x400000; + pub const UDP_ENCAP: c_int = 1; + pub const HW_MACHINE_ARCH: c_int = 11; + pub const AF_ARP: c_int = 35; + pub const AF_IEEE80211: c_int = 37; + pub const AF_NATM: c_int = 29; + pub const BIOCGDLTLIST: c_ulong = 0xffffffffc0104279; + pub const BIOCGETIF: c_int = 0x4020426b; + pub const BIOCGSEESENT: c_int = 0x40044276; + pub const BIOCGSTATS: c_int = 0x4008426f; + pub const BIOCSDLT: c_int = 0x80044278; + pub const BIOCSETIF: c_int = 0x8020426c; + pub const BIOCSSEESENT: c_int = 0x80044277; + pub const KERN_ARND: c_int = 37; + pub const KERN_IOV_MAX: c_int = 35; + pub const KERN_LOGSIGEXIT: c_int = 34; + pub const KERN_PROC_ARGS: c_int = 7; + pub const KERN_PROC_ENV: c_int = 35; + pub const KERN_PROC_GID: c_int = 11; + pub const KERN_PROC_RGID: c_int = 10; + pub const LOCAL_CONNWAIT: c_int = 4; + pub const LOCAL_CREDS: c_int = 2; + pub const MSG_NOTIFICATION: c_int = 0x00002000; + pub const NET_RT_IFLIST: c_int = 3; + pub const NI_NUMERICSCOPE: c_int = 0x00000020; + pub const PF_ARP: c_int = AF_ARP; + pub const PF_NATM: c_int = AF_NATM; + pub const pseudo_AF_HDRCMPLT: c_int = 31; + pub const SIOCGIFADDR: c_int = 0xc0206921; + pub const SO_SETFIB: c_int = 0x1014; + } +} pub const MAP_TYPE: c_int = 0x3; @@ -1241,7 +1217,6 @@ pub const IFF_BROADCAST: c_int = 0x00000002; pub const IFF_DEBUG: c_int = 0x00000004; pub const IFF_LOOPBACK: c_int = 0x00000008; pub const IFF_POINTOPOINT: c_int = 0x00000010; -pub const IFF_NOTRAILERS: c_int = 0x00000020; pub const IFF_RUNNING: c_int = 0x00000040; pub const IFF_NOARP: c_int = 0x00000080; pub const IFF_PROMISC: c_int = 0x00000100; @@ -1254,10 +1229,9 @@ pub const AF_LOCAL: c_int = 1; pub const AF_INET: c_int = 2; pub const AF_IPX: c_int = 23; pub const AF_APPLETALK: c_int = 16; -pub const AF_INET6: c_int = 24; pub const AF_ROUTE: c_int = 17; pub const AF_SNA: c_int = 11; -pub const AF_BLUETOOTH: c_int = 31; + pub const AF_ISDN: c_int = 26; pub const PF_UNSPEC: c_int = AF_UNSPEC; @@ -1267,7 +1241,6 @@ pub const PF_INET: c_int = AF_INET; pub const PF_IPX: c_int = AF_IPX; pub const PF_APPLETALK: c_int = AF_APPLETALK; pub const PF_INET6: c_int = AF_INET6; -pub const pseudo_AF_KEY: c_int = 29; pub const PF_KEY: c_int = pseudo_AF_KEY; pub const PF_ROUTE: c_int = AF_ROUTE; pub const PF_SNA: c_int = AF_SNA; @@ -1285,8 +1258,6 @@ pub const MSG_TRUNC: c_int = 0x0010; pub const MSG_DONTWAIT: c_int = 0x0080; pub const MSG_EOR: c_int = 0x0008; pub const MSG_WAITALL: c_int = 0x0040; -pub const MSG_NOSIGNAL: c_int = 0x0800; -pub const MSG_WAITFORONE: c_int = 0x2000; pub const IP_TOS: c_int = 3; pub const IP_TTL: c_int = 4; @@ -1294,8 +1265,6 @@ pub const IP_HDRINCL: c_int = 2; pub const IP_OPTIONS: c_int = 1; pub const IP_RECVOPTS: c_int = 5; pub const IP_RETOPTS: c_int = 8; -pub const IP_PKTINFO: c_int = 25; -pub const IP_IPSEC_POLICY_COMPAT: c_int = 22; pub const IP_MULTICAST_IF: c_int = 9; pub const IP_MULTICAST_TTL: c_int = 10; pub const IP_MULTICAST_LOOP: c_int = 11; @@ -1325,7 +1294,6 @@ pub const IPPROTO_SCTP: c_int = 132; pub const IPPROTO_RAW: c_int = 255; pub const IPPROTO_MAX: c_int = 256; pub const IPPROTO_CARP: c_int = 112; -pub const IPPROTO_DIVERT: c_int = 259; pub const IPPROTO_DONE: c_int = 257; pub const IPPROTO_EON: c_int = 80; pub const IPPROTO_ETHERIP: c_int = 97; @@ -1343,7 +1311,6 @@ pub const IPV6_JOIN_GROUP: c_int = 12; pub const IPV6_LEAVE_GROUP: c_int = 13; pub const IPV6_CHECKSUM: c_int = 26; pub const IPV6_V6ONLY: c_int = 27; -pub const IPV6_IPSEC_POLICY_COMPAT: c_int = 28; pub const IPV6_RTHDRDSTOPTS: c_int = 35; pub const IPV6_RECVPKTINFO: c_int = 36; pub const IPV6_RECVHOPLIMIT: c_int = 37; @@ -1364,7 +1331,6 @@ pub const IPV6_DONTFRAG: c_int = 62; pub const TCP_NODELAY: c_int = 0x01; pub const TCP_MAXSEG: c_int = 0x02; pub const TCP_MD5SIG: c_int = 0x10; -pub const TCP_KEEPALIVE: c_int = 0x04; pub const SHUT_RD: c_int = 0; pub const SHUT_WR: c_int = 1; @@ -1514,7 +1480,6 @@ pub const MAXTTL: u8 = 255; pub const ARPHRD_ETHER: u16 = 1; pub const ARPHRD_IEEE802: u16 = 6; -pub const ARPHRD_ARCNET: u16 = 7; pub const ARPHRD_IEEE1394: u16 = 24; pub const SOL_SOCKET: c_int = 0xffff; @@ -1535,7 +1500,6 @@ pub const SO_RCVLOWAT: c_int = 0x1004; pub const SO_SNDLOWAT: c_int = 0x1003; pub const SO_RCVTIMEO: c_int = 0x1006; pub const SO_SNDTIMEO: c_int = 0x1005; -pub const SO_BINDTODEVICE: c_int = 0x0800; pub const SO_TIMESTAMP: c_int = 0x0400; pub const SO_ACCEPTCONN: c_int = 0x0002; @@ -1581,7 +1545,6 @@ pub const EAI_BADFLAGS: c_int = 3; pub const EAI_NONAME: c_int = 8; pub const EAI_AGAIN: c_int = 2; pub const EAI_FAIL: c_int = 4; -pub const EAI_NODATA: c_int = 7; pub const EAI_FAMILY: c_int = 5; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SERVICE: c_int = 9; @@ -1616,8 +1579,6 @@ pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x00000002; pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x00000400; pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x00000040; -pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; - pub const RTF_UP: c_ushort = 0x0001; pub const RTF_GATEWAY: c_ushort = 0x0002; @@ -1627,14 +1588,11 @@ pub const RTF_MODIFIED: c_ushort = 0x0020; pub const RTF_REJECT: c_ushort = 0x0008; pub const RTF_STATIC: c_ushort = 0x0800; pub const RTF_XRESOLVE: c_ushort = 0x0200; -pub const RTF_BROADCAST: u32 = 0x80000; pub const RTM_NEWADDR: u16 = 0xc; pub const RTM_DELADDR: u16 = 0xd; pub const RTA_DST: c_ushort = 0x1; pub const RTA_GATEWAY: c_ushort = 0x2; -pub const UDP_ENCAP: c_int = 100; - pub const IN_ACCESS: u32 = 0x00000001; pub const IN_MODIFY: u32 = 0x00000002; pub const IN_ATTRIB: u32 = 0x00000004; @@ -2037,27 +1995,27 @@ pub const S_IEXEC: mode_t = crate::S_IXUSR; pub const S_IWRITE: mode_t = crate::S_IWUSR; pub const S_IREAD: mode_t = crate::S_IRUSR; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; - -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IRWXU: crate::mode_t = 0o0700; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; + +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; @@ -2268,16 +2226,6 @@ pub const HW_PHYSMEM: c_int = 5; pub const HW_USERMEM: c_int = 6; pub const HW_PAGESIZE: c_int = 7; pub const HW_DISKNAMES: c_int = 8; -pub const HW_IOSTATS: c_int = 9; -pub const HW_MACHINE_ARCH: c_int = 10; -pub const HW_ALIGNBYTES: c_int = 11; -pub const HW_CNMAGIC: c_int = 12; -pub const HW_PHYSMEM64: c_int = 13; -pub const HW_USERMEM64: c_int = 14; -pub const HW_IOSTATNAMES: c_int = 15; -pub const HW_MAXID: c_int = 15; - -pub const CTL_UNSPEC: c_int = 0; pub const CTL_KERN: c_int = 1; pub const CTL_VM: c_int = 2; pub const CTL_VFS: c_int = 3; @@ -2286,12 +2234,6 @@ pub const CTL_DEBUG: c_int = 5; pub const CTL_HW: c_int = 6; pub const CTL_MACHDEP: c_int = 7; pub const CTL_USER: c_int = 8; -pub const CTL_QNX: c_int = 9; -pub const CTL_PROC: c_int = 10; -pub const CTL_VENDOR: c_int = 11; -pub const CTL_EMUL: c_int = 12; -pub const CTL_SECURITY: c_int = 13; -pub const CTL_MAXID: c_int = 14; pub const DAY_1: crate::nl_item = 8; pub const DAY_2: crate::nl_item = 9; @@ -2335,7 +2277,6 @@ pub const ABMON_10: crate::nl_item = 43; pub const ABMON_11: crate::nl_item = 44; pub const ABMON_12: crate::nl_item = 45; -pub const AF_ARP: c_int = 28; pub const AF_CCITT: c_int = 10; pub const AF_CHAOS: c_int = 5; pub const AF_CNT: c_int = 21; @@ -2346,13 +2287,10 @@ pub const AF_DLI: c_int = 13; pub const AF_E164: c_int = 26; pub const AF_ECMA: c_int = 8; pub const AF_HYLINK: c_int = 15; -pub const AF_IEEE80211: c_int = 32; pub const AF_IMPLINK: c_int = 3; pub const AF_ISO: c_int = 7; pub const AF_LAT: c_int = 14; pub const AF_LINK: c_int = 18; -pub const AF_NATM: c_int = 27; -pub const AF_NS: c_int = 6; pub const AF_OSI: c_int = 7; pub const AF_PUP: c_int = 4; pub const ALT_DIGITS: crate::nl_item = 50; @@ -2362,24 +2300,17 @@ pub const B76800: crate::speed_t = 76800; pub const BIOCFLUSH: c_int = 17000; pub const BIOCGBLEN: c_int = 1074020966; pub const BIOCGDLT: c_int = 1074020970; -pub const BIOCGDLTLIST: c_int = -1072676233; -pub const BIOCGETIF: c_int = 1083196011; pub const BIOCGHDRCMPLT: c_int = 1074020980; pub const BIOCGRTIMEOUT: c_int = 1074807406; -pub const BIOCGSEESENT: c_int = 1074020984; -pub const BIOCGSTATS: c_int = 1082147439; pub const BIOCIMMEDIATE: c_int = -2147204496; pub const BIOCPROMISC: c_int = 17001; pub const BIOCSBLEN: c_int = -1073462682; -pub const BIOCSDLT: c_int = -2147204490; pub const BIOCSETF: c_int = -2146418073; -pub const BIOCSETIF: c_int = -2138029460; pub const BIOCSHDRCMPLT: c_int = -2147204491; pub const BIOCSRTIMEOUT: c_int = -2146418067; -pub const BIOCSSEESENT: c_int = -2147204487; pub const BIOCVERSION: c_int = 1074020977; -pub const BPF_ALIGNMENT: usize = mem::size_of::<c_long>(); +pub const BPF_ALIGNMENT: usize = size_of::<c_long>(); pub const CHAR_BIT: usize = 8; pub const CODESET: crate::nl_item = 1; pub const CRNCYSTR: crate::nl_item = 55; @@ -2412,18 +2343,13 @@ pub const FIOCLEX: c_int = 26113; pub const FIOGETOWN: c_int = 1074030203; pub const FIONCLEX: c_int = 26114; pub const FIONREAD: c_int = 1074030207; -pub const FIONSPACE: c_int = 1074030200; -pub const FIONWRITE: c_int = 1074030201; pub const FIOSETOWN: c_int = -2147195268; pub const F_SETOWN: c_int = 36; -pub const IFF_ACCEPTRTADV: c_int = 0x40000000; -pub const IFF_IP6FORWARDING: c_int = 0x20000000; pub const IFF_LINK0: c_int = 0x00001000; pub const IFF_LINK1: c_int = 0x00002000; pub const IFF_LINK2: c_int = 0x00004000; pub const IFF_OACTIVE: c_int = 0x00000400; -pub const IFF_SHIM: c_int = 0x80000000; pub const IFF_SIMPLEX: c_int = 0x00000800; pub const IHFLOW: tcflag_t = 0x00000001; pub const IIDLE: tcflag_t = 0x00000008; @@ -2434,17 +2360,13 @@ pub const IUCLC: tcflag_t = 0x00000200; pub const IUTF8: tcflag_t = 0x0004000; pub const KERN_ARGMAX: c_int = 8; -pub const KERN_ARND: c_int = 81; pub const KERN_BOOTTIME: c_int = 21; pub const KERN_CLOCKRATE: c_int = 12; pub const KERN_FILE: c_int = 15; pub const KERN_HOSTID: c_int = 11; pub const KERN_HOSTNAME: c_int = 10; -pub const KERN_IOV_MAX: c_int = 38; pub const KERN_JOB_CONTROL: c_int = 19; -pub const KERN_LOGSIGEXIT: c_int = 46; pub const KERN_MAXFILES: c_int = 7; -pub const KERN_MAXID: c_int = 83; pub const KERN_MAXPROC: c_int = 6; pub const KERN_MAXVNODES: c_int = 5; pub const KERN_NGROUPS: c_int = 18; @@ -2454,12 +2376,8 @@ pub const KERN_OSTYPE: c_int = 1; pub const KERN_POSIX1: c_int = 17; pub const KERN_PROC: c_int = 14; pub const KERN_PROC_ALL: c_int = 0; -pub const KERN_PROC_ARGS: c_int = 48; -pub const KERN_PROC_ENV: c_int = 3; -pub const KERN_PROC_GID: c_int = 7; pub const KERN_PROC_PGRP: c_int = 2; pub const KERN_PROC_PID: c_int = 1; -pub const KERN_PROC_RGID: c_int = 8; pub const KERN_PROC_RUID: c_int = 6; pub const KERN_PROC_SESSION: c_int = 3; pub const KERN_PROC_TTY: c_int = 4; @@ -2478,25 +2396,16 @@ pub const LC_MONETARY: c_int = 4; pub const LC_NUMERIC: c_int = 8; pub const LC_TIME: c_int = 16; -pub const LOCAL_CONNWAIT: c_int = 0x0002; -pub const LOCAL_CREDS: c_int = 0x0001; -pub const LOCAL_PEEREID: c_int = 0x0003; - pub const MAP_STACK: c_int = 0x00001000; pub const MNT_NOEXEC: c_int = 0x02; pub const MNT_NOSUID: c_int = 0x04; pub const MNT_RDONLY: c_int = 0x01; -pub const MSG_NOTIFICATION: c_int = 0x0400; - pub const NET_RT_DUMP: c_int = 1; pub const NET_RT_FLAGS: c_int = 2; -pub const NET_RT_IFLIST: c_int = 4; -pub const NI_NUMERICSCOPE: c_int = 0x00000040; pub const OHFLOW: tcflag_t = 0x00000002; pub const P_ALL: idtype_t = 0; pub const PARSTK: tcflag_t = 0x00000004; -pub const PF_ARP: c_int = 28; pub const PF_CCITT: c_int = 10; pub const PF_CHAOS: c_int = 5; pub const PF_CNT: c_int = 21; @@ -2510,7 +2419,6 @@ pub const PF_IMPLINK: c_int = 3; pub const PF_ISO: c_int = 7; pub const PF_LAT: c_int = 14; pub const PF_LINK: c_int = 18; -pub const PF_NATM: c_int = 27; pub const PF_OSI: c_int = 7; pub const PF_PIP: c_int = 25; pub const PF_PUP: c_int = 4; @@ -2528,7 +2436,6 @@ pub const P_PID: idtype_t = 1; pub const PRIO_PGRP: c_int = 1; pub const PRIO_PROCESS: c_int = 0; pub const PRIO_USER: c_int = 2; -pub const pseudo_AF_HDRCMPLT: c_int = 30; pub const pseudo_AF_PIP: c_int = 25; pub const pseudo_AF_RTIP: c_int = 22; pub const pseudo_AF_XTP: c_int = 19; @@ -2573,14 +2480,8 @@ pub const SIGEMT: c_int = 7; pub const SIGEV_NONE: c_int = 0; pub const SIGEV_SIGNAL: c_int = 129; pub const SIGEV_THREAD: c_int = 135; -pub const SIOCGIFADDR: c_int = -1064277727; -pub const SO_FIB: c_int = 0x100a; -pub const SO_OVERFLOWED: c_int = 0x1009; -pub const SO_SETFIB: c_int = 0x100a; -pub const SO_TXPRIO: c_int = 0x100b; pub const SO_USELOOPBACK: c_int = 0x0040; -pub const SO_VLANPRIO: c_int = 0x100c; -pub const _SS_ALIGNSIZE: usize = mem::size_of::<i64>(); +pub const _SS_ALIGNSIZE: usize = size_of::<i64>(); pub const _SS_MAXSIZE: usize = 128; pub const _SS_PAD1SIZE: usize = _SS_ALIGNSIZE - 2; pub const _SS_PAD2SIZE: usize = _SS_MAXSIZE - 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE; @@ -2649,8 +2550,6 @@ pub const USER_POSIX2_SW_DEV: c_int = 17; pub const USER_POSIX2_UPE: c_int = 18; pub const USER_STREAM_MAX: c_int = 19; pub const USER_TZNAME_MAX: c_int = 20; -pub const USER_ATEXIT_MAX: c_int = 21; -pub const USER_MAXID: c_int = 22; pub const VDOWN: usize = 31; pub const VINS: usize = 32; @@ -2708,63 +2607,61 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __spare: 0, }; -const_fn! { - {const} fn _CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1) - } +const fn _CMSG_ALIGN(len: usize) -> usize { + len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1) +} - {const} fn _ALIGN(p: usize, b: usize) -> usize { - (p + b - 1) & !(b - 1) - } +const fn _ALIGN(p: usize, b: usize) -> usize { + (p + b - 1) & !(b - 1) } f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() { + if (*mhdr).msg_controllen as usize >= size_of::<cmsghdr>() { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let msg = _CMSG_ALIGN((*cmsg).cmsg_len as usize); - let next = cmsg as usize + msg + _CMSG_ALIGN(mem::size_of::<cmsghdr>()); + let next = cmsg as usize + msg + _CMSG_ALIGN(size_of::<cmsghdr>()); if next > (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { (cmsg as usize + msg) as *mut cmsghdr } } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::<cmsghdr>()) as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _CMSG_ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _CMSG_ALIGN(size_of::<cmsghdr>()) as c_uint + length } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_CMSG_ALIGN(mem::size_of::<cmsghdr>()) + _CMSG_ALIGN(length as usize)) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_CMSG_ALIGN(size_of::<cmsghdr>()) + _CMSG_ALIGN(length as usize)) as c_uint } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } @@ -2783,7 +2680,7 @@ f! { } pub fn _DEXTRA_VALID(_x: *const crate::dirent_extra, _d: *const dirent) -> bool { - let sz = _x as usize - _d as usize + mem::size_of::<crate::dirent_extra>(); + let sz = _x as usize - _d as usize + size_of::<crate::dirent_extra>(); let rsz = (*_d).d_reclen as usize; if sz > rsz || sz + (*_x).d_datalen as usize > rsz { @@ -2795,67 +2692,103 @@ f! { pub fn _DEXTRA_NEXT(_x: *const crate::dirent_extra) -> *mut crate::dirent_extra { _ALIGN( - _x as usize + mem::size_of::<crate::dirent_extra>() + (*_x).d_datalen as usize, + _x as usize + size_of::<crate::dirent_extra>() + (*_x).d_datalen as usize, 8, ) as *mut crate::dirent_extra } pub fn SOCKCREDSIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::<sockcred>() + mem::size_of::<crate::gid_t>() * ngrps + size_of::<sockcred>() + size_of::<crate::gid_t>() * ngrps } } safe_f! { - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0xffff } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0x7f) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } - pub {const} fn IPTOS_ECN(x: u8) -> u8 { + pub const fn IPTOS_ECN(x: u8) -> u8 { x & crate::IPTOS_ECN_MASK } - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { ((major << 10) | (minor)) as crate::dev_t } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { ((dev as c_uint) >> 10) & 0x3f } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { (dev as c_uint) & 0x3ff } } +cfg_if! { + if #[cfg(not(target_env = "nto71_iosock"))] { + extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + ) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + timeout: *mut crate::timespec, + ) -> c_int; + } + } else { + extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + ) -> ssize_t; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + timeout: *const crate::timespec, + ) -> ssize_t; + } + } +} + // Network related functions are provided by libsocket and regex // functions are provided by libregex. // In QNX <=7.0, libregex functions were included in libc itself. @@ -2867,13 +2800,8 @@ extern "C" { pub fn fdatasync(fd: c_int) -> c_int; pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat( - __fd: c_int, - pathname: *const c_char, - mode: crate::mode_t, - dev: crate::dev_t, - ) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(__fd: c_int, pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; @@ -3246,7 +3174,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, @@ -3277,20 +3205,6 @@ extern "C" { flags: c_int, ) -> c_int; - pub fn sendmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - ) -> c_int; - pub fn recvmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - timeout: *mut crate::timespec, - ) -> c_int; - pub fn mallopt(param: c_int, value: i64) -> c_int; pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; diff --git a/third_party/rust/libc/src/unix/nto/neutrino.rs b/third_party/rust/libc/src/unix/nto/neutrino.rs @@ -137,6 +137,8 @@ s! { pub ev: crate::__c_anonymous_struct_ev, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct _sighandler_info { pub siginfo: crate::siginfo_t, pub handler: Option<unsafe extern "C" fn(value: c_int)>, diff --git a/third_party/rust/libc/src/unix/nuttx/mod.rs b/third_party/rust/libc/src/unix/nuttx/mod.rs @@ -32,7 +32,7 @@ s! { pub st_dev: dev_t, pub st_ino: ino_t, pub st_mode: mode_t, - pub st_nlink: u64, + pub st_nlink: nlink_t, pub st_uid: u32, pub st_gid: u32, pub st_rdev: dev_t, @@ -274,7 +274,7 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { }; // dlfcn.h -pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // stdlib.h pub const EXIT_SUCCESS: i32 = 0; @@ -517,7 +517,39 @@ pub const _SC_THREAD_STACK_MIN: i32 = 0x58; pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25; // signal.h -pub const SIGPIPE: i32 = 13; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGIOT: c_int = 6; +pub const SIGBUS: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGUSR1: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGUSR2: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGSTKFLT: c_int = 16; +pub const SIGCHLD: c_int = 17; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGURG: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGIO: c_int = 29; +pub const SIGPOLL: c_int = SIGIO; +pub const SIGPWR: c_int = 30; +pub const SIGSYS: c_int = 31; // pthread.h pub const PTHREAD_MUTEX_NORMAL: i32 = 0; @@ -534,6 +566,7 @@ pub const IP_ADD_MEMBERSHIP: i32 = 0x14; pub const IP_DROP_MEMBERSHIP: i32 = 0x15; extern "C" { + pub fn __errno() -> *mut c_int; pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; pub fn ioctl(fd: i32, request: i32, ...) -> i32; pub fn dirfd(dirp: *mut DIR) -> i32; @@ -559,4 +592,6 @@ extern "C" { pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> i32; pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: usize) -> i32; pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize; + pub fn arc4random() -> u32; + pub fn arc4random_buf(bytes: *mut c_void, nbytes: usize); } diff --git a/third_party/rust/libc/src/unix/redox/mod.rs b/third_party/rust/libc/src/unix/redox/mod.rs @@ -29,10 +29,10 @@ pub type tcflag_t = u32; pub type time_t = c_longlong; pub type id_t = c_uint; pub type pid_t = usize; -pub type uid_t = u32; -pub type gid_t = u32; +pub type uid_t = c_int; +pub type gid_t = c_int; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -67,7 +67,7 @@ s_no_extra_traits! { pub struct sockaddr_storage { pub ss_family: crate::sa_family_t, - __ss_padding: [u8; 128 - mem::size_of::<sa_family_t>() - mem::size_of::<c_ulong>()], + __ss_padding: [u8; 128 - size_of::<sa_family_t>() - size_of::<c_ulong>()], __ss_align: c_ulong, } } @@ -131,6 +131,22 @@ s! { pub thousands_sep: *const c_char, } + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + pub struct passwd { pub pw_name: *mut c_char, pub pw_passwd: *mut c_char, @@ -141,6 +157,8 @@ s! { pub pw_shell: *mut c_char, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_sigaction: crate::sighandler_t, pub sa_flags: c_ulong, @@ -180,7 +198,7 @@ s! { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, @@ -334,8 +352,10 @@ pub const F_LOCK: c_int = 1; pub const F_TLOCK: c_int = 2; pub const F_TEST: c_int = 3; +pub const AT_FDCWD: c_int = -100; + // FIXME(redox): relibc { -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // } // dlfcn.h @@ -499,6 +519,7 @@ pub const O_WRONLY: c_int = 0x0002_0000; pub const O_RDWR: c_int = 0x0003_0000; pub const O_ACCMODE: c_int = 0x0003_0000; pub const O_NONBLOCK: c_int = 0x0004_0000; +pub const O_NDELAY: c_int = O_NONBLOCK; pub const O_APPEND: c_int = 0x0008_0000; pub const O_SHLOCK: c_int = 0x0010_0000; pub const O_EXLOCK: c_int = 0x0020_0000; @@ -514,6 +535,7 @@ pub const O_SYMLINK: c_int = 0x4000_0000; // Negative to allow it to be used as int // FIXME(redox): Fix negative values missing from includes pub const O_NOFOLLOW: c_int = -0x8000_0000; +pub const O_NOCTTY: c_int = 0x00000200; // locale.h pub const LC_ALL: c_int = 0; @@ -645,14 +667,14 @@ pub const SIGPWR: c_int = 30; pub const SIGSYS: c_int = 31; pub const NSIG: c_int = 32; -pub const SA_NOCLDSTOP: c_ulong = 0x00000001; -pub const SA_NOCLDWAIT: c_ulong = 0x00000002; -pub const SA_SIGINFO: c_ulong = 0x00000004; -pub const SA_RESTORER: c_ulong = 0x04000000; -pub const SA_ONSTACK: c_ulong = 0x08000000; -pub const SA_RESTART: c_ulong = 0x10000000; -pub const SA_NODEFER: c_ulong = 0x40000000; -pub const SA_RESETHAND: c_ulong = 0x80000000; +pub const SA_NOCLDWAIT: c_ulong = 0x0000_0002; +pub const SA_RESTORER: c_ulong = 0x0000_0004; // FIXME(redox): remove after relibc removes it +pub const SA_SIGINFO: c_ulong = 0x0200_0000; +pub const SA_ONSTACK: c_ulong = 0x0400_0000; +pub const SA_RESTART: c_ulong = 0x0800_0000; +pub const SA_NODEFER: c_ulong = 0x1000_0000; +pub const SA_RESETHAND: c_ulong = 0x2000_0000; +pub const SA_NOCLDSTOP: c_ulong = 0x4000_0000; // sys/file.h pub const LOCK_SH: c_int = 1; @@ -739,13 +761,39 @@ pub const MAP_SHARED: c_int = 0x0001; pub const MAP_PRIVATE: c_int = 0x0002; pub const MAP_ANON: c_int = 0x0020; pub const MAP_ANONYMOUS: c_int = MAP_ANON; -pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_FIXED: c_int = 0x0004; pub const MAP_FAILED: *mut c_void = !0 as _; pub const MS_ASYNC: c_int = 0x0001; pub const MS_INVALIDATE: c_int = 0x0002; pub const MS_SYNC: c_int = 0x0004; +// sys/resource.h +pub const RLIM_INFINITY: rlim_t = !0; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_NPROC: c_int = 6; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_MEMLOCK: c_int = 8; +pub const RLIMIT_AS: c_int = 9; +pub const RLIMIT_LOCKS: c_int = 10; +pub const RLIMIT_SIGPENDING: c_int = 11; +pub const RLIMIT_MSGQUEUE: c_int = 12; +pub const RLIMIT_NICE: c_int = 13; +pub const RLIMIT_RTPRIO: c_int = 14; +pub const RLIMIT_NLIMITS: c_int = 15; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; +pub const RUSAGE_BOTH: c_int = -2; +pub const RUSAGE_THREAD: c_int = 1; + // sys/select.h pub const FD_SETSIZE: usize = 1024; @@ -766,6 +814,7 @@ pub const MSG_PEEK: c_int = 2; pub const MSG_TRUNC: c_int = 32; pub const MSG_DONTWAIT: c_int = 64; pub const MSG_WAITALL: c_int = 256; +pub const SCM_RIGHTS: c_int = 1; pub const SHUT_RD: c_int = 0; pub const SHUT_WR: c_int = 1; pub const SHUT_RDWR: c_int = 2; @@ -916,6 +965,8 @@ pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; +pub const _POSIX_VDISABLE: crate::cc_t = 0; + // sys/wait.h pub const WNOHANG: c_int = 1; pub const WUNTRACED: c_int = 2; @@ -960,11 +1011,54 @@ pub const _SC_SYMLOOP_MAX: c_int = 173; pub const _SC_HOST_NAME_MAX: c_int = 180; // } POSIX.1 +// confstr +pub const _CS_PATH: c_int = 0; +pub const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS: c_int = 1; +pub const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS: c_int = 4; +pub const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS: c_int = 5; +pub const _CS_POSIX_V6_ILP32_OFF32_CFLAGS: c_int = 1116; +pub const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS: c_int = 1117; +pub const _CS_POSIX_V6_ILP32_OFF32_LIBS: c_int = 1118; +pub const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS: c_int = 1119; +pub const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS: c_int = 1120; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS: c_int = 1121; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LIBS: c_int = 1122; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS: c_int = 1123; +pub const _CS_POSIX_V6_LP64_OFF64_CFLAGS: c_int = 1124; +pub const _CS_POSIX_V6_LP64_OFF64_LDFLAGS: c_int = 1125; +pub const _CS_POSIX_V6_LP64_OFF64_LIBS: c_int = 1126; +pub const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS: c_int = 1127; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS: c_int = 1128; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS: c_int = 1129; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS: c_int = 1130; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS: c_int = 1131; +pub const _CS_POSIX_V7_ILP32_OFF32_CFLAGS: c_int = 1132; +pub const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS: c_int = 1133; +pub const _CS_POSIX_V7_ILP32_OFF32_LIBS: c_int = 1134; +pub const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS: c_int = 1135; +pub const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS: c_int = 1136; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS: c_int = 1137; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LIBS: c_int = 1138; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS: c_int = 1139; +pub const _CS_POSIX_V7_LP64_OFF64_CFLAGS: c_int = 1140; +pub const _CS_POSIX_V7_LP64_OFF64_LDFLAGS: c_int = 1141; +pub const _CS_POSIX_V7_LP64_OFF64_LIBS: c_int = 1142; +pub const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS: c_int = 1143; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS: c_int = 1144; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147; + pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; +// stdio.h +pub const BUFSIZ: c_uint = 1024; +pub const _IOFBF: c_int = 0; +pub const _IOLBF: c_int = 1; +pub const _IONBF: c_int = 2; pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; @@ -998,24 +1092,35 @@ pub const PRIO_PROCESS: c_int = 0; pub const PRIO_PGRP: c_int = 1; pub const PRIO_USER: c_int = 2; -// wait.h f! { + //sys/socket.h + pub const fn CMSG_ALIGN(len: size_t) -> size_t { + (len + size_of::<size_t>() - 1) & !(size_of::<size_t>() - 1) + } + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + (CMSG_ALIGN(size_of::<cmsghdr>()) + length as usize) as c_uint + } + pub const fn CMSG_SPACE(len: c_uint) -> c_uint { + (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint + } + + // wait.h pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } @@ -1028,35 +1133,35 @@ f! { } safe_f! { - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0x7f } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0xffff } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0x7f) + 1) as i8 >= 2 } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0x7f) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } } @@ -1066,6 +1171,9 @@ extern "C" { pub fn __errno_location() -> *mut c_int; pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + // dirent.h + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + // unistd.h pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; pub fn getdtablesize() -> c_int; @@ -1177,6 +1285,8 @@ extern "C" { tokens: *const *mut c_char, valuep: *mut *mut c_char, ) -> c_int; + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; // string.h @@ -1212,6 +1322,9 @@ extern "C" { pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; // sys/socket.h + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar; + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr; + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr; pub fn bind( socket: c_int, address: *const crate::sockaddr, @@ -1225,11 +1338,15 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; + pub fn recvmsg(socket: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; + pub fn sendmsg(socket: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; // sys/stat.h pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; // sys/uio.h + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; @@ -1239,6 +1356,12 @@ extern "C" { // time.h pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn strftime( + s: *mut c_char, + max: size_t, + format: *const c_char, + tm: *const crate::tm, + ) -> size_t; // utmp.h pub fn login_tty(fd: c_int) -> c_int; @@ -1262,18 +1385,6 @@ cfg_if! { impl Eq for dirent {} - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> 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(debug): .field("d_name", &self.d_name) - .finish() - } - } - impl hash::Hash for dirent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.d_ino.hash(state); @@ -1297,15 +1408,6 @@ cfg_if! { impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_family", &self.sun_family) - // FIXME(debug): .field("sun_path", &self.sun_path) - .finish() - } - } - impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sun_family.hash(state); @@ -1327,16 +1429,6 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_family", &self.ss_family) - .field("__ss_align", &self.__ss_align) - // FIXME(debug): .field("__ss_padding", &self.__ss_padding) - .finish() - } - } - impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_family.hash(state); @@ -1381,19 +1473,6 @@ cfg_if! { impl Eq for utsname {} - impl fmt::Debug for utsname { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utsname") - // FIXME(debug): .field("sysname", &self.sysname) - // FIXME(debug): .field("nodename", &self.nodename) - // FIXME(debug): .field("release", &self.release) - // FIXME(debug): .field("version", &self.version) - // FIXME(debug): .field("machine", &self.machine) - // FIXME(debug): .field("domainname", &self.domainname) - .finish() - } - } - impl hash::Hash for utsname { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sysname.hash(state); diff --git a/third_party/rust/libc/src/unix/solarish/compat.rs b/third_party/rust/libc/src/unix/solarish/compat.rs @@ -5,9 +5,6 @@ use core::cmp::min; use crate::unix::solarish::*; use crate::{c_char, c_int, size_t}; -const PTEM: &[u8] = b"ptem\0"; -const LDTERM: &[u8] = b"ldterm\0"; - pub unsafe fn cfmakeraw(termios: *mut crate::termios) { (*termios).c_iflag &= !(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); @@ -41,6 +38,7 @@ pub unsafe fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> 0 } +#[cfg(target_os = "illumos")] unsafe fn bail(fdm: c_int, fds: c_int) -> c_int { let e = *___errno(); if fds >= 0 { @@ -50,9 +48,10 @@ unsafe fn bail(fdm: c_int, fds: c_int) -> c_int { crate::close(fdm); } *___errno() = e; - return -1; + -1 } +#[cfg(target_os = "illumos")] pub unsafe fn openpty( amain: *mut c_int, asubord: *mut c_int, @@ -60,6 +59,9 @@ pub unsafe fn openpty( termp: *const termios, winp: *const crate::winsize, ) -> c_int { + const PTEM: &[u8] = b"ptem\0"; + const LDTERM: &[u8] = b"ldterm\0"; + // Open the main pseudo-terminal device, making sure not to set it as the // controlling terminal for this process: let fdm = crate::posix_openpt(O_RDWR | O_NOCTTY); @@ -123,6 +125,7 @@ pub unsafe fn openpty( 0 } +#[cfg(target_os = "illumos")] pub unsafe fn forkpty( amain: *mut c_int, name: *mut c_char, @@ -182,7 +185,7 @@ pub unsafe fn getpwent_r( ) -> c_int { let old_errno = *crate::___errno(); *crate::___errno() = 0; - *result = native_getpwent_r(pwd, buf, min(buflen, c_int::max_value() as size_t) as c_int); + *result = native_getpwent_r(pwd, buf, min(buflen, c_int::MAX as size_t) as c_int); let ret = if (*result).is_null() { *crate::___errno() @@ -202,7 +205,7 @@ pub unsafe fn getgrent_r( ) -> c_int { let old_errno = *crate::___errno(); *crate::___errno() = 0; - *result = native_getgrent_r(grp, buf, min(buflen, c_int::max_value() as size_t) as c_int); + *result = native_getgrent_r(grp, buf, min(buflen, c_int::MAX as size_t) as c_int); let ret = if (*result).is_null() { *crate::___errno() diff --git a/third_party/rust/libc/src/unix/solarish/illumos.rs b/third_party/rust/libc/src/unix/solarish/illumos.rs @@ -89,24 +89,6 @@ cfg_if! { impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - .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_exit", &self.ut_exit) - .field("ut_tv", &self.ut_tv) - .field("ut_session", &self.ut_session) - .field("ut_pad", &self.ut_pad) - .field("ut_syslen", &self.ut_syslen) - .field("ut_host", &&self.ut_host[..]) - .finish() - } - } - impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_user.hash(state); @@ -129,16 +111,6 @@ cfg_if! { } } impl Eq for epoll_event {} - impl fmt::Debug for epoll_event { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let events = self.events; - let u64 = self.u64; - f.debug_struct("epoll_event") - .field("events", &events) - .field("u64", &u64) - .finish() - } - } impl hash::Hash for epoll_event { fn hash<H: hash::Hasher>(&self, state: &mut H) { let events = self.events; @@ -286,6 +258,12 @@ pub const B4000000: crate::speed_t = 31; // sys/systeminfo.h pub const SI_ADDRESS_WIDTH: c_int = 520; +// sys/timerfd.h +pub const TFD_CLOEXEC: i32 = 0o2000000; +pub const TFD_NONBLOCK: i32 = 0o4000; +pub const TFD_TIMER_ABSTIME: i32 = 1 << 0; +pub const TFD_TIMER_CANCEL_ON_SET: i32 = 1 << 1; + extern "C" { pub fn eventfd(init: c_uint, flags: c_int) -> c_int; @@ -353,4 +331,13 @@ extern "C" { n: size_t, loc: crate::locale_t, ) -> c_int; + + pub fn timerfd_create(clockid: c_int, flags: c_int) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; } diff --git a/third_party/rust/libc/src/unix/solarish/mod.rs b/third_party/rust/libc/src/unix/solarish/mod.rs @@ -1,5 +1,3 @@ -use core::mem::size_of; - use crate::prelude::*; pub type caddr_t = *mut c_char; @@ -57,7 +55,7 @@ pub type lgrp_view_t = c_uint; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -66,7 +64,7 @@ impl Clone for timezone { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum ucred_t {} impl Copy for ucred_t {} impl Clone for ucred_t { @@ -96,7 +94,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub seq: c_uint, pub key: crate::key_t, } @@ -328,7 +326,7 @@ s! { pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, @@ -585,14 +583,6 @@ cfg_if! { } } impl Eq for sockaddr_un {} - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_family", &self.sun_family) - // FIXME(debug): .field("sun_path", &self.sun_path) - .finish() - } - } impl hash::Hash for sockaddr_un { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sun_family.hash(state); @@ -629,17 +619,6 @@ cfg_if! { } } impl Eq for utsname {} - impl fmt::Debug for utsname { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utsname") - // FIXME(debug): .field("sysname", &self.sysname) - // FIXME(debug): .field("nodename", &self.nodename) - // FIXME(debug): .field("release", &self.release) - // FIXME(debug): .field("version", &self.version) - // FIXME(debug): .field("machine", &self.machine) - .finish() - } - } impl hash::Hash for utsname { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sysname.hash(state); @@ -659,13 +638,6 @@ cfg_if! { } } impl Eq for fd_set {} - impl fmt::Debug for fd_set { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fd_set") - // FIXME(debug): .field("fds_bits", &self.fds_bits) - .finish() - } - } impl hash::Hash for fd_set { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.fds_bits.hash(state); @@ -685,16 +657,6 @@ cfg_if! { } } impl Eq for sockaddr_storage {} - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_family", &self.ss_family) - .field("__ss_pad1", &self.__ss_pad1) - .field("__ss_align", &self.__ss_align) - // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) - .finish() - } - } impl hash::Hash for sockaddr_storage { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ss_family.hash(state); @@ -754,16 +716,6 @@ cfg_if! { } } impl Eq for siginfo_t {} - impl fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("siginfo_t") - .field("si_signo", &self.si_signo) - .field("si_code", &self.si_code) - .field("si_errno", &self.si_errno) - // FIXME(debug): .field("__pad", &self.__pad) - .finish() - } - } impl hash::Hash for siginfo_t { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.si_signo.hash(state); @@ -794,19 +746,6 @@ cfg_if! { } } impl Eq for sockaddr_dl {} - impl fmt::Debug for sockaddr_dl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_dl") - .field("sdl_family", &self.sdl_family) - .field("sdl_index", &self.sdl_index) - .field("sdl_type", &self.sdl_type) - .field("sdl_nlen", &self.sdl_nlen) - .field("sdl_alen", &self.sdl_alen) - .field("sdl_slen", &self.sdl_slen) - // FIXME(debug): .field("sdl_data", &self.sdl_data) - .finish() - } - } impl hash::Hash for sockaddr_dl { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sdl_family.hash(state); @@ -829,17 +768,6 @@ cfg_if! { } } impl Eq for sigevent {} - impl fmt::Debug for sigevent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sigevent") - .field("sigev_notify", &self.sigev_notify) - .field("sigev_signo", &self.sigev_signo) - .field("sigev_value", &self.sigev_value) - .field("ss_sp", &self.ss_sp) - .field("sigev_notify_attributes", &self.sigev_notify_attributes) - .finish() - } - } impl hash::Hash for sigevent { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.sigev_notify.hash(state); @@ -2462,14 +2390,12 @@ const NEWDEV: c_int = 1; // sys/sendfile.h pub const SFV_FD_SELF: c_int = -2; -const_fn! { - {const} fn _CMSG_HDR_ALIGN(p: usize) -> usize { - (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1) - } +const fn _CMSG_HDR_ALIGN(p: usize) -> usize { + (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1) +} - {const} fn _CMSG_DATA_ALIGN(p: usize) -> usize { - (p + _CMSG_DATA_ALIGNMENT - 1) & !(_CMSG_DATA_ALIGNMENT - 1) - } +const fn _CMSG_DATA_ALIGN(p: usize) -> usize { + (p + _CMSG_DATA_ALIGNMENT - 1) & !(_CMSG_DATA_ALIGNMENT - 1) } f! { @@ -2477,13 +2403,13 @@ f! { _CMSG_DATA_ALIGN(cmsg.offset(1) as usize) as *mut c_uchar } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _CMSG_DATA_ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _CMSG_DATA_ALIGN(size_of::<cmsghdr>()) as c_uint + length } pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { if ((*mhdr).msg_controllen as usize) < size_of::<cmsghdr>() { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { (*mhdr).msg_control as *mut cmsghdr } @@ -2492,36 +2418,36 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); - }; + } let next = _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize + size_of::<cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } else { _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { _CMSG_HDR_ALIGN(size_of::<cmsghdr>() as usize + length as usize) as c_uint } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; @@ -2543,39 +2469,39 @@ safe_f! { unsafe { crate::sysconf(_SC_SIGRT_MIN) as c_int } } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xFF) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xFF } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7F } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0xffff) == 0xffff } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status & 0xff00) >> 8 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0xff) > 0) && (status & 0xff00 == 0) } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { ((status & 0xff) == 0x7f) && ((status & 0xff00) != 0) } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } - pub {const} fn MR_GET_TYPE(flags: c_uint) -> c_uint { + pub const fn MR_GET_TYPE(flags: c_uint) -> c_uint { flags & 0x0000ffff } } @@ -2648,9 +2574,8 @@ extern "C" { pub fn getpriority(which: c_int, who: c_int) -> c_int; pub fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn sethostname(name: *const c_char, len: c_int) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); @@ -2727,7 +2652,7 @@ extern "C" { fildes: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( file_actions: *mut posix_spawn_file_actions_t, @@ -2810,7 +2735,7 @@ extern "C" { pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); @@ -3201,6 +3126,23 @@ extern "C" { pub fn arc4random() -> u32; pub fn arc4random_buf(buf: *mut c_void, nbytes: size_t); pub fn arc4random_uniform(upper_bound: u32) -> u32; + + pub fn secure_getenv(name: *const c_char) -> *mut c_char; + + #[cfg_attr(target_os = "solaris", link_name = "__strftime_xpg7")] + pub fn strftime( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + ) -> size_t; + pub fn strftime_l( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + loc: crate::locale_t, + ) -> size_t; } #[link(name = "sendfile")] diff --git a/third_party/rust/libc/src/unix/solarish/solaris.rs b/third_party/rust/libc/src/unix/solarish/solaris.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, - PRIV_PFEXEC, PRIV_XPOLICY, + exit_status, off_t, termios, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, + PRIV_DEBUG, PRIV_PFEXEC, PRIV_XPOLICY, }; pub type door_attr_t = c_uint; @@ -59,7 +59,6 @@ s! { s_no_extra_traits! { #[repr(packed)] - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub struct door_desc_t__d_data__d_desc { pub d_descriptor: c_int, pub d_id: crate::door_id_t, @@ -70,13 +69,11 @@ s_no_extra_traits! { d_resv: [c_int; 5], /* Check out /usr/include/sys/door.h */ } - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub struct door_desc_t { pub d_attributes: door_attr_t, pub d_data: door_desc_t__d_data, } - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub struct door_arg_t { pub data_ptr: *const c_char, pub data_size: size_t, @@ -125,24 +122,6 @@ cfg_if! { impl Eq for utmpx {} - impl fmt::Debug for utmpx { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("utmpx") - .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_exit", &self.ut_exit) - .field("ut_tv", &self.ut_tv) - .field("ut_session", &self.ut_session) - .field("pad", &self.pad) - .field("ut_syslen", &self.ut_syslen) - .field("ut_host", &&self.ut_host[..]) - .finish() - } - } - impl hash::Hash for utmpx { fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ut_user.hash(state); @@ -161,6 +140,14 @@ cfg_if! { } } +// FIXME(solaris): O_DIRECT and SIGINFO are NOT available on Solaris. +// But in past they were defined here and thus other crates expected them. +// Latest version v0.29.0 of Nix crate still expects this. Since last +// version of Nix crate is almost one year ago let's define these two +// temporarily before new Nix version is released. +pub const O_DIRECT: c_int = 0x2000000; +pub const SIGINFO: c_int = 41; + pub const _UTMP_USER_LEN: usize = 32; pub const _UTMP_LINE_LEN: usize = 32; pub const _UTMP_ID_LEN: usize = 4; @@ -234,4 +221,19 @@ extern "C" { pub fn pthread_getattr_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; pub fn euidaccess(path: *const c_char, amode: c_int) -> c_int; + + pub fn openpty( + amain: *mut c_int, + asubord: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> c_int; + + pub fn forkpty( + amain: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; } diff --git a/third_party/rust/libc/src/unix/solarish/x86_64.rs b/third_party/rust/libc/src/unix/solarish/x86_64.rs @@ -91,7 +91,9 @@ s_no_extra_traits! { #[cfg(target_os = "solaris")] pub uc_xrs: solaris::xrs_t, #[cfg(target_os = "solaris")] - pub uc_filler: [c_long; 3], + pub uc_lwpid: c_uint, + #[cfg(target_os = "solaris")] + pub uc_filler: [c_long; 2], } } @@ -116,27 +118,12 @@ cfg_if! { } } impl Eq for fpregset_t {} - impl fmt::Debug for fpregset_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("fpregset_t") - .field("fp_reg_set", &self.fp_reg_set) - .finish() - } - } impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { self.gregs == other.gregs && self.fpregs == other.fpregs } } impl Eq for mcontext_t {} - impl fmt::Debug for mcontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("mcontext_t") - .field("gregs", &self.gregs) - .field("fpregs", &self.fpregs) - .finish() - } - } impl PartialEq for ucontext_t { fn eq(&self, other: &ucontext_t) -> bool { self.uc_flags == other.uc_flags @@ -148,18 +135,6 @@ cfg_if! { } } impl Eq for ucontext_t {} - impl fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) - .field("uc_sigmask", &self.uc_sigmask) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_filler", &self.uc_filler) - .finish() - } - } } } diff --git a/third_party/rust/libc/src/vxworks/mod.rs b/third_party/rust/libc/src/vxworks/mod.rs @@ -1,11 +1,10 @@ //! Interface to VxWorks C library -use core::mem::size_of; use core::ptr::null_mut; use crate::prelude::*; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum DIR {} impl Copy for DIR {} impl Clone for DIR { @@ -96,7 +95,7 @@ pub type sa_family_t = c_uchar; // mqueue.h pub type mqd_t = c_int; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum _Vx_semaphore {} impl Copy for _Vx_semaphore {} impl Clone for _Vx_semaphore { @@ -220,7 +219,7 @@ s! { pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, @@ -410,6 +409,7 @@ s_no_extra_traits! { pub struct dirent { pub d_ino: crate::ino_t, pub d_name: [c_char; _PARM_NAME_MAX as usize + 1], + pub d_type: c_uchar, } pub struct sockaddr_un { @@ -453,52 +453,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl fmt::Debug for dirent { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_name", &&self.d_name[..]) - .finish() - } - } - - impl fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_len", &self.sun_len) - .field("sun_family", &self.sun_family) - .field("sun_path", &&self.sun_path[..]) - .finish() - } - } - - impl fmt::Debug for RTP_DESC { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("RTP_DESC") - .field("status", &self.status) - .field("options", &self.options) - .field("entrAddr", &self.entrAddr) - .field("initTaskId", &self.initTaskId) - .field("parentId", &self.parentId) - .field("pathName", &&self.pathName[..]) - .field("taskCnt", &self.taskCnt) - .field("textStart", &self.textStart) - .field("textEnd", &self.textEnd) - .finish() - } - } - impl fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut fmt::Formatter) -> 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) - .field("__ss_pad2", &&self.__ss_pad2[..]) - .finish() - } - } - impl PartialEq for sa_u_t { fn eq(&self, other: &sa_u_t) -> bool { unsafe { @@ -554,7 +508,7 @@ pub const EAI_SYSTEM: c_int = 11; // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); //Clock Lib Stuff pub const CLOCK_REALTIME: c_int = 0x0; @@ -620,6 +574,9 @@ pub const ENODEV: c_int = 19; pub const ENOTDIR: c_int = 20; pub const EISDIR: c_int = 21; pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; pub const ENAMETOOLONG: c_int = 26; pub const EFBIG: c_int = 27; pub const ENOSPC: c_int = 28; @@ -628,7 +585,12 @@ pub const EROFS: c_int = 30; pub const EMLINK: c_int = 31; pub const EPIPE: c_int = 32; pub const EDEADLK: c_int = 33; +pub const ENOLCK: c_int = 34; +pub const ENOTSUP: c_int = 35; +pub const EMSGSIZE: c_int = 36; +pub const EDOM: c_int = 37; pub const ERANGE: c_int = 38; +pub const EDOOM: c_int = 39; pub const EDESTADDRREQ: c_int = 40; pub const EPROTOTYPE: c_int = 41; pub const ENOPROTOOPT: c_int = 42; @@ -655,12 +617,30 @@ pub const ENETDOWN: c_int = 62; pub const ETXTBSY: c_int = 63; pub const ELOOP: c_int = 64; pub const EHOSTUNREACH: c_int = 65; +pub const ENOTBLK: c_int = 66; +pub const EHOSTDOWN: c_int = 67; pub const EINPROGRESS: c_int = 68; pub const EALREADY: c_int = 69; pub const EWOULDBLOCK: c_int = 70; pub const ENOSYS: c_int = 71; +pub const ECANCELED: c_int = 72; +pub const ENOSR: c_int = 74; +pub const ENOSTR: c_int = 75; +pub const EPROTO: c_int = 76; +pub const EBADMSG: c_int = 77; +pub const ENODATA: c_int = 78; +pub const ETIME: c_int = 79; +pub const ENOMSG: c_int = 80; +pub const EFPOS: c_int = 81; +pub const EILSEQ: c_int = 82; pub const EDQUOT: c_int = 83; +pub const EIDRM: c_int = 84; +pub const EOVERFLOW: c_int = 85; +pub const EMULTIHOP: c_int = 86; +pub const ENOLINK: c_int = 87; pub const ESTALE: c_int = 88; +pub const EOWNERDEAD: c_int = 89; +pub const ENOTRECOVERABLE: c_int = 90; // NFS errnos: Refer to pkgs_v2/storage/fs/nfs/h/nfs/nfsCommon.h const M_nfsStat: c_int = 48 << 16; @@ -717,6 +697,7 @@ pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x0068; // FIXME(vxworks): could also be useful for TASK_DESC type pub const VX_TASK_NAME_LENGTH: c_int = 31; +pub const VX_TASK_RENAME_LENGTH: c_int = 16; // semLibCommon.h pub const S_semLib_INVALID_STATE: c_int = semErrorBase + 0x0065; @@ -778,6 +759,9 @@ pub const S_IWOTH: c_int = 0o0002; pub const S_IXOTH: c_int = 0o0001; pub const S_IRWXO: c_int = 0o0007; +pub const UTIME_OMIT: c_long = 0x3ffffffe; +pub const UTIME_NOW: c_long = 0x3fffffff; + // socket.h pub const SOL_SOCKET: c_int = 0xffff; pub const SOMAXCONN: c_int = 128; @@ -941,11 +925,34 @@ pub const SIGCONT: c_int = 19; pub const SIGCHLD: c_int = 20; pub const SIGTTIN: c_int = 21; pub const SIGTTOU: c_int = 22; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGPOLL: c_int = 32; +pub const SIGPROF: c_int = 33; +pub const SIGSYS: c_int = 34; +pub const SIGURG: c_int = 35; +pub const SIGVTALRM: c_int = 36; +pub const SIGXCPU: c_int = 37; +pub const SIGXFSZ: c_int = 38; +pub const SIGRTMIN: c_int = 48; + +pub const SIGIO: c_int = SIGRTMIN; +pub const SIGWINCH: c_int = SIGRTMIN + 5; +pub const SIGLOST: c_int = SIGRTMIN + 6; pub const SIG_BLOCK: c_int = 1; pub const SIG_UNBLOCK: c_int = 2; pub const SIG_SETMASK: c_int = 3; +pub const SA_NOCLDSTOP: c_int = 0x0001; +pub const SA_SIGINFO: c_int = 0x0002; +pub const SA_ONSTACK: c_int = 0x0004; +pub const SA_INTERRUPT: c_int = 0x0008; +pub const SA_RESETHAND: c_int = 0x0010; +pub const SA_RESTART: c_int = 0x0020; +pub const SA_NODEFER: c_int = 0x0040; +pub const SA_NOCLDWAIT: c_int = 0x0080; + pub const SI_SYNC: c_int = 0; pub const SI_USER: c_int = -1; pub const SI_QUEUE: c_int = -2; @@ -1047,7 +1054,7 @@ pub const MAP_CONTIG: c_int = 0x0020; pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum FILE {} impl Copy for FILE {} impl Clone for FILE { @@ -1055,7 +1062,7 @@ impl Clone for FILE { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { @@ -1065,19 +1072,19 @@ impl Clone for fpos_t { } f! { - pub {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1) + pub const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1) } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize) - + CMSG_ALIGN(mem::size_of::<cmsghdr>()); + + CMSG_ALIGN(size_of::<cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next <= max { (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } @@ -1085,20 +1092,20 @@ f! { if (*mhdr).msg_controllen as usize > 0 { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::<cmsghdr>() } } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::<cmsghdr>()) as isize) + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::<cmsghdr>()) as isize) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::<cmsghdr>())) as c_uint + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::<cmsghdr>()) as c_uint + length } } @@ -1231,6 +1238,7 @@ extern "C" { pub fn umask(mask: mode_t) -> mode_t; pub fn mlock(addr: *const c_void, len: size_t) -> c_int; pub fn mlockall(flags: c_int) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; pub fn munlockall() -> c_int; pub fn mmap( @@ -1242,8 +1250,12 @@ extern "C" { offset: off_t, ) -> *mut c_void; pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + pub fn truncate(path: *const c_char, length: off_t) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; @@ -1258,6 +1270,8 @@ extern "C" { pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + #[link_name = "_rtld_dlopen"] pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; @@ -1714,7 +1728,7 @@ extern "C" { pub fn getppid() -> pid_t; // wait.h - pub fn waitpid(pid: pid_t, status: *mut c_int, optons: c_int) -> pid_t; + pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; // unistd.h pub fn sysconf(attr: c_int) -> c_long; @@ -1752,13 +1766,13 @@ extern "C" { pub fn rmdir(path: *const c_char) -> c_int; // stat.h - pub fn mkdir(dirName: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdir(dirName: *const c_char, mode: mode_t) -> c_int; // stat.h - pub fn chmod(path: *const c_char, mode: crate::mode_t) -> c_int; + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; // stat.h - pub fn fchmod(attr1: c_int, attr2: crate::mode_t) -> c_int; + pub fn fchmod(attr1: c_int, attr2: mode_t) -> c_int; // unistd.h pub fn fsync(fd: c_int) -> c_int; @@ -1923,22 +1937,22 @@ extern "C" { // wait.h macros safe_f! { - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xFF00) == 0 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0xFF00) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xFF0000) != 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { status & 0xFF } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { (status >> 8) & 0xFF } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 16) & 0xFF } } diff --git a/third_party/rust/libc/src/wasi/mod.rs b/third_party/rust/libc/src/wasi/mod.rs @@ -36,20 +36,19 @@ pub type locale_t = *mut __locale_struct; s_no_extra_traits! { #[repr(align(16))] - #[allow(missing_debug_implementations)] pub struct max_align_t { priv_: [f64; 4], } } #[allow(missing_copy_implementations)] -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum FILE {} #[allow(missing_copy_implementations)] -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum DIR {} #[allow(missing_copy_implementations)] -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum __locale_struct {} s_paren! { @@ -177,7 +176,7 @@ s! { // etc., since it contains a flexible array member with a dynamic size. #[repr(C)] #[allow(missing_copy_implementations)] -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub struct dirent { pub d_ino: ino_t, pub d_type: c_uchar, @@ -362,26 +361,17 @@ pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; pub const _SC_IOV_MAX: c_int = 60; pub const _SC_SYMLOOP_MAX: c_int = 173; -cfg_if! { - if #[cfg(libc_ctest)] { - // skip these constants when this is active because `ctest` currently - // panics on parsing the constants below - } else { - // `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 - #[allow(unused_unsafe)] - pub static CLOCK_MONOTONIC: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) }; - #[allow(unused_unsafe)] - pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; - #[allow(unused_unsafe)] - pub static CLOCK_REALTIME: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; - #[allow(unused_unsafe)] - pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; - } -} +// FIXME(msrv): `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 +#[allow(unused_unsafe)] +pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) }; +#[allow(unused_unsafe)] +pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; +#[allow(unused_unsafe)] +pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; +#[allow(unused_unsafe)] +pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; pub const ABDAY_1: crate::nl_item = 0x20000; pub const ABDAY_2: crate::nl_item = 0x20001; @@ -653,7 +643,7 @@ extern "C" { newpath: *const c_char, flags: c_int, ) -> c_int; - pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn readlinkat( dirfd: c_int, pathname: *const c_char, diff --git a/third_party/rust/libc/src/windows/gnu/mod.rs b/third_party/rust/libc/src/windows/gnu/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; cfg_if! { if #[cfg(target_pointer_width = "64")] { s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], @@ -11,7 +10,6 @@ cfg_if! { } } else if #[cfg(target_pointer_width = "32")] { s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [i64; 6], diff --git a/third_party/rust/libc/src/windows/mod.rs b/third_party/rust/libc/src/windows/mod.rs @@ -29,7 +29,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))] +#[derive(Debug)] pub enum timezone {} impl Copy for timezone {} impl Clone for timezone { @@ -251,7 +251,7 @@ pub const SIG_ACK: crate::sighandler_t = 4; #[link(name = "libcmt", cfg(target_feature = "crt-static"))] extern "C" {} -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum FILE {} impl Copy for FILE {} impl Clone for FILE { @@ -259,7 +259,7 @@ impl Clone for FILE { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[derive(Debug)] pub enum fpos_t {} // FIXME(windows): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { @@ -297,6 +297,19 @@ extern "C" { pub fn isblank(c: c_int) -> c_int; pub fn tolower(c: c_int) -> c_int; pub fn toupper(c: c_int) -> c_int; + pub fn qsort( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>, + ); + pub fn qsort_s( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>, + arg: *mut c_void, + ); pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; pub fn fflush(file: *mut FILE) -> c_int; @@ -382,12 +395,30 @@ extern "C" { pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; pub fn raise(signum: c_int) -> c_int; + pub fn clock() -> clock_t; + pub fn ctime(sourceTime: *const time_t) -> *mut c_char; + pub fn difftime(timeEnd: time_t, timeStart: time_t) -> c_double; #[link_name = "_gmtime64_s"] pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> c_int; + #[link_name = "_get_daylight"] + pub fn get_daylight(hours: *mut c_int) -> errno_t; + #[link_name = "_get_dstbias"] + pub fn get_dstbias(seconds: *mut c_long) -> errno_t; + #[link_name = "_get_timezone"] + pub fn get_timezone(seconds: *mut c_long) -> errno_t; + #[link_name = "_get_tzname"] + pub fn get_tzname( + p_return_value: *mut size_t, + time_zone_name: *mut c_char, + size_in_bytes: size_t, + index: c_int, + ) -> errno_t; #[link_name = "_localtime64_s"] pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> crate::errno_t; #[link_name = "_time64"] pub fn time(destTime: *mut time_t) -> time_t; + #[link_name = "_tzset"] + pub fn tzset(); #[link_name = "_chmod"] pub fn chmod(path: *const c_char, mode: c_int) -> c_int; #[link_name = "_wchmod"]