Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1 @@
{"files":{"Cargo.lock":"27c1bb929fa24f9cd47c0436ccbf7fed7eac7da90961355d1b3f7e55ef926163","Cargo.toml":"4dadc7d3670575a95285001b4b391acffdb26e39c89017a0cc463f12d8cbfbed","LICENSE-APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE-MIT":"508a77d2e7b51d98adeed32648ad124b7b30241a8e70b2e72c99f92d8e5874d1","README.md":"0766c244a5fa03c202a991bb598d415923c8819fd6a2857979c56ccdc5f3b103","src/collections/hash_map.rs":"c3b8d5b77269494277d5b49992978cc38a4be5c8830851e5aea7760e6d0b123b","src/collections/hash_set.rs":"5a487e1ff3c9dc59f40876718271095d2361976396b34db2dc1ea0c30b91d546","src/collections/hash_table.rs":"8c56acacdbdedca8a1c43e4c2af69c553523a806e82e5de83560964a046de320","src/collections/mod.rs":"ef17759abf55999538f9a216597e185cf408ba25bde8f523ab1248997912ad2a","src/hash.rs":"d294813dfa447707f1b3c94629f1b3329530f03e8750adb6b2b7e1f902484e50","src/lib.rs":"9ed6cdb2c37ff8a352999678b8c909f70b7f511835963f04e83d1760570cf5fa","src/sync/atomic.rs":"947f032513b13ac02563d73c86364bcb9a8b496b0141258fa993203be889d0d4","src/sync/barrier.rs":"8a963163141dcb578b3b28fc2172cc97eea9b5382a1d9ea4ff06315b945368fc","src/sync/lazy_lock.rs":"7a3fb92f53c985ed87eee9cab71433ddc3efb6e1ade77fa40d1984267db12193","src/sync/mod.rs":"5b3b7fb8859e2f558d12e0602e51fa7d4bf767cdf99e1c2a37d07ca65fa6f1e3","src/sync/mutex.rs":"f50106d0e11011881a668defbb66b644c97c61b01a817471ad5e767d97b0cdde","src/sync/once.rs":"e14addd3885871eea6fcc813a732c04827d417b0885cd533273f7b50e74760e0","src/sync/poison.rs":"7aa3a6d753e20f5c9be34b587aae4b1dac30d696ec43954838b0a47dab08ae6c","src/sync/rwlock.rs":"b1a40103ef0666277b4b8a18a927fd7b8833cae3b623bee95dfb5488f2e9db45","src/thread.rs":"fec798cc303dd8aa166b5a2712adbb6c1a36c656e718fd453821576617ab6f43","src/time/fallback.rs":"719971a87d1fc708a8d5bb56abb3710cafdc0d28cd79cef4b1ce1e5c960af04d","src/time/mod.rs":"893fc7db00ef9c8e1a2ab2de4c7e36d61ace74dc1921ef1f703afaea62d92d93"},"package":"f7573dc824a1b08b4c93fdbe421c53e1e8188e9ca1dd74a414455fe571facb47"}

308
vendor/bevy_platform/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,308 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bevy_platform"
version = "0.16.1"
dependencies = [
"cfg-if",
"critical-section",
"foldhash",
"getrandom",
"hashbrown",
"portable-atomic",
"portable-atomic-util",
"rayon",
"serde",
"spin",
"web-time",
]
[[package]]
name = "bumpalo"
version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "critical-section"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
[[package]]
name = "crossbeam-deque"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "getrandom"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi",
"wasm-bindgen",
]
[[package]]
name = "hashbrown"
version = "0.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
dependencies = [
"equivalent",
"rayon",
"serde",
]
[[package]]
name = "js-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "libc"
version = "0.2.172"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
[[package]]
name = "log"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "once_cell"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "portable-atomic"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
dependencies = [
"critical-section",
]
[[package]]
name = "portable-atomic-util"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
dependencies = [
"portable-atomic",
]
[[package]]
name = "proc-macro2"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rayon"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "serde"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
dependencies = [
"portable-atomic",
]
[[package]]
name = "syn"
version = "2.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
dependencies = [
"unicode-ident",
]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]

176
vendor/bevy_platform/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,176 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2024"
name = "bevy_platform"
version = "0.16.1"
build = false
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Provides common platform agnostic APIs, as well as platform-specific features for Bevy Engine"
homepage = "https://bevyengine.org"
readme = "README.md"
keywords = ["bevy"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/bevyengine/bevy"
resolver = "2"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"-Zunstable-options",
"--generate-link-to-definition",
]
[features]
alloc = [
"portable-atomic-util/alloc",
"dep:hashbrown",
"serde?/alloc",
]
critical-section = [
"dep:critical-section",
"portable-atomic/critical-section",
]
default = ["std"]
rayon = [
"dep:rayon",
"hashbrown/rayon",
]
serialize = [
"dep:serde",
"hashbrown/serde",
]
std = [
"alloc",
"critical-section?/std",
"portable-atomic/std",
"portable-atomic-util/std",
"spin/std",
"foldhash/std",
"serde?/std",
]
web = [
"dep:web-time",
"dep:getrandom",
]
[lib]
name = "bevy_platform"
path = "src/lib.rs"
[dependencies.cfg-if]
version = "1.0.0"
[dependencies.critical-section]
version = "1.2.0"
optional = true
default-features = false
[dependencies.foldhash]
version = "0.1.3"
default-features = false
[dependencies.hashbrown]
version = "0.15.1"
features = [
"equivalent",
"raw-entry",
]
optional = true
default-features = false
[dependencies.rayon]
version = "1"
optional = true
default-features = false
[dependencies.serde]
version = "1"
optional = true
default-features = false
[dependencies.spin]
version = "0.9.8"
features = [
"mutex",
"spin_mutex",
"rwlock",
"once",
"lazy",
"barrier",
]
default-features = false
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies.portable-atomic]
version = "1"
features = ["fallback"]
default-features = false
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies.spin]
version = "0.9.8"
features = ["portable_atomic"]
default-features = false
[target.'cfg(not(target_has_atomic = "ptr"))'.dependencies.portable-atomic-util]
version = "0.2.4"
default-features = false
[target.'cfg(target_arch = "wasm32")'.dependencies.getrandom]
version = "0.2.0"
features = ["js"]
optional = true
default-features = false
[target.'cfg(target_arch = "wasm32")'.dependencies.web-time]
version = "1.1"
optional = true
default-features = false
[lints.clippy]
alloc_instead_of_core = "warn"
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
doc_markdown = "warn"
manual_let_else = "warn"
match_same_arms = "warn"
needless_lifetimes = "allow"
nonstandard_macro_braces = "warn"
print_stderr = "warn"
print_stdout = "warn"
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
ref_as_ptr = "warn"
semicolon_if_nothing_returned = "warn"
std_instead_of_alloc = "warn"
std_instead_of_core = "warn"
too_long_first_doc_paragraph = "allow"
too_many_arguments = "allow"
type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"
[lints.rust]
missing_docs = "warn"
unsafe_code = "deny"
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"
[lints.rust.unexpected_cfgs]
level = "warn"
priority = 0
check-cfg = ["cfg(docsrs_dep)"]

176
vendor/bevy_platform/LICENSE-APACHE vendored Normal file
View File

@@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

19
vendor/bevy_platform/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,19 @@
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

51
vendor/bevy_platform/README.md vendored Normal file
View File

@@ -0,0 +1,51 @@
# Bevy Platform Support
[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/bevyengine/bevy#license)
[![Crates.io](https://img.shields.io/crates/v/bevy_platform.svg)](https://crates.io/crates/bevy_platform)
[![Downloads](https://img.shields.io/crates/d/bevy_platform.svg)](https://crates.io/crates/bevy_platform)
[![Docs](https://docs.rs/bevy_platform/badge.svg)](https://docs.rs/bevy_platform/latest/bevy_platform/)
[![Discord](https://img.shields.io/discord/691052431525675048.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/bevy)
Rust is a fantastic multi-platform language with extensive support for modern targets through its [standard library](https://doc.rust-lang.org/stable/std/).
However, some items within the standard library have alternatives that are better suited for [Bevy](https://crates.io/crates/bevy) and game engines in general.
Additionally, to support embedded and other esoteric platforms, it's often necessary to shed reliance on `std`, making your crate [`no_std`](https://docs.rust-embedded.org/book/intro/no-std.html).
These needs are handled by this crate, `bevy_platform`.
The goal of this crate is to provide alternatives and extensions to the Rust standard library which minimize friction when developing with and for Bevy across multiple platforms.
## Getting Started
Like any dependency from [crates.io](https://crates.io/), use `cargo` to add it to your `Cargo.toml` file:
```sh
cargo add bevy_platform
```
Now, instead of importing from `std` you can use `bevy_platform` for items it has alternative for.
See the documentation for what items are available, and explanations for _why_ you may want to use them.
## `no_std` Support
By default, `bevy_platform` will activate the `std` feature, requiring access to the `std` crate for whichever platforms you're targeting.
To use this crate on `no_std` platforms, disable default features:
```toml
bevy_platform = { version = "x.y.z", default-features = false }
```
## Features
### `std` (_default_)
Enables usage of the standard library. Note that where this crate has alternatives to the standard library that it considers _better_ than what's provided, it will provide the alternative even when `std` is enabled.
This is explicitly incompatible with `no_std` targets.
### `alloc` (_default_)
Enables usage of the [`alloc`](https://doc.rust-lang.org/stable/alloc/) crate. Note that this feature is automatically enabled when enabling `std`.
This is compatible with most `no_std` targets, but not all.
### `critical-section`
Switches to using [`critical-section`](https://docs.rs/critical-section/latest/critical_section/) as a backend for synchronization.
You may need to enable this feature on platforms with little to no support for atomic operations.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
//! Provides [`HashTable`]
pub use hashbrown::hash_table::{
AbsentEntry, Drain, Entry, ExtractIf, HashTable, IntoIter, Iter, IterHash, IterHashMut,
IterMut, OccupiedEntry, VacantEntry,
};

View File

@@ -0,0 +1,12 @@
//! Provides [`HashMap`] and [`HashSet`] from [`hashbrown`] with some customized defaults.
//!
//! Also provides the [`HashTable`] type, which is specific to [`hashbrown`].
pub use hash_map::HashMap;
pub use hash_set::HashSet;
pub use hash_table::HashTable;
pub use hashbrown::Equivalent;
pub mod hash_map;
pub mod hash_set;
pub mod hash_table;

180
vendor/bevy_platform/src/hash.rs vendored Normal file
View File

@@ -0,0 +1,180 @@
//! Provides replacements for `std::hash` items using [`foldhash`].
//!
//! Also provides some additional items beyond the standard library.
use core::{
fmt::Debug,
hash::{BuildHasher, Hash, Hasher},
marker::PhantomData,
ops::Deref,
};
pub use foldhash::fast::{FixedState, FoldHasher as DefaultHasher, RandomState};
/// For when you want a deterministic hasher.
///
/// Seed was randomly generated with a fair dice roll. Guaranteed to be random:
/// <https://github.com/bevyengine/bevy/pull/1268/files#r560918426>
const FIXED_HASHER: FixedState =
FixedState::with_seed(0b1001010111101110000001001100010000000011001001101011001001111000);
/// Deterministic hasher based upon a random but fixed state.
#[derive(Copy, Clone, Default, Debug)]
pub struct FixedHasher;
impl BuildHasher for FixedHasher {
type Hasher = DefaultHasher;
#[inline]
fn build_hasher(&self) -> Self::Hasher {
FIXED_HASHER.build_hasher()
}
}
/// A pre-hashed value of a specific type. Pre-hashing enables memoization of hashes that are expensive to compute.
///
/// It also enables faster [`PartialEq`] comparisons by short circuiting on hash equality.
/// See [`PassHash`] and [`PassHasher`] for a "pass through" [`BuildHasher`] and [`Hasher`] implementation
/// designed to work with [`Hashed`]
/// See `PreHashMap` for a hashmap pre-configured to use [`Hashed`] keys.
pub struct Hashed<V, S = FixedHasher> {
hash: u64,
value: V,
marker: PhantomData<S>,
}
impl<V: Hash, H: BuildHasher + Default> Hashed<V, H> {
/// Pre-hashes the given value using the [`BuildHasher`] configured in the [`Hashed`] type.
pub fn new(value: V) -> Self {
Self {
hash: H::default().hash_one(&value),
value,
marker: PhantomData,
}
}
/// The pre-computed hash.
#[inline]
pub fn hash(&self) -> u64 {
self.hash
}
}
impl<V, H> Hash for Hashed<V, H> {
#[inline]
fn hash<R: Hasher>(&self, state: &mut R) {
state.write_u64(self.hash);
}
}
impl<V, H> Deref for Hashed<V, H> {
type Target = V;
#[inline]
fn deref(&self) -> &Self::Target {
&self.value
}
}
impl<V: PartialEq, H> PartialEq for Hashed<V, H> {
/// A fast impl of [`PartialEq`] that first checks that `other`'s pre-computed hash
/// matches this value's pre-computed hash.
#[inline]
fn eq(&self, other: &Self) -> bool {
self.hash == other.hash && self.value.eq(&other.value)
}
}
impl<V: Debug, H> Debug for Hashed<V, H> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Hashed")
.field("hash", &self.hash)
.field("value", &self.value)
.finish()
}
}
impl<V: Clone, H> Clone for Hashed<V, H> {
#[inline]
fn clone(&self) -> Self {
Self {
hash: self.hash,
value: self.value.clone(),
marker: PhantomData,
}
}
}
impl<V: Copy, H> Copy for Hashed<V, H> {}
impl<V: Eq, H> Eq for Hashed<V, H> {}
/// A [`BuildHasher`] that results in a [`PassHasher`].
#[derive(Default, Clone)]
pub struct PassHash;
impl BuildHasher for PassHash {
type Hasher = PassHasher;
fn build_hasher(&self) -> Self::Hasher {
PassHasher::default()
}
}
/// A no-op hash that only works on `u64`s. Will panic if attempting to
/// hash a type containing non-u64 fields.
#[derive(Debug, Default)]
pub struct PassHasher {
hash: u64,
}
impl Hasher for PassHasher {
#[inline]
fn finish(&self) -> u64 {
self.hash
}
fn write(&mut self, _bytes: &[u8]) {
panic!("can only hash u64 using PassHasher");
}
#[inline]
fn write_u64(&mut self, i: u64) {
self.hash = i;
}
}
/// [`BuildHasher`] for types that already contain a high-quality hash.
#[derive(Clone, Default)]
pub struct NoOpHash;
impl BuildHasher for NoOpHash {
type Hasher = NoOpHasher;
fn build_hasher(&self) -> Self::Hasher {
NoOpHasher(0)
}
}
#[doc(hidden)]
pub struct NoOpHasher(u64);
// This is for types that already contain a high-quality hash and want to skip
// re-hashing that hash.
impl Hasher for NoOpHasher {
fn finish(&self) -> u64 {
self.0
}
fn write(&mut self, bytes: &[u8]) {
// This should never be called by consumers. Prefer to call `write_u64` instead.
// Don't break applications (slower fallback, just check in test):
self.0 = bytes.iter().fold(self.0, |hash, b| {
hash.rotate_left(8).wrapping_add(*b as u64)
});
}
#[inline]
fn write_u64(&mut self, i: u64) {
self.0 = i;
}
}

49
vendor/bevy_platform/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,49 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"
)]
#![no_std]
//! Platform compatibility support for first-party [Bevy] engine crates.
//!
//! [Bevy]: https://bevyengine.org/
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "alloc")]
extern crate alloc;
pub mod hash;
pub mod sync;
pub mod thread;
pub mod time;
#[cfg(feature = "alloc")]
pub mod collections;
/// Frequently used items which would typically be included in most contexts.
///
/// When adding `no_std` support to a crate for the first time, often there's a substantial refactor
/// required due to the change in implicit prelude from `std::prelude` to `core::prelude`.
/// This unfortunately leaves out many items from `alloc`, even if the crate unconditionally
/// includes that crate.
///
/// This prelude aims to ease the transition by re-exporting items from `alloc` which would
/// otherwise be included in the `std` implicit prelude.
pub mod prelude {
#[cfg(feature = "alloc")]
pub use alloc::{
borrow::ToOwned, boxed::Box, format, string::String, string::ToString, vec, vec::Vec,
};
// Items from `std::prelude` that are missing in this module:
// * dbg
// * eprint
// * eprintln
// * is_x86_feature_detected
// * print
// * println
// * thread_local
}

43
vendor/bevy_platform/src/sync/atomic.rs vendored Normal file
View File

@@ -0,0 +1,43 @@
//! Provides various atomic alternatives to language primitives.
//!
//! Certain platforms lack complete atomic support, requiring the use of a fallback
//! such as `portable-atomic`.
//! Using these types will ensure the correct atomic provider is used without the need for
//! feature gates in your own code.
pub use atomic_16::{AtomicI16, AtomicU16};
pub use atomic_32::{AtomicI32, AtomicU32};
pub use atomic_64::{AtomicI64, AtomicU64};
pub use atomic_8::{AtomicBool, AtomicI8, AtomicU8};
pub use atomic_ptr::{AtomicIsize, AtomicPtr, AtomicUsize};
pub use core::sync::atomic::Ordering;
#[cfg(target_has_atomic = "8")]
use core::sync::atomic as atomic_8;
#[cfg(not(target_has_atomic = "8"))]
use portable_atomic as atomic_8;
#[cfg(target_has_atomic = "16")]
use core::sync::atomic as atomic_16;
#[cfg(not(target_has_atomic = "16"))]
use portable_atomic as atomic_16;
#[cfg(target_has_atomic = "32")]
use core::sync::atomic as atomic_32;
#[cfg(not(target_has_atomic = "32"))]
use portable_atomic as atomic_32;
#[cfg(target_has_atomic = "64")]
use core::sync::atomic as atomic_64;
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic as atomic_64;
#[cfg(target_has_atomic = "ptr")]
use core::sync::atomic as atomic_ptr;
#[cfg(not(target_has_atomic = "ptr"))]
use portable_atomic as atomic_ptr;

View File

@@ -0,0 +1,66 @@
//! Provides `Barrier` and `BarrierWaitResult`
pub use implementation::{Barrier, BarrierWaitResult};
#[cfg(feature = "std")]
use std::sync as implementation;
#[cfg(not(feature = "std"))]
mod implementation {
use core::fmt;
/// Fallback implementation of `Barrier` from the standard library.
pub struct Barrier {
inner: spin::Barrier,
}
impl Barrier {
/// Creates a new barrier that can block a given number of threads.
///
/// See the standard library for further details.
#[must_use]
pub const fn new(n: usize) -> Self {
Self {
inner: spin::Barrier::new(n),
}
}
/// Blocks the current thread until all threads have rendezvoused here.
///
/// See the standard library for further details.
pub fn wait(&self) -> BarrierWaitResult {
BarrierWaitResult {
inner: self.inner.wait(),
}
}
}
impl fmt::Debug for Barrier {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Barrier").finish_non_exhaustive()
}
}
/// Fallback implementation of `BarrierWaitResult` from the standard library.
pub struct BarrierWaitResult {
inner: spin::barrier::BarrierWaitResult,
}
impl BarrierWaitResult {
/// Returns `true` if this thread is the "leader thread" for the call to [`Barrier::wait()`].
///
/// See the standard library for further details.
#[must_use]
pub fn is_leader(&self) -> bool {
self.inner.is_leader()
}
}
impl fmt::Debug for BarrierWaitResult {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BarrierWaitResult")
.field("is_leader", &self.is_leader())
.finish()
}
}
}

View File

@@ -0,0 +1,11 @@
//! Provides `LazyLock`
pub use implementation::LazyLock;
#[cfg(feature = "std")]
use std::sync as implementation;
#[cfg(not(feature = "std"))]
mod implementation {
pub use spin::Lazy as LazyLock;
}

33
vendor/bevy_platform/src/sync/mod.rs vendored Normal file
View File

@@ -0,0 +1,33 @@
//! Provides various synchronization alternatives to language primitives.
//!
//! Currently missing from this module are the following items:
//! * `Condvar`
//! * `WaitTimeoutResult`
//! * `mpsc`
//!
//! Otherwise, this is a drop-in replacement for `std::sync`.
pub use barrier::{Barrier, BarrierWaitResult};
pub use lazy_lock::LazyLock;
pub use mutex::{Mutex, MutexGuard};
pub use once::{Once, OnceLock, OnceState};
pub use poison::{LockResult, PoisonError, TryLockError, TryLockResult};
pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
#[cfg(feature = "alloc")]
pub use arc::{Arc, Weak};
pub mod atomic;
mod barrier;
mod lazy_lock;
mod mutex;
mod once;
mod poison;
mod rwlock;
#[cfg(all(feature = "alloc", not(target_has_atomic = "ptr")))]
use portable_atomic_util as arc;
#[cfg(all(feature = "alloc", target_has_atomic = "ptr"))]
use alloc::sync as arc;

108
vendor/bevy_platform/src/sync/mutex.rs vendored Normal file
View File

@@ -0,0 +1,108 @@
//! Provides `Mutex` and `MutexGuard`
pub use implementation::{Mutex, MutexGuard};
#[cfg(feature = "std")]
use std::sync as implementation;
#[cfg(not(feature = "std"))]
mod implementation {
use crate::sync::{LockResult, TryLockError, TryLockResult};
use core::fmt;
pub use spin::MutexGuard;
/// Fallback implementation of `Mutex` from the standard library.
pub struct Mutex<T: ?Sized> {
inner: spin::Mutex<T>,
}
impl<T> Mutex<T> {
/// Creates a new mutex in an unlocked state ready for use.
///
/// See the standard library for further details.
pub const fn new(t: T) -> Self {
Self {
inner: spin::Mutex::new(t),
}
}
}
impl<T: ?Sized> Mutex<T> {
/// Acquires a mutex, blocking the current thread until it is able to do so.
///
/// See the standard library for further details.
pub fn lock(&self) -> LockResult<MutexGuard<'_, T>> {
Ok(self.inner.lock())
}
/// Attempts to acquire this lock.
///
/// See the standard library for further details.
pub fn try_lock(&self) -> TryLockResult<MutexGuard<'_, T>> {
self.inner.try_lock().ok_or(TryLockError::WouldBlock)
}
/// Determines whether the mutex is poisoned.
///
/// See the standard library for further details.
pub fn is_poisoned(&self) -> bool {
false
}
/// Clear the poisoned state from a mutex.
///
/// See the standard library for further details.
pub fn clear_poison(&self) {
// no-op
}
/// Consumes this mutex, returning the underlying data.
///
/// See the standard library for further details.
pub fn into_inner(self) -> LockResult<T>
where
T: Sized,
{
Ok(self.inner.into_inner())
}
/// Returns a mutable reference to the underlying data.
///
/// See the standard library for further details.
pub fn get_mut(&mut self) -> LockResult<&mut T> {
Ok(self.inner.get_mut())
}
}
impl<T> From<T> for Mutex<T> {
fn from(t: T) -> Self {
Mutex::new(t)
}
}
impl<T: Default> Default for Mutex<T> {
fn default() -> Mutex<T> {
Mutex::new(Default::default())
}
}
impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut d = f.debug_struct("Mutex");
match self.try_lock() {
Ok(guard) => {
d.field("data", &&*guard);
}
Err(TryLockError::Poisoned(err)) => {
d.field("data", &&**err.get_ref());
}
Err(TryLockError::WouldBlock) => {
d.field("data", &format_args!("<locked>"));
}
}
d.field("poisoned", &false);
d.finish_non_exhaustive()
}
}
}

217
vendor/bevy_platform/src/sync/once.rs vendored Normal file
View File

@@ -0,0 +1,217 @@
//! Provides `Once`, `OnceState`, `OnceLock`
pub use implementation::{Once, OnceLock, OnceState};
#[cfg(feature = "std")]
use std::sync as implementation;
#[cfg(not(feature = "std"))]
mod implementation {
use core::{
fmt,
panic::{RefUnwindSafe, UnwindSafe},
};
/// Fallback implementation of `OnceLock` from the standard library.
pub struct OnceLock<T> {
inner: spin::Once<T>,
}
impl<T> OnceLock<T> {
/// Creates a new empty cell.
///
/// See the standard library for further details.
#[must_use]
pub const fn new() -> Self {
Self {
inner: spin::Once::new(),
}
}
/// Gets the reference to the underlying value.
///
/// See the standard library for further details.
pub fn get(&self) -> Option<&T> {
self.inner.get()
}
/// Gets the mutable reference to the underlying value.
///
/// See the standard library for further details.
pub fn get_mut(&mut self) -> Option<&mut T> {
self.inner.get_mut()
}
/// Sets the contents of this cell to `value`.
///
/// See the standard library for further details.
pub fn set(&self, value: T) -> Result<(), T> {
let mut value = Some(value);
self.inner.call_once(|| value.take().unwrap());
match value {
Some(value) => Err(value),
None => Ok(()),
}
}
/// Gets the contents of the cell, initializing it with `f` if the cell
/// was empty.
///
/// See the standard library for further details.
pub fn get_or_init<F>(&self, f: F) -> &T
where
F: FnOnce() -> T,
{
self.inner.call_once(f)
}
/// Consumes the `OnceLock`, returning the wrapped value. Returns
/// `None` if the cell was empty.
///
/// See the standard library for further details.
pub fn into_inner(mut self) -> Option<T> {
self.take()
}
/// Takes the value out of this `OnceLock`, moving it back to an uninitialized state.
///
/// See the standard library for further details.
pub fn take(&mut self) -> Option<T> {
if self.inner.is_completed() {
let mut inner = spin::Once::new();
core::mem::swap(&mut self.inner, &mut inner);
inner.try_into_inner()
} else {
None
}
}
}
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T> {}
impl<T: UnwindSafe> UnwindSafe for OnceLock<T> {}
impl<T> Default for OnceLock<T> {
fn default() -> OnceLock<T> {
OnceLock::new()
}
}
impl<T: fmt::Debug> fmt::Debug for OnceLock<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut d = f.debug_tuple("OnceLock");
match self.get() {
Some(v) => d.field(v),
None => d.field(&format_args!("<uninit>")),
};
d.finish()
}
}
impl<T: Clone> Clone for OnceLock<T> {
fn clone(&self) -> OnceLock<T> {
let cell = Self::new();
if let Some(value) = self.get() {
cell.set(value.clone()).ok().unwrap();
}
cell
}
}
impl<T> From<T> for OnceLock<T> {
fn from(value: T) -> Self {
let cell = Self::new();
cell.set(value).map(move |_| cell).ok().unwrap()
}
}
impl<T: PartialEq> PartialEq for OnceLock<T> {
fn eq(&self, other: &OnceLock<T>) -> bool {
self.get() == other.get()
}
}
impl<T: Eq> Eq for OnceLock<T> {}
/// Fallback implementation of `Once` from the standard library.
pub struct Once {
inner: OnceLock<()>,
}
impl Once {
/// Creates a new `Once` value.
///
/// See the standard library for further details.
#[expect(clippy::new_without_default, reason = "matching std::sync::Once")]
pub const fn new() -> Self {
Self {
inner: OnceLock::new(),
}
}
/// Performs an initialization routine once and only once. The given closure
/// will be executed if this is the first time `call_once` has been called,
/// and otherwise the routine will *not* be invoked.
///
/// See the standard library for further details.
pub fn call_once<F: FnOnce()>(&self, f: F) {
self.inner.get_or_init(f);
}
/// Performs the same function as [`call_once()`] except ignores poisoning.
///
/// See the standard library for further details.
pub fn call_once_force<F: FnOnce(&OnceState)>(&self, f: F) {
const STATE: OnceState = OnceState { _private: () };
self.call_once(move || f(&STATE));
}
/// Returns `true` if some [`call_once()`] call has completed
/// successfully. Specifically, `is_completed` will return false in
/// the following situations:
/// * [`call_once()`] was not called at all,
/// * [`call_once()`] was called, but has not yet completed,
/// * the [`Once`] instance is poisoned
///
/// See the standard library for further details.
pub fn is_completed(&self) -> bool {
self.inner.get().is_some()
}
}
impl RefUnwindSafe for Once {}
impl UnwindSafe for Once {}
impl fmt::Debug for Once {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Once").finish_non_exhaustive()
}
}
/// Fallback implementation of `OnceState` from the standard library.
pub struct OnceState {
_private: (),
}
impl OnceState {
/// Returns `true` if the associated [`Once`] was poisoned prior to the
/// invocation of the closure passed to [`Once::call_once_force()`].
///
/// See the standard library for further details.
pub fn is_poisoned(&self) -> bool {
false
}
}
impl fmt::Debug for OnceState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("OnceState")
.field("poisoned", &self.is_poisoned())
.finish()
}
}
}

107
vendor/bevy_platform/src/sync/poison.rs vendored Normal file
View File

@@ -0,0 +1,107 @@
//! Provides `LockResult`, `PoisonError`, `TryLockError`, `TryLockResult`
pub use implementation::{LockResult, PoisonError, TryLockError, TryLockResult};
#[cfg(feature = "std")]
use std::sync as implementation;
#[cfg(not(feature = "std"))]
mod implementation {
use core::{error::Error, fmt};
/// Fallback implementation of `PoisonError` from the standard library.
pub struct PoisonError<T> {
guard: T,
}
impl<T> fmt::Debug for PoisonError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PoisonError").finish_non_exhaustive()
}
}
impl<T> fmt::Display for PoisonError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"poisoned lock: another task failed inside".fmt(f)
}
}
impl<T> Error for PoisonError<T> {}
impl<T> PoisonError<T> {
/// Creates a `PoisonError`.
///
/// See the standard library for further details.
#[cfg(panic = "unwind")]
pub fn new(guard: T) -> PoisonError<T> {
PoisonError { guard }
}
/// Consumes this error indicating that a lock is poisoned, returning the
/// underlying guard to allow access regardless.
///
/// See the standard library for further details.
pub fn into_inner(self) -> T {
self.guard
}
/// Reaches into this error indicating that a lock is poisoned, returning a
/// reference to the underlying guard to allow access regardless.
///
/// See the standard library for further details.
pub fn get_ref(&self) -> &T {
&self.guard
}
/// Reaches into this error indicating that a lock is poisoned, returning a
/// mutable reference to the underlying guard to allow access regardless.
///
/// See the standard library for further details.
pub fn get_mut(&mut self) -> &mut T {
&mut self.guard
}
}
/// Fallback implementation of `TryLockError` from the standard library.
pub enum TryLockError<T> {
/// The lock could not be acquired because another thread failed while holding
/// the lock.
Poisoned(PoisonError<T>),
/// The lock could not be acquired at this time because the operation would
/// otherwise block.
WouldBlock,
}
impl<T> From<PoisonError<T>> for TryLockError<T> {
fn from(err: PoisonError<T>) -> TryLockError<T> {
TryLockError::Poisoned(err)
}
}
impl<T> fmt::Debug for TryLockError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
TryLockError::Poisoned(..) => "Poisoned(..)".fmt(f),
TryLockError::WouldBlock => "WouldBlock".fmt(f),
}
}
}
impl<T> fmt::Display for TryLockError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
TryLockError::Poisoned(..) => "poisoned lock: another task failed inside",
TryLockError::WouldBlock => "try_lock failed because the operation would block",
}
.fmt(f)
}
}
impl<T> Error for TryLockError<T> {}
/// Fallback implementation of `LockResult` from the standard library.
pub type LockResult<Guard> = Result<Guard, PoisonError<Guard>>;
/// Fallback implementation of `TryLockResult` from the standard library.
pub type TryLockResult<Guard> = Result<Guard, TryLockError<Guard>>;
}

124
vendor/bevy_platform/src/sync/rwlock.rs vendored Normal file
View File

@@ -0,0 +1,124 @@
//! Provides `RwLock`, `RwLockReadGuard`, `RwLockWriteGuard`
pub use implementation::{RwLock, RwLockReadGuard, RwLockWriteGuard};
#[cfg(feature = "std")]
use std::sync as implementation;
#[cfg(not(feature = "std"))]
mod implementation {
use crate::sync::{LockResult, TryLockError, TryLockResult};
use core::fmt;
pub use spin::rwlock::{RwLockReadGuard, RwLockWriteGuard};
/// Fallback implementation of `RwLock` from the standard library.
pub struct RwLock<T: ?Sized> {
inner: spin::RwLock<T>,
}
impl<T> RwLock<T> {
/// Creates a new instance of an `RwLock<T>` which is unlocked.
///
/// See the standard library for further details.
pub const fn new(t: T) -> RwLock<T> {
Self {
inner: spin::RwLock::new(t),
}
}
}
impl<T: ?Sized> RwLock<T> {
/// Locks this `RwLock` with shared read access, blocking the current thread
/// until it can be acquired.
///
/// See the standard library for further details.
pub fn read(&self) -> LockResult<RwLockReadGuard<'_, T>> {
Ok(self.inner.read())
}
/// Attempts to acquire this `RwLock` with shared read access.
///
/// See the standard library for further details.
pub fn try_read(&self) -> TryLockResult<RwLockReadGuard<'_, T>> {
self.inner.try_read().ok_or(TryLockError::WouldBlock)
}
/// Locks this `RwLock` with exclusive write access, blocking the current
/// thread until it can be acquired.
///
/// See the standard library for further details.
pub fn write(&self) -> LockResult<RwLockWriteGuard<'_, T>> {
Ok(self.inner.write())
}
/// Attempts to lock this `RwLock` with exclusive write access.
///
/// See the standard library for further details.
pub fn try_write(&self) -> TryLockResult<RwLockWriteGuard<'_, T>> {
self.inner.try_write().ok_or(TryLockError::WouldBlock)
}
/// Determines whether the lock is poisoned.
///
/// See the standard library for further details.
pub fn is_poisoned(&self) -> bool {
false
}
/// Clear the poisoned state from a lock.
///
/// See the standard library for further details.
pub fn clear_poison(&self) {
// no-op
}
/// Consumes this `RwLock`, returning the underlying data.
///
/// See the standard library for further details.
pub fn into_inner(self) -> LockResult<T>
where
T: Sized,
{
Ok(self.inner.into_inner())
}
/// Returns a mutable reference to the underlying data.
///
/// See the standard library for further details.
pub fn get_mut(&mut self) -> LockResult<&mut T> {
Ok(self.inner.get_mut())
}
}
impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut d = f.debug_struct("RwLock");
match self.try_read() {
Ok(guard) => {
d.field("data", &&*guard);
}
Err(TryLockError::Poisoned(err)) => {
d.field("data", &&**err.get_ref());
}
Err(TryLockError::WouldBlock) => {
d.field("data", &format_args!("<locked>"));
}
}
d.field("poisoned", &false);
d.finish_non_exhaustive()
}
}
impl<T: Default> Default for RwLock<T> {
fn default() -> RwLock<T> {
RwLock::new(Default::default())
}
}
impl<T> From<T> for RwLock<T> {
fn from(t: T) -> Self {
RwLock::new(t)
}
}
}

29
vendor/bevy_platform/src/thread.rs vendored Normal file
View File

@@ -0,0 +1,29 @@
//! Provides `sleep` for all platforms.
pub use thread::sleep;
cfg_if::cfg_if! {
// TODO: use browser timeouts based on ScheduleRunnerPlugin::build
if #[cfg(feature = "std")] {
use std::thread;
} else {
mod fallback {
use core::{hint::spin_loop, time::Duration};
use crate::time::Instant;
/// Puts the current thread to sleep for at least the specified amount of time.
///
/// As this is a `no_std` fallback implementation, this will spin the current thread.
pub fn sleep(dur: Duration) {
let start = Instant::now();
while start.elapsed() < dur {
spin_loop()
}
}
}
use fallback as thread;
}
}

View File

@@ -0,0 +1,177 @@
//! Provides a fallback implementation of `Instant` from the standard library.
#![expect(
unsafe_code,
reason = "Instant fallback requires unsafe to allow users to update the internal value"
)]
use crate::sync::atomic::{AtomicPtr, Ordering};
use core::{
fmt,
ops::{Add, AddAssign, Sub, SubAssign},
time::Duration,
};
static ELAPSED_GETTER: AtomicPtr<()> = AtomicPtr::new(unset_getter as *mut _);
/// Fallback implementation of `Instant` suitable for a `no_std` environment.
///
/// If you are on any of the following target architectures, this is a drop-in replacement:
///
/// - `x86`
/// - `x86_64`
/// - `aarch64`
///
/// On any other architecture, you must call [`Instant::set_elapsed`], providing a method
/// which when called supplies a monotonically increasing count of elapsed nanoseconds relative
/// to some arbitrary point in time.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Instant(Duration);
impl Instant {
/// Returns an instant corresponding to "now".
#[must_use]
pub fn now() -> Instant {
let getter = ELAPSED_GETTER.load(Ordering::Acquire);
// SAFETY: Function pointer is always valid
let getter = unsafe { core::mem::transmute::<*mut (), fn() -> Duration>(getter) };
Self((getter)())
}
/// Provides a function returning the amount of time that has elapsed since execution began.
/// The getter provided to this method will be used by [`now`](Instant::now).
///
/// # Safety
///
/// - The function provided must accurately represent the elapsed time.
/// - The function must preserve all invariants of the [`Instant`] type.
/// - The pointer to the function must be valid whenever [`Instant::now`] is called.
pub unsafe fn set_elapsed(getter: fn() -> Duration) {
ELAPSED_GETTER.store(getter as *mut _, Ordering::Release);
}
/// Returns the amount of time elapsed from another instant to this one,
/// or zero duration if that instant is later than this one.
#[must_use]
pub fn duration_since(&self, earlier: Instant) -> Duration {
self.saturating_duration_since(earlier)
}
/// Returns the amount of time elapsed from another instant to this one,
/// or None if that instant is later than this one.
///
/// Due to monotonicity bugs, even under correct logical ordering of the passed `Instant`s,
/// this method can return `None`.
#[must_use]
pub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration> {
self.0.checked_sub(earlier.0)
}
/// Returns the amount of time elapsed from another instant to this one,
/// or zero duration if that instant is later than this one.
#[must_use]
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
self.0.saturating_sub(earlier.0)
}
/// Returns the amount of time elapsed since this instant.
#[must_use]
pub fn elapsed(&self) -> Duration {
Instant::now().saturating_duration_since(*self)
}
/// Returns `Some(t)` where `t` is the time `self + duration` if `t` can be represented as
/// `Instant` (which means it's inside the bounds of the underlying data structure), `None`
/// otherwise.
pub fn checked_add(&self, duration: Duration) -> Option<Instant> {
self.0.checked_add(duration).map(Instant)
}
/// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as
/// `Instant` (which means it's inside the bounds of the underlying data structure), `None`
/// otherwise.
pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
self.0.checked_sub(duration).map(Instant)
}
}
impl Add<Duration> for Instant {
type Output = Instant;
/// # Panics
///
/// This function may panic if the resulting point in time cannot be represented by the
/// underlying data structure. See [`Instant::checked_add`] for a version without panic.
fn add(self, other: Duration) -> Instant {
self.checked_add(other)
.expect("overflow when adding duration to instant")
}
}
impl AddAssign<Duration> for Instant {
fn add_assign(&mut self, other: Duration) {
*self = *self + other;
}
}
impl Sub<Duration> for Instant {
type Output = Instant;
fn sub(self, other: Duration) -> Instant {
self.checked_sub(other)
.expect("overflow when subtracting duration from instant")
}
}
impl SubAssign<Duration> for Instant {
fn sub_assign(&mut self, other: Duration) {
*self = *self - other;
}
}
impl Sub<Instant> for Instant {
type Output = Duration;
/// Returns the amount of time elapsed from another instant to this one,
/// or zero duration if that instant is later than this one.
fn sub(self, other: Instant) -> Duration {
self.duration_since(other)
}
}
impl fmt::Debug for Instant {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
fn unset_getter() -> Duration {
cfg_if::cfg_if! {
if #[cfg(target_arch = "x86")] {
// SAFETY: standard technique for getting a nanosecond counter on x86
let nanos = unsafe {
core::arch::x86::_rdtsc()
};
Duration::from_nanos(nanos)
} else if #[cfg(target_arch = "x86_64")] {
// SAFETY: standard technique for getting a nanosecond counter on x86_64
let nanos = unsafe {
core::arch::x86_64::_rdtsc()
};
Duration::from_nanos(nanos)
} else if #[cfg(target_arch = "aarch64")] {
// SAFETY: standard technique for getting a nanosecond counter of aarch64
let nanos = unsafe {
let mut ticks: u64;
core::arch::asm!("mrs {}, cntvct_el0", out(reg) ticks);
ticks
};
Duration::from_nanos(nanos)
} else {
panic!("An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`")
}
}
}

15
vendor/bevy_platform/src/time/mod.rs vendored Normal file
View File

@@ -0,0 +1,15 @@
//! Provides `Instant` for all platforms.
pub use time::Instant;
cfg_if::cfg_if! {
if #[cfg(all(target_arch = "wasm32", feature = "web"))] {
use web_time as time;
} else if #[cfg(feature = "std")] {
use std::time;
} else {
mod fallback;
use fallback as time;
}
}