diff --git a/Cargo.lock b/Cargo.lock index 31086945509..6b5ba3a94a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,17 +14,41 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +[[package]] +name = "aead" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" +dependencies = [ + "crypto-common 0.2.2", + "inout", +] + [[package]] name = "aes" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8" +checksum = "f1fc76eaeac4c9164506c466d4ffdd8ec9d0c5bf57ee97177c4d8eceb3a0e138" dependencies = [ "cipher", "cpubits", "cpufeatures 0.3.0", ] +[[package]] +name = "aes-gcm" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdf011db2e21ce0d575593d749db5554b47fed37aff429e4dc50bc91ac93a028" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + [[package]] name = "aho-corasick" version = "1.1.4" @@ -116,9 +140,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "approx" @@ -131,9 +155,9 @@ dependencies = [ [[package]] name = "ar_archive_writer" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb93bbb63b9c227414f6eb3a0adfddca591a8ce1e9b60661bb08969b87e340b" +checksum = "4087686b4b0a3427190bae57a1d9a478dbb2d40c5dc1bd6e2b6d797913bdd348" dependencies = [ "object", ] @@ -152,9 +176,9 @@ checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" [[package]] name = "asn1-rs" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56624a96882bb8c26d61312ae18cb45868e5a9992ea73c58e45c3101e56a1e60" +checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", @@ -230,29 +254,30 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "aws-lc-fips-sys" -version = "0.13.14" +version = "0.13.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3d619165468401dec3caa3366ebffbcb83f2f31883e5b3932f8e2dec2ddc568" +checksum = "6c0e6249c249b8916c98ebae7bc06216c8dcab3002f32872b4abe642d17063b1" dependencies = [ "bindgen 0.72.1", "cc", "cmake", "dunce", "fs_extra", + "pkg-config", "regex", ] [[package]] name = "aws-lc-rs" -version = "1.16.3" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec6fb3fe69024a75fa7e1bfb48aa6cf59706a101658ea01bfd33b2b248a038f" +checksum = "4342d8937fc7e5dd9b1c60292261c0670c882a2cd1719cfc11b1af41731e32ad" dependencies = [ "aws-lc-fips-sys", "aws-lc-sys", @@ -261,14 +286,15 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.40.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50037ee5e1e41e7b8f9d161680a725bd1626cb6f8c7e901f91f942850852fe7" +checksum = "6d9ceb1da931507a12f4fccea479dccd00da1943e1b4ae72d8e502d707361444" dependencies = [ "cc", "cmake", "dunce", "fs_extra", + "pkg-config", ] [[package]] @@ -299,7 +325,7 @@ dependencies = [ "quote", "regex", "rustc-hash", - "shlex", + "shlex 1.3.0", "syn", ] @@ -319,7 +345,7 @@ dependencies = [ "quote", "regex", "rustc-hash", - "shlex", + "shlex 1.3.0", "syn", ] @@ -367,9 +393,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" dependencies = [ "hybrid-array", ] @@ -385,20 +411,20 @@ dependencies = [ [[package]] name = "bstr" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" +checksum = "5cee35f73844aa3014bb606320a6c1f010249dbdf43342fe54b5a4f6a8ed4b79" dependencies = [ "memchr", "regex-automata", - "serde", + "serde_core", ] [[package]] name = "bumpalo" -version = "3.20.2" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" dependencies = [ "allocator-api2", ] @@ -411,9 +437,9 @@ checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" [[package]] name = "bzip2" @@ -450,14 +476,14 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.61" +version = "1.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d" +checksum = "f5d6cac793997bd970000024b2934968efe83b382de4fdcf4fcb46b6ee4ad996" dependencies = [ "find-msvc-tools", "jobserver", "libc", - "shlex", + "shlex 2.0.1", ] [[package]] @@ -483,9 +509,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chacha20" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" dependencies = [ "cfg-if", "cpufeatures 0.3.0", @@ -538,7 +564,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" dependencies = [ - "block-buffer 0.12.0", + "block-buffer 0.12.1", "crypto-common 0.2.2", "inout", ] @@ -627,9 +653,9 @@ dependencies = [ [[package]] name = "compact_str" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb1325a1cece981e8a296ab8f0f9b63ae357bd0784a9faaf548cc7b480707a" +checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" dependencies = [ "castaway", "cfg-if", @@ -641,9 +667,9 @@ dependencies = [ [[package]] name = "console" -version = "0.16.3" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d64e8af5551369d19cf50138de61f1c42074ab970f74e99be916646777f8fc87" +checksum = "4fe5f465a4f6fee88fad41b85d990f84c835335e85b5d9e6e63e0d06d28cba7c" dependencies = [ "encode_unicode", "libc", @@ -730,9 +756,9 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5c702984722ad27d12c532df8467890f922bf5b1932286906dd2bb6779982c" +checksum = "69c8702ad42c0aac8d585f1c3ffe8039bcd996898615c8948a1943e0c9661232" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -741,27 +767,27 @@ dependencies = [ [[package]] name = "cranelift-assembler-x64" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c4ebb31662e2051dcc49b7342d222405a99e951720756cc4b93315972abd67" +checksum = "3d521bdbc6098937af83ef4ab6d5c07398126bc71878f7ef4ea9499977978ef5" dependencies = [ "cranelift-assembler-x64-meta", ] [[package]] name = "cranelift-assembler-x64-meta" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "106dfc2ec96ec1c3a8a250602e936712e00a381df032f7a8ad175c8f768c03bb" +checksum = "3dde0b83164d4a497860af4236271178bc640512b067101e0853e4f74eaa4df5" dependencies = [ "cranelift-srcgen", ] [[package]] name = "cranelift-bforest" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5694aa8a2eb2571a15b3feee38d16ccaf2712200e7b5c9ae0479069bdfb46949" +checksum = "0111d110b72b4efad69a372e29e21628652fd0bcab66967e5c8350ab679affd5" dependencies = [ "cranelift-entity", "wasmtime-internal-core", @@ -769,18 +795,18 @@ dependencies = [ [[package]] name = "cranelift-bitset" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ab349d30a5fad9699440ee7ccb435374e8a8735dcca26696a4245bcefcc47e" +checksum = "cf01ecc92fc5499789d79c3b817299d5a8ddd828d31dcf0f9cc3cc66f38dbb36" dependencies = [ "wasmtime-internal-core", ] [[package]] name = "cranelift-codegen" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e95970bdb51d145c828a114a1084cb8b63e65569a51600ad398cb49fa78b062" +checksum = "6cd2563bead0090c3879a7ff7327f7550c9d59bb5d05ecc8cd7886977aa3125a" dependencies = [ "bumpalo", "cranelift-assembler-x64", @@ -792,7 +818,7 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli", - "hashbrown 0.17.0", + "hashbrown 0.17.1", "libm", "log", "regalloc2", @@ -805,9 +831,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e8414b8ecc81f89f8a3f2c5cbc785b9ed690200cd6f9d780e96a92f88879704" +checksum = "9640d250d26f9381a73dc7f9862b27928d4809119aec73be0e556612e67b6a99" dependencies = [ "cranelift-assembler-x64-meta", "cranelift-codegen-shared", @@ -817,24 +843,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631c4e5db42e6a0f9e7a68f18f7faba3692862114870c7c598aee7e0e5677e59" +checksum = "a07f156b90efc94371ddb3536f76e4ab671ad2e093bfa5511e10198cadbb0c47" [[package]] name = "cranelift-control" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c6e92c825abfbb739a4beaa5db3988f98a96a68d6ea656f562098efc142976" +checksum = "d75a76fd9dd37dcbc3d2d2e00abe3281a7e88adc035fba3b8114cc69981576ec" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e57cd185782abada9ab2606bfe88d0abc0d42d83a7d432dcf69991e17fe76e" +checksum = "2eea22522144ba08c7e7ef94bfc25d474ef016c2771974b8ab1986734ac85965" dependencies = [ "cranelift-bitset", "wasmtime-internal-core", @@ -842,9 +868,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0f17e48d15e29552e2f264d302c31a661a830196d879bbdaf4d7b2bf2f7011" +checksum = "efa2826c80dff1d93b19b3cfbcaf9fae44c78d739a98d146dd5bd89c51e14367" dependencies = [ "cranelift-codegen", "log", @@ -854,15 +880,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "407b80b46934c9dce9a6581f0e80d079b7a69e11372fb03d7dce4c7ba3fee4e3" +checksum = "e238a69b95c5415456f22189494a12db94f313bb72b6ec9cc88ddf2f1056e28e" [[package]] name = "cranelift-jit" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea72887b62db0e7c387f8c0b7af600772fd9190c6f7205fd2182b0ce10159c80" +checksum = "a7def01f2b14f97421558d1db33e396b97b97ab2ed40dedc8165ba00d13088e6" dependencies = [ "anyhow", "cranelift-codegen", @@ -881,9 +907,9 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd3b5369ba0f409b9b218e2356a71285c6e2815e187329a59db09228fd927c4" +checksum = "985df7eceefc91cb75bf7f51b32b7f1739d0fc0e25ddf023b1de407cb3c93d77" dependencies = [ "anyhow", "cranelift-codegen", @@ -892,9 +918,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a40e056e421d9a6c757983f2184f765ae1c28a51555d3877e98afc97ce5705b" +checksum = "eceb0ebd8d6aef6bb287e8d532a164b0db1c0062961211e9c22a91f67521c098" dependencies = [ "cranelift-codegen", "libc", @@ -903,9 +929,9 @@ dependencies = [ [[package]] name = "cranelift-srcgen" -version = "0.132.1" +version = "0.132.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cdbadda21e49798825a1ec795dab30bcb03235891f662b5ccf23fa45b39682f" +checksum = "004643f39a7bec553de5263d650db30e5b9caec1d5cbe065fd732b7ec9ae40d0" [[package]] name = "crc32fast" @@ -953,9 +979,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +checksum = "5181e0de7b61eb03a81e347d6dd8797bae9da5146707b51077e2d71a54ec0ceb" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -963,18 +989,18 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.18" +version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" [[package]] name = "crunchy" @@ -1010,6 +1036,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "ctr" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baaca1c4b237092596f64d571e9db6ce4109c4ef9742e27590f1709594461f21" +dependencies = [ + "cipher", +] + [[package]] name = "ctutils" version = "0.4.2" @@ -1025,6 +1060,37 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" +[[package]] +name = "defmt" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "defmt-parser" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" +dependencies = [ + "thiserror", +] + [[package]] name = "der" version = "0.7.10" @@ -1079,9 +1145,6 @@ name = "deranged" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -dependencies = [ - "powerfmt", -] [[package]] name = "derive-where" @@ -1110,7 +1173,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.0", + "block-buffer 0.12.1", "const-oid 0.10.2", "crypto-common 0.2.2", "ctutils", @@ -1139,9 +1202,9 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", @@ -1174,9 +1237,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" [[package]] name = "encode_unicode" @@ -1192,9 +1255,9 @@ checksum = "869b0adbda23651a9c5c0c3d270aac9fcb52e8622a8f2b17e57802d7791962f2" [[package]] name = "env_filter" -version = "1.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e90c2accc4b07a8456ea0debdc2e7587bdd890680d71173a15d4ae604f6eef" +checksum = "900d271a03799a1ee8d1ca9b19893b48ca674a9284fefcfb85f05e74ed314217" dependencies = [ "log", "regex", @@ -1202,9 +1265,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.10" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0621c04f2196ac3f488dd583365b9c09be011a4ab8b9f37248ffcc8f6198b56a" +checksum = "de671bd27a75a797dc9ae289ba1e77276e75e2026408aab65185384e2d5cd3f6" dependencies = [ "anstream", "anstyle", @@ -1452,6 +1515,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "ghash" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5" +dependencies = [ + "polyval", +] + [[package]] name = "gimli" version = "0.33.0" @@ -1502,9 +1574,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "foldhash", ] @@ -1553,9 +1625,9 @@ dependencies = [ [[package]] name = "hybrid-array" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9155a582abd142abc056962c29e3ce5ff2ad5469f4246b537ed42c5deba857da" +checksum = "818356c5132c1fede50f837ca96afbe78ff42413047f4abb886217845e1b6c8c" dependencies = [ "typenum", ] @@ -1723,7 +1795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.17.0", + "hashbrown 0.17.1", ] [[package]] @@ -1807,10 +1879,11 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jiff" -version = "0.2.24" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00b5dbd620d61dfdcb6007c9c1f6054ebd75319f163d886a9055cec1155073d" +checksum = "ccfe6121cbe750cf81efa362d85c0bde7ea298ec43092d3a193baca59cdbd634" dependencies = [ + "defmt", "jiff-static", "log", "portable-atomic", @@ -1820,9 +1893,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.24" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e000de030ff8022ea1da3f466fbb0f3a809f5e51ed31f6dd931c35181ad8e6d7" +checksum = "e165e897f662d428f3cd3828a919dbe067c2d42bb1031eede74ef9d27ecdedd2" dependencies = [ "proc-macro2", "quote", @@ -1880,23 +1953,22 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" dependencies = [ - "getrandom 0.3.4", + "getrandom 0.4.3", "libc", ] [[package]] name = "js-sys" -version = "0.3.97" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1840c94c045fbcf8ba2812c95db44499f7c64910a912551aaaa541decebcacf" +checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" dependencies = [ "cfg-if", "futures-util", - "once_cell", "wasm-bindgen", ] @@ -1965,9 +2037,9 @@ checksum = "803ec87c9cfb29b9d2633f20cba1f488db3fd53f2158b1024cbefb47ba05d413" [[package]] name = "libbz2-rs-sys" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a6a8c165077efc8f3a971534c50ea6a1a18b329ef4a66e897a7e3a1494565f" +checksum = "34b357333733e8260735ba5894eb928c02ecc69c78715f01a8019e7fa7f2db4c" [[package]] name = "libc" @@ -2022,9 +2094,9 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" +checksum = "c943259e342f1e06ff2da7a83eabdfe7f92ce10262688dbf1895ff0b3e6e4652" dependencies = [ "libc", ] @@ -2042,9 +2114,9 @@ dependencies = [ [[package]] name = "libz-rs-sys" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deaad727e11899800b9a177af14682bfa5d5d96fa525a6c9bd13e650c019f40" +checksum = "5c12cd6e7e66c601f22d849241e2257b38b4685a34b41401f4aefdd9c431c1c6" dependencies = [ "zlib-rs", ] @@ -2072,9 +2144,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "lz4_flex" @@ -2203,9 +2275,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.10" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "714098028fe011992e1c3962653c96b2d578c4b4bce9036e15ff220319b1e0e3" +checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" dependencies = [ "libc", ] @@ -2291,9 +2363,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" dependencies = [ "num-integer", "num-traits", @@ -2310,9 +2382,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] name = "num-integer" @@ -2432,9 +2504,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "openssl-src" -version = "300.6.0+3.6.2" +version = "300.6.1+3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e8cbfd3a4a8c8f089147fd7aaa33cf8c7450c4d09f8f80698a0cf093abeff4" +checksum = "46eb8fb9fb3b61ce1c0f8a026c4c1a0714d3a9e138e7fbde78753ce2babc3846" dependencies = [ "cc", ] @@ -2496,7 +2568,7 @@ dependencies = [ [[package]] name = "parking_lot_core" version = "0.9.12" -source = "git+https://github.com/youknowone/parking_lot?branch=rustpython#4392edbe879acc9c0dd94eda53d2205d3ab912c9" +source = "git+https://github.com/youknowone/parking_lot?branch=rustpython#f4ee53a7b803354a8f0a6de2f28e93fc141240bf" dependencies = [ "cfg-if", "libc", @@ -2628,11 +2700,12 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pkcs5" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279a91971a1d8eb1260a30938eae3be9cb67b472dffecb222fbbbe2fd2dc1453" +checksum = "63d440a804ec8d6fafbb6b84471e013286658d373248927692ab3366686220ca" dependencies = [ "aes", + "aes-gcm", "cbc", "der 0.8.0", "pbkdf2", @@ -2699,6 +2772,17 @@ dependencies = [ "syn", ] +[[package]] +name = "polyval" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfc63250416fea14f5749b90725916a6c903f599d51cb635aa7a52bfd03eede" +dependencies = [ + "cpubits", + "cpufeatures 0.3.0", + "universal-hash", +] + [[package]] name = "portable-atomic" version = "1.13.1" @@ -2853,9 +2937,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" dependencies = [ "proc-macro2", ] @@ -2926,9 +3010,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ "chacha20", "getrandom 0.4.3", @@ -2962,9 +3046,9 @@ checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" [[package]] name = "rapidhash" -version = "4.4.1" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e48930979c155e2f33aa36ab3119b5ee81332beb6482199a8ecd6029b80b59" +checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" dependencies = [ "rustversion", ] @@ -3043,7 +3127,7 @@ checksum = "de2c52737737f8609e94f975dee22854a2d5c125772d4b1cf292120f4d45c186" dependencies = [ "allocator-api2", "bumpalo", - "hashbrown 0.17.0", + "hashbrown 0.17.1", "log", "rustc-hash", "smallvec", @@ -3051,9 +3135,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.12.3" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" dependencies = [ "aho-corasick", "memchr", @@ -3074,9 +3158,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "region" @@ -3127,9 +3211,9 @@ dependencies = [ [[package]] name = "rustc-hash" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" [[package]] name = "rustc_version" @@ -3164,9 +3248,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.40" +version = "0.23.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f" dependencies = [ "aws-lc-rs", "once_cell", @@ -3209,9 +3293,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.14.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046" dependencies = [ "zeroize", ] @@ -3412,12 +3496,15 @@ name = "rustpython-host_env" version = "0.5.0" dependencies = [ "bitflags 2.13.0", + "dns-lookup", + "gethostname", "getrandom 0.4.3", "junction", "libc", "libffi", "libloading 0.9.0", - "memmap2 0.9.10", + "mac_address", + "memmap2 0.9.11", "nix 0.31.3", "num-traits", "num_cpus", @@ -3425,8 +3512,12 @@ dependencies = [ "paste", "rustix", "rustpython-wtf8", + "rustyline", "schannel", + "socket2", + "system-configuration", "termios", + "which", "widestring", "windows-sys 0.61.2", ] @@ -3455,7 +3546,7 @@ dependencies = [ "is-macro", "lexical-parse-float", "num-traits", - "rand 0.10.1", + "rand 0.10.2", "rustpython-unicode", "rustpython-wtf8", ] @@ -3563,12 +3654,10 @@ dependencies = [ "csv-core", "der 0.8.0", "digest 0.11.3", - "dns-lookup", "dyn-clone", "flame", "flate2", "foreign-types-shared", - "gethostname", "hex", "hmac", "indexmap", @@ -3577,7 +3666,6 @@ dependencies = [ "libc", "libsqlite3-sys", "libz-rs-sys", - "mac_address", "malachite-bigint", "md-5", "memchr", @@ -3596,7 +3684,7 @@ dependencies = [ "phf 0.14.0", "pkcs8", "pymath", - "rand 0.10.1", + "rand 0.10.2", "rapidhash", "rustls", "rustls-native-certs", @@ -3616,8 +3704,6 @@ dependencies = [ "sha2", "sha3", "shake", - "socket2", - "system-configuration", "tcl-sys", "tk-sys", "uuid", @@ -3695,7 +3781,6 @@ dependencies = [ "rustpython-ruff_text_size", "rustpython-sre_engine", "rustpython-unicode", - "rustyline", "scopeguard", "serde_core", "static_assertions", @@ -3705,7 +3790,6 @@ dependencies = [ "thiserror", "timsort", "wasm-bindgen", - "which", "widestring", "writeable", ] @@ -3740,9 +3824,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] name = "rustyline" @@ -3898,9 +3982,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", @@ -3987,6 +4071,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + [[package]] name = "signature" version = "2.2.0" @@ -4038,9 +4128,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "socket2" @@ -4116,9 +4206,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.117" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -4250,12 +4340,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.47" +version = "0.3.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +checksum = "18dfaaeddcb932337b5e7866ee7d0ce9b76d2fd092997146f187ec09b4558a50" dependencies = [ "deranged", - "itoa", "num-conv", "powerfmt", "serde_core", @@ -4265,15 +4354,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.27" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +checksum = "c431b87111666e491a90baa837f914fb45cd5dc3c268591b0220ff5057f2085f" dependencies = [ "num-conv", "time-core", @@ -4398,9 +4487,9 @@ checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" [[package]] name = "typenum" -version = "1.20.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" [[package]] name = "unicode-ident" @@ -4419,9 +4508,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.13.2" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-width" @@ -4471,6 +4560,16 @@ dependencies = [ "rand 0.8.6", ] +[[package]] +name = "universal-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" +dependencies = [ + "crypto-common 0.2.2", + "ctutils", +] + [[package]] name = "untrusted" version = "0.9.0" @@ -4497,9 +4596,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.23.3" +version = "1.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "144d6b123cef80b301b8f72a9e2ca4370ddec21950d0a103dd22c437006d2db7" +checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53" dependencies = [ "atomic", "js-sys", @@ -4536,18 +4635,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.3+wasi-0.2.9" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.120" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df52b6d9b87e0c74c9edfa1eb2d9bf85e5d63515474513aa50fa181b3c4f5db1" +checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" dependencies = [ "cfg-if", "once_cell", @@ -4558,9 +4657,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.70" +version = "0.4.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af934872acec734c2d80e6617bbb5ff4f12b052dd8e6332b0817bce889516084" +checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" dependencies = [ "js-sys", "wasm-bindgen", @@ -4568,9 +4667,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.120" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b1041f495fb322e64aca85f5756b2172e35cd459376e67f2a6c9dffcedb103" +checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4578,9 +4677,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.120" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dcd0ff20416988a18ac686d4d4d0f6aae9ebf08a389ff5d29012b05af2a1b41" +checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" dependencies = [ "bumpalo", "proc-macro2", @@ -4591,28 +4690,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.120" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49757b3c82ebf16c57d69365a142940b384176c24df52a087fb748e2085359ea" +checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" dependencies = [ "unicode-ident", ] [[package]] name = "wasmtime-internal-core" -version = "45.0.1" +version = "45.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "110bf85122cd451d3b9ff67f8911d428ec9b729208abe950a0333c3244660e88" +checksum = "3073c03f97f871fe6400e68621c863b93ba79296f8e570285231952d23fcc804" dependencies = [ - "hashbrown 0.17.0", + "hashbrown 0.17.1", "libm", ] [[package]] name = "wasmtime-internal-jit-icache-coherence" -version = "45.0.1" +version = "45.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa6818a4864719772680694f4e4649a8600bb5efcf71111ebaf7419b266463e8" +checksum = "37dee05e8c35759826f6b926cd949c51f771b6a58619d8e60c63c3f3d3e5e59b" dependencies = [ "cfg-if", "libc", @@ -4622,9 +4721,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.97" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eadbac71025cd7b0834f20d1fe8472e8495821b4e9801eb0a60bd1f19827602" +checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141" dependencies = [ "js-sys", "wasm-bindgen", @@ -4632,9 +4731,9 @@ dependencies = [ [[package]] name = "webpki-root-certs" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31141ce3fc3e300ae89b78c0dd67f9708061d1d2eda54b8209346fd6be9a92c" +checksum = "0d46a5a140e6f7afeccd8eae97eff335163939eac8b929834875168b29b3d267" dependencies = [ "rustls-pki-types", ] @@ -4659,9 +4758,9 @@ dependencies = [ [[package]] name = "wide" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9479f84a757f819cfab37295955906479181395de83add28f74975fde083141" +checksum = "dfdfe6a32973f2d1b268b8895845a8a96cac2f0191e72c27cc929036060dbf89" dependencies = [ "bytemuck", "safe_arch", @@ -4921,9 +5020,9 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0" +checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" [[package]] name = "winresource" @@ -5022,9 +5121,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -5045,18 +5144,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +checksum = "75726053136156d419e285b9b7eddaaea9e3fea6ce32eed44a89901f0bd98de1" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +checksum = "4714fd92cf900833d49538023a9b3915155210801d1c1169eba513b2addefd71" dependencies = [ "proc-macro2", "quote", @@ -5065,9 +5164,9 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" dependencies = [ "zerofrom-derive", ] @@ -5086,18 +5185,18 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" dependencies = [ "proc-macro2", "quote", @@ -5141,9 +5240,9 @@ dependencies = [ [[package]] name = "zlib-rs" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "977347db8caa080403f6b6b7c1cda9479a8e869316f7e13a59b19076a40f94e3" +checksum = "5431d5661c32445236631278f27946e444ddafe4684cac70b185272d4f9c52d5" [[package]] name = "zmij" diff --git a/crates/host_env/Cargo.toml b/crates/host_env/Cargo.toml index 91a56ea91df..3beda890bb4 100644 --- a/crates/host_env/Cargo.toml +++ b/crates/host_env/Cargo.toml @@ -27,6 +27,16 @@ rustix = { workspace = true } [target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies] num_cpus = "1.17.0" +[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32", target_os = "redox")))'.dependencies] +mac_address = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +dns-lookup = { workspace = true } +gethostname = { workspace = true } +rustyline = { workspace = true } +socket2 = { workspace = true, features = ["all"] } +which = { workspace = true } + [target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "redox")))'.dependencies] termios = { workspace = true } @@ -37,6 +47,9 @@ libloading = "0.9" [target.'cfg(all(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"), not(any(target_env = "musl", target_env = "sgx"))))'.dependencies] libffi = { workspace = true, features = ["system"] } +[target.'cfg(target_os = "macos")'.dependencies] +system-configuration = { workspace = true } + [target.'cfg(windows)'.dependencies] junction = { workspace = true } schannel = { workspace = true } diff --git a/crates/host_env/src/faulthandler.rs b/crates/host_env/src/faulthandler.rs index 3afbdebb42b..5b19359167b 100644 --- a/crates/host_env/src/faulthandler.rs +++ b/crates/host_env/src/faulthandler.rs @@ -12,6 +12,10 @@ use alloc::vec::Vec; #[cfg(unix)] use parking_lot::Mutex; + +#[cfg(unix)] +pub use libc::{SA_NODEFER, c_int}; +pub use libc::{SIGFPE, SIGSEGV}; #[cfg(windows)] use windows_sys::Win32::System::{ Diagnostics::Debug::{ diff --git a/crates/host_env/src/fcntl.rs b/crates/host_env/src/fcntl.rs index 2467a8727bc..6fb974ba514 100644 --- a/crates/host_env/src/fcntl.rs +++ b/crates/host_env/src/fcntl.rs @@ -5,6 +5,32 @@ use std::os::fd::BorrowedFd; use crate::os::CheckLibcResult; +pub use libc::{F_GETFD, F_GETFL, F_SETFD, F_SETFL, FD_CLOEXEC}; + +#[cfg(not(target_os = "wasi"))] +pub use libc::{F_DUPFD, F_DUPFD_CLOEXEC, F_GETLK, F_SETLK, F_SETLKW}; + +#[cfg(not(any(target_os = "wasi", target_os = "redox")))] +pub use libc::{F_GETOWN, F_RDLCK, F_SETOWN, F_UNLCK, F_WRLCK, LOCK_EX, LOCK_NB, LOCK_SH, LOCK_UN}; + +#[cfg(target_vendor = "apple")] +pub use libc::{F_FULLFSYNC, F_NOCACHE}; + +#[cfg(target_os = "freebsd")] +pub use libc::{F_DUP2FD, F_DUP2FD_CLOEXEC}; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use libc::{F_OFD_GETLK, F_OFD_SETLK, F_OFD_SETLKW}; + +#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] +pub use libc::{ + F_ADD_SEALS, F_GET_SEALS, F_GETLEASE, F_GETPIPE_SZ, F_NOTIFY, F_SEAL_GROW, F_SEAL_SEAL, + F_SEAL_SHRINK, F_SEAL_WRITE, F_SETLEASE, F_SETPIPE_SZ, +}; + +#[cfg(any(target_os = "dragonfly", target_os = "netbsd", target_vendor = "apple"))] +pub use libc::F_GETPATH; + pub fn normalize_ioctl_request(request: i64) -> libc::c_ulong { (request as u32) as libc::c_ulong } diff --git a/crates/host_env/src/fileutils.rs b/crates/host_env/src/fileutils.rs index c9e366e3dd5..5cfe3f1d757 100644 --- a/crates/host_env/src/fileutils.rs +++ b/crates/host_env/src/fileutils.rs @@ -442,10 +442,22 @@ pub mod windows { } } +/// C `FILE *` handle as returned by [`fopen`] and consumed by [`fclose`]. +pub type CFile = libc::FILE; + +/// Close a file opened with [`fopen`]. +/// +/// # Safety +/// `fp` must be a non-null pointer returned by [`fopen`] and must not have been +/// closed already. +pub unsafe fn fclose(fp: *mut CFile) -> core::ffi::c_int { + unsafe { libc::fclose(fp) } +} + // _Py_fopen_obj in cpython (Python/fileutils.c:1757-1835) // Open a file using std::fs::File and convert to FILE* // Automatically handles path encoding and EINTR retries -pub fn fopen(path: &std::path::Path, mode: &str) -> std::io::Result<*mut libc::FILE> { +pub fn fopen(path: &std::path::Path, mode: &str) -> std::io::Result<*mut CFile> { use alloc::ffi::CString; use std::fs::File; diff --git a/crates/host_env/src/fs.rs b/crates/host_env/src/fs.rs index 911bd4575b9..01040e73ed5 100644 --- a/crates/host_env/src/fs.rs +++ b/crates/host_env/src/fs.rs @@ -1,7 +1,7 @@ use std::{ fs::{self, File, Metadata, ReadDir}, io, - path::Path, + path::{Path, PathBuf}, }; pub fn open(path: impl AsRef) -> io::Result { @@ -44,10 +44,16 @@ pub fn open_write(path: impl AsRef) -> io::Result { fs::OpenOptions::new().write(true).open(path) } -pub fn canonicalize(path: impl AsRef) -> io::Result { +pub fn canonicalize(path: impl AsRef) -> io::Result { fs::canonicalize(path) } +/// Resolve `binary_name` to an absolute path by searching `PATH` (and `PATHEXT` on Windows). +#[cfg(not(target_arch = "wasm32"))] +pub fn which>(binary_name: T) -> Option { + ::which::which(binary_name).ok() +} + #[cfg(windows)] pub fn open_write_with_custom_flags(path: impl AsRef, flags: u32) -> io::Result { use std::os::windows::fs::OpenOptionsExt; diff --git a/crates/host_env/src/grp.rs b/crates/host_env/src/grp.rs index 131369ce949..54afe8aa54d 100644 --- a/crates/host_env/src/grp.rs +++ b/crates/host_env/src/grp.rs @@ -1,5 +1,7 @@ use std::io; +pub use libc::gid_t; + pub struct Group { pub name: String, pub passwd: String, diff --git a/crates/host_env/src/lib.rs b/crates/host_env/src/lib.rs index 15f816ea8f4..4d123e7e0db 100644 --- a/crates/host_env/src/lib.rs +++ b/crates/host_env/src/lib.rs @@ -30,6 +30,7 @@ pub mod fileutils; pub mod fs; #[cfg(any(unix, windows))] pub mod locale; +pub mod readline; #[cfg(windows)] pub mod windows; @@ -67,6 +68,10 @@ pub mod time; #[cfg(windows)] pub mod cert_store; +#[cfg(target_os = "macos")] +pub mod system_configuration { + pub use ::system_configuration::*; +} #[cfg(any(unix, windows))] pub mod faulthandler; #[cfg(any(unix, windows))] diff --git a/crates/host_env/src/locale.rs b/crates/host_env/src/locale.rs index 52fa7904421..6363515081c 100644 --- a/crates/host_env/src/locale.rs +++ b/crates/host_env/src/locale.rs @@ -1,6 +1,23 @@ use alloc::vec::Vec; use core::{ffi::CStr, ptr}; +pub use libc::{LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME}; + +#[cfg(all(unix, not(any(target_os = "ios", target_os = "redox"))))] +pub use libc::LC_MESSAGES; + +#[cfg(all( + unix, + not(any(target_os = "ios", target_os = "android", target_os = "redox")) +))] +pub use libc::{ + ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4, ABDAY_5, ABDAY_6, ABDAY_7, ABMON_1, ABMON_2, ABMON_3, + ABMON_4, ABMON_5, ABMON_6, ABMON_7, ABMON_8, ABMON_9, ABMON_10, ABMON_11, ABMON_12, ALT_DIGITS, + AM_STR, CODESET, CRNCYSTR, D_FMT, D_T_FMT, DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7, + ERA, ERA_D_FMT, ERA_D_T_FMT, ERA_T_FMT, MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, MON_8, + MON_9, MON_10, MON_11, MON_12, NOEXPR, PM_STR, RADIXCHAR, T_FMT, T_FMT_AMPM, THOUSEP, YESEXPR, +}; + #[cfg(windows)] #[repr(C)] struct RawLconv { diff --git a/crates/host_env/src/mmap.rs b/crates/host_env/src/mmap.rs index ce5575061e3..c1071a716e4 100644 --- a/crates/host_env/src/mmap.rs +++ b/crates/host_env/src/mmap.rs @@ -59,7 +59,6 @@ pub use libc::MAP_STACK; #[cfg(target_os = "freebsd")] pub use libc::{MADV_AUTOSYNC, MADV_CORE, MADV_NOCORE, MADV_NOSYNC, MADV_PROTECT}; -#[cfg(windows)] pub use libc::EOVERFLOW; #[cfg(windows)] diff --git a/crates/host_env/src/multiprocessing.rs b/crates/host_env/src/multiprocessing.rs index 4e79b2573cb..0030245dbb4 100644 --- a/crates/host_env/src/multiprocessing.rs +++ b/crates/host_env/src/multiprocessing.rs @@ -13,7 +13,7 @@ use alloc::ffi::CString; use std::io; #[cfg(unix)] -use libc::sem_t; +pub use libc::{sem_t, timespec}; #[cfg(unix)] use nix::errno::Errno; diff --git a/crates/host_env/src/posix.rs b/crates/host_env/src/posix.rs index 1239d3526c4..f15dc576d47 100644 --- a/crates/host_env/src/posix.rs +++ b/crates/host_env/src/posix.rs @@ -12,6 +12,8 @@ use std::path::Path; use crate::crt_fd; +pub use libc::{c_char, pid_t}; + pub struct UnameInfo { pub sysname: String, pub nodename: String, diff --git a/crates/vm/src/readline.rs b/crates/host_env/src/readline.rs similarity index 86% rename from crates/vm/src/readline.rs rename to crates/host_env/src/readline.rs index 53475358ce6..1015ec093aa 100644 --- a/crates/vm/src/readline.rs +++ b/crates/host_env/src/readline.rs @@ -106,34 +106,18 @@ pub mod rustyline_readline { } pub fn load_history(&mut self, path: &Path) -> OtherResult<()> { - #[cfg(not(feature = "host_env"))] - { - let _ = path; - Err(io::Error::other("history requires the `host_env` feature").into()) - } - #[cfg(feature = "host_env")] - { - self.repl.load_history(path)?; - Ok(()) - } + self.repl.load_history(path)?; + Ok(()) } pub fn save_history(&mut self, path: &Path) -> OtherResult<()> { - #[cfg(not(feature = "host_env"))] - { - let _ = path; - Err(io::Error::other("history requires the `host_env` feature").into()) - } - #[cfg(feature = "host_env")] + if !path.exists() + && let Some(parent) = path.parent() { - if !path.exists() - && let Some(parent) = path.parent() - { - crate::host_env::fs::create_dir_all(parent)?; - } - self.repl.save_history(path)?; - Ok(()) + crate::fs::create_dir_all(parent)?; } + self.repl.save_history(path)?; + Ok(()) } pub fn add_history_entry(&mut self, entry: &str) -> OtherResult<()> { diff --git a/crates/host_env/src/resource.rs b/crates/host_env/src/resource.rs index 587428fe9b0..a0ba79b1b6b 100644 --- a/crates/host_env/src/resource.rs +++ b/crates/host_env/src/resource.rs @@ -2,6 +2,40 @@ use std::io; use crate::os::CheckLibcResult; +pub use libc::{ + RLIM_INFINITY, RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_MEMLOCK, + RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_STACK, c_long, rlim_t, rlimit, timeval, +}; + +#[cfg(target_os = "android")] +pub use libc::RLIM_NLIMITS; + +#[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))] +pub use libc::{RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_SIGPENDING}; + +#[cfg(target_os = "linux")] +pub use libc::RLIMIT_RTTIME; + +#[cfg(any( + target_os = "freebsd", + target_os = "netbsd", + target_os = "solaris", + target_os = "illumos" +))] +pub use libc::RLIMIT_SBSIZE; + +#[cfg(any(target_os = "freebsd", target_os = "solaris", target_os = "illumos"))] +pub use libc::{RLIMIT_NPTS, RLIMIT_SWAP}; + +#[cfg(any(target_os = "solaris", target_os = "illumos"))] +pub use libc::RLIMIT_VMEM; + +#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "freebsd"))] +pub use libc::RUSAGE_THREAD; + +#[cfg(not(any(target_os = "windows", target_os = "redox")))] +pub use libc::{RUSAGE_CHILDREN, RUSAGE_SELF}; + #[derive(Debug, Clone, Copy)] pub struct RUsage { pub ru_utime: libc::timeval, diff --git a/crates/host_env/src/select.rs b/crates/host_env/src/select.rs index 385a6a110b2..3191f8d97c0 100644 --- a/crates/host_env/src/select.rs +++ b/crates/host_env/src/select.rs @@ -1,6 +1,16 @@ use core::mem::MaybeUninit; use std::io; +#[cfg(unix)] +pub use libc::{EINTR, FD_SETSIZE, POLLERR, POLLHUP, POLLIN, POLLNVAL, POLLOUT, POLLPRI}; + +#[cfg(any(target_os = "linux", target_os = "android", target_os = "redox"))] +pub use libc::{ + EPOLL_CLOEXEC, EPOLLERR, EPOLLET, EPOLLEXCLUSIVE, EPOLLHUP, EPOLLIN, EPOLLMSG, EPOLLONESHOT, + EPOLLOUT, EPOLLPRI, EPOLLRDBAND, EPOLLRDHUP, EPOLLRDNORM, EPOLLWAKEUP, EPOLLWRBAND, + EPOLLWRNORM, +}; + #[cfg(unix)] pub mod platform { pub use libc::pollfd; diff --git a/crates/host_env/src/shm.rs b/crates/host_env/src/shm.rs index 78e7d3921bc..b50e460b79a 100644 --- a/crates/host_env/src/shm.rs +++ b/crates/host_env/src/shm.rs @@ -3,6 +3,8 @@ use std::io; use crate::os::CheckLibcResult; +pub use libc::mode_t; + pub fn shm_open(name: &CStr, flags: libc::c_int, mode: libc::c_uint) -> io::Result { #[cfg(target_os = "freebsd")] let mode = mode.try_into().unwrap(); diff --git a/crates/host_env/src/socket.rs b/crates/host_env/src/socket.rs index c409132a725..af4af2717cd 100644 --- a/crates/host_env/src/socket.rs +++ b/crates/host_env/src/socket.rs @@ -7,6 +7,43 @@ use std::os::fd::AsRawFd; #[cfg(unix)] use std::{io, os::fd::BorrowedFd}; +/// Returns the system's hostname. +#[cfg(not(target_arch = "wasm32"))] +pub fn hostname() -> std::ffi::OsString { + gethostname::gethostname() +} + +#[cfg(not(target_arch = "wasm32"))] +pub use ::dns_lookup as dns; +#[cfg(not(target_arch = "wasm32"))] +pub use ::socket2 as raw; + +/// Returns the first non-loopback MAC address as 6 bytes, or `None` when no +/// MAC address is available or the lookup fails. +#[cfg(not(any( + target_os = "ios", + target_os = "android", + target_os = "windows", + target_arch = "wasm32", + target_os = "redox" +)))] +pub fn mac_address() -> Option<[u8; 6]> { + mac_address::get_mac_address() + .ok() + .flatten() + .map(|m| m.bytes()) +} + +#[cfg(unix)] +pub use libc::{AF_UNIX, SOCK_STREAM, sa_family_t, sockaddr_storage, socklen_t}; + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub use libc::{AF_ALG, AF_CAN}; + +// bionic (Android) does not define the CAN/ALG sockaddr structs. +#[cfg(target_os = "linux")] +pub use libc::{sockaddr_alg, sockaddr_can}; + #[cfg(all(unix, not(target_os = "redox")))] pub fn sethostname(hostname: &str) -> io::Result<()> { nix::unistd::sethostname(hostname).map_err(io::Error::from) diff --git a/crates/host_env/src/syslog.rs b/crates/host_env/src/syslog.rs index 8820b8f1c5d..2ba38377326 100644 --- a/crates/host_env/src/syslog.rs +++ b/crates/host_env/src/syslog.rs @@ -3,6 +3,16 @@ use core::ffi::CStr; use parking_lot::RwLock; use std::{os::raw::c_char, sync::OnceLock}; +pub use libc::{ + LOG_ALERT, LOG_AUTH, LOG_CONS, LOG_CRIT, LOG_DAEMON, LOG_DEBUG, LOG_EMERG, LOG_ERR, LOG_INFO, + LOG_KERN, LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, + LOG_LOCAL7, LOG_LPR, LOG_MAIL, LOG_NDELAY, LOG_NEWS, LOG_NOTICE, LOG_NOWAIT, LOG_ODELAY, + LOG_PID, LOG_SYSLOG, LOG_USER, LOG_UUCP, LOG_WARNING, +}; + +#[cfg(not(target_os = "redox"))] +pub use libc::{LOG_AUTHPRIV, LOG_CRON, LOG_PERROR}; + #[derive(Debug)] enum GlobalIdent { Explicit(Box), diff --git a/crates/host_env/src/termios.rs b/crates/host_env/src/termios.rs index 074d03a455b..0a96078be94 100644 --- a/crates/host_env/src/termios.rs +++ b/crates/host_env/src/termios.rs @@ -1,5 +1,55 @@ pub type Termios = ::termios::Termios; +#[cfg(any(target_os = "illumos", target_os = "solaris"))] +pub use libc::{CSTART, CSTOP, CSWTCH}; + +#[cfg(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd" +))] +pub use libc::{FIOASYNC, TIOCGETD, TIOCSETD}; + +pub use libc::{FIOCLEX, FIONBIO, TIOCGWINSZ, TIOCSWINSZ}; + +#[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd" +))] +pub use libc::{ + FIONCLEX, FIONREAD, TIOCEXCL, TIOCM_CAR, TIOCM_CD, TIOCM_CTS, TIOCM_DSR, TIOCM_DTR, TIOCM_LE, + TIOCM_RI, TIOCM_RNG, TIOCM_RTS, TIOCM_SR, TIOCM_ST, TIOCMBIC, TIOCMBIS, TIOCMGET, TIOCMSET, + TIOCNXCL, TIOCSCTTY, +}; + +#[cfg(any(target_os = "android", target_os = "linux"))] +pub use libc::{ + IBSHIFT, TCFLSH, TCGETA, TCGETS, TCSBRK, TCSETA, TCSETAF, TCSETAW, TCSETS, TCSETSF, TCSETSW, + TCXONC, TIOCGSERIAL, TIOCGSOFTCAR, TIOCINQ, TIOCLINUX, TIOCSSOFTCAR, XTABS, +}; + +#[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos" +))] +pub use libc::{TIOCCONS, TIOCGPGRP, TIOCOUTQ, TIOCSPGRP, TIOCSTI}; + +#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos"))] +pub use libc::{ + TIOCNOTTY, TIOCPKT, TIOCPKT_DATA, TIOCPKT_DOSTOP, TIOCPKT_FLUSHREAD, TIOCPKT_FLUSHWRITE, + TIOCPKT_NOSTOP, TIOCPKT_START, TIOCPKT_STOP, +}; + #[cfg(any( target_os = "android", target_os = "freebsd", diff --git a/crates/stdlib/Cargo.toml b/crates/stdlib/Cargo.toml index 1ba6148e8cf..1e071869549 100644 --- a/crates/stdlib/Cargo.toml +++ b/crates/stdlib/Cargo.toml @@ -92,14 +92,10 @@ chrono.workspace = true # uuid [target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32", target_os = "redox")))'.dependencies] -mac_address = { workspace = true } uuid = { workspace = true, features = ["v1"] } # mmap + socket dependencies [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -gethostname = { workspace = true } -socket2 = { workspace = true, features = ["all"] } -dns-lookup = { workspace = true } # OpenSSL dependencies (optional, for ssl-openssl feature) openssl = { workspace = true, optional = true } @@ -129,9 +125,6 @@ xz-sys = { workspace = true } paste = { workspace = true } widestring = { workspace = true } -[target.'cfg(target_os = "macos")'.dependencies] -system-configuration = { workspace = true } - [dev-dependencies] insta = { workspace = true } rustpython-pylib = { workspace = true, features = [ "freeze-stdlib" ] } diff --git a/crates/stdlib/src/faulthandler.rs b/crates/stdlib/src/faulthandler.rs index e890cecfac4..3717c18b78f 100644 --- a/crates/stdlib/src/faulthandler.rs +++ b/crates/stdlib/src/faulthandler.rs @@ -373,7 +373,7 @@ mod decl { // faulthandler_fatal_error #[cfg(unix)] - extern "C" fn faulthandler_fatal_error(signum: libc::c_int) { + extern "C" fn faulthandler_fatal_error(signum: core::ffi::c_int) { let save_errno = get_errno(); if !FATAL_ERROR.enabled.load(Ordering::Relaxed) { @@ -410,7 +410,7 @@ mod decl { // faulthandler_fatal_error for Windows #[cfg(windows)] - extern "C" fn faulthandler_fatal_error(signum: libc::c_int) { + extern "C" fn faulthandler_fatal_error(signum: core::ffi::c_int) { let save_errno = get_errno(); if !FATAL_ERROR.enabled.load(Ordering::Relaxed) { @@ -479,7 +479,7 @@ mod decl { // Disable SIGSEGV handler for access violations to avoid double output if host_faulthandler::is_access_violation(code) { - host_faulthandler::disable_fatal_signal(libc::SIGSEGV); + host_faulthandler::disable_fatal_signal(host_faulthandler::SIGSEGV); } let all_threads = FATAL_ERROR.all_threads.load(Ordering::Relaxed); @@ -495,7 +495,10 @@ mod decl { return true; } - if !host_faulthandler::enable_fatal_handlers(faulthandler_fatal_error, libc::SA_NODEFER) { + if !host_faulthandler::enable_fatal_handlers( + faulthandler_fatal_error, + host_faulthandler::SA_NODEFER, + ) { return false; } @@ -769,7 +772,7 @@ mod decl { } #[cfg(unix)] - extern "C" fn faulthandler_user_signal(signum: libc::c_int) { + extern "C" fn faulthandler_user_signal(signum: core::ffi::c_int) { let save_errno = get_errno(); let user = match host_faulthandler::get_user_signal(signum as usize) { @@ -900,7 +903,7 @@ mod decl { #[cfg(not(target_arch = "wasm32"))] { suppress_crash_report(); - host_faulthandler::raise_signal(libc::SIGFPE); + host_faulthandler::raise_signal(host_faulthandler::SIGFPE); } } diff --git a/crates/stdlib/src/fcntl.rs b/crates/stdlib/src/fcntl.rs index 5081c9e9c14..8e24f2b6e4a 100644 --- a/crates/stdlib/src/fcntl.rs +++ b/crates/stdlib/src/fcntl.rs @@ -25,38 +25,40 @@ mod fcntl { // I_LINK, I_UNLINK, I_PLINK, I_PUNLINK #[pyattr] - use libc::{F_GETFD, F_GETFL, F_SETFD, F_SETFL, FD_CLOEXEC}; + use host_fcntl::{F_GETFD, F_GETFL, F_SETFD, F_SETFL, FD_CLOEXEC}; #[cfg(not(target_os = "wasi"))] #[pyattr] - use libc::{F_DUPFD, F_DUPFD_CLOEXEC, F_GETLK, F_SETLK, F_SETLKW}; + use host_fcntl::{F_DUPFD, F_DUPFD_CLOEXEC, F_GETLK, F_SETLK, F_SETLKW}; #[cfg(not(any(target_os = "wasi", target_os = "redox")))] #[pyattr] - use libc::{F_GETOWN, F_RDLCK, F_SETOWN, F_UNLCK, F_WRLCK, LOCK_EX, LOCK_NB, LOCK_SH, LOCK_UN}; + use host_fcntl::{ + F_GETOWN, F_RDLCK, F_SETOWN, F_UNLCK, F_WRLCK, LOCK_EX, LOCK_NB, LOCK_SH, LOCK_UN, + }; #[cfg(target_vendor = "apple")] #[pyattr] - use libc::{F_FULLFSYNC, F_NOCACHE}; + use host_fcntl::{F_FULLFSYNC, F_NOCACHE}; #[cfg(target_os = "freebsd")] #[pyattr] - use libc::{F_DUP2FD, F_DUP2FD_CLOEXEC}; + use host_fcntl::{F_DUP2FD, F_DUP2FD_CLOEXEC}; #[cfg(any(target_os = "android", target_os = "linux"))] #[pyattr] - use libc::{F_OFD_GETLK, F_OFD_SETLK, F_OFD_SETLKW}; + use host_fcntl::{F_OFD_GETLK, F_OFD_SETLK, F_OFD_SETLKW}; #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))] #[pyattr] - use libc::{ + use host_fcntl::{ F_ADD_SEALS, F_GET_SEALS, F_GETLEASE, F_GETPIPE_SZ, F_NOTIFY, F_SEAL_GROW, F_SEAL_SEAL, F_SEAL_SHRINK, F_SEAL_WRITE, F_SETLEASE, F_SETPIPE_SZ, }; #[cfg(any(target_os = "dragonfly", target_os = "netbsd", target_vendor = "apple"))] #[pyattr] - use libc::F_GETPATH; + use host_fcntl::F_GETPATH; #[pyfunction] fn fcntl( diff --git a/crates/stdlib/src/grp.rs b/crates/stdlib/src/grp.rs index 34e9929d2c4..c2a231bef27 100644 --- a/crates/stdlib/src/grp.rs +++ b/crates/stdlib/src/grp.rs @@ -43,7 +43,7 @@ mod grp { #[pyfunction] fn getgrgid(gid: PyIntRef, vm: &VirtualMachine) -> PyResult { let gr_gid = gid.as_bigint(); - let gid = libc::gid_t::try_from(gr_gid).ok(); + let gid = host_grp::gid_t::try_from(gr_gid).ok(); let group = gid .map(host_grp::getgrgid) .transpose() diff --git a/crates/stdlib/src/locale.rs b/crates/stdlib/src/locale.rs index 74e9053fbfb..2f929e8b57f 100644 --- a/crates/stdlib/src/locale.rs +++ b/crates/stdlib/src/locale.rs @@ -18,7 +18,7 @@ mod _locale { not(any(target_os = "ios", target_os = "android", target_os = "redox")) ))] #[pyattr] - use libc::{ + use rustpython_host_env::locale::{ ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4, ABDAY_5, ABDAY_6, ABDAY_7, ABMON_1, ABMON_2, ABMON_3, ABMON_4, ABMON_5, ABMON_6, ABMON_7, ABMON_8, ABMON_9, ABMON_10, ABMON_11, ABMON_12, ALT_DIGITS, AM_STR, CODESET, CRNCYSTR, D_FMT, D_T_FMT, DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, @@ -29,17 +29,19 @@ mod _locale { #[cfg(all(unix, not(any(target_os = "ios", target_os = "redox"))))] #[pyattr] - use libc::LC_MESSAGES; + use rustpython_host_env::locale::LC_MESSAGES; #[pyattr] - use libc::{LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME}; + use rustpython_host_env::locale::{ + LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, + }; #[pyattr(name = "CHAR_MAX")] fn char_max(vm: &VirtualMachine) -> PyIntRef { - vm.ctx.new_int(libc::c_char::MAX) + vm.ctx.new_int(core::ffi::c_char::MAX) } - fn copy_grouping(group: &[libc::c_char], vm: &VirtualMachine) -> PyListRef { + fn copy_grouping(group: &[core::ffi::c_char], vm: &VirtualMachine) -> PyListRef { let mut group_vec: Vec = Vec::new(); for &value in group { let val = vm.ctx.new_int(value); diff --git a/crates/stdlib/src/multiprocessing.rs b/crates/stdlib/src/multiprocessing.rs index 78debdc7813..1eee2ec04e4 100644 --- a/crates/stdlib/src/multiprocessing.rs +++ b/crates/stdlib/src/multiprocessing.rs @@ -333,7 +333,7 @@ mod _multiprocessing { } #[pyfunction] - fn send(socket: usize, buf: ArgBytesLike, vm: &VirtualMachine) -> PyResult { + fn send(socket: usize, buf: ArgBytesLike, vm: &VirtualMachine) -> PyResult { buf.with_ref(|b| { host_multiprocessing::send_socket(socket as host_multiprocessing::RawSocket, b) }) @@ -355,7 +355,7 @@ mod _multiprocessing { }; use core::sync::atomic::{AtomicI32, AtomicU64, Ordering}; #[cfg(target_vendor = "apple")] - use libc::sem_t; + use rustpython_host_env::multiprocessing::sem_t; use rustpython_host_env::multiprocessing::{ self as host_multiprocessing, SemError, TryAcquireStatus, WaitStatus, }; @@ -373,7 +373,7 @@ mod _multiprocessing { #[cfg(target_vendor = "apple")] fn sem_timedwait_polled( sem: *mut sem_t, - deadline: &libc::timespec, + deadline: &host_multiprocessing::timespec, vm: &VirtualMachine, ) -> Result<(), SemWaitError> { let mut delay: u64 = 0; diff --git a/crates/stdlib/src/openssl.rs b/crates/stdlib/src/openssl.rs index 76309d3c21d..3397fff8ef0 100644 --- a/crates/stdlib/src/openssl.rs +++ b/crates/stdlib/src/openssl.rs @@ -154,63 +154,63 @@ mod _ssl { // SSL Alert Descriptions (RFC 5246 and extensions) // Hybrid approach: use openssl_sys constants where available, hardcode others #[pyattr] - const ALERT_DESCRIPTION_CLOSE_NOTIFY: libc::c_int = 0; + const ALERT_DESCRIPTION_CLOSE_NOTIFY: core::ffi::c_int = 0; #[pyattr] - const ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: libc::c_int = 10; + const ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: core::ffi::c_int = 10; #[pyattr] - const ALERT_DESCRIPTION_BAD_RECORD_MAC: libc::c_int = 20; + const ALERT_DESCRIPTION_BAD_RECORD_MAC: core::ffi::c_int = 20; #[pyattr] - const ALERT_DESCRIPTION_RECORD_OVERFLOW: libc::c_int = 22; + const ALERT_DESCRIPTION_RECORD_OVERFLOW: core::ffi::c_int = 22; #[pyattr] - const ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: libc::c_int = 30; + const ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: core::ffi::c_int = 30; #[pyattr] - const ALERT_DESCRIPTION_HANDSHAKE_FAILURE: libc::c_int = 40; + const ALERT_DESCRIPTION_HANDSHAKE_FAILURE: core::ffi::c_int = 40; #[pyattr] - const ALERT_DESCRIPTION_BAD_CERTIFICATE: libc::c_int = 42; + const ALERT_DESCRIPTION_BAD_CERTIFICATE: core::ffi::c_int = 42; #[pyattr] - const ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: libc::c_int = 43; + const ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: core::ffi::c_int = 43; #[pyattr] - const ALERT_DESCRIPTION_CERTIFICATE_REVOKED: libc::c_int = 44; + const ALERT_DESCRIPTION_CERTIFICATE_REVOKED: core::ffi::c_int = 44; #[pyattr] - const ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: libc::c_int = 45; + const ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: core::ffi::c_int = 45; #[pyattr] - const ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: libc::c_int = 46; + const ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: core::ffi::c_int = 46; #[pyattr] - const ALERT_DESCRIPTION_ILLEGAL_PARAMETER: libc::c_int = SSL_AD_ILLEGAL_PARAMETER; + const ALERT_DESCRIPTION_ILLEGAL_PARAMETER: core::ffi::c_int = SSL_AD_ILLEGAL_PARAMETER; #[pyattr] - const ALERT_DESCRIPTION_UNKNOWN_CA: libc::c_int = 48; + const ALERT_DESCRIPTION_UNKNOWN_CA: core::ffi::c_int = 48; #[pyattr] - const ALERT_DESCRIPTION_ACCESS_DENIED: libc::c_int = 49; + const ALERT_DESCRIPTION_ACCESS_DENIED: core::ffi::c_int = 49; #[pyattr] - const ALERT_DESCRIPTION_DECODE_ERROR: libc::c_int = SSL_AD_DECODE_ERROR; + const ALERT_DESCRIPTION_DECODE_ERROR: core::ffi::c_int = SSL_AD_DECODE_ERROR; #[pyattr] - const ALERT_DESCRIPTION_DECRYPT_ERROR: libc::c_int = 51; + const ALERT_DESCRIPTION_DECRYPT_ERROR: core::ffi::c_int = 51; #[pyattr] - const ALERT_DESCRIPTION_PROTOCOL_VERSION: libc::c_int = 70; + const ALERT_DESCRIPTION_PROTOCOL_VERSION: core::ffi::c_int = 70; #[pyattr] - const ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: libc::c_int = 71; + const ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: core::ffi::c_int = 71; #[pyattr] - const ALERT_DESCRIPTION_INTERNAL_ERROR: libc::c_int = 80; + const ALERT_DESCRIPTION_INTERNAL_ERROR: core::ffi::c_int = 80; #[pyattr] - const ALERT_DESCRIPTION_USER_CANCELLED: libc::c_int = 90; + const ALERT_DESCRIPTION_USER_CANCELLED: core::ffi::c_int = 90; #[pyattr] - const ALERT_DESCRIPTION_NO_RENEGOTIATION: libc::c_int = 100; + const ALERT_DESCRIPTION_NO_RENEGOTIATION: core::ffi::c_int = 100; #[pyattr] - const ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: libc::c_int = 110; + const ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: core::ffi::c_int = 110; #[pyattr] - const ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: libc::c_int = 111; + const ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: core::ffi::c_int = 111; #[pyattr] - const ALERT_DESCRIPTION_UNRECOGNIZED_NAME: libc::c_int = SSL_AD_UNRECOGNIZED_NAME; + const ALERT_DESCRIPTION_UNRECOGNIZED_NAME: core::ffi::c_int = SSL_AD_UNRECOGNIZED_NAME; #[pyattr] - const ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: libc::c_int = 113; + const ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: core::ffi::c_int = 113; #[pyattr] - const ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: libc::c_int = 114; + const ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: core::ffi::c_int = 114; #[pyattr] - const ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: libc::c_int = 115; + const ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: core::ffi::c_int = 115; // CRL verification constants #[pyattr] - const VERIFY_CRL_CHECK_CHAIN: libc::c_ulong = + const VERIFY_CRL_CHECK_CHAIN: core::ffi::c_ulong = sys::X509_V_FLAG_CRL_CHECK | sys::X509_V_FLAG_CRL_CHECK_ALL; // taken from CPython, should probably be kept up to date with their version if it ever changes @@ -248,7 +248,8 @@ mod _ssl { #[pyattr] const PROTO_MAXIMUM_SUPPORTED: i32 = ProtoVersion::MaxSupported as i32; #[pyattr] - const OP_ALL: libc::c_ulong = (sys::SSL_OP_ALL & !sys::SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) as _; + const OP_ALL: core::ffi::c_ulong = + (sys::SSL_OP_ALL & !sys::SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) as _; #[pyattr] const HAS_TLS_UNIQUE: bool = true; #[pyattr] @@ -298,7 +299,7 @@ mod _ssl { // SSL_VERIFY constants for post-handshake authentication #[cfg(ossl111)] - const SSL_VERIFY_POST_HANDSHAKE: libc::c_int = 0x20; + const SSL_VERIFY_POST_HANDSHAKE: core::ffi::c_int = 0x20; // the openssl version from the API headers @@ -393,7 +394,7 @@ mod _ssl { unsafe { ptr2obj(sys::OBJ_nid2obj(nid.as_raw())) } } - type PyNid = (libc::c_int, String, String, Option); + type PyNid = (core::ffi::c_int, String, String, Option); fn obj2py(obj: &Asn1ObjectRef, vm: &VirtualMachine) -> PyResult { let nid = obj.nid(); let short_name = nid @@ -428,7 +429,7 @@ mod _ssl { } #[pyfunction] - fn nid2obj(nid: libc::c_int, vm: &VirtualMachine) -> PyResult { + fn nid2obj(nid: core::ffi::c_int, vm: &VirtualMachine) -> PyResult { _nid2obj(Nid::from_raw(nid)) .as_deref() .ok_or_else(|| vm.new_value_error(format!("unknown NID {nid}"))) @@ -508,7 +509,7 @@ mod _ssl { #[pyfunction(name = "RAND_add")] fn rand_add(string: ArgStrOrBytesLike, entropy: f64) { let f = |b: &[u8]| { - for buf in b.chunks(libc::c_int::MAX as usize) { + for buf in b.chunks(core::ffi::c_int::MAX as usize) { unsafe { sys::RAND_add(buf.as_ptr() as *const _, buf.len() as _, entropy) } } }; @@ -573,9 +574,9 @@ mod _ssl { } // Get or create an ex_data index for SNI callback data - fn get_sni_ex_data_index() -> libc::c_int { + fn get_sni_ex_data_index() -> core::ffi::c_int { use rustpython_common::lock::LazyLock; - static SNI_EX_DATA_IDX: LazyLock = LazyLock::new(|| unsafe { + static SNI_EX_DATA_IDX: LazyLock = LazyLock::new(|| unsafe { sys::SSL_get_ex_new_index( 0, core::ptr::null_mut(), @@ -591,12 +592,12 @@ mod _ssl { // NOTE: We don't free the data here because it's managed manually in do_handshake // to avoid use-after-free when the SSL object is dropped after timeout unsafe extern "C" fn sni_callback_data_free( - _parent: *mut libc::c_void, - _ptr: *mut libc::c_void, + _parent: *mut core::ffi::c_void, + _ptr: *mut core::ffi::c_void, _ad: *mut sys::CRYPTO_EX_DATA, - _idx: libc::c_int, - _argl: libc::c_long, - _argp: *mut libc::c_void, + _idx: core::ffi::c_int, + _argl: core::ffi::c_long, + _argp: *mut core::ffi::c_void, ) { // Intentionally empty - data is freed in cleanup_sni_ex_data() } @@ -617,9 +618,9 @@ mod _ssl { } // Get or create an ex_data index for msg_callback data - fn get_msg_callback_ex_data_index() -> libc::c_int { + fn get_msg_callback_ex_data_index() -> core::ffi::c_int { use rustpython_common::lock::LazyLock; - static MSG_CB_EX_DATA_IDX: LazyLock = LazyLock::new(|| unsafe { + static MSG_CB_EX_DATA_IDX: LazyLock = LazyLock::new(|| unsafe { sys::SSL_get_ex_new_index( 0, core::ptr::null_mut(), @@ -633,12 +634,12 @@ mod _ssl { // Free function for msg_callback data - called by OpenSSL when SSL is freed unsafe extern "C" fn msg_callback_data_free( - _parent: *mut libc::c_void, - ptr: *mut libc::c_void, + _parent: *mut core::ffi::c_void, + ptr: *mut core::ffi::c_void, _ad: *mut sys::CRYPTO_EX_DATA, - _idx: libc::c_int, - _argl: libc::c_long, - _argp: *mut libc::c_void, + _idx: core::ffi::c_int, + _argl: core::ffi::c_long, + _argp: *mut core::ffi::c_void, ) { if !ptr.is_null() { unsafe { @@ -652,13 +653,13 @@ mod _ssl { // SNI callback function called by OpenSSL unsafe extern "C" fn _servername_callback( ssl_ptr: *mut sys::SSL, - al: *mut libc::c_int, - arg: *mut libc::c_void, - ) -> libc::c_int { - const SSL_TLSEXT_ERR_OK: libc::c_int = 0; - const SSL_TLSEXT_ERR_ALERT_FATAL: libc::c_int = 2; - const SSL_AD_INTERNAL_ERROR: libc::c_int = 80; - const TLSEXT_NAMETYPE_host_name: libc::c_int = 0; + al: *mut core::ffi::c_int, + arg: *mut core::ffi::c_void, + ) -> core::ffi::c_int { + const SSL_TLSEXT_ERR_OK: core::ffi::c_int = 0; + const SSL_TLSEXT_ERR_ALERT_FATAL: core::ffi::c_int = 2; + const SSL_AD_INTERNAL_ERROR: core::ffi::c_int = 80; + const TLSEXT_NAMETYPE_host_name: core::ffi::c_int = 0; if arg.is_null() { return SSL_TLSEXT_ERR_OK; @@ -766,13 +767,13 @@ mod _ssl { // Called during SSL operations to report protocol messages. // debughelpers.c:_PySSL_msg_callback unsafe extern "C" fn _msg_callback( - write_p: libc::c_int, - mut version: libc::c_int, - content_type: libc::c_int, - buf: *const libc::c_void, + write_p: core::ffi::c_int, + mut version: core::ffi::c_int, + content_type: core::ffi::c_int, + buf: *const core::ffi::c_void, len: usize, ssl_ptr: *mut sys::SSL, - _arg: *mut libc::c_void, + _arg: *mut core::ffi::c_void, ) { if ssl_ptr.is_null() { return; @@ -1122,7 +1123,7 @@ mod _ssl { } #[pygetset] - fn options(&self) -> libc::c_ulong { + fn options(&self) -> core::ffi::c_ulong { self.ctx.read().options().bits() as _ } #[pygetset(setter)] @@ -1130,10 +1131,10 @@ mod _ssl { if new_opts < 0 { return Err(vm.new_value_error("invalid options value")); } - let new_opts = new_opts as libc::c_ulong; + let new_opts = new_opts as core::ffi::c_ulong; let mut ctx = self.builder(); // Get current options - let current = ctx.options().bits() as libc::c_ulong; + let current = ctx.options().bits() as core::ffi::c_ulong; // Calculate options to clear and set let clear = current & !new_opts; @@ -1190,7 +1191,7 @@ mod _ssl { Ok(()) } #[pygetset] - fn verify_flags(&self) -> libc::c_ulong { + fn verify_flags(&self) -> core::ffi::c_ulong { unsafe { let ctx_ptr = self.ctx().as_ptr(); let param = sys::SSL_CTX_get0_param(ctx_ptr); @@ -1198,7 +1199,11 @@ mod _ssl { } } #[pygetset(setter)] - fn set_verify_flags(&self, new_flags: libc::c_ulong, vm: &VirtualMachine) -> PyResult<()> { + fn set_verify_flags( + &self, + new_flags: core::ffi::c_ulong, + vm: &VirtualMachine, + ) -> PyResult<()> { unsafe { let ctx_ptr = self.ctx().as_ptr(); let param = sys::SSL_CTX_get0_param(ctx_ptr); @@ -1359,10 +1364,10 @@ mod _ssl { { let mut ctx = self.builder(); let server = protos.with_ref(|pbuf| { - if pbuf.len() > libc::c_uint::MAX as usize { + if pbuf.len() > core::ffi::c_uint::MAX as usize { return Err(vm.new_overflow_error(format!( "protocols longer than {} bytes", - libc::c_uint::MAX + core::ffi::c_uint::MAX ))); } ctx.set_alpn_protos(pbuf) @@ -1523,7 +1528,7 @@ mod _ssl { return Err(vm .new_os_subtype_error( vm.ctx.exceptions.file_not_found_error.to_owned(), - Some(libc::ENOENT), + Some(rustpython_host_env::errno::errors::ENOENT), format!("No such file or directory: '{}'", path.display()), ) .upcast()); @@ -1534,7 +1539,7 @@ mod _ssl { return Err(vm .new_os_subtype_error( vm.ctx.exceptions.file_not_found_error.to_owned(), - Some(libc::ENOENT), + Some(rustpython_host_env::errno::errors::ENOENT), format!("No such file or directory: '{}'", path.display()), ) .upcast()); @@ -1667,7 +1672,7 @@ mod _ssl { std::io::ErrorKind::NotFound => vm .new_os_subtype_error( vm.ctx.exceptions.file_not_found_error.to_owned(), - Some(libc::ENOENT), + Some(rustpython_host_env::errno::errors::ENOENT), e.to_string(), ) .upcast(), @@ -1684,7 +1689,7 @@ mod _ssl { ) }; unsafe { - libc::fclose(fp); + rustpython_host_env::fileutils::fclose(fp); } if dh.is_null() { @@ -1842,7 +1847,7 @@ mod _ssl { return Err(vm .new_os_subtype_error( vm.ctx.exceptions.file_not_found_error.to_owned(), - Some(libc::ENOENT), + Some(rustpython_host_env::errno::errors::ENOENT), format!("No such file or directory: '{}'", cert_path.display()), ) .upcast()); @@ -1853,7 +1858,7 @@ mod _ssl { return Err(vm .new_os_subtype_error( vm.ctx.exceptions.file_not_found_error.to_owned(), - Some(libc::ENOENT), + Some(rustpython_host_env::errno::errors::ENOENT), format!("No such file or directory: '{}'", kp.display()), ) .upcast()); @@ -2013,7 +2018,7 @@ mod _ssl { let ret = SSL_set_session_id_context( ssl.as_ptr(), SID_CTX.as_ptr(), - SID_CTX.len() as libc::c_uint, + SID_CTX.len() as core::ffi::c_uint, ); if ret == 0 { return Err(convert_openssl_error(vm, ErrorStack::get())); @@ -2061,7 +2066,7 @@ mod _ssl { // Server socket: add SSL_VERIFY_POST_HANDSHAKE flag // Only in combination with SSL_VERIFY_PEER let mode = sys::SSL_get_verify_mode(ssl.as_ptr()); - if (mode & sys::SSL_VERIFY_PEER as libc::c_int) != 0 { + if (mode & sys::SSL_VERIFY_PEER as core::ffi::c_int) != 0 { sys::SSL_set_verify( ssl.as_ptr(), mode | SSL_VERIFY_POST_HANDSHAKE, @@ -2553,7 +2558,7 @@ mod _ssl { unsafe { let ssl_ctx = sys::SSL_get_SSL_CTX(stream.ssl().as_ptr()); let verify_mode = sys::SSL_CTX_get_verify_mode(ssl_ctx); - if (verify_mode & sys::SSL_VERIFY_PEER as libc::c_int) == 0 { + if (verify_mode & sys::SSL_VERIFY_PEER as core::ffi::c_int) == 0 { // Return empty dict when SSL_VERIFY_PEER is not set Ok(Some(vm.ctx.new_dict().into())) } else { @@ -2723,8 +2728,8 @@ mod _ssl { // Use thread-local SSL pointer during handshake to avoid deadlock let ssl_ptr = get_ssl_ptr_for_context_change(&self.connection); unsafe { - let mut out: *const libc::c_uchar = core::ptr::null(); - let mut outlen: libc::c_uint = 0; + let mut out: *const core::ffi::c_uchar = core::ptr::null(); + let mut outlen: core::ffi::c_uint = 0; sys::SSL_get0_alpn_selected(ssl_ptr, &mut out, &mut outlen); @@ -3308,8 +3313,8 @@ mod _ssl { return Ok(PyComparisonValue::NotImplemented); } let mut eq = unsafe { - let mut self_len: libc::c_uint = 0; - let mut other_len: libc::c_uint = 0; + let mut self_len: core::ffi::c_uint = 0; + let mut other_len: core::ffi::c_uint = 0; let self_id = sys::SSL_SESSION_get_id(zelf.session, &mut self_len); let other_id = sys::SSL_SESSION_get_id(other.session, &mut other_len); @@ -3359,7 +3364,7 @@ mod _ssl { unsafe extern "C" { // X509_check_ca returns 1 for CA certificates, 0 otherwise - fn X509_check_ca(x: *const sys::X509) -> libc::c_int; + fn X509_check_ca(x: *const sys::X509) -> core::ffi::c_int; } unsafe extern "C" { @@ -3373,13 +3378,13 @@ mod _ssl { #[cfg(ossl111)] unsafe extern "C" { - fn SSL_verify_client_post_handshake(ssl: *const sys::SSL) -> libc::c_int; - fn SSL_set_post_handshake_auth(ssl: *mut sys::SSL, val: libc::c_int); + fn SSL_verify_client_post_handshake(ssl: *const sys::SSL) -> core::ffi::c_int; + fn SSL_set_post_handshake_auth(ssl: *mut sys::SSL, val: core::ffi::c_int); } #[cfg(ossl110)] unsafe extern "C" { - fn SSL_CTX_get_security_level(ctx: *const sys::SSL_CTX) -> libc::c_int; + fn SSL_CTX_get_security_level(ctx: *const sys::SSL_CTX) -> core::ffi::c_int; } unsafe extern "C" { @@ -3390,13 +3395,13 @@ mod _ssl { #[allow(non_camel_case_types)] type SSL_CTX_msg_callback = Option< unsafe extern "C" fn( - write_p: libc::c_int, - version: libc::c_int, - content_type: libc::c_int, - buf: *const libc::c_void, + write_p: core::ffi::c_int, + version: core::ffi::c_int, + content_type: core::ffi::c_int, + buf: *const core::ffi::c_void, len: usize, ssl: *mut sys::SSL, - arg: *mut libc::c_void, + arg: *mut core::ffi::c_void, ), >; @@ -3406,40 +3411,42 @@ mod _ssl { #[cfg(ossl110)] unsafe extern "C" { - fn SSL_SESSION_has_ticket(session: *const sys::SSL_SESSION) -> libc::c_int; - fn SSL_SESSION_get_ticket_lifetime_hint(session: *const sys::SSL_SESSION) -> libc::c_ulong; + fn SSL_SESSION_has_ticket(session: *const sys::SSL_SESSION) -> core::ffi::c_int; + fn SSL_SESSION_get_ticket_lifetime_hint( + session: *const sys::SSL_SESSION, + ) -> core::ffi::c_ulong; } // X509 object types - const X509_LU_X509: libc::c_int = 1; - const X509_LU_CRL: libc::c_int = 2; + const X509_LU_X509: core::ffi::c_int = 1; + const X509_LU_CRL: core::ffi::c_int = 2; unsafe extern "C" { - fn X509_OBJECT_get_type(obj: *const sys::X509_OBJECT) -> libc::c_int; + fn X509_OBJECT_get_type(obj: *const sys::X509_OBJECT) -> core::ffi::c_int; fn SSL_set_session_id_context( ssl: *mut sys::SSL, - sid_ctx: *const libc::c_uchar, - sid_ctx_len: libc::c_uint, - ) -> libc::c_int; + sid_ctx: *const core::ffi::c_uchar, + sid_ctx_len: core::ffi::c_uint, + ) -> core::ffi::c_int; fn SSL_get1_session(ssl: *const sys::SSL) -> *mut sys::SSL_SESSION; } // SSL session statistics constants (used with SSL_CTX_ctrl) - const SSL_CTRL_SESS_NUMBER: libc::c_int = 20; - const SSL_CTRL_SESS_CONNECT: libc::c_int = 21; - const SSL_CTRL_SESS_CONNECT_GOOD: libc::c_int = 22; - const SSL_CTRL_SESS_CONNECT_RENEGOTIATE: libc::c_int = 23; - const SSL_CTRL_SESS_ACCEPT: libc::c_int = 24; - const SSL_CTRL_SESS_ACCEPT_GOOD: libc::c_int = 25; - const SSL_CTRL_SESS_ACCEPT_RENEGOTIATE: libc::c_int = 26; - const SSL_CTRL_SESS_HIT: libc::c_int = 27; - const SSL_CTRL_SESS_MISSES: libc::c_int = 29; - const SSL_CTRL_SESS_TIMEOUTS: libc::c_int = 30; - const SSL_CTRL_SESS_CACHE_FULL: libc::c_int = 31; + const SSL_CTRL_SESS_NUMBER: core::ffi::c_int = 20; + const SSL_CTRL_SESS_CONNECT: core::ffi::c_int = 21; + const SSL_CTRL_SESS_CONNECT_GOOD: core::ffi::c_int = 22; + const SSL_CTRL_SESS_CONNECT_RENEGOTIATE: core::ffi::c_int = 23; + const SSL_CTRL_SESS_ACCEPT: core::ffi::c_int = 24; + const SSL_CTRL_SESS_ACCEPT_GOOD: core::ffi::c_int = 25; + const SSL_CTRL_SESS_ACCEPT_RENEGOTIATE: core::ffi::c_int = 26; + const SSL_CTRL_SESS_HIT: core::ffi::c_int = 27; + const SSL_CTRL_SESS_MISSES: core::ffi::c_int = 29; + const SSL_CTRL_SESS_TIMEOUTS: core::ffi::c_int = 30; + const SSL_CTRL_SESS_CACHE_FULL: core::ffi::c_int = 31; // SSL session statistics functions (implemented as macros in OpenSSL) #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_number(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_number(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3451,7 +3458,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_connect(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_connect(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3463,7 +3470,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_connect_good(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_connect_good(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3475,7 +3482,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_connect_renegotiate(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_connect_renegotiate(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3487,7 +3494,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_accept(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_accept(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3499,7 +3506,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_accept_good(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_accept_good(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3511,7 +3518,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_accept_renegotiate(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_accept_renegotiate(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3523,12 +3530,12 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_hits(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_hits(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl(ctx as *mut _, SSL_CTRL_SESS_HIT, 0, core::ptr::null_mut()) } } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_misses(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_misses(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3540,7 +3547,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_timeouts(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_timeouts(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3552,7 +3559,7 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn SSL_CTX_sess_cache_full(ctx: *const sys::SSL_CTX) -> libc::c_long { + unsafe fn SSL_CTX_sess_cache_full(ctx: *const sys::SSL_CTX) -> core::ffi::c_long { unsafe { sys::SSL_CTX_ctrl( ctx as *mut _, @@ -3566,17 +3573,17 @@ mod _ssl { // DH parameters functions unsafe extern "C" { fn PEM_read_DHparams( - fp: *mut libc::FILE, + fp: *mut rustpython_host_env::fileutils::CFile, x: *mut *mut sys::DH, - cb: *mut libc::c_void, - u: *mut libc::c_void, + cb: *mut core::ffi::c_void, + u: *mut core::ffi::c_void, ) -> *mut sys::DH; } // OpenSSL BIO helper functions // These are typically macros in OpenSSL, implemented via BIO_ctrl - const BIO_CTRL_PENDING: libc::c_int = 10; - const BIO_CTRL_SET_EOF: libc::c_int = 2; + const BIO_CTRL_PENDING: core::ffi::c_int = 10; + const BIO_CTRL_SET_EOF: core::ffi::c_int = 2; #[allow(non_snake_case)] unsafe fn BIO_ctrl_pending(bio: *mut sys::BIO) -> usize { @@ -3584,14 +3591,17 @@ mod _ssl { } #[allow(non_snake_case)] - unsafe fn BIO_set_mem_eof_return(bio: *mut sys::BIO, eof: libc::c_int) -> libc::c_int { + unsafe fn BIO_set_mem_eof_return( + bio: *mut sys::BIO, + eof: core::ffi::c_int, + ) -> core::ffi::c_int { unsafe { sys::BIO_ctrl( bio, BIO_CTRL_SET_EOF, - eof as libc::c_long, + eof as core::ffi::c_long, core::ptr::null_mut(), - ) as libc::c_int + ) as core::ffi::c_int } } @@ -3721,7 +3731,7 @@ mod _ssl { #[pygetset] fn id(&self, vm: &VirtualMachine) -> PyBytesRef { unsafe { - let mut len: libc::c_uint = 0; + let mut len: core::ffi::c_uint = 0; let id_ptr = sys::SSL_SESSION_get_id(self.session, &mut len); let id_slice = core::slice::from_raw_parts(id_ptr, len as usize); vm.ctx.new_bytes(id_slice.to_vec()) @@ -3976,7 +3986,7 @@ mod _ssl { let mut buf = vec![0u8; 256]; let result = sys::SSL_CIPHER_description( cipher, - buf.as_mut_ptr() as *mut libc::c_char, + buf.as_mut_ptr() as *mut core::ffi::c_char, buf.len() as i32, ); if result.is_null() { @@ -4142,7 +4152,7 @@ mod windows { mod bio { //! based off rust-openssl's private `bio` module - use libc::c_int; + use core::ffi::c_int; use openssl::error::ErrorStack; use openssl_sys as sys; use std::marker::PhantomData; diff --git a/crates/stdlib/src/openssl/cert.rs b/crates/stdlib/src/openssl/cert.rs index e18e7feb9f0..7704e51f0a2 100644 --- a/crates/stdlib/src/openssl/cert.rs +++ b/crates/stdlib/src/openssl/cert.rs @@ -39,7 +39,7 @@ pub(crate) mod ssl_cert { let buflen = buflen as usize; let mut buf = Vec::::with_capacity(buflen + 1); let ret = sys::OBJ_obj2txt( - buf.as_mut_ptr() as *mut libc::c_char, + buf.as_mut_ptr() as *mut core::ffi::c_char, buf.capacity() as _, ptr, no_name, diff --git a/crates/stdlib/src/posixshmem.rs b/crates/stdlib/src/posixshmem.rs index 91fdf4aafbc..6bc1c006513 100644 --- a/crates/stdlib/src/posixshmem.rs +++ b/crates/stdlib/src/posixshmem.rs @@ -16,15 +16,15 @@ mod _posixshmem { #[pyarg(any)] name: PyUtf8StrRef, #[pyarg(any)] - flags: libc::c_int, + flags: core::ffi::c_int, #[pyarg(any, default = 0o600)] - mode: libc::mode_t, + mode: shm::mode_t, } #[pyfunction] - fn shm_open(args: ShmOpenArgs, vm: &VirtualMachine) -> PyResult { + fn shm_open(args: ShmOpenArgs, vm: &VirtualMachine) -> PyResult { let name = CString::new(args.name.as_str()).map_err(|e| e.into_pyexception(vm))?; - let mode: libc::c_uint = args.mode as _; + let mode: core::ffi::c_uint = args.mode as _; shm::shm_open(name.as_c_str(), args.flags, mode).map_err(|e| e.into_pyexception(vm)) } diff --git a/crates/stdlib/src/posixsubprocess.rs b/crates/stdlib/src/posixsubprocess.rs index 0371d12e3c2..080c0646845 100644 --- a/crates/stdlib/src/posixsubprocess.rs +++ b/crates/stdlib/src/posixsubprocess.rs @@ -26,7 +26,7 @@ mod _posixsubprocess { use crate::vm::{PyResult, VirtualMachine, convert::IntoPyException}; #[pyfunction] - fn fork_exec(args: ForkExecArgs<'_>, vm: &VirtualMachine) -> PyResult { + fn fork_exec(args: ForkExecArgs<'_>, vm: &VirtualMachine) -> PyResult { // Check for interpreter shutdown when preexec_fn is used if args.preexec_fn.is_some() && vm @@ -85,7 +85,7 @@ impl AsRef for CStrPathLike { #[derive(Default)] struct CharPtrVec<'a> { - vec: Vec<*const libc::c_char>, + vec: Vec<*const host_posix::c_char>, marker: PhantomData>, } @@ -107,7 +107,7 @@ impl<'a> Deref for CharPtrVec<'a> { type Target = CharPtrSlice<'a>; fn deref(&self) -> &Self::Target { unsafe { - &*(self.vec.as_slice() as *const [*const libc::c_char] as *const CharPtrSlice<'a>) + &*(self.vec.as_slice() as *const [*const host_posix::c_char] as *const CharPtrSlice<'a>) } } } @@ -115,11 +115,11 @@ impl<'a> Deref for CharPtrVec<'a> { #[repr(transparent)] struct CharPtrSlice<'a> { marker: PhantomData<[&'a CStr]>, - slice: [*const libc::c_char], + slice: [*const host_posix::c_char], } impl CharPtrSlice<'_> { - const fn as_ptr(&self) -> *const *const libc::c_char { + const fn as_ptr(&self) -> *const *const host_posix::c_char { self.slice.as_ptr() } } @@ -254,7 +254,7 @@ gen_args! { errpipe_write: Fd, restore_signals: bool, call_setsid: bool, - pgid_to_set: libc::pid_t, + pgid_to_set: host_posix::pid_t, gid: Option, groups_list: Option, uid: Option, diff --git a/crates/stdlib/src/resource.rs b/crates/stdlib/src/resource.rs index bac708435c9..cf7fe23d8cc 100644 --- a/crates/stdlib/src/resource.rs +++ b/crates/stdlib/src/resource.rs @@ -16,7 +16,7 @@ mod resource { #[cfg_attr(target_os = "android", expect(deprecated))] const RLIM_NLIMITS: i32 = cfg_select! { target_os = "android" => { - libc::RLIM_NLIMITS + host_resource::RLIM_NLIMITS } _ => { // This constant isn't abi-stable across os versions, so we just @@ -28,18 +28,18 @@ mod resource { // TODO: RLIMIT_OFILE, #[pyattr] - use libc::{ + use host_resource::{ RLIM_INFINITY, RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_MEMLOCK, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_STACK, }; #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))] #[pyattr] - use libc::{RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_SIGPENDING}; + use host_resource::{RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_SIGPENDING}; // TODO: I think this is supposed to be defined for all linux_like? #[cfg(target_os = "linux")] #[pyattr] - use libc::RLIMIT_RTTIME; + use host_resource::RLIMIT_RTTIME; #[cfg(any( target_os = "freebsd", @@ -48,41 +48,41 @@ mod resource { target_os = "illumos" ))] #[pyattr] - use libc::RLIMIT_SBSIZE; + use host_resource::RLIMIT_SBSIZE; #[cfg(any(target_os = "freebsd", target_os = "solaris", target_os = "illumos"))] #[pyattr] - use libc::{RLIMIT_NPTS, RLIMIT_SWAP}; + use host_resource::{RLIMIT_NPTS, RLIMIT_SWAP}; #[cfg(any(target_os = "solaris", target_os = "illumos"))] #[pyattr] - use libc::RLIMIT_VMEM; + use host_resource::RLIMIT_VMEM; #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "freebsd"))] #[pyattr] - use libc::RUSAGE_THREAD; + use host_resource::RUSAGE_THREAD; #[cfg(not(any(target_os = "windows", target_os = "redox")))] #[pyattr] - use libc::{RUSAGE_CHILDREN, RUSAGE_SELF}; + use host_resource::{RUSAGE_CHILDREN, RUSAGE_SELF}; #[pystruct_sequence_data] struct RUsageData { ru_utime: f64, ru_stime: f64, - ru_maxrss: libc::c_long, - ru_ixrss: libc::c_long, - ru_idrss: libc::c_long, - ru_isrss: libc::c_long, - ru_minflt: libc::c_long, - ru_majflt: libc::c_long, - ru_nswap: libc::c_long, - ru_inblock: libc::c_long, - ru_oublock: libc::c_long, - ru_msgsnd: libc::c_long, - ru_msgrcv: libc::c_long, - ru_nsignals: libc::c_long, - ru_nvcsw: libc::c_long, - ru_nivcsw: libc::c_long, + ru_maxrss: host_resource::c_long, + ru_ixrss: host_resource::c_long, + ru_idrss: host_resource::c_long, + ru_isrss: host_resource::c_long, + ru_minflt: host_resource::c_long, + ru_majflt: host_resource::c_long, + ru_nswap: host_resource::c_long, + ru_inblock: host_resource::c_long, + ru_oublock: host_resource::c_long, + ru_msgsnd: host_resource::c_long, + ru_msgrcv: host_resource::c_long, + ru_nsignals: host_resource::c_long, + ru_nvcsw: host_resource::c_long, + ru_nivcsw: host_resource::c_long, } #[pyattr] @@ -94,7 +94,8 @@ mod resource { impl From for RUsageData { fn from(rusage: host_resource::RUsage) -> Self { - let tv = |tv: libc::timeval| tv.tv_sec as f64 + (tv.tv_usec as f64 / 1_000_000.0); + let tv = + |tv: host_resource::timeval| tv.tv_sec as f64 + (tv.tv_usec as f64 / 1_000_000.0); Self { ru_utime: tv(rusage.ru_utime), ru_stime: tv(rusage.ru_stime), @@ -128,13 +129,13 @@ mod resource { }) } - struct Limits(libc::rlimit); + struct Limits(host_resource::rlimit); impl<'a> TryFromBorrowedObject<'a> for Limits { fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult { - let seq: Vec = obj.try_to_value(vm)?; + let seq: Vec = obj.try_to_value(vm)?; match *seq { - [cur, max] => Ok(Self(libc::rlimit { + [cur, max] => Ok(Self(host_resource::rlimit { rlim_cur: cur & RLIM_INFINITY, rlim_max: max & RLIM_INFINITY, })), @@ -149,14 +150,14 @@ mod resource { } } - fn py2rlim(obj: PyIntRef, vm: &VirtualMachine) -> PyResult { + fn py2rlim(obj: PyIntRef, vm: &VirtualMachine) -> PyResult { let value = obj.try_to_primitive::(vm)?; if value.is_negative() { return Err(vm.new_value_error("Cannot convert negative int")); } - libc::rlim_t::try_from(value) + host_resource::rlim_t::try_from(value) .map_err(|_| vm.new_overflow_error("Python int too large to convert to C rlim_t")) } @@ -164,7 +165,7 @@ mod resource { fn getrlimit(resource: PyIntRef, vm: &VirtualMachine) -> PyResult { let resource = py2rlim(resource, vm)?; - if resource >= RLIM_NLIMITS as libc::rlim_t { + if resource >= RLIM_NLIMITS as host_resource::rlim_t { return Err(vm.new_value_error("invalid resource specified")); } @@ -176,7 +177,7 @@ mod resource { fn setrlimit(resource: PyIntRef, limits: Limits, vm: &VirtualMachine) -> PyResult<()> { let resource = py2rlim(resource, vm)?; - if resource >= RLIM_NLIMITS as libc::rlim_t { + if resource >= RLIM_NLIMITS as host_resource::rlim_t { return Err(vm.new_value_error("invalid resource specified")); } diff --git a/crates/stdlib/src/scproxy.rs b/crates/stdlib/src/scproxy.rs index 09e7cdc6046..f31432cbb51 100644 --- a/crates/stdlib/src/scproxy.rs +++ b/crates/stdlib/src/scproxy.rs @@ -9,14 +9,14 @@ mod _scproxy { builtins::{PyDict, PyDictRef, PyStr}, convert::ToPyObject, }; - use system_configuration::core_foundation::{ + use rustpython_host_env::system_configuration::core_foundation::{ array::CFArray, base::{CFType, FromVoid, TCFType}, dictionary::CFDictionary, number::CFNumber, string::{CFString, CFStringRef}, }; - use system_configuration::sys::{ + use rustpython_host_env::system_configuration::sys::{ dynamic_store_copy_specific::SCDynamicStoreCopyProxies, schema_definitions::*, }; diff --git a/crates/stdlib/src/select.rs b/crates/stdlib/src/select.rs index f8125ea375f..c1f10f3ecc2 100644 --- a/crates/stdlib/src/select.rs +++ b/crates/stdlib/src/select.rs @@ -170,7 +170,7 @@ mod decl { #[cfg(unix)] #[pyattr] - use libc::{POLLERR, POLLHUP, POLLIN, POLLNVAL, POLLOUT, POLLPRI}; + use host_select::{POLLERR, POLLHUP, POLLIN, POLLNVAL, POLLOUT, POLLPRI}; #[cfg(unix)] pub(super) mod poll { @@ -261,7 +261,8 @@ mod decl { } } - const DEFAULT_EVENTS: i16 = libc::POLLIN | libc::POLLPRI | libc::POLLOUT; + const DEFAULT_EVENTS: i16 = + host_select::POLLIN | host_select::POLLPRI | host_select::POLLOUT; #[pyclass] impl PyPoll { @@ -315,7 +316,7 @@ mod decl { loop { match vm.allow_threads(|| host_select::poll_fds(&mut fds, poll_timeout)) { Ok(_) => break, - Err(err) if err.raw_os_error() == Some(libc::EINTR) => { + Err(err) if err.raw_os_error() == Some(host_select::EINTR) => { vm.check_signals()? } Err(err) => return Err(err.into_pyexception(vm)), @@ -346,14 +347,14 @@ mod decl { #[cfg(any(target_os = "linux", target_os = "android", target_os = "redox"))] #[pyattr] - use libc::{ + use host_select::{ EPOLL_CLOEXEC, EPOLLERR, EPOLLEXCLUSIVE, EPOLLHUP, EPOLLIN, EPOLLMSG, EPOLLONESHOT, EPOLLOUT, EPOLLPRI, EPOLLRDBAND, EPOLLRDHUP, EPOLLRDNORM, EPOLLWAKEUP, EPOLLWRBAND, EPOLLWRNORM, }; #[cfg(any(target_os = "linux", target_os = "android", target_os = "redox"))] #[pyattr] - const EPOLLET: u32 = libc::EPOLLET as u32; + const EPOLLET: u32 = host_select::EPOLLET as u32; #[cfg(any(target_os = "linux", target_os = "android", target_os = "redox"))] pub(super) mod epoll { @@ -392,7 +393,7 @@ mod decl { if let ..=-2 | 0 = args.sizehint { return Err(vm.new_value_error("negative sizehint")); } - if !matches!(args.flags, 0 | libc::EPOLL_CLOEXEC) { + if !matches!(args.flags, 0 | host_select::EPOLL_CLOEXEC) { return Err(vm.new_os_error("invalid flags")); } Self::new().map_err(|e| e.into_pyexception(vm)) @@ -497,7 +498,7 @@ mod decl { "maxevents must be greater than 0, got {maxevents}" ))); } - -1 => libc::FD_SETSIZE - 1, + -1 => host_select::FD_SETSIZE - 1, _ => maxevents as usize, }; diff --git a/crates/stdlib/src/socket.rs b/crates/stdlib/src/socket.rs index e3ce52b943a..e7ee6c907db 100644 --- a/crates/stdlib/src/socket.rs +++ b/crates/stdlib/src/socket.rs @@ -45,8 +45,8 @@ mod _socket { time::Duration, }; use crossbeam_utils::atomic::AtomicCell; + use host_socket::raw::Socket; use num_traits::ToPrimitive; - use socket2::Socket; use std::{ ffi, io::{self, Read, Write}, @@ -885,9 +885,9 @@ mod _socket { fn get_raw_sock(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult { #[cfg(unix)] - type CastFrom = libc::c_long; + type CastFrom = core::ffi::c_long; #[cfg(windows)] - type CastFrom = libc::c_longlong; + type CastFrom = core::ffi::c_longlong; // should really just be to_index() but test_socket tests the error messages explicitly if obj.fast_isinstance(vm.ctx.types.float_type) { @@ -1109,7 +1109,7 @@ mod _socket { addr: PyObjectRef, caller: &str, vm: &VirtualMachine, - ) -> Result { + ) -> Result { let family = self.family.load(); match family { #[cfg(unix)] @@ -1122,7 +1122,7 @@ mod _socket { ArgStrOrBytesLike::Buf(_) => ffi::OsStr::from_bytes(bytes).into(), ArgStrOrBytesLike::Str(s) => vm.fsencode(s)?, }; - socket2::SockAddr::unix(path) + host_socket::raw::SockAddr::unix(path) .map_err(|_| vm.new_os_error("AF_UNIX path too long").into()) } c::AF_INET => { @@ -1214,19 +1214,18 @@ mod _socket { }; // Create sockaddr_can - let mut storage: libc::sockaddr_storage = unsafe { core::mem::zeroed() }; - let can_addr = - &mut storage as *mut libc::sockaddr_storage as *mut libc::sockaddr_can; + let mut storage: c::sockaddr_storage = unsafe { core::mem::zeroed() }; + let can_addr = &mut storage as *mut c::sockaddr_storage as *mut c::sockaddr_can; unsafe { - (*can_addr).can_family = libc::AF_CAN as libc::sa_family_t; + (*can_addr).can_family = c::AF_CAN as c::sa_family_t; (*can_addr).can_ifindex = ifindex; } - let storage: socket2::SockAddrStorage = + let storage: host_socket::raw::SockAddrStorage = unsafe { core::mem::transmute(storage) }; Ok(unsafe { - socket2::SockAddr::new( + host_socket::raw::SockAddr::new( storage, - core::mem::size_of::() as libc::socklen_t, + core::mem::size_of::() as c::socklen_t, ) }) } @@ -1273,11 +1272,10 @@ mod _socket { } // Create sockaddr_alg - let mut storage: libc::sockaddr_storage = unsafe { core::mem::zeroed() }; - let alg_addr = - &mut storage as *mut libc::sockaddr_storage as *mut libc::sockaddr_alg; + let mut storage: c::sockaddr_storage = unsafe { core::mem::zeroed() }; + let alg_addr = &mut storage as *mut c::sockaddr_storage as *mut c::sockaddr_alg; unsafe { - (*alg_addr).salg_family = libc::AF_ALG as libc::sa_family_t; + (*alg_addr).salg_family = c::AF_ALG as c::sa_family_t; // Copy type string for (i, b) in type_str.bytes().enumerate() { (*alg_addr).salg_type[i] = b; @@ -1287,12 +1285,12 @@ mod _socket { (*alg_addr).salg_name[i] = b; } } - let storage: socket2::SockAddrStorage = + let storage: host_socket::raw::SockAddrStorage = unsafe { core::mem::transmute(storage) }; Ok(unsafe { - socket2::SockAddr::new( + host_socket::raw::SockAddr::new( storage, - core::mem::size_of::() as libc::socklen_t, + core::mem::size_of::() as c::socklen_t, ) }) } @@ -1773,7 +1771,7 @@ mod _socket { vm: &VirtualMachine, ) -> PyResult { let flags = flags.unwrap_or(0); - let mut msg = socket2::MsgHdr::new(); + let mut msg = host_socket::raw::MsgHdr::new(); let sockaddr; if let Some(addr) = addr.flatten() { @@ -1896,9 +1894,9 @@ mod _socket { // Build address tuple let address = if let Some(address) = msg.address { - let storage: socket2::SockAddrStorage = + let storage: host_socket::raw::SockAddrStorage = unsafe { core::mem::transmute(address.storage) }; - let addr = unsafe { socket2::SockAddr::new(storage, address.len as _) }; + let addr = unsafe { host_socket::raw::SockAddr::new(storage, address.len as _) }; get_addr_tuple(&addr, vm) } else { vm.ctx.none() @@ -2260,7 +2258,7 @@ mod _socket { } } - fn get_addr_tuple(addr: &socket2::SockAddr, vm: &VirtualMachine) -> PyObjectRef { + fn get_addr_tuple(addr: &host_socket::raw::SockAddr, vm: &VirtualMachine) -> PyObjectRef { if let Some(addr) = addr.as_socket() { return get_ip_addr_tuple(&addr, vm); } @@ -2280,9 +2278,9 @@ mod _socket { #[cfg(target_os = "linux")] { let family = addr.family(); - if family == libc::AF_CAN as libc::sa_family_t { + if family == c::AF_CAN as c::sa_family_t { // AF_CAN address: (interface_name,) or (interface_name, can_id) - let can_addr = unsafe { &*(addr.as_ptr() as *const libc::sockaddr_can) }; + let can_addr = unsafe { &*(addr.as_ptr() as *const c::sockaddr_can) }; let ifindex = can_addr.can_ifindex; let ifname = if ifindex == 0 { String::new() @@ -2291,9 +2289,9 @@ mod _socket { }; return vm.ctx.new_tuple(vec![vm.ctx.new_str(ifname).into()]).into(); } - if family == libc::AF_ALG as libc::sa_family_t { + if family == c::AF_ALG as c::sa_family_t { // AF_ALG address: (type, name) - let alg_addr = unsafe { &*(addr.as_ptr() as *const libc::sockaddr_alg) }; + let alg_addr = unsafe { &*(addr.as_ptr() as *const c::sockaddr_alg) }; let type_bytes = &alg_addr.salg_type; let name_bytes = &alg_addr.salg_name; let type_nul = memchr::memchr(b'\0', type_bytes).unwrap_or(type_bytes.len()); @@ -2319,7 +2317,7 @@ mod _socket { audit.call((vm.ctx.new_str("socket.gethostname"),), vm)?; } - gethostname::gethostname() + rustpython_host_env::socket::hostname() .into_string() .map(|hostname| vm.ctx.new_str(hostname)) .map_err(|err| vm.new_os_error(err.into_string().unwrap())) @@ -2348,7 +2346,7 @@ mod _socket { Ok(vm.ctx.new_str(Ipv4Addr::from(*packed_ip).to_string())) } - fn cstr_opt_as_ptr(x: &OptionalArg) -> *const libc::c_char { + fn cstr_opt_as_ptr(x: &OptionalArg) -> *const core::ffi::c_char { x.as_ref().map_or_else(core::ptr::null, |s| s.as_ptr()) } @@ -2593,7 +2591,7 @@ mod _socket { opts: GAIOptions, vm: &VirtualMachine, ) -> Result, IoOrPyException> { - let hints = dns_lookup::AddrInfoHints { + let hints = host_socket::dns::AddrInfoHints { socktype: opts.ty, protocol: opts.proto, address: opts.family, @@ -2646,7 +2644,7 @@ mod _socket { }; let port = port_encoded.as_deref(); - let addrs = dns_lookup::getaddrinfo(host, port, Some(hints)) + let addrs = host_socket::dns::getaddrinfo(host, port, Some(hints)) .map_err(|err| convert_socket_error(vm, err, SocketError::GaiError))?; let list = addrs @@ -2672,7 +2670,7 @@ mod _socket { vm: &VirtualMachine, ) -> Result<(String, PyListRef, PyListRef), IoOrPyException> { let addr = get_addr(vm, addr, c::AF_UNSPEC)?; - let (hostname, _) = dns_lookup::getnameinfo(&addr, 0) + let (hostname, _) = host_socket::dns::getnameinfo(&addr, 0) .map_err(|e| convert_socket_error(vm, e, SocketError::HError))?; Ok(( hostname, @@ -2697,7 +2695,7 @@ mod _socket { vm: &VirtualMachine, ) -> Result<(String, PyListRef, PyListRef), IoOrPyException> { let addr = get_addr(vm, name, c::AF_INET)?; - let (hostname, _) = dns_lookup::getnameinfo(&addr, 0) + let (hostname, _) = host_socket::dns::getnameinfo(&addr, 0) .map_err(|e| convert_socket_error(vm, e, SocketError::HError))?; Ok(( hostname, @@ -2772,7 +2770,7 @@ mod _socket { } } let (addr, flowinfo, scopeid) = Address::from_tuple_ipv6(&address, vm)?; - let hints = dns_lookup::AddrInfoHints { + let hints = host_socket::dns::AddrInfoHints { address: c::AF_UNSPEC, socktype: c::SOCK_DGRAM, flags: c::AI_NUMERICHOST, @@ -2780,7 +2778,7 @@ mod _socket { }; let service = addr.port.to_string(); let host_str = addr.host.as_str(); - let mut res = dns_lookup::getaddrinfo(Some(host_str), Some(&service), Some(hints)) + let mut res = host_socket::dns::getaddrinfo(Some(host_str), Some(&service), Some(hints)) .map_err(|e| convert_socket_error(vm, e, SocketError::GaiError))? .filter_map(Result::ok); let mut ainfo = res.next().unwrap(); @@ -2800,7 +2798,7 @@ mod _socket { addr.set_scope_id(scopeid); } } - dns_lookup::getnameinfo(&ainfo.sockaddr, flags) + host_socket::dns::getnameinfo(&ainfo.sockaddr, flags) .map_err(|e| convert_socket_error(vm, e, SocketError::GaiError)) } @@ -2811,8 +2809,8 @@ mod _socket { socket_kind: OptionalArg, proto: OptionalArg, ) -> Result<(PySocket, PySocket), IoOrPyException> { - let family = family.unwrap_or(libc::AF_UNIX); - let socket_kind = socket_kind.unwrap_or(libc::SOCK_STREAM); + let family = family.unwrap_or(c::AF_UNIX); + let socket_kind = socket_kind.unwrap_or(c::SOCK_STREAM); let proto = proto.unwrap_or(0); let (a, b) = Socket::pair(family.into(), socket_kind.into(), Some(proto.into()))?; let py_a = PySocket::default(); @@ -2839,7 +2837,7 @@ mod _socket { { let name = name.to_cstring(vm)?; // in case 'if_nametoindex' does not set errno - rustpython_host_env::os::set_errno(libc::ENODEV); + rustpython_host_env::os::set_errno(c::ENODEV); let ret = unsafe { c::if_nametoindex(name.as_ptr() as _) }; if ret == 0 { Err(vm.new_last_errno_error()) @@ -2860,7 +2858,7 @@ mod _socket { { let mut buf = [0; c::IF_NAMESIZE + 1]; // in case 'if_indextoname' does not set errno - rustpython_host_env::os::set_errno(libc::ENXIO); + rustpython_host_env::os::set_errno(c::ENXIO); let ret = unsafe { c::if_indextoname(index, buf.as_mut_ptr()) }; if ret.is_null() { Err(vm.new_last_errno_error()) @@ -2912,13 +2910,13 @@ mod _socket { ) -> Result { let name = pyname.as_str(); if name.is_empty() { - let hints = dns_lookup::AddrInfoHints { + let hints = host_socket::dns::AddrInfoHints { address: af, socktype: c::SOCK_DGRAM, flags: c::AI_PASSIVE, protocol: 0, }; - let mut res = dns_lookup::getaddrinfo(None, Some("0"), Some(hints)) + let mut res = host_socket::dns::getaddrinfo(None, Some("0"), Some(hints)) .map_err(|e| convert_socket_error(vm, e, SocketError::GaiError))?; let ainfo = res.next().unwrap()?; if res.next().is_some() { @@ -2951,7 +2949,7 @@ mod _socket { { return Ok(SocketAddr::V6(net::SocketAddrV6::new(addr, 0, 0, 0))); } - let hints = dns_lookup::AddrInfoHints { + let hints = host_socket::dns::AddrInfoHints { address: af, ..Default::default() }; @@ -2961,7 +2959,7 @@ mod _socket { .encode_text(pyname.into_wtf8(), "idna", None, vm)?; let name = core::str::from_utf8(name.as_bytes()) .map_err(|_| vm.new_runtime_error("idna output is not utf8"))?; - let mut res = dns_lookup::getaddrinfo(Some(name), None, Some(hints)) + let mut res = host_socket::dns::getaddrinfo(Some(name), None, Some(hints)) .map_err(|e| convert_socket_error(vm, e, SocketError::GaiError))?; Ok(res.next().unwrap().map(|ainfo| ainfo.sockaddr)?) } @@ -3027,10 +3025,10 @@ mod _socket { fn convert_socket_error( vm: &VirtualMachine, - err: dns_lookup::LookupError, + err: host_socket::dns::LookupError, err_kind: SocketError, ) -> IoOrPyException { - if let dns_lookup::LookupErrorKind::System = err.kind() { + if let host_socket::dns::LookupErrorKind::System = err.kind() { return io::Error::from(err).into(); } let strerr = { diff --git a/crates/stdlib/src/syslog.rs b/crates/stdlib/src/syslog.rs index 52424972a0a..910175ec6ec 100644 --- a/crates/stdlib/src/syslog.rs +++ b/crates/stdlib/src/syslog.rs @@ -13,7 +13,7 @@ mod syslog { use rustpython_host_env::syslog as host_syslog; #[pyattr] - use libc::{ + use host_syslog::{ LOG_ALERT, LOG_AUTH, LOG_CONS, LOG_CRIT, LOG_DAEMON, LOG_DEBUG, LOG_EMERG, LOG_ERR, LOG_INFO, LOG_KERN, LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7, LOG_LPR, LOG_MAIL, LOG_NDELAY, LOG_NEWS, LOG_NOTICE, LOG_NOWAIT, @@ -22,7 +22,7 @@ mod syslog { #[cfg(not(target_os = "redox"))] #[pyattr] - use libc::{LOG_AUTHPRIV, LOG_CRON, LOG_PERROR}; + use host_syslog::{LOG_AUTHPRIV, LOG_CRON, LOG_PERROR}; fn get_argv(vm: &VirtualMachine) -> Option { if let Some(argv) = vm.state.config.settings.argv.first() diff --git a/crates/stdlib/src/termios.rs b/crates/stdlib/src/termios.rs index 7a2c2472443..2207276f81e 100644 --- a/crates/stdlib/src/termios.rs +++ b/crates/stdlib/src/termios.rs @@ -99,25 +99,9 @@ mod termios { ))] #[pyattr] use host_termios::{CBAUD, CIBAUD, IUCLC, OLCUC, XCASE}; - #[cfg(any( - target_os = "android", - target_os = "freebsd", - target_os = "illumos", - target_os = "linux", - target_os = "macos", - target_os = "solaris" - ))] - #[pyattr] - use host_termios::{TAB0, TABDLY}; - #[cfg(any(target_os = "android", target_os = "linux"))] - #[pyattr] - use host_termios::{VSWTC, VSWTC as VSWTCH}; #[cfg(any(target_os = "illumos", target_os = "solaris"))] #[pyattr] - use host_termios::{VSWTCH, VSWTCH as VSWTC}; - #[cfg(any(target_os = "illumos", target_os = "solaris"))] - #[pyattr] - use libc::{CSTART, CSTOP, CSWTCH}; + use host_termios::{CSTART, CSTOP, CSWTCH}; #[cfg(any( target_os = "dragonfly", target_os = "freebsd", @@ -126,9 +110,9 @@ mod termios { target_os = "openbsd" ))] #[pyattr] - use libc::{FIOASYNC, TIOCGETD, TIOCSETD}; + use host_termios::{FIOASYNC, TIOCGETD, TIOCSETD}; #[pyattr] - use libc::{FIOCLEX, FIONBIO, TIOCGWINSZ, TIOCSWINSZ}; + use host_termios::{FIOCLEX, FIONBIO, TIOCGWINSZ, TIOCSWINSZ}; #[cfg(any( target_os = "android", target_os = "dragonfly", @@ -139,17 +123,27 @@ mod termios { target_os = "openbsd" ))] #[pyattr] - use libc::{ + use host_termios::{ FIONCLEX, FIONREAD, TIOCEXCL, TIOCM_CAR, TIOCM_CD, TIOCM_CTS, TIOCM_DSR, TIOCM_DTR, TIOCM_LE, TIOCM_RI, TIOCM_RNG, TIOCM_RTS, TIOCM_SR, TIOCM_ST, TIOCMBIC, TIOCMBIS, TIOCMGET, TIOCMSET, TIOCNXCL, TIOCSCTTY, }; #[cfg(any(target_os = "android", target_os = "linux"))] #[pyattr] - use libc::{ + use host_termios::{ IBSHIFT, TCFLSH, TCGETA, TCGETS, TCSBRK, TCSETA, TCSETAF, TCSETAW, TCSETS, TCSETSF, TCSETSW, TCXONC, TIOCGSERIAL, TIOCGSOFTCAR, TIOCINQ, TIOCLINUX, TIOCSSOFTCAR, XTABS, }; + #[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", + target_os = "macos", + target_os = "solaris" + ))] + #[pyattr] + use host_termios::{TAB0, TABDLY}; #[cfg(any( target_os = "android", target_os = "dragonfly", @@ -158,13 +152,19 @@ mod termios { target_os = "macos" ))] #[pyattr] - use libc::{TIOCCONS, TIOCGPGRP, TIOCOUTQ, TIOCSPGRP, TIOCSTI}; + use host_termios::{TIOCCONS, TIOCGPGRP, TIOCOUTQ, TIOCSPGRP, TIOCSTI}; #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "macos"))] #[pyattr] - use libc::{ + use host_termios::{ TIOCNOTTY, TIOCPKT, TIOCPKT_DATA, TIOCPKT_DOSTOP, TIOCPKT_FLUSHREAD, TIOCPKT_FLUSHWRITE, TIOCPKT_NOSTOP, TIOCPKT_START, TIOCPKT_STOP, }; + #[cfg(any(target_os = "android", target_os = "linux"))] + #[pyattr] + use host_termios::{VSWTC, VSWTC as VSWTCH}; + #[cfg(any(target_os = "illumos", target_os = "solaris"))] + #[pyattr] + use host_termios::{VSWTCH, VSWTCH as VSWTC}; #[pyfunction] fn tcgetattr(fd: PyObjectRef, vm: &VirtualMachine) -> PyResult> { diff --git a/crates/stdlib/src/uuid.rs b/crates/stdlib/src/uuid.rs index 44121683628..10dc9541755 100644 --- a/crates/stdlib/src/uuid.rs +++ b/crates/stdlib/src/uuid.rs @@ -3,16 +3,13 @@ pub(crate) use _uuid::module_def; #[pymodule] mod _uuid { use crate::{builtins::PyNone, vm::VirtualMachine}; - use mac_address::get_mac_address; use std::sync::OnceLock; use uuid::{ContextV1, Uuid, timestamp::Timestamp}; fn get_node_id() -> [u8; 6] { - match get_mac_address() { - Ok(Some(_ma)) => get_mac_address().unwrap().unwrap().bytes(), - // os_random is expensive, but this is only ever called once - _ => rustpython_common::rand::os_random::<6>(), - } + // os_random is expensive, but this is only ever called once + rustpython_host_env::socket::mac_address() + .unwrap_or_else(rustpython_common::rand::os_random::<6>) } #[pyfunction] diff --git a/crates/vm/Cargo.toml b/crates/vm/Cargo.toml index f4e59e6acc4..0b2feed50a3 100644 --- a/crates/vm/Cargo.toml +++ b/crates/vm/Cargo.toml @@ -91,8 +91,6 @@ writeable = { workspace = true } exitcode = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -rustyline = { workspace = true } -which = { workspace = true } widestring = { workspace = true } [target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] diff --git a/crates/vm/src/getpath.rs b/crates/vm/src/getpath.rs index 63454720178..437db37835b 100644 --- a/crates/vm/src/getpath.rs +++ b/crates/vm/src/getpath.rs @@ -359,7 +359,7 @@ fn get_executable_path() -> Option { #[cfg(not(target_arch = "wasm32"))] { let exec_arg = env::args_os().next()?; - which::which(exec_arg).ok() + crate::host_env::fs::which(exec_arg) } #[cfg(target_arch = "wasm32")] { diff --git a/crates/vm/src/lib.rs b/crates/vm/src/lib.rs index cca5b43457c..c353f8dfc46 100644 --- a/crates/vm/src/lib.rs +++ b/crates/vm/src/lib.rs @@ -86,7 +86,7 @@ pub mod py_io; pub mod py_serde; pub mod gc_state; -pub mod readline; +pub use rustpython_host_env::readline; pub mod recursion; pub mod scope; pub mod sequence;