`zerocopy` support
Subsystems (6)
Miguel Ojeda
maintainercover `zerocopy` support
This patch series introduces support for zerocopy:
Fast, safe, compile error. Pick two.
Zerocopy makes zero-cost memory manipulation effortless. We write unsafe so you don't have to.
It essentially provides derivable traits (e.g. FromBytes) and macros (e.g. transmute!) for safely converting between byte sequences and other types. Having such support allows us to remove some unsafe code.
It is among the most downloaded Rust crates (top #50 recent, top #100 all-time downloads; according to crates.io), and it is also used by the Rust compiler itself.
The series starts with a few preparation commits, then the zerocopy and zerocopy-derive crates are added. Finally, an example patch using it is on top, removing one unsafe impl.
I had to adapt the crates slightly (just +2/-3 lines), but both patches could potentially be provided upstream eventually. Please see the commits for details.
In total, it is about ~39k lines added, ~32k without counting benches/ which are just for documentation purposes.
See the cover letter for syn for some more details about depending on third-party crates in commit 54e3eae85562 ("Merge patch series "syn support"").
The codegen of an isolated example function similar to the patch on top is essentially identical. It also turns out that (for that particular case) zerocopy's version, even under debug-assertions enabled, has no remaining panics, unlike a few in the current code (because the compiler can prove the remaining ub_checks statically).
So their "fast, safe" does indeed check out -- at least in that case.
P.S. This version of zerocopy has already the unstable Ptr{,Inner} types -- to play with them, please use:
make ... KRUSTFLAGS=--cfg=zerocopy_unstable_ptr
Miguel Ojeda (18):
scripts: generate_rust_analyzer: support passing env vars
rust: kbuild: show the right quiet_cmd_rustc_procmacrolibrary
rust: kbuild: remove unused variable
rust: kbuild: define procmacro-name function
rust: kbuild: define procmacro-extension variable
rust: kbuild: support per-target environment variables
rust: kbuild: support skip_clippy for rustc_procmacro
rust: zerocopy: import crate
rust: zerocopy: add SPDX License Identifiers
rust: zerocopy: remove float Display support
rust: zerocopy: add README.md
rust: zerocopy: enable support in kbuild
rust: zerocopy-derive: import crate
rust: zerocopy-derive: add SPDX License Identifiers
rust: zerocopy-derive: avoid generating non-ASCII identifiers
rust: zerocopy-derive: add README.md
rust: zerocopy-derive: enable support in kbuild
gpu: nova-core: firmware: parse FalconUCodeDescV2 via zerocopy
Makefile | 2 + drivers/gpu/nova-core/firmware.rs | 5 +- drivers/gpu/nova-core/vbios.rs | 4 +- rust/Makefile | 91 +- rust/zerocopy-derive/README.md | 14 + rust/zerocopy-derive/derive/from_bytes.rs | 192 + rust/zerocopy-derive/derive/into_bytes.rs | 164 + rust/zerocopy-derive/derive/known_layout.rs | 350 + rust/zerocopy-derive/derive/mod.rs | 132 + rust/zerocopy-derive/derive/try_from_bytes.rs | 765 ++ rust/zerocopy-derive/derive/unaligned.rs | 80 + rust/zerocopy-derive/lib.rs | 146 + rust/zerocopy-derive/repr.rs | 851 ++ rust/zerocopy-derive/util.rs | 845 ++ rust/zerocopy/README.md | 14 + .../zerocopy/benches/as_bytes_dynamic_size.rs | 9 + .../benches/as_bytes_dynamic_size.x86-64 | 5 + .../benches/as_bytes_dynamic_size.x86-64.mca | 47 + rust/zerocopy/benches/as_bytes_static_size.rs | 9 + .../benches/as_bytes_static_size.x86-64 | 4 + .../benches/as_bytes_static_size.x86-64.mca | 45 + rust/zerocopy/benches/extend_vec_zeroed.rs | 9 + .../zerocopy/benches/extend_vec_zeroed.x86-64 | 60 + .../benches/extend_vec_zeroed.x86-64.mca | 147 + .../benches/formats/coco_dynamic_padding.rs | 24 + .../benches/formats/coco_dynamic_size.rs | 27 + .../benches/formats/coco_static_size.rs | 27 + rust/zerocopy/benches/insert_vec_zeroed.rs | 13 + .../zerocopy/benches/insert_vec_zeroed.x86-64 | 79 + .../benches/insert_vec_zeroed.x86-64.mca | 183 + rust/zerocopy/benches/new_box_zeroed.rs | 9 + rust/zerocopy/benches/new_box_zeroed.x86-64 | 7 + .../benches/new_box_zeroed.x86-64.mca | 51 + ...w_box_zeroed_with_elems_dynamic_padding.rs | 11 + ...x_zeroed_with_elems_dynamic_padding.x86-64 | 24 + ...roed_with_elems_dynamic_padding.x86-64.mca | 81 + .../new_box_zeroed_with_elems_dynamic_size.rs | 9 + ..._box_zeroed_with_elems_dynamic_size.x86-64 | 22 + ..._zeroed_with_elems_dynamic_size.x86-64.mca | 77 + rust/zerocopy/benches/new_vec_zeroed.rs | 9 + rust/zerocopy/benches/new_vec_zeroed.x86-64 | 40 + .../benches/new_vec_zeroed.x86-64.mca | 113 + rust/zerocopy/benches/new_zeroed.rs | 9 + rust/zerocopy/benches/new_zeroed.x86-64 | 3 + rust/zerocopy/benches/new_zeroed.x86-64.mca | 43 + rust/zerocopy/benches/read_from_bytes.rs | 7 + rust/zerocopy/benches/read_from_bytes.x86-64 | 15 + .../benches/read_from_bytes.x86-64.mca | 65 + rust/zerocopy/benches/read_from_prefix.rs | 10 + rust/zerocopy/benches/read_from_prefix.x86-64 | 14 + .../benches/read_from_prefix.x86-64.mca | 63 + rust/zerocopy/benches/read_from_suffix.rs | 10 + rust/zerocopy/benches/read_from_suffix.x86-64 | 15 + .../benches/read_from_suffix.x86-64.mca | 65 + .../benches/ref_from_bytes_dynamic_padding.rs | 7 + .../ref_from_bytes_dynamic_padding.x86-64 | 22 + .../ref_from_bytes_dynamic_padding.x86-64.mca | 77 + .../benches/ref_from_bytes_dynamic_size.rs | 7 + .../ref_from_bytes_dynamic_size.x86-64 | 20 + .../ref_from_bytes_dynamic_size.x86-64.mca | 75 + .../benches/ref_from_bytes_static_size.rs | 7 + .../benches/ref_from_bytes_static_size.x86-64 | 8 + .../ref_from_bytes_static_size.x86-64.mca | 53 + ...f_from_bytes_with_elems_dynamic_padding.rs | 10 + ...om_bytes_with_elems_dynamic_padding.x86-64 | 19 + ...ytes_with_elems_dynamic_padding.x86-64.mca | 71 + .../ref_from_bytes_with_elems_dynamic_size.rs | 10 + ..._from_bytes_with_elems_dynamic_size.x86-64 | 16 + ...m_bytes_with_elems_dynamic_size.x86-64.mca | 65 + .../ref_from_prefix_dynamic_padding.rs | 10 + .../ref_from_prefix_dynamic_padding.x86-64 | 22 + ...ref_from_prefix_dynamic_padding.x86-64.mca | 77 + .../benches/ref_from_prefix_dynamic_size.rs | 10 + .../ref_from_prefix_dynamic_size.x86-64 | 17 + .../ref_from_prefix_dynamic_size.x86-64.mca | 67 + .../benches/ref_from_prefix_static_size.rs | 10 + .../ref_from_prefix_static_size.x86-64 | 8 + .../ref_from_prefix_static_size.x86-64.mca | 53 + ..._from_prefix_with_elems_dynamic_padding.rs | 13 + ...m_prefix_with_elems_dynamic_padding.x86-64 | 26 + ...efix_with_elems_dynamic_padding.x86-64.mca | 85 + ...ref_from_prefix_with_elems_dynamic_size.rs | 13 + ...from_prefix_with_elems_dynamic_size.x86-64 | 22 + ..._prefix_with_elems_dynamic_size.x86-64.mca | 77 + .../ref_from_suffix_dynamic_padding.rs | 10 + .../ref_from_suffix_dynamic_padding.x86-64 | 23 + ...ref_from_suffix_dynamic_padding.x86-64.mca | 79 + .../benches/ref_from_suffix_dynamic_size.rs | 10 + .../ref_from_suffix_dynamic_size.x86-64 | 13 + .../ref_from_suffix_dynamic_size.x86-64.mca | 63 + .../benches/ref_from_suffix_static_size.rs | 10 + .../ref_from_suffix_static_size.x86-64 | 13 + .../ref_from_suffix_static_size.x86-64.mca | 61 + ..._from_suffix_with_elems_dynamic_padding.rs | 13 + ...m_suffix_with_elems_dynamic_padding.x86-64 | 27 + ...ffix_with_elems_dynamic_padding.x86-64.mca | 85 + ...ref_from_suffix_with_elems_dynamic_size.rs | 13 + ...from_suffix_with_elems_dynamic_size.x86-64 | 23 + ..._suffix_with_elems_dynamic_size.x86-64.mca | 77 + .../benches/split_at_dynamic_padding.rs | 12 + .../benches/split_at_dynamic_padding.x86-64 | 12 + .../split_at_dynamic_padding.x86-64.mca | 59 + .../zerocopy/benches/split_at_dynamic_size.rs | 12 + .../benches/split_at_dynamic_size.x86-64 | 12 + .../benches/split_at_dynamic_size.x86-64.mca | 59 + .../split_at_unchecked_dynamic_padding.rs | 12 + .../split_at_unchecked_dynamic_padding.x86-64 | 6 + ...it_at_unchecked_dynamic_padding.x86-64.mca | 49 + .../split_at_unchecked_dynamic_size.rs | 12 + .../split_at_unchecked_dynamic_size.x86-64 | 6 + ...split_at_unchecked_dynamic_size.x86-64.mca | 49 + .../split_via_immutable_dynamic_padding.rs | 11 + ...split_via_immutable_dynamic_padding.x86-64 | 14 + ...t_via_immutable_dynamic_padding.x86-64.mca | 65 + .../split_via_immutable_dynamic_size.rs | 11 + .../split_via_immutable_dynamic_size.x86-64 | 13 + ...plit_via_immutable_dynamic_size.x86-64.mca | 63 + ...split_via_runtime_check_dynamic_padding.rs | 11 + ...t_via_runtime_check_dynamic_padding.x86-64 | 22 + ...a_runtime_check_dynamic_padding.x86-64.mca | 79 + .../split_via_runtime_check_dynamic_size.rs | 11 + ...plit_via_runtime_check_dynamic_size.x86-64 | 13 + ..._via_runtime_check_dynamic_size.x86-64.mca | 63 + .../split_via_unchecked_dynamic_padding.rs | 11 + ...split_via_unchecked_dynamic_padding.x86-64 | 14 + ...t_via_unchecked_dynamic_padding.x86-64.mca | 65 + .../split_via_unchecked_dynamic_size.rs | 11 + .../split_via_unchecked_dynamic_size.x86-64 | 13 + ...plit_via_unchecked_dynamic_size.x86-64.mca | 63 + rust/zerocopy/benches/transmute.rs | 16 + rust/zerocopy/benches/transmute.x86-64 | 3 + rust/zerocopy/benches/transmute.x86-64.mca | 43 + .../benches/transmute_ref_dynamic_size.rs | 16 + .../benches/transmute_ref_dynamic_size.x86-64 | 4 + .../transmute_ref_dynamic_size.x86-64.mca | 45 + .../benches/transmute_ref_static_size.rs | 15 + .../benches/transmute_ref_static_size.x86-64 | 3 + .../transmute_ref_static_size.x86-64.mca | 43 + rust/zerocopy/benches/try_read_from_bytes.rs | 7 + .../benches/try_read_from_bytes.x86-64 | 23 + .../benches/try_read_from_bytes.x86-64.mca | 79 + rust/zerocopy/benches/try_read_from_prefix.rs | 10 + .../benches/try_read_from_prefix.x86-64 | 16 + .../benches/try_read_from_prefix.x86-64.mca | 67 + rust/zerocopy/benches/try_read_from_suffix.rs | 10 + .../benches/try_read_from_suffix.x86-64 | 18 + .../benches/try_read_from_suffix.x86-64.mca | 71 + .../try_ref_from_bytes_dynamic_padding.rs | 7 + .../try_ref_from_bytes_dynamic_padding.x86-64 | 24 + ..._ref_from_bytes_dynamic_padding.x86-64.mca | 81 + .../try_ref_from_bytes_dynamic_size.rs | 7 + .../try_ref_from_bytes_dynamic_size.x86-64 | 22 + ...try_ref_from_bytes_dynamic_size.x86-64.mca | 79 + .../benches/try_ref_from_bytes_static_size.rs | 7 + .../try_ref_from_bytes_static_size.x86-64 | 13 + .../try_ref_from_bytes_static_size.x86-64.mca | 59 + ...f_from_bytes_with_elems_dynamic_padding.rs | 10 + ...om_bytes_with_elems_dynamic_padding.x86-64 | 21 + ...ytes_with_elems_dynamic_padding.x86-64.mca | 75 + ..._ref_from_bytes_with_elems_dynamic_size.rs | 10 + ..._from_bytes_with_elems_dynamic_size.x86-64 | 18 + ...m_bytes_with_elems_dynamic_size.x86-64.mca | 69 + .../try_ref_from_prefix_dynamic_padding.rs | 10 + ...try_ref_from_prefix_dynamic_padding.x86-64 | 29 + ...ref_from_prefix_dynamic_padding.x86-64.mca | 91 + .../try_ref_from_prefix_dynamic_size.rs | 10 + .../try_ref_from_prefix_dynamic_size.x86-64 | 22 + ...ry_ref_from_prefix_dynamic_size.x86-64.mca | 77 + .../try_ref_from_prefix_static_size.rs | 10 + .../try_ref_from_prefix_static_size.x86-64 | 15 + ...try_ref_from_prefix_static_size.x86-64.mca | 63 + ..._from_prefix_with_elems_dynamic_padding.rs | 13 + ...m_prefix_with_elems_dynamic_padding.x86-64 | 30 + ...efix_with_elems_dynamic_padding.x86-64.mca | 91 + ...ref_from_prefix_with_elems_dynamic_size.rs | 13 + ...from_prefix_with_elems_dynamic_size.x86-64 | 26 + ..._prefix_with_elems_dynamic_size.x86-64.mca | 83 + .../try_ref_from_suffix_dynamic_padding.rs | 10 + ...try_ref_from_suffix_dynamic_padding.x86-64 | 26 + ...ref_from_suffix_dynamic_padding.x86-64.mca | 85 + .../try_ref_from_suffix_dynamic_size.rs | 10 + .../try_ref_from_suffix_dynamic_size.x86-64 | 18 + ...ry_ref_from_suffix_dynamic_size.x86-64.mca | 71 + .../try_ref_from_suffix_static_size.rs | 10 + .../try_ref_from_suffix_static_size.x86-64 | 16 + ...try_ref_from_suffix_static_size.x86-64.mca | 67 + ..._from_suffix_with_elems_dynamic_padding.rs | 13 + ...m_suffix_with_elems_dynamic_padding.x86-64 | 32 + ...ffix_with_elems_dynamic_padding.x86-64.mca | 95 + ...ref_from_suffix_with_elems_dynamic_size.rs | 13 + ...from_suffix_with_elems_dynamic_size.x86-64 | 28 + ..._suffix_with_elems_dynamic_size.x86-64.mca | 87 + rust/zerocopy/benches/try_transmute.rs | 16 + rust/zerocopy/benches/try_transmute.x86-64 | 9 + .../zerocopy/benches/try_transmute.x86-64.mca | 55 + .../benches/try_transmute_ref_dynamic_size.rs | 18 + .../try_transmute_ref_dynamic_size.x86-64 | 6 + .../try_transmute_ref_dynamic_size.x86-64.mca | 49 + .../benches/try_transmute_ref_static_size.rs | 17 + .../try_transmute_ref_static_size.x86-64 | 5 + .../try_transmute_ref_static_size.x86-64.mca | 47 + .../zerocopy/benches/write_to_dynamic_size.rs | 9 + .../benches/write_to_dynamic_size.x86-64 | 21 + .../benches/write_to_dynamic_size.x86-64.mca | 77 + .../benches/write_to_prefix_dynamic_size.rs | 12 + .../write_to_prefix_dynamic_size.x86-64 | 21 + .../write_to_prefix_dynamic_size.x86-64.mca | 77 + .../benches/write_to_prefix_static_size.rs | 12 + .../write_to_prefix_static_size.x86-64 | 11 + .../write_to_prefix_static_size.x86-64.mca | 57 + rust/zerocopy/benches/write_to_static_size.rs | 9 + .../benches/write_to_static_size.x86-64 | 11 + .../benches/write_to_static_size.x86-64.mca | 57 + .../benches/write_to_suffix_dynamic_size.rs | 12 + .../write_to_suffix_dynamic_size.x86-64 | 22 + .../write_to_suffix_dynamic_size.x86-64.mca | 79 + .../benches/write_to_suffix_static_size.rs | 12 + .../write_to_suffix_static_size.x86-64 | 11 + .../write_to_suffix_static_size.x86-64.mca | 57 + rust/zerocopy/benches/zero_dynamic_padding.rs | 9 + .../benches/zero_dynamic_padding.x86-64 | 7 + .../benches/zero_dynamic_padding.x86-64.mca | 51 + rust/zerocopy/benches/zero_dynamic_size.rs | 9 + .../zerocopy/benches/zero_dynamic_size.x86-64 | 5 + .../benches/zero_dynamic_size.x86-64.mca | 47 + rust/zerocopy/benches/zero_static_size.rs | 9 + rust/zerocopy/benches/zero_static_size.x86-64 | 4 + .../benches/zero_static_size.x86-64.mca | 45 + rust/zerocopy/rustdoc/style.css | 57 + rust/zerocopy/src/byte_slice.rs | 434 + rust/zerocopy/src/byteorder.rs | 1564 ++++ rust/zerocopy/src/deprecated.rs | 281 + rust/zerocopy/src/error.rs | 1350 +++ rust/zerocopy/src/impls.rs | 2389 ++++++ rust/zerocopy/src/layout.rs | 2225 +++++ rust/zerocopy/src/lib.rs | 7612 +++++++++++++++++ rust/zerocopy/src/macros.rs | 1825 ++++ rust/zerocopy/src/pointer/inner.rs | 754 ++ rust/zerocopy/src/pointer/invariant.rs | 298 + rust/zerocopy/src/pointer/mod.rs | 410 + rust/zerocopy/src/pointer/ptr.rs | 1586 ++++ rust/zerocopy/src/pointer/transmute.rs | 522 ++ rust/zerocopy/src/ref.rs | 1358 +++ rust/zerocopy/src/split_at.rs | 1090 +++ rust/zerocopy/src/util/macro_util.rs | 1310 +++ rust/zerocopy/src/util/macros.rs | 1067 +++ rust/zerocopy/src/util/mod.rs | 938 ++ rust/zerocopy/src/wrappers.rs | 1034 +++ scripts/Makefile.build | 1 + scripts/generate_rust_analyzer.py | 38 +- 250 files changed, 38711 insertions(+), 27 deletions(-) create mode 100644 rust/zerocopy-derive/README.md create mode 100644 rust/zerocopy-derive/derive/from_bytes.rs create mode 100644 rust/zerocopy-derive/derive/into_bytes.rs create mode 100644 rust/zerocopy-derive/derive/known_layout.rs create mode 100644 rust/zerocopy-derive/derive/mod.rs create mode 100644 rust/zerocopy-derive/derive/try_from_bytes.rs create mode 100644 rust/zerocopy-derive/derive/unaligned.rs create mode 100644 rust/zerocopy-derive/lib.rs create mode 100644 rust/zerocopy-derive/repr.rs create mode 100644 rust/zerocopy-derive/util.rs create mode 100644 rust/zerocopy/README.md create mode 100644 rust/zerocopy/benches/as_bytes_dynamic_size.rs create mode 100644 rust/zerocopy/benches/as_bytes_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/as_bytes_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/as_bytes_static_size.rs create mode 100644 rust/zerocopy/benches/as_bytes_static_size.x86-64 create mode 100644 rust/zerocopy/benches/as_bytes_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/extend_vec_zeroed.rs create mode 100644 rust/zerocopy/benches/extend_vec_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/extend_vec_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/formats/coco_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/formats/coco_dynamic_size.rs create mode 100644 rust/zerocopy/benches/formats/coco_static_size.rs create mode 100644 rust/zerocopy/benches/insert_vec_zeroed.rs create mode 100644 rust/zerocopy/benches/insert_vec_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/insert_vec_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/new_box_zeroed.rs create mode 100644 rust/zerocopy/benches/new_box_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/new_box_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/new_vec_zeroed.rs create mode 100644 rust/zerocopy/benches/new_vec_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/new_vec_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/new_zeroed.rs create mode 100644 rust/zerocopy/benches/new_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/new_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/read_from_bytes.rs create mode 100644 rust/zerocopy/benches/read_from_bytes.x86-64 create mode 100644 rust/zerocopy/benches/read_from_bytes.x86-64.mca create mode 100644 rust/zerocopy/benches/read_from_prefix.rs create mode 100644 rust/zerocopy/benches/read_from_prefix.x86-64 create mode 100644 rust/zerocopy/benches/read_from_prefix.x86-64.mca create mode 100644 rust/zerocopy/benches/read_from_suffix.rs create mode 100644 rust/zerocopy/benches/read_from_suffix.x86-64 create mode 100644 rust/zerocopy/benches/read_from_suffix.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_static_size.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_static_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_static_size.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_static_size.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_at_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_at_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_at_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_at_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/transmute.rs create mode 100644 rust/zerocopy/benches/transmute.x86-64 create mode 100644 rust/zerocopy/benches/transmute.x86-64.mca create mode 100644 rust/zerocopy/benches/transmute_ref_dynamic_size.rs create mode 100644 rust/zerocopy/benches/transmute_ref_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/transmute_ref_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/transmute_ref_static_size.rs create mode 100644 rust/zerocopy/benches/transmute_ref_static_size.x86-64 create mode 100644 rust/zerocopy/benches/transmute_ref_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_read_from_bytes.rs create mode 100644 rust/zerocopy/benches/try_read_from_bytes.x86-64 create mode 100644 rust/zerocopy/benches/try_read_from_bytes.x86-64.mca create mode 100644 rust/zerocopy/benches/try_read_from_prefix.rs create mode 100644 rust/zerocopy/benches/try_read_from_prefix.x86-64 create mode 100644 rust/zerocopy/benches/try_read_from_prefix.x86-64.mca create mode 100644 rust/zerocopy/benches/try_read_from_suffix.rs create mode 100644 rust/zerocopy/benches/try_read_from_suffix.x86-64 create mode 100644 rust/zerocopy/benches/try_read_from_suffix.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_static_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_static_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_static_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_transmute.rs create mode 100644 rust/zerocopy/benches/try_transmute.x86-64 create mode 100644 rust/zerocopy/benches/try_transmute.x86-64.mca create mode 100644 rust/zerocopy/benches/try_transmute_ref_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_transmute_ref_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_transmute_ref_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_transmute_ref_static_size.rs create mode 100644 rust/zerocopy/benches/try_transmute_ref_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_transmute_ref_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_dynamic_size.rs create mode 100644 rust/zerocopy/benches/write_to_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_prefix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/write_to_prefix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_prefix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_prefix_static_size.rs create mode 100644 rust/zerocopy/benches/write_to_prefix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_prefix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_static_size.rs create mode 100644 rust/zerocopy/benches/write_to_static_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_suffix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/write_to_suffix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_suffix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_suffix_static_size.rs create mode 100644 rust/zerocopy/benches/write_to_suffix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_suffix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/zero_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/zero_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/zero_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/zero_dynamic_size.rs create mode 100644 rust/zerocopy/benches/zero_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/zero_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/zero_static_size.rs create mode 100644 rust/zerocopy/benches/zero_static_size.x86-64 create mode 100644 rust/zerocopy/benches/zero_static_size.x86-64.mca create mode 100644 rust/zerocopy/rustdoc/style.css create mode 100644 rust/zerocopy/src/byte_slice.rs create mode 100644 rust/zerocopy/src/byteorder.rs create mode 100644 rust/zerocopy/src/deprecated.rs create mode 100644 rust/zerocopy/src/error.rs create mode 100644 rust/zerocopy/src/impls.rs create mode 100644 rust/zerocopy/src/layout.rs create mode 100644 rust/zerocopy/src/lib.rs create mode 100644 rust/zerocopy/src/macros.rs create mode 100644 rust/zerocopy/src/pointer/inner.rs create mode 100644 rust/zerocopy/src/pointer/invariant.rs create mode 100644 rust/zerocopy/src/pointer/mod.rs create mode 100644 rust/zerocopy/src/pointer/ptr.rs create mode 100644 rust/zerocopy/src/pointer/transmute.rs create mode 100644 rust/zerocopy/src/ref.rs create mode 100644 rust/zerocopy/src/split_at.rs create mode 100644 rust/zerocopy/src/util/macro_util.rs create mode 100644 rust/zerocopy/src/util/macros.rs create mode 100644 rust/zerocopy/src/util/mod.rs create mode 100644 rust/zerocopy/src/wrappers.rs
base-commit: 025fd4b4fd382112bd4489e5b4437a295934fc19 --
2.54.0
Miguel Ojeda
maintainerPATCH 1/18 scripts: generate_rust_analyzer: support passing env vars
A future commit adding zerocopy support will need to pass an environment variable during its build.
Thus add support for an --envs parameter, similar to --cfgs, that allows to pass a map of variables to set for a given crate.
This allows us to keep a single source of truth for those values.
No change intended in the generated rust-project.json.
--- scripts/generate_rust_analyzer.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
scripts/generate_rust_analyzer.py +18 -4
@@ -26,6 +26,14 @@ def args_crates_cfgs(cfgs: List[str]) -> Dict[str, List[str]]: return crates_cfgs +def args_crates_envs(envs: List[str]) -> Dict[str, Dict[str, str]]: + crates_envs = {} + for env in envs: + crate, vals = env.split("=", 1) + crates_envs[crate] = dict(v.split("=", 1) for v in vals.split()) + + return crates_envs + class Dependency(TypedDict): crate: int name: str
@@ -61,6 +69,7 @@ def generate_crates( sysroot_src: pathlib.Path, external_src: Optional[pathlib.Path], cfgs: List[str], + envs: List[str], core_edition: str, ) -> List[Crate]: # Generate the configuration list.
@@ -74,6 +83,7 @@ def generate_crates( # Now fill the crates list. crates: List[Crate] = [] crates_cfgs = args_crates_cfgs(cfgs) + crates_envs = args_crates_envs(envs) def get_crate_name(path: pathlib.Path) -> str: return invoke_rustc(["--print", "crate-name", str(path)])
@@ -92,6 +102,10 @@ def generate_crates( is_workspace_member if is_workspace_member is not None else True ) edition = edition if edition is not None else "2021" + crate_env = { + "RUST_MODFILE": "This is only for rust-analyzer" + } + crate_env.update(crates_envs.get(display_name, {})) return { "display_name": display_name, "root_module": str(root_module),
@@ -99,9 +113,7 @@ def generate_crates( "deps": deps, "cfg": cfg, "edition": edition, - "env": { - "RUST_MODFILE": "This is only for rust-analyzer" - } + "env": crate_env, } def append_proc_macro_crate(
@@ -347,6 +359,7 @@ def main() -> None: parser = argparse.ArgumentParser() parser.add_argument('--verbose', '-v', action='store_true') parser.add_argument('--cfgs', action='append', default=[]) + parser.add_argument('--envs', action='append', default=[]) parser.add_argument("core_edition") parser.add_argument("srctree", type=pathlib.Path) parser.add_argument("objtree", type=pathlib.Path)
@@ -357,6 +370,7 @@ def main() -> None: class Args(argparse.Namespace): verbose: bool cfgs: List[str] + envs: List[str] srctree: pathlib.Path objtree: pathlib.Path sysroot: pathlib.Path
@@ -372,7 +386,7 @@ def main() -> None: ) rust_project = { - "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.core_edition), + "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.envs, args.core_edition), "sysroot": str(args.sysroot), }
Signature · 1 line
2.54.0
Re: [PATCH 01/18] scripts: generate_rust_analyzer: support passing env vars
Quoted 4 lines · Miguel Ojeda
A future commit adding
zerocopysupport will need to pass an environment variable during its build.
Quoted 8 lines
Thus add support for an
--envsparameter, similar to--cfgs, that allows to pass a map of variables to set for a given crate.This allows us to keep a single source of truth for those values.
No change intended in the generated
rust-project.json.Signed-off-by Miguel Ojeda <[email protected]>
Cc'ing Tamir and Jesung for this one.
Cheers,
Miguel
Re: [PATCH 01/18] scripts: generate_rust_analyzer: support passing env vars
In reply to Miguel OjedaQuoted 52 lines · Miguel Ojeda
A future commit adding
zerocopysupport will need to pass an environment variable during its build.Thus add support for an
--envsparameter, similar to--cfgs, that allows to pass a map of variables to set for a given crate.This allows us to keep a single source of truth for those values.
No change intended in the generated
rust-project.json.Signed-off-by Miguel Ojeda <[email protected]>--- scripts/generate_rust_analyzer.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)scripts/generate_rust_analyzer.py +10
-0@@ -26,6 +26,14 @@ def args_crates_cfgs(cfgs: List[str]) -> Dict[str, List[str]]: return crates_cfgs +def args_crates_envs(envs: List[str]) -> Dict[str, Dict[str, str]]: + crates_envs = {} + for env in envs: + crate, vals = env.split("=", 1) + crates_envs[crate] = dict(v.split("=", 1) for v in vals.split()) + + return crates_envs + class Dependency(TypedDict): crate: int name: str@@ -61,6 +69,7 @@ def generate_crates( sysroot_src: pathlib.Path, external_src: Optional[pathlib.Path], cfgs: List[str], + envs: List[str], core_edition: str, ) -> List[Crate]: # Generate the configuration list.@@ -74,6 +83,7 @@ def generate_crates( # Now fill the crates list. crates: List[Crate] = [] crates_cfgs = args_crates_cfgs(cfgs) + crates_envs = args_crates_envs(envs) def get_crate_name(path: pathlib.Path) -> str: return invoke_rustc(["--print", "crate-name", str(path)])
scripts/generate_rust_analyzer.py def generate_crates( · line 108
Quoted 7 lines
scripts/generate_rust_analyzer.py +4
-0@@ -92,6 +102,10 @@ def generate_crates( is_workspace_member if is_workspace_member is not None else True ) edition = edition if edition is not None else "2021" + crate_env = { + "RUST_MODFILE": "This is only for rust-analyzer" + } + crate_env.update(crates_envs.get(display_name, {}))
This can be
crate_env = {
"RUST_MODFILE": "This is only for rust-analyzer", **crates_envs.get(display_name, {}),
}
Quoted 40 lines
scripts/generate_rust_analyzer.py +4
-5return { "display_name": display_name, "root_module": str(root_module),@@ -99,9 +113,7 @@ def generate_crates( "deps": deps, "cfg": cfg, "edition": edition, - "env": { - "RUST_MODFILE": "This is only for rust-analyzer" - } + "env": crate_env, } def append_proc_macro_crate(@@ -347,6 +359,7 @@ def main() -> None: parser = argparse.ArgumentParser() parser.add_argument('--verbose', '-v', action='store_true') parser.add_argument('--cfgs', action='append', default=[]) + parser.add_argument('--envs', action='append', default=[]) parser.add_argument("core_edition") parser.add_argument("srctree", type=pathlib.Path) parser.add_argument("objtree", type=pathlib.Path)@@ -357,6 +370,7 @@ def main() -> None: class Args(argparse.Namespace): verbose: bool cfgs: List[str] + envs: List[str] srctree: pathlib.Path objtree: pathlib.Path sysroot: pathlib.Path@@ -372,7 +386,7 @@ def main() -> None: ) rust_project = { - "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.core_edition), + "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.envs, args.core_edition), "sysroot": str(args.sysroot), } --
Quoted 3 lines
2.54.0
Did you want to take this through rust or did you want me to pick it?
Re: [PATCH 01/18] scripts: generate_rust_analyzer: support passing env vars
Quoted 7 lines · Tamir Duberstein
This can be
crate_env= {
"RUST_MODFILE": "This is only for rust-analyzer", **crates_envs.get(display_name, {}),
}
Sounds good.
Quoted 3 lines
Acked-by Tamir Duberstein <[email protected]>Did you want to take this through rust or did you want me to pick it?
It is cleaner to carry it with the series (I will likely create a merge commit for the patch series anyway, since it is a major one in volume at least).
Unless you need it through rust-analyzer-next for some reason, of course (but still it should land in the same cycle; otherwise, it would be broken for folks later on).
Thanks for the quick reply!
Cheers,
Miguel
Tamir Duberstein
maintainerRe: [PATCH 01/18] scripts: generate_rust_analyzer: support passing env vars
Quoted 12 lines · Miguel Ojeda
Quoted 7 lines · Tamir Duberstein
This can be
crate_env= {
"RUST_MODFILE": "This is only for rust-analyzer", **crates_envs.get(display_name, {}),
}Sounds good.
Quoted 7 lines
Quoted 3 lines
Acked-by Tamir Duberstein <[email protected]>Did you want to take this through rust or did you want me to pick it?
It is cleaner to carry it with the series (I will likely create a merge commit for the patch series anyway, since it is a major one in volume at least).
Duh, I missed that this was in a series. Makes sense!
Quoted 1 line
Thanks for the quick reply!
You're welcome!
Miguel Ojeda
maintainerPATCH 2/18 rust: kbuild: show the right `quiet_cmd_rustc_procmacrolibrary`
In reply to Miguel OjedaWhen Clippy is skipped, RUSTC should be shown in quiet instead of CLIPPY to be accurate and to avoid confusion.
Thus do so, matching what we do in quiet_cmd_rustc_library.
--- rust/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/Makefile +1 -1
@@ -517,7 +517,7 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE $(call if_changed,exports) -quiet_cmd_rustc_procmacrolibrary = $(RUSTC_OR_CLIPPY_QUIET) PL $@ +quiet_cmd_rustc_procmacrolibrary = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) PL $@ cmd_rustc_procmacrolibrary = \ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
Signature · 1 line
2.54.0
Re: [PATCH 02/18] rust: kbuild: show the right `quiet_cmd_rustc_procmacrolibrary`
Quoted 11 lines · Miguel Ojeda
When Clippy is skipped,
RUSTCshould be shown inquietinstead ofCLIPPYto be accurate and to avoid confusion.Thus do so, matching what we do in
quiet_cmd_rustc_library.Fixes 7dbe46c0b11d ("rust: kbuild: add proc macro library support")Signed-off-by Miguel Ojeda <[email protected]>--- rust/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Miguel Ojeda
maintainerPATCH 3/18 rust: kbuild: remove unused variable
In reply to Miguel OjedaSince we are adding one more proc macro crate (zerocopy-derive), we are refactoring their handling.
libpin_init_internal_extension was added to mimic the setup for macros, but it is not used, since the extension is expected to be the same.
Thus remove it.
--- rust/Makefile | 1 - 1 file changed, 1 deletion(-)
rust/Makefile +0 -1
@@ -51,7 +51,6 @@ libmacros_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name ma libmacros_extension := $(patsubst libmacros.%,%,$(libmacros_name)) libpin_init_internal_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name pin_init_internal --crate-type proc-macro - </dev/null) -libpin_init_internal_extension := $(patsubst libpin_init_internal.%,%,$(libpin_init_internal_name)) always-$(CONFIG_RUST) += $(libmacros_name) $(libpin_init_internal_name)
Signature · 1 line
2.54.0
Re: [PATCH 03/18] rust: kbuild: remove unused variable
Quoted 7 lines · Miguel Ojeda
Since we are adding one more proc macro crate (
zerocopy-derive), we are refactoring their handling.
libpin_init_internal_extensionwas added to mimic the setup formacros, but it is not used, since the extension is expected to be the same.
Quoted 7 lines
Thus remove it.
Signed-off-by Miguel Ojeda <[email protected]>--- rust/Makefile | 1 - 1 file changed, 1 deletion(-)
Miguel Ojeda
maintainerPATCH 4/18 rust: kbuild: define `procmacro-name` function
In reply to Miguel OjedaSince we are adding one more proc macro crate (zerocopy-derive), we are refactoring their handling.
Thus define a procmacro-name function and use it to fill the existing variables' values.
--- rust/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
rust/Makefile +4 -2
@@ -47,10 +47,12 @@ endif # Avoids running `$(RUSTC)` when it may not be available. ifdef CONFIG_RUST -libmacros_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name macros --crate-type proc-macro - </dev/null) +procmacro-name = $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name $(1) --crate-type proc-macro - </dev/null) + +libmacros_name := $(call procmacro-name,macros) libmacros_extension := $(patsubst libmacros.%,%,$(libmacros_name)) -libpin_init_internal_name := $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name pin_init_internal --crate-type proc-macro - </dev/null) +libpin_init_internal_name := $(call procmacro-name,pin_init_internal) always-$(CONFIG_RUST) += $(libmacros_name) $(libpin_init_internal_name)
Signature · 1 line
2.54.0
Re: [PATCH 04/18] rust: kbuild: define `procmacro-name` function
Quoted 11 lines · Miguel Ojeda
Since we are adding one more proc macro crate (
zerocopy-derive), we are refactoring their handling.Thus define a
procmacro-namefunction and use it to fill the existing variables' values.Signed-off-by Miguel Ojeda <[email protected]>--- rust/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Miguel Ojeda
maintainerPATCH 5/18 rust: kbuild: define `procmacro-extension` variable
In reply to Miguel OjedaSince we are adding one more proc macro crate (zerocopy-derive), we are refactoring their handling.
Thus, instead of using libmacros_extension as the common variable to hold the extension for all of them, use a dedicated variable with a more generic name (including for its implementation).
--- rust/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
rust/Makefile +2 -3
@@ -48,10 +48,9 @@ endif ifdef CONFIG_RUST procmacro-name = $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name $(1) --crate-type proc-macro - </dev/null) +procmacro-extension := $(patsubst libname.%,%,$(call procmacro-name,name)) libmacros_name := $(call procmacro-name,macros) -libmacros_extension := $(patsubst libmacros.%,%,$(libmacros_name)) - libpin_init_internal_name := $(call procmacro-name,pin_init_internal) always-$(CONFIG_RUST) += $(libmacros_name) $(libpin_init_internal_name)
@@ -549,7 +548,7 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ -Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \ --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \ --crate-type proc-macro -L$(objtree)/$(obj) \ - --crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) \ + --crate-name $(patsubst lib%.$(procmacro-extension),%,$(notdir $@)) \ @$(objtree)/include/generated/rustc_cfg $< # Procedural macros can only be used with the `rustc` that compiled it.
Signature · 1 line
2.54.0
Nicolas Schier
maintainerRe: [PATCH 05/18] rust: kbuild: define `procmacro-extension` variable
Quoted 17 lines · Miguel Ojeda
Since we are adding one more proc macro crate (
zerocopy-derive), we are refactoring their handling.Thus, instead of using
libmacros_extensionas the common variable to hold the extension for all of them, use a dedicated variable with a more generic name (including for its implementation).Signed-off-by Miguel Ojeda <[email protected]>--- rust/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)rust/Makefile +0
-0
rust/Makefile endif · line 51
Quoted 4 lines
rust/Makefile +1
-0@@ -48,10 +48,9 @@ endif ifdef CONFIG_RUST procmacro-name = $(shell MAKEFLAGS= $(RUSTC) --print file-names --crate-name $(1) --crate-type proc-macro - </dev/null) +procmacro-extension := $(patsubst libname.%,%,$(call procmacro-name,name))
Where does the 'libname.%' pattern come from? Looking at the current users of cmd_rustc_procmacro I'd expect a 'lib%' pattern instead.
Signature · 1 line
Nicolas
Re: [PATCH 05/18] rust: kbuild: define `procmacro-extension` variable
Quoted 3 lines · Nicolas Schier
Where does the 'libname.%' pattern come from? Looking at the current users of
cmd_rustc_procmacroI'd expect a 'lib%' pattern instead.
Here, we want to extract the extension the operating system uses -- this was originally added for macOS build support (Cc Tamir), and is .so in Linux but .dylib there (and if I recall correctly, we couldn't force rustc in macOS to use a file with .so as the extension, sadly).
In the commands, however, what we are trying to extract is the name of the crate instead. So that is why one is lib% and the other libname.% (a dummy library name).
Or do you mean something else?
Thanks a lot for the reviews! By the way, I sent a bit ago v2 (it doesn't change much, so I will pick your tags from here :)
Cheers,
Miguel
Re: [PATCH 05/18] rust: kbuild: define `procmacro-extension` variable
Quoted 11 lines · Miguel Ojeda
Quoted 3 lines · Nicolas Schier
Where does the 'libname.%' pattern come from? Looking at the current users of
cmd_rustc_procmacroI'd expect a 'lib%' pattern instead.Here, we want to extract the extension the operating system uses -- this was originally added for macOS build support (Cc Tamir), and is
.soin Linux but.dylibthere (and if I recall correctly, we couldn't forcerustcin macOS to use a file with.soas the extension, sadly).
Quoted 5 lines
In the commands, however, what we are trying to extract is the name of the crate instead. So that is why one is
lib%and the otherlibname.%(a dummy library name).Or do you mean something else?
Ah thanks! If only that filename extension ('so' or 'dylib') is wanted, I'd rather expected the use of the '$(suffix)' function instead, as it may be easier to understand w/o knowing the name conversion rustc does:
procmacro-extension := $(suffix $(call procmacro-name,dummy-crate-name))
but that's bike-shedding.
Quoted 2 lines
Thanks a lot for the reviews! By the way, I sent a bit ago v2 (it doesn't change much, so I will pick your tags from here :)
Thanks.
Kind regards,
Nicolas
Re: [PATCH 05/18] rust: kbuild: define `procmacro-extension` variable
Quoted 8 lines · Nicolas Schier
Ah thanks! If only that filename extension ('so' or 'dylib') is wanted, I'd rather expected the use of the '$(suffix)' function instead, as it may be easier to understand w/o knowing the name conversion rustc does:
procmacro-extension := $(suffix $(call procmacro-name,dummy-crate-name))but that's bike-shedding.
Good point, I didn't consider suffix at all, so we can definitely do that. Do you want to submit a patch?
Although from a quick test, suffix keeps the period, so we need changes elsewhere (also we cannot use - in the crate name, so dummy or the current name should suffice).
Thanks!
Cheers,
Miguel
Miguel Ojeda
maintainerPATCH 6/18 rust: kbuild: support per-target environment variables
In reply to Miguel OjedaCertain vendored crates, like the upcoming zerocopy, use extra environment variables (e.g. via env!).
Thus add support to easily specify those.
--- rust/Makefile | 3 +++ 1 file changed, 3 insertions(+)
rust/Makefile +3 -0
@@ -144,6 +144,7 @@ doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rust quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< cmd_rustdoc = \ + $(rustc_target_envs) \ OBJTREE=$(abspath $(objtree)) \ $(RUSTDOC) $(filter-out $(skip_flags) --remap-path-scope=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \ $(rustc_target_flags) -L$(objtree)/$(obj) \
@@ -250,6 +251,7 @@ rustdoc-clean: FORCE quiet_cmd_rustc_test_library = $(RUSTC_OR_CLIPPY_QUIET) TL $< cmd_rustc_test_library = \ + $(rustc_target_envs) \ OBJTREE=$(abspath $(objtree)) \ $(RUSTC_OR_CLIPPY) $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \ @$(objtree)/include/generated/rustc_cfg \
@@ -567,6 +569,7 @@ $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs \ # since Rust 1.95.0 (https://github.com/rust-lang/rust/pull/151534). quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@ cmd_rustc_library = \ + $(rustc_target_envs) \ OBJTREE=$(abspath $(objtree)) \ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ $(filter-out $(skip_flags),$(rust_flags)) $(rustc_target_flags) \
Signature · 1 line
2.54.0
Re: [PATCH 06/18] rust: kbuild: support per-target environment variables
Quoted 10 lines · Miguel Ojeda
Certain vendored crates, like the upcoming
zerocopy, use extra environment variables (e.g. viaenv!).Thus add support to easily specify those.
Signed-off-by Miguel Ojeda <[email protected]>--- rust/Makefile | 3 +++ 1 file changed, 3 insertions(+)
Signature · 1 line
Nicolas
Miguel Ojeda
maintainerPATCH 7/18 rust: kbuild: support `skip_clippy` for `rustc_procmacro`
In reply to Miguel OjedaCertain vendored crates, like the upcoming zerocopy-derive, do not need to be built with Clippy since we --cap-lints=allow them anyway.
Thus add support to skip Clippy for proc macro crates.
--- rust/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rust/Makefile +2 -2
@@ -543,9 +543,9 @@ $(obj)/libsyn.rlib: private rustc_target_flags = $(syn-flags) $(obj)/libsyn.rlib: $(src)/syn/lib.rs $(obj)/libquote.rlib FORCE +$(call if_changed_dep,rustc_procmacrolibrary) -quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ +quiet_cmd_rustc_procmacro = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) P $@ cmd_rustc_procmacro = \ - $(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \ + $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) $(rust_common_flags) $(rustc_target_flags) \ -Clinker-flavor=gcc -Clinker=$(HOSTCC) \ -Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \ --emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
Signature · 1 line
2.54.0
Re: [PATCH 07/18] rust: kbuild: support `skip_clippy` for `rustc_procmacro`
Quoted 10 lines · Miguel Ojeda
Certain vendored crates, like the upcoming
zerocopy-derive, do not need to be built with Clippy since we--cap-lints=allowthem anyway.Thus add support to skip Clippy for proc macro crates.
Signed-off-by Miguel Ojeda <[email protected]>--- rust/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
Nicolas
Miguel Ojeda
maintainerPATCH 8/18 rust: zerocopy: import crate
In reply to Miguel OjedaThis is a subset of the Rust zerocopy crate, version v0.8.50 (released 2026-05-31), licensed under "BSD-2-Clause OR Apache-2.0 OR MIT", from:
https://github.com/google/zerocopy/tree/v0.8.50
The files are copied as-is, with no modifications whatsoever (not even adding the SPDX identifiers).
The benches folder is added (i.e. not just src like in other cases) since the files there are included in the rendered documentation, as well as the rustdoc CSS style file that is needed to make those visually more understandable.
For copyright details, please see:
https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT
The next two patches modify these files as needed for use within the kernel. This patch split allows reviewers to double-check the import and to clearly see the differences introduced.
The following script may be used to verify the contents:
for path in $(cd rust/zerocopy/ && find . -type f); do
curl --silent --show-error --location \
https://github.com/google/zerocopy/raw/v0.8.50/$path \
| diff --unified rust/zerocopy/$path - && echo $path: OK
done--- .../zerocopy/benches/as_bytes_dynamic_size.rs | 9 + .../benches/as_bytes_dynamic_size.x86-64 | 5 + .../benches/as_bytes_dynamic_size.x86-64.mca | 47 + rust/zerocopy/benches/as_bytes_static_size.rs | 9 + .../benches/as_bytes_static_size.x86-64 | 4 + .../benches/as_bytes_static_size.x86-64.mca | 45 + rust/zerocopy/benches/extend_vec_zeroed.rs | 9 + .../zerocopy/benches/extend_vec_zeroed.x86-64 | 60 + .../benches/extend_vec_zeroed.x86-64.mca | 147 + .../benches/formats/coco_dynamic_padding.rs | 24 + .../benches/formats/coco_dynamic_size.rs | 27 + .../benches/formats/coco_static_size.rs | 27 + rust/zerocopy/benches/insert_vec_zeroed.rs | 13 + .../zerocopy/benches/insert_vec_zeroed.x86-64 | 79 + .../benches/insert_vec_zeroed.x86-64.mca | 183 + rust/zerocopy/benches/new_box_zeroed.rs | 9 + rust/zerocopy/benches/new_box_zeroed.x86-64 | 7 + .../benches/new_box_zeroed.x86-64.mca | 51 + ...w_box_zeroed_with_elems_dynamic_padding.rs | 11 + ...x_zeroed_with_elems_dynamic_padding.x86-64 | 24 + ...roed_with_elems_dynamic_padding.x86-64.mca | 81 + .../new_box_zeroed_with_elems_dynamic_size.rs | 9 + ..._box_zeroed_with_elems_dynamic_size.x86-64 | 22 + ..._zeroed_with_elems_dynamic_size.x86-64.mca | 77 + rust/zerocopy/benches/new_vec_zeroed.rs | 9 + rust/zerocopy/benches/new_vec_zeroed.x86-64 | 40 + .../benches/new_vec_zeroed.x86-64.mca | 113 + rust/zerocopy/benches/new_zeroed.rs | 9 + rust/zerocopy/benches/new_zeroed.x86-64 | 3 + rust/zerocopy/benches/new_zeroed.x86-64.mca | 43 + rust/zerocopy/benches/read_from_bytes.rs | 7 + rust/zerocopy/benches/read_from_bytes.x86-64 | 15 + .../benches/read_from_bytes.x86-64.mca | 65 + rust/zerocopy/benches/read_from_prefix.rs | 10 + rust/zerocopy/benches/read_from_prefix.x86-64 | 14 + .../benches/read_from_prefix.x86-64.mca | 63 + rust/zerocopy/benches/read_from_suffix.rs | 10 + rust/zerocopy/benches/read_from_suffix.x86-64 | 15 + .../benches/read_from_suffix.x86-64.mca | 65 + .../benches/ref_from_bytes_dynamic_padding.rs | 7 + .../ref_from_bytes_dynamic_padding.x86-64 | 22 + .../ref_from_bytes_dynamic_padding.x86-64.mca | 77 + .../benches/ref_from_bytes_dynamic_size.rs | 7 + .../ref_from_bytes_dynamic_size.x86-64 | 20 + .../ref_from_bytes_dynamic_size.x86-64.mca | 75 + .../benches/ref_from_bytes_static_size.rs | 7 + .../benches/ref_from_bytes_static_size.x86-64 | 8 + .../ref_from_bytes_static_size.x86-64.mca | 53 + ...f_from_bytes_with_elems_dynamic_padding.rs | 10 + ...om_bytes_with_elems_dynamic_padding.x86-64 | 19 + ...ytes_with_elems_dynamic_padding.x86-64.mca | 71 + .../ref_from_bytes_with_elems_dynamic_size.rs | 10 + ..._from_bytes_with_elems_dynamic_size.x86-64 | 16 + ...m_bytes_with_elems_dynamic_size.x86-64.mca | 65 + .../ref_from_prefix_dynamic_padding.rs | 10 + .../ref_from_prefix_dynamic_padding.x86-64 | 22 + ...ref_from_prefix_dynamic_padding.x86-64.mca | 77 + .../benches/ref_from_prefix_dynamic_size.rs | 10 + .../ref_from_prefix_dynamic_size.x86-64 | 17 + .../ref_from_prefix_dynamic_size.x86-64.mca | 67 + .../benches/ref_from_prefix_static_size.rs | 10 + .../ref_from_prefix_static_size.x86-64 | 8 + .../ref_from_prefix_static_size.x86-64.mca | 53 + ..._from_prefix_with_elems_dynamic_padding.rs | 13 + ...m_prefix_with_elems_dynamic_padding.x86-64 | 26 + ...efix_with_elems_dynamic_padding.x86-64.mca | 85 + ...ref_from_prefix_with_elems_dynamic_size.rs | 13 + ...from_prefix_with_elems_dynamic_size.x86-64 | 22 + ..._prefix_with_elems_dynamic_size.x86-64.mca | 77 + .../ref_from_suffix_dynamic_padding.rs | 10 + .../ref_from_suffix_dynamic_padding.x86-64 | 23 + ...ref_from_suffix_dynamic_padding.x86-64.mca | 79 + .../benches/ref_from_suffix_dynamic_size.rs | 10 + .../ref_from_suffix_dynamic_size.x86-64 | 13 + .../ref_from_suffix_dynamic_size.x86-64.mca | 63 + .../benches/ref_from_suffix_static_size.rs | 10 + .../ref_from_suffix_static_size.x86-64 | 13 + .../ref_from_suffix_static_size.x86-64.mca | 61 + ..._from_suffix_with_elems_dynamic_padding.rs | 13 + ...m_suffix_with_elems_dynamic_padding.x86-64 | 27 + ...ffix_with_elems_dynamic_padding.x86-64.mca | 85 + ...ref_from_suffix_with_elems_dynamic_size.rs | 13 + ...from_suffix_with_elems_dynamic_size.x86-64 | 23 + ..._suffix_with_elems_dynamic_size.x86-64.mca | 77 + .../benches/split_at_dynamic_padding.rs | 12 + .../benches/split_at_dynamic_padding.x86-64 | 12 + .../split_at_dynamic_padding.x86-64.mca | 59 + .../zerocopy/benches/split_at_dynamic_size.rs | 12 + .../benches/split_at_dynamic_size.x86-64 | 12 + .../benches/split_at_dynamic_size.x86-64.mca | 59 + .../split_at_unchecked_dynamic_padding.rs | 12 + .../split_at_unchecked_dynamic_padding.x86-64 | 6 + ...it_at_unchecked_dynamic_padding.x86-64.mca | 49 + .../split_at_unchecked_dynamic_size.rs | 12 + .../split_at_unchecked_dynamic_size.x86-64 | 6 + ...split_at_unchecked_dynamic_size.x86-64.mca | 49 + .../split_via_immutable_dynamic_padding.rs | 11 + ...split_via_immutable_dynamic_padding.x86-64 | 14 + ...t_via_immutable_dynamic_padding.x86-64.mca | 65 + .../split_via_immutable_dynamic_size.rs | 11 + .../split_via_immutable_dynamic_size.x86-64 | 13 + ...plit_via_immutable_dynamic_size.x86-64.mca | 63 + ...split_via_runtime_check_dynamic_padding.rs | 11 + ...t_via_runtime_check_dynamic_padding.x86-64 | 22 + ...a_runtime_check_dynamic_padding.x86-64.mca | 79 + .../split_via_runtime_check_dynamic_size.rs | 11 + ...plit_via_runtime_check_dynamic_size.x86-64 | 13 + ..._via_runtime_check_dynamic_size.x86-64.mca | 63 + .../split_via_unchecked_dynamic_padding.rs | 11 + ...split_via_unchecked_dynamic_padding.x86-64 | 14 + ...t_via_unchecked_dynamic_padding.x86-64.mca | 65 + .../split_via_unchecked_dynamic_size.rs | 11 + .../split_via_unchecked_dynamic_size.x86-64 | 13 + ...plit_via_unchecked_dynamic_size.x86-64.mca | 63 + rust/zerocopy/benches/transmute.rs | 16 + rust/zerocopy/benches/transmute.x86-64 | 3 + rust/zerocopy/benches/transmute.x86-64.mca | 43 + .../benches/transmute_ref_dynamic_size.rs | 16 + .../benches/transmute_ref_dynamic_size.x86-64 | 4 + .../transmute_ref_dynamic_size.x86-64.mca | 45 + .../benches/transmute_ref_static_size.rs | 15 + .../benches/transmute_ref_static_size.x86-64 | 3 + .../transmute_ref_static_size.x86-64.mca | 43 + rust/zerocopy/benches/try_read_from_bytes.rs | 7 + .../benches/try_read_from_bytes.x86-64 | 23 + .../benches/try_read_from_bytes.x86-64.mca | 79 + rust/zerocopy/benches/try_read_from_prefix.rs | 10 + .../benches/try_read_from_prefix.x86-64 | 16 + .../benches/try_read_from_prefix.x86-64.mca | 67 + rust/zerocopy/benches/try_read_from_suffix.rs | 10 + .../benches/try_read_from_suffix.x86-64 | 18 + .../benches/try_read_from_suffix.x86-64.mca | 71 + .../try_ref_from_bytes_dynamic_padding.rs | 7 + .../try_ref_from_bytes_dynamic_padding.x86-64 | 24 + ..._ref_from_bytes_dynamic_padding.x86-64.mca | 81 + .../try_ref_from_bytes_dynamic_size.rs | 7 + .../try_ref_from_bytes_dynamic_size.x86-64 | 22 + ...try_ref_from_bytes_dynamic_size.x86-64.mca | 79 + .../benches/try_ref_from_bytes_static_size.rs | 7 + .../try_ref_from_bytes_static_size.x86-64 | 13 + .../try_ref_from_bytes_static_size.x86-64.mca | 59 + ...f_from_bytes_with_elems_dynamic_padding.rs | 10 + ...om_bytes_with_elems_dynamic_padding.x86-64 | 21 + ...ytes_with_elems_dynamic_padding.x86-64.mca | 75 + ..._ref_from_bytes_with_elems_dynamic_size.rs | 10 + ..._from_bytes_with_elems_dynamic_size.x86-64 | 18 + ...m_bytes_with_elems_dynamic_size.x86-64.mca | 69 + .../try_ref_from_prefix_dynamic_padding.rs | 10 + ...try_ref_from_prefix_dynamic_padding.x86-64 | 29 + ...ref_from_prefix_dynamic_padding.x86-64.mca | 91 + .../try_ref_from_prefix_dynamic_size.rs | 10 + .../try_ref_from_prefix_dynamic_size.x86-64 | 22 + ...ry_ref_from_prefix_dynamic_size.x86-64.mca | 77 + .../try_ref_from_prefix_static_size.rs | 10 + .../try_ref_from_prefix_static_size.x86-64 | 15 + ...try_ref_from_prefix_static_size.x86-64.mca | 63 + ..._from_prefix_with_elems_dynamic_padding.rs | 13 + ...m_prefix_with_elems_dynamic_padding.x86-64 | 30 + ...efix_with_elems_dynamic_padding.x86-64.mca | 91 + ...ref_from_prefix_with_elems_dynamic_size.rs | 13 + ...from_prefix_with_elems_dynamic_size.x86-64 | 26 + ..._prefix_with_elems_dynamic_size.x86-64.mca | 83 + .../try_ref_from_suffix_dynamic_padding.rs | 10 + ...try_ref_from_suffix_dynamic_padding.x86-64 | 26 + ...ref_from_suffix_dynamic_padding.x86-64.mca | 85 + .../try_ref_from_suffix_dynamic_size.rs | 10 + .../try_ref_from_suffix_dynamic_size.x86-64 | 18 + ...ry_ref_from_suffix_dynamic_size.x86-64.mca | 71 + .../try_ref_from_suffix_static_size.rs | 10 + .../try_ref_from_suffix_static_size.x86-64 | 16 + ...try_ref_from_suffix_static_size.x86-64.mca | 67 + ..._from_suffix_with_elems_dynamic_padding.rs | 13 + ...m_suffix_with_elems_dynamic_padding.x86-64 | 32 + ...ffix_with_elems_dynamic_padding.x86-64.mca | 95 + ...ref_from_suffix_with_elems_dynamic_size.rs | 13 + ...from_suffix_with_elems_dynamic_size.x86-64 | 28 + ..._suffix_with_elems_dynamic_size.x86-64.mca | 87 + rust/zerocopy/benches/try_transmute.rs | 16 + rust/zerocopy/benches/try_transmute.x86-64 | 9 + .../zerocopy/benches/try_transmute.x86-64.mca | 55 + .../benches/try_transmute_ref_dynamic_size.rs | 18 + .../try_transmute_ref_dynamic_size.x86-64 | 6 + .../try_transmute_ref_dynamic_size.x86-64.mca | 49 + .../benches/try_transmute_ref_static_size.rs | 17 + .../try_transmute_ref_static_size.x86-64 | 5 + .../try_transmute_ref_static_size.x86-64.mca | 47 + .../zerocopy/benches/write_to_dynamic_size.rs | 9 + .../benches/write_to_dynamic_size.x86-64 | 21 + .../benches/write_to_dynamic_size.x86-64.mca | 77 + .../benches/write_to_prefix_dynamic_size.rs | 12 + .../write_to_prefix_dynamic_size.x86-64 | 21 + .../write_to_prefix_dynamic_size.x86-64.mca | 77 + .../benches/write_to_prefix_static_size.rs | 12 + .../write_to_prefix_static_size.x86-64 | 11 + .../write_to_prefix_static_size.x86-64.mca | 57 + rust/zerocopy/benches/write_to_static_size.rs | 9 + .../benches/write_to_static_size.x86-64 | 11 + .../benches/write_to_static_size.x86-64.mca | 57 + .../benches/write_to_suffix_dynamic_size.rs | 12 + .../write_to_suffix_dynamic_size.x86-64 | 22 + .../write_to_suffix_dynamic_size.x86-64.mca | 79 + .../benches/write_to_suffix_static_size.rs | 12 + .../write_to_suffix_static_size.x86-64 | 11 + .../write_to_suffix_static_size.x86-64.mca | 57 + rust/zerocopy/benches/zero_dynamic_padding.rs | 9 + .../benches/zero_dynamic_padding.x86-64 | 7 + .../benches/zero_dynamic_padding.x86-64.mca | 51 + rust/zerocopy/benches/zero_dynamic_size.rs | 9 + .../zerocopy/benches/zero_dynamic_size.x86-64 | 5 + .../benches/zero_dynamic_size.x86-64.mca | 47 + rust/zerocopy/benches/zero_static_size.rs | 9 + rust/zerocopy/benches/zero_static_size.x86-64 | 4 + .../benches/zero_static_size.x86-64.mca | 45 + rust/zerocopy/rustdoc/style.css | 55 + rust/zerocopy/src/byte_slice.rs | 432 + rust/zerocopy/src/byteorder.rs | 1563 ++++ rust/zerocopy/src/deprecated.rs | 279 + rust/zerocopy/src/error.rs | 1348 +++ rust/zerocopy/src/impls.rs | 2387 ++++++ rust/zerocopy/src/layout.rs | 2223 +++++ rust/zerocopy/src/lib.rs | 7610 +++++++++++++++++ rust/zerocopy/src/macros.rs | 1823 ++++ rust/zerocopy/src/pointer/inner.rs | 752 ++ rust/zerocopy/src/pointer/invariant.rs | 296 + rust/zerocopy/src/pointer/mod.rs | 408 + rust/zerocopy/src/pointer/ptr.rs | 1584 ++++ rust/zerocopy/src/pointer/transmute.rs | 520 ++ rust/zerocopy/src/ref.rs | 1356 +++ rust/zerocopy/src/split_at.rs | 1088 +++ rust/zerocopy/src/util/macro_util.rs | 1308 +++ rust/zerocopy/src/util/macros.rs | 1065 +++ rust/zerocopy/src/util/mod.rs | 936 ++ rust/zerocopy/src/wrappers.rs | 1032 +++ 233 files changed, 35005 insertions(+) create mode 100644 rust/zerocopy/benches/as_bytes_dynamic_size.rs create mode 100644 rust/zerocopy/benches/as_bytes_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/as_bytes_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/as_bytes_static_size.rs create mode 100644 rust/zerocopy/benches/as_bytes_static_size.x86-64 create mode 100644 rust/zerocopy/benches/as_bytes_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/extend_vec_zeroed.rs create mode 100644 rust/zerocopy/benches/extend_vec_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/extend_vec_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/formats/coco_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/formats/coco_dynamic_size.rs create mode 100644 rust/zerocopy/benches/formats/coco_static_size.rs create mode 100644 rust/zerocopy/benches/insert_vec_zeroed.rs create mode 100644 rust/zerocopy/benches/insert_vec_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/insert_vec_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/new_box_zeroed.rs create mode 100644 rust/zerocopy/benches/new_box_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/new_box_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/new_vec_zeroed.rs create mode 100644 rust/zerocopy/benches/new_vec_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/new_vec_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/new_zeroed.rs create mode 100644 rust/zerocopy/benches/new_zeroed.x86-64 create mode 100644 rust/zerocopy/benches/new_zeroed.x86-64.mca create mode 100644 rust/zerocopy/benches/read_from_bytes.rs create mode 100644 rust/zerocopy/benches/read_from_bytes.x86-64 create mode 100644 rust/zerocopy/benches/read_from_bytes.x86-64.mca create mode 100644 rust/zerocopy/benches/read_from_prefix.rs create mode 100644 rust/zerocopy/benches/read_from_prefix.x86-64 create mode 100644 rust/zerocopy/benches/read_from_prefix.x86-64.mca create mode 100644 rust/zerocopy/benches/read_from_suffix.rs create mode 100644 rust/zerocopy/benches/read_from_suffix.x86-64 create mode 100644 rust/zerocopy/benches/read_from_suffix.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_static_size.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_static_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_static_size.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_static_size.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_at_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_at_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_at_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_at_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_at_unchecked_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_via_immutable_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_via_runtime_check_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_size.rs create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/split_via_unchecked_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/transmute.rs create mode 100644 rust/zerocopy/benches/transmute.x86-64 create mode 100644 rust/zerocopy/benches/transmute.x86-64.mca create mode 100644 rust/zerocopy/benches/transmute_ref_dynamic_size.rs create mode 100644 rust/zerocopy/benches/transmute_ref_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/transmute_ref_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/transmute_ref_static_size.rs create mode 100644 rust/zerocopy/benches/transmute_ref_static_size.x86-64 create mode 100644 rust/zerocopy/benches/transmute_ref_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_read_from_bytes.rs create mode 100644 rust/zerocopy/benches/try_read_from_bytes.x86-64 create mode 100644 rust/zerocopy/benches/try_read_from_bytes.x86-64.mca create mode 100644 rust/zerocopy/benches/try_read_from_prefix.rs create mode 100644 rust/zerocopy/benches/try_read_from_prefix.x86-64 create mode 100644 rust/zerocopy/benches/try_read_from_prefix.x86-64.mca create mode 100644 rust/zerocopy/benches/try_read_from_suffix.rs create mode 100644 rust/zerocopy/benches/try_read_from_suffix.x86-64 create mode 100644 rust/zerocopy/benches/try_read_from_suffix.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_static_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_static_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_static_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_transmute.rs create mode 100644 rust/zerocopy/benches/try_transmute.x86-64 create mode 100644 rust/zerocopy/benches/try_transmute.x86-64.mca create mode 100644 rust/zerocopy/benches/try_transmute_ref_dynamic_size.rs create mode 100644 rust/zerocopy/benches/try_transmute_ref_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/try_transmute_ref_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/try_transmute_ref_static_size.rs create mode 100644 rust/zerocopy/benches/try_transmute_ref_static_size.x86-64 create mode 100644 rust/zerocopy/benches/try_transmute_ref_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_dynamic_size.rs create mode 100644 rust/zerocopy/benches/write_to_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_prefix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/write_to_prefix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_prefix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_prefix_static_size.rs create mode 100644 rust/zerocopy/benches/write_to_prefix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_prefix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_static_size.rs create mode 100644 rust/zerocopy/benches/write_to_static_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_suffix_dynamic_size.rs create mode 100644 rust/zerocopy/benches/write_to_suffix_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_suffix_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/write_to_suffix_static_size.rs create mode 100644 rust/zerocopy/benches/write_to_suffix_static_size.x86-64 create mode 100644 rust/zerocopy/benches/write_to_suffix_static_size.x86-64.mca create mode 100644 rust/zerocopy/benches/zero_dynamic_padding.rs create mode 100644 rust/zerocopy/benches/zero_dynamic_padding.x86-64 create mode 100644 rust/zerocopy/benches/zero_dynamic_padding.x86-64.mca create mode 100644 rust/zerocopy/benches/zero_dynamic_size.rs create mode 100644 rust/zerocopy/benches/zero_dynamic_size.x86-64 create mode 100644 rust/zerocopy/benches/zero_dynamic_size.x86-64.mca create mode 100644 rust/zerocopy/benches/zero_static_size.rs create mode 100644 rust/zerocopy/benches/zero_static_size.x86-64 create mode 100644 rust/zerocopy/benches/zero_static_size.x86-64.mca create mode 100644 rust/zerocopy/rustdoc/style.css create mode 100644 rust/zerocopy/src/byte_slice.rs create mode 100644 rust/zerocopy/src/byteorder.rs create mode 100644 rust/zerocopy/src/deprecated.rs create mode 100644 rust/zerocopy/src/error.rs create mode 100644 rust/zerocopy/src/impls.rs create mode 100644 rust/zerocopy/src/layout.rs create mode 100644 rust/zerocopy/src/lib.rs create mode 100644 rust/zerocopy/src/macros.rs create mode 100644 rust/zerocopy/src/pointer/inner.rs create mode 100644 rust/zerocopy/src/pointer/invariant.rs create mode 100644 rust/zerocopy/src/pointer/mod.rs create mode 100644 rust/zerocopy/src/pointer/ptr.rs create mode 100644 rust/zerocopy/src/pointer/transmute.rs create mode 100644 rust/zerocopy/src/ref.rs create mode 100644 rust/zerocopy/src/split_at.rs create mode 100644 rust/zerocopy/src/util/macro_util.rs create mode 100644 rust/zerocopy/src/util/macros.rs create mode 100644 rust/zerocopy/src/util/mod.rs create mode 100644 rust/zerocopy/src/wrappers.rs
rust/zerocopy/benches/as_bytes_dynamic_size.rs new file +9 -0
@@ -0,0 +1,9 @@ +use zerocopy::*; + +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_as_bytes_dynamic_size (source: &format::CocoPacket ) -> &[u8 ] { + source.as_bytes () +}
rust/zerocopy/benches/as_bytes_dynamic_size.x86-64 new file +5 -0
@@ -0,0 +1,5 @@ +bench_as_bytes_dynamic_size: + mov rax, rdi + lea rdx, [2*rsi + 5] + and rdx, -2 + ret
rust/zerocopy/benches/as_bytes_dynamic_size.x86-64.mca new file +47 -0
47 lines not on this page · raw message
rust/zerocopy/benches/as_bytes_static_size.rs new file +9 -0
@@ -0,0 +1,9 @@ +use zerocopy::*; + +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_as_bytes_static_size (source: &format::CocoPacket ) -> &[u8 ] { + source.as_bytes () +}
rust/zerocopy/benches/as_bytes_static_size.x86-64 new file +4 -0
@@ -0,0 +1,4 @@ +bench_as_bytes_static_size: + mov rax, rdi + mov edx, 6 + ret
rust/zerocopy/benches/as_bytes_static_size.x86-64.mca new file +45 -0
45 lines not on this page · raw message
rust/zerocopy/benches/extend_vec_zeroed.rs new file +9 -0
@@ -0,0 +1,9 @@ +use zerocopy::*; + +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_extend_vec_zeroed (v: &mut Vec <format::LocoPacket >, additional:usize ) ->Option <()> { +FromZeros ::extend_vec_zeroed (v, additional).ok () +}
rust/zerocopy/benches/extend_vec_zeroed.x86-64 new file +60 -0
60 lines not on this page · raw message
rust/zerocopy/benches/extend_vec_zeroed.x86-64.mca new file +147 -0
147 lines not on this page · raw message
rust/zerocopy/benches/formats/coco_dynamic_padding.rs new file +24 -0
@@ -0,0 +1,24 @@ +use zerocopy_derive::*; + +// The only valid value of this type are the bytes `0xC0C0`. +#[derive( TryFromBytes , KnownLayout , Immutable )] +#[repr( u16 )] +pub enum C0C0 { + _XC0C0 =0xC0C0 , +} + +#[derive( FromBytes , KnownLayout , Immutable , SplitAt )] +#[repr( C , align( 4 ))] +pub struct Packet <Magic > { + magic_number:Magic , + milk:u8 , + mug_size:u8 , + temperature: [u8 ;5 ], + marshmallows: [[u8 ;3 ]], +} + +/// A packet begining with the magic number `0xC0C0`. +pub type CocoPacket =Packet <C0C0 >; + +/// A packet beginning with any two initialized bytes. +pub type LocoPacket =Packet <[u8 ;2 ]>;
rust/zerocopy/benches/formats/coco_dynamic_size.rs new file +27 -0
@@ -0,0 +1,27 @@ +use zerocopy_derive::*; + +// The only valid value of this type are the bytes `0xC0C0`. +#[derive( TryFromBytes , KnownLayout , Immutable , IntoBytes )] +#[repr( u16 )] +pub enum C0C0 { + _XC0C0 =0xC0C0 , +} + +macro_rules! define_packet { + ($name: ident, $trait: ident, $leading_field: ty) => { +#[derive($ trait , KnownLayout , Immutable , IntoBytes , SplitAt )] +#[repr( C , align( 2 ))] +pub struct $name { + magic_number: $leading_field, + mug_size:u8 , + temperature:u8 , +marshmallows : [[u8 ;2 ]], + } + }; +} + +/// Packet begins with bytes 0xC0C0. +define_packet! (CocoPacket ,TryFromBytes ,C0C0 ); + +/// Packet begins with any two bytes. +define_packet! (LocoPacket ,FromBytes , [u8 ;2 ]);
rust/zerocopy/benches/formats/coco_static_size.rs new file +27 -0
@@ -0,0 +1,27 @@ +use zerocopy_derive::*; + +// The only valid value of this type are the bytes `0xC0C0`. +#[derive( TryFromBytes , KnownLayout , Immutable , IntoBytes )] +#[repr( u16 )] +pub enum C0C0 { + _XC0C0 =0xC0C0 , +} + +macro_rules! define_packet { + ($name: ident, $trait: ident, $leading_field: ty) => { +#[derive($ trait , KnownLayout , Immutable , IntoBytes )] +#[repr( C , align( 2 ))] +pub struct $name { + magic_number: $leading_field, + mug_size:u8 , + temperature:u8 , +marshmallows : [u8 ;2 ], + } + }; +} + +/// Packet begins with bytes 0xC0C0. +define_packet! (CocoPacket ,TryFromBytes ,C0C0 ); + +/// Packet begins with any two bytes. +define_packet! (LocoPacket ,FromBytes , [u8 ;2 ]);
rust/zerocopy/benches/insert_vec_zeroed.rs new file +13 -0
@@ -0,0 +1,13 @@ +use zerocopy::*; + +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_insert_vec_zeroed ( + v: &mut Vec <format::LocoPacket >, + position:usize , + additional:usize , +) ->Option <()> { +FromZeros ::insert_vec_zeroed (v, position, additional).ok () +}
rust/zerocopy/benches/insert_vec_zeroed.x86-64 new file +79 -0
79 lines not on this page · raw message
rust/zerocopy/benches/insert_vec_zeroed.x86-64.mca new file +183 -0
183 lines not on this page · raw message
rust/zerocopy/benches/new_box_zeroed.rs new file +9 -0
@@ -0,0 +1,9 @@ +use zerocopy::*; + +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_new_box_zeroed () ->Option <Box <format::LocoPacket >> { +FromZeros ::new_box_zeroed ().ok () +}
rust/zerocopy/benches/new_box_zeroed.x86-64 new file +7 -0
@@ -0,0 +1,7 @@ +bench_new_box_zeroed: + push rax + call qword ptr [rip + __rustc::__rust_no_alloc_shim_is_unstable_v2@GOTPCREL] + mov edi, 6 + mov esi, 2 + pop rax + jmp qword ptr [rip + __rustc::__rust_alloc_zeroed@GOTPCREL]
rust/zerocopy/benches/new_box_zeroed.x86-64.mca new file +51 -0
51 lines not on this page · raw message
rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.rs new file +11 -0
@@ -0,0 +1,11 @@ +use zerocopy::*; + +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_new_box_zeroed_with_elems_dynamic_padding ( + count:usize , +) ->Option <Box <format::LocoPacket >> { +FromZeros ::new_box_zeroed_with_elems (count).ok () +}
rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.x86-64 new file +24 -0
@@ -0,0 +1,24 @@ +bench_new_box_zeroed_with_elems_dynamic_padding: + push r14 + push rbx + push rax + mov rbx, rdi + movabs rax, 3074457345618258598 + cmp rdi, rax + ja .LBB5_1 + lea r14, [rbx + 2*rbx] + or r14, 3 + add r14, 9 + call qword ptr [rip + __rustc::__rust_no_alloc_shim_is_unstable_v2@GOTPCREL] + mov esi, 4 + mov rdi, r14 + call qword ptr [rip + __rustc::__rust_alloc_zeroed@GOTPCREL] + jmp .LBB5_3 +.LBB5_1: + xor eax, eax +.LBB5_3: + mov rdx, rbx + add rsp, 8 + pop rbx + pop r14 + ret
rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_padding.x86-64.mca new file +81 -0
81 lines not on this page · raw message
rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.rs new file +9 -0
@@ -0,0 +1,9 @@ +use zerocopy::*; + +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_new_box_zeroed_with_elems_dynamic_size (count:usize ) ->Option <Box <format::LocoPacket >> { +FromZeros ::new_box_zeroed_with_elems (count).ok () +}
rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.x86-64 new file +22 -0
@@ -0,0 +1,22 @@ +bench_new_box_zeroed_with_elems_dynamic_size: + push r14 + push rbx + push rax + mov rbx, rdi + movabs rax, 4611686018427387901 + cmp rdi, rax + ja .LBB5_1 + lea r14, [2*rbx + 4] + call qword ptr [rip + __rustc::__rust_no_alloc_shim_is_unstable_v2@GOTPCREL] + mov esi, 2 + mov rdi, r14 + call qword ptr [rip + __rustc::__rust_alloc_zeroed@GOTPCREL] + jmp .LBB5_3 +.LBB5_1: + xor eax, eax +.LBB5_3: + mov rdx, rbx + add rsp, 8 + pop rbx + pop r14 + ret
rust/zerocopy/benches/new_box_zeroed_with_elems_dynamic_size.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/new_vec_zeroed.rs new file +9 -0
@@ -0,0 +1,9 @@ +use zerocopy::*; + +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_new_vec_zeroed (len:usize ) ->Option <Vec <format::LocoPacket >> { +FromZeros ::new_vec_zeroed (len).ok () +}
rust/zerocopy/benches/new_vec_zeroed.x86-64 new file +40 -0
@@ -0,0 +1,40 @@ +bench_new_vec_zeroed: + mov rax, rdi + movabs rcx, 1537228672809129301 + cmp rsi, rcx + ja .LBB5_5 + test rsi, rsi + je .LBB5_2 + push r15 + push r14 + push rbx + lea rcx, [rsi + rsi] + lea rbx, [rcx + 2*rcx] + mov r14, rax + mov r15, rsi + call qword ptr [rip + __rustc::__rust_no_alloc_shim_is_unstable_v2@GOTPCREL] + mov esi, 2 + mov rdi, rbx + call qword ptr [rip + __rustc::__rust_alloc_zeroed@GOTPCREL] + mov rsi, r15 + mov rcx, rax + mov rax, r14 + test rcx, rcx + pop rbx + pop r14 + pop r15 + je .LBB5_5 + mov qword ptr [rax], rsi + mov qword ptr [rax + 8], rcx + mov qword ptr [rax + 16], rsi + ret +.LBB5_5: + movabs rcx, -9223372036854775808 + mov qword ptr [rax], rcx + ret +.LBB5_2: + mov ecx, 2 + mov qword ptr [rax], rsi + mov qword ptr [rax + 8], rcx + mov qword ptr [rax + 16], rsi + ret
rust/zerocopy/benches/new_vec_zeroed.x86-64.mca new file +113 -0
113 lines not on this page · raw message
rust/zerocopy/benches/new_zeroed.rs new file +9 -0
@@ -0,0 +1,9 @@ +use zerocopy::*; + +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_new_zeroed () -> format::LocoPacket { +FromZeros ::new_zeroed () +}
rust/zerocopy/benches/new_zeroed.x86-64 new file +3 -0
@@ -0,0 +1,3 @@ +bench_new_zeroed: + xor eax, eax + ret
rust/zerocopy/benches/new_zeroed.x86-64.mca new file +43 -0
43 lines not on this page · raw message
rust/zerocopy/benches/read_from_bytes.rs new file +7 -0
@@ -0,0 +1,7 @@ +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_read_from_bytes_static_size (source: &[u8 ]) ->Option <format::LocoPacket > { + zerocopy::FromBytes ::read_from_bytes (source).ok () +}
rust/zerocopy/benches/read_from_bytes.x86-64 new file +15 -0
@@ -0,0 +1,15 @@ +bench_read_from_bytes_static_size: + mov rcx, rsi + cmp rsi, 6 + jne .LBB5_2 + mov eax, dword ptr [rdi] + movzx ecx, word ptr [rdi + 4] + shl rcx, 32 + or rcx, rax +.LBB5_2: + shl rcx, 16 + inc rcx + xor eax, eax + cmp rsi, 6 + cmove rax, rcx + ret
rust/zerocopy/benches/read_from_bytes.x86-64.mca new file +65 -0
65 lines not on this page · raw message
rust/zerocopy/benches/read_from_prefix.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_read_from_prefix_static_size (source: &[u8 ]) ->Option <format::LocoPacket > { +match zerocopy::FromBytes ::read_from_prefix (source) { +Ok ((packet, _rest)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/read_from_prefix.x86-64 new file +14 -0
@@ -0,0 +1,14 @@ +bench_read_from_prefix_static_size: + cmp rsi, 5 + jbe .LBB5_2 + mov eax, dword ptr [rdi] + movzx edi, word ptr [rdi + 4] + shl rdi, 32 + or rdi, rax +.LBB5_2: + shl rdi, 16 + inc rdi + xor eax, eax + cmp rsi, 6 + cmovae rax, rdi + ret
rust/zerocopy/benches/read_from_prefix.x86-64.mca new file +63 -0
63 lines not on this page · raw message
rust/zerocopy/benches/read_from_suffix.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_read_from_suffix_static_size (source: &[u8 ]) ->Option <format::LocoPacket > { +match zerocopy::FromBytes ::read_from_suffix (source) { +Ok ((_rest, packet)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/read_from_suffix.x86-64 new file +15 -0
@@ -0,0 +1,15 @@ +bench_read_from_suffix_static_size: + mov rcx, rsi + cmp rsi, 6 + jb .LBB5_2 + mov eax, dword ptr [rdi + rsi - 6] + movzx ecx, word ptr [rdi + rsi - 2] + shl rcx, 32 + or rcx, rax +.LBB5_2: + shl rcx, 16 + inc rcx + xor eax, eax + cmp rsi, 6 + cmovae rax, rcx + ret
rust/zerocopy/benches/read_from_suffix.x86-64.mca new file +65 -0
65 lines not on this page · raw message
rust/zerocopy/benches/ref_from_bytes_dynamic_padding.rs new file +7 -0
@@ -0,0 +1,7 @@ +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_bytes_dynamic_padding (source: &[u8 ]) ->Option <&format::LocoPacket > { + zerocopy::FromBytes ::ref_from_bytes (source).ok () +}
rust/zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64 new file +22 -0
@@ -0,0 +1,22 @@ +bench_ref_from_bytes_dynamic_padding: + test dil, 3 + jne .LBB5_3 + movabs rax, 9223372036854775804 + and rax, rsi + cmp rax, 9 + jb .LBB5_3 + add rax, -9 + movabs rcx, -6148914691236517205 + mul rcx + shr rdx + lea rax, [rdx + 2*rdx] + or rax, 3 + add rax, 9 + cmp rsi, rax + je .LBB5_4 +.LBB5_3: + xor edi, edi + mov rdx, rsi +.LBB5_4: + mov rax, rdi + ret
rust/zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/ref_from_bytes_dynamic_size.rs new file +7 -0
@@ -0,0 +1,7 @@ +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_bytes_dynamic_size (source: &[u8 ]) ->Option <&format::LocoPacket > { + zerocopy::FromBytes ::ref_from_bytes (source).ok () +}
rust/zerocopy/benches/ref_from_bytes_dynamic_size.x86-64 new file +20 -0
@@ -0,0 +1,20 @@ +bench_ref_from_bytes_dynamic_size: + mov rdx, rsi + cmp rsi, 4 + setb al + or al, dil + test al, 1 + je .LBB5_2 + xor eax, eax + ret +.LBB5_2: + lea rcx, [rdx - 4] + mov rsi, rcx + and rsi, -2 + add rsi, 4 + shr rcx + xor eax, eax + cmp rdx, rsi + cmove rdx, rcx + cmove rax, rdi + ret
rust/zerocopy/benches/ref_from_bytes_dynamic_size.x86-64.mca new file +75 -0
75 lines not on this page · raw message
rust/zerocopy/benches/ref_from_bytes_static_size.rs new file +7 -0
@@ -0,0 +1,7 @@ +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_bytes_static_size (source: &[u8 ]) ->Option <&format::LocoPacket > { + zerocopy::FromBytes ::ref_from_bytes (source).ok () +}
rust/zerocopy/benches/ref_from_bytes_static_size.x86-64 new file +8 -0
@@ -0,0 +1,8 @@ +bench_ref_from_bytes_static_size: + mov ecx, edi + and ecx, 1 + xor rsi, 6 + xor eax, eax + or rsi, rcx + cmove rax, rdi + ret
rust/zerocopy/benches/ref_from_bytes_static_size.x86-64.mca new file +53 -0
53 lines not on this page · raw message
rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_bytes_with_elems_dynamic_padding ( + source: &[u8 ], + count:usize , +) ->Option <&format::LocoPacket > { + zerocopy::FromBytes ::ref_from_bytes_with_elems (source, count).ok () +}
rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.x86-64 new file +19 -0
@@ -0,0 +1,19 @@ +bench_ref_from_bytes_with_elems_dynamic_padding: + movabs rax, 3074457345618258598 + cmp rdx, rax + seta cl + mov rax, rdi + test al, 3 + setne dil + or dil, cl + jne .LBB5_2 + lea rcx, [rdx + 2*rdx] + or rcx, 3 + add rcx, 9 + cmp rsi, rcx + je .LBB5_3 +.LBB5_2: + xor eax, eax + mov rdx, rsi +.LBB5_3: + ret
rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_padding.x86-64.mca new file +71 -0
71 lines not on this page · raw message
rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_bytes_with_elems_dynamic_size ( + source: &[u8 ], + count:usize , +) ->Option <&format::LocoPacket > { + zerocopy::FromBytes ::ref_from_bytes_with_elems (source, count).ok () +}
rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.x86-64 new file +16 -0
@@ -0,0 +1,16 @@ +bench_ref_from_bytes_with_elems_dynamic_size: + movabs rax, 4611686018427387901 + cmp rdx, rax + seta cl + mov rax, rdi + or dil, cl + test dil, 1 + jne .LBB5_2 + lea rcx, [2*rdx + 4] + cmp rsi, rcx + je .LBB5_3 +.LBB5_2: + xor eax, eax + mov rdx, rsi +.LBB5_3: + ret
rust/zerocopy/benches/ref_from_bytes_with_elems_dynamic_size.x86-64.mca new file +65 -0
65 lines not on this page · raw message
rust/zerocopy/benches/ref_from_prefix_dynamic_padding.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_prefix_dynamic_padding (source: &[u8 ]) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_prefix (source) { +Ok ((packet, _rest)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64 new file +22 -0
@@ -0,0 +1,22 @@ +bench_ref_from_prefix_dynamic_padding: + xor edx, edx + mov eax, 0 + test dil, 3 + je .LBB5_1 + ret +.LBB5_1: + movabs rax, 9223372036854775804 + and rsi, rax + cmp rsi, 9 + jae .LBB5_3 + mov edx, 1 + xor eax, eax + ret +.LBB5_3: + add rsi, -9 + movabs rcx, -6148914691236517205 + mov rax, rsi + mul rcx + shr rdx + mov rax, rdi + ret
rust/zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/ref_from_prefix_dynamic_size.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_prefix_dynamic_size (source: &[u8 ]) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_prefix (source) { +Ok ((packet, _rest)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_prefix_dynamic_size.x86-64 new file +17 -0
@@ -0,0 +1,17 @@ +bench_ref_from_prefix_dynamic_size: + xor edx, edx + mov eax, 0 + test dil, 1 + jne .LBB5_4 + cmp rsi, 4 + jae .LBB5_3 + mov edx, 1 + xor eax, eax + ret +.LBB5_3: + add rsi, -4 + shr rsi + mov rdx, rsi + mov rax, rdi +.LBB5_4: + ret
rust/zerocopy/benches/ref_from_prefix_dynamic_size.x86-64.mca new file +67 -0
67 lines not on this page · raw message
rust/zerocopy/benches/ref_from_prefix_static_size.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_prefix_static_size (source: &[u8 ]) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_prefix (source) { +Ok ((packet, _rest)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_prefix_static_size.x86-64 new file +8 -0
@@ -0,0 +1,8 @@ +bench_ref_from_prefix_static_size: + xor eax, eax + cmp rsi, 6 + mov rcx, rdi + cmovb rcx, rax + test dil, 1 + cmove rax, rcx + ret
rust/zerocopy/benches/ref_from_prefix_static_size.x86-64.mca new file +53 -0
53 lines not on this page · raw message
rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.rs new file +13 -0
@@ -0,0 +1,13 @@ +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_prefix_with_elems_dynamic_padding ( + source: &[u8 ], + count:usize , +) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_prefix_with_elems (source, count) { +Ok ((packet, _rest)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.x86-64 new file +26 -0
@@ -0,0 +1,26 @@ +bench_ref_from_prefix_with_elems_dynamic_padding: + movabs rax, 3074457345618258598 + cmp rdx, rax + ja .LBB5_1 + xor ecx, ecx + mov eax, 0 + test dil, 3 + je .LBB5_3 + mov rdx, rcx + ret +.LBB5_1: + mov edx, 1 + xor eax, eax + ret +.LBB5_3: + lea rax, [rdx + 2*rdx] + or rax, 3 + add rax, 9 + xor r8d, r8d + cmp rax, rsi + mov ecx, 1 + cmovbe rcx, rdx + cmova rdi, r8 + mov rax, rdi + mov rdx, rcx + ret
rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_padding.x86-64.mca new file +85 -0
85 lines not on this page · raw message
rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.rs new file +13 -0
@@ -0,0 +1,13 @@ +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_prefix_with_elems_dynamic_size ( + source: &[u8 ], + count:usize , +) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_prefix_with_elems (source, count) { +Ok ((packet, _rest)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.x86-64 new file +22 -0
@@ -0,0 +1,22 @@ +bench_ref_from_prefix_with_elems_dynamic_size: + movabs rax, 4611686018427387901 + cmp rdx, rax + ja .LBB5_1 + mov rcx, rdx + xor edx, edx + mov eax, 0 + test dil, 1 + jne .LBB5_4 + lea rax, [2*rcx + 4] + xor r8d, r8d + cmp rax, rsi + mov edx, 1 + cmovbe rdx, rcx + cmova rdi, r8 + mov rax, rdi +.LBB5_4: + ret +.LBB5_1: + mov edx, 1 + xor eax, eax + ret
rust/zerocopy/benches/ref_from_prefix_with_elems_dynamic_size.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/ref_from_suffix_dynamic_padding.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_suffix_dynamic_padding (source: &[u8 ]) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_suffix (source) { +Ok ((_rest, packet)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_suffix_dynamic_padding.x86-64 new file +23 -0
@@ -0,0 +1,23 @@ +bench_ref_from_suffix_dynamic_padding: + lea eax, [rsi + rdi] + test al, 3 + jne .LBB5_1 + movabs rax, 9223372036854775804 + and rax, rsi + cmp rax, 9 + jae .LBB5_3 +.LBB5_1: + xor eax, eax + ret +.LBB5_3: + add rax, -9 + movabs rcx, -6148914691236517205 + mul rcx + shr rdx + lea rax, [rdx + 2*rdx] + sub rsi, rax + or rax, -4 + add rsi, rdi + add rax, rsi + add rax, -8 + ret
rust/zerocopy/benches/ref_from_suffix_dynamic_padding.x86-64.mca new file +79 -0
79 lines not on this page · raw message
rust/zerocopy/benches/ref_from_suffix_dynamic_size.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_suffix_dynamic_size (source: &[u8 ]) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_suffix (source) { +Ok ((_rest, packet)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_suffix_dynamic_size.x86-64 new file +13 -0
@@ -0,0 +1,13 @@ +bench_ref_from_suffix_dynamic_size: + mov rdx, rsi + lea ecx, [rsi + rdi] + mov eax, edx + and eax, 1 + add rax, rdi + xor esi, esi + sub rdx, 4 + cmovb rax, rsi + shr rdx + test cl, 1 + cmovne rax, rsi + ret
rust/zerocopy/benches/ref_from_suffix_dynamic_size.x86-64.mca new file +63 -0
63 lines not on this page · raw message
rust/zerocopy/benches/ref_from_suffix_static_size.rs new file +10 -0
@@ -0,0 +1,10 @@ +#[path = "formats/coco_static_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_suffix_static_size (source: &[u8 ]) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_suffix (source) { +Ok ((_rest, packet)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_suffix_static_size.x86-64 new file +13 -0
@@ -0,0 +1,13 @@ +bench_ref_from_suffix_static_size: + lea eax, [rsi + rdi] + cmp rsi, 6 + setb cl + or cl, al + test cl, 1 + je .LBB5_2 + xor eax, eax + ret +.LBB5_2: + lea rax, [rdi + rsi] + add rax, -6 + ret
rust/zerocopy/benches/ref_from_suffix_static_size.x86-64.mca new file +61 -0
61 lines not on this page · raw message
rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.rs new file +13 -0
@@ -0,0 +1,13 @@ +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_suffix_with_elems_dynamic_padding ( + source: &[u8 ], + count:usize , +) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_suffix_with_elems (source, count) { +Ok ((_rest, packet)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.x86-64 new file +27 -0
@@ -0,0 +1,27 @@ +bench_ref_from_suffix_with_elems_dynamic_padding: + movabs rax, 3074457345618258598 + cmp rdx, rax + ja .LBB5_1 + lea r8d, [rsi + rdi] + xor ecx, ecx + mov eax, 0 + test r8b, 3 + je .LBB5_3 + mov rdx, rcx + ret +.LBB5_3: + lea rax, [rdx + 2*rdx] + or rax, 3 + add rax, 9 + sub rsi, rax + jae .LBB5_4 +.LBB5_1: + xor eax, eax + mov edx, 1 + ret +.LBB5_4: + add rdi, rsi + mov rcx, rdx + mov rax, rdi + mov rdx, rcx + ret
rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_padding.x86-64.mca new file +85 -0
85 lines not on this page · raw message
rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.rs new file +13 -0
@@ -0,0 +1,13 @@ +#[path = "formats/coco_dynamic_size.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_ref_from_suffix_with_elems_dynamic_size ( + source: &[u8 ], + count:usize , +) ->Option <&format::LocoPacket > { +match zerocopy::FromBytes ::ref_from_suffix_with_elems (source, count) { +Ok ((_rest, packet)) =>Some (packet), + _ =>None , + } +}
rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.x86-64 new file +23 -0
@@ -0,0 +1,23 @@ +bench_ref_from_suffix_with_elems_dynamic_size: + movabs rax, 4611686018427387901 + cmp rdx, rax + ja .LBB5_1 + lea r8d, [rsi + rdi] + xor ecx, ecx + mov eax, 0 + test r8b, 1 + jne .LBB5_5 + lea rax, [2*rdx + 4] + sub rsi, rax + jae .LBB5_4 +.LBB5_1: + xor eax, eax + mov edx, 1 + ret +.LBB5_4: + add rdi, rsi + mov rcx, rdx + mov rax, rdi +.LBB5_5: + mov rdx, rcx + ret
rust/zerocopy/benches/ref_from_suffix_with_elems_dynamic_size.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/split_at_dynamic_padding.rs new file +12 -0
@@ -0,0 +1,12 @@ +use zerocopy::*; + +#[path = "formats/coco_dynamic_padding.rs" ] +mod format; + +#[unsafe(no_mangle)] +fn bench_split_at_dynamic_padding ( + source: &format::CocoPacket , + len:usize , +) ->Option <Split <&format::CocoPacket >> { + source.split_at (len) +}
rust/zerocopy/benches/split_at_dynamic_padding.x86-64 new file +12 -0
@@ -0,0 +1,12 @@ +bench_split_at_dynamic_padding: + mov rax, rdi + cmp rcx, rdx + jbe .LBB5_2 + xor esi, esi + mov qword ptr [rax], rsi + ret +.LBB5_2: + mov qword ptr [rax + 8], rdx + mov qword ptr [rax + 16], rcx + mov qword ptr [rax], rsi + ret
rust/zerocopy/benches/split_at_dynamic_padding.x86-64.mca new file +59 -0
19 lines not on this page · raw message
rust/zerocopy/benches/split_at_dynamic_size.rs new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_at_dynamic_size.x86-64 new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_at_dynamic_size.x86-64.mca new file +59 -0
59 lines not on this page · raw message
rust/zerocopy/benches/split_at_unchecked_dynamic_padding.rs new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_at_unchecked_dynamic_padding.x86-64 new file +6 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_at_unchecked_dynamic_padding.x86-64.mca new file +49 -0
49 lines not on this page · raw message
rust/zerocopy/benches/split_at_unchecked_dynamic_size.rs new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_at_unchecked_dynamic_size.x86-64 new file +6 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_at_unchecked_dynamic_size.x86-64.mca new file +49 -0
49 lines not on this page · raw message
rust/zerocopy/benches/split_via_immutable_dynamic_padding.rs new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_immutable_dynamic_padding.x86-64 new file +14 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_immutable_dynamic_padding.x86-64.mca new file +65 -0
65 lines not on this page · raw message
rust/zerocopy/benches/split_via_immutable_dynamic_size.rs new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_immutable_dynamic_size.x86-64 new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_immutable_dynamic_size.x86-64.mca new file +63 -0
63 lines not on this page · raw message
rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.rs new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.x86-64 new file +22 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_runtime_check_dynamic_padding.x86-64.mca new file +79 -0
79 lines not on this page · raw message
rust/zerocopy/benches/split_via_runtime_check_dynamic_size.rs new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_runtime_check_dynamic_size.x86-64 new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_runtime_check_dynamic_size.x86-64.mca new file +63 -0
63 lines not on this page · raw message
rust/zerocopy/benches/split_via_unchecked_dynamic_padding.rs new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_unchecked_dynamic_padding.x86-64 new file +14 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_unchecked_dynamic_padding.x86-64.mca new file +65 -0
65 lines not on this page · raw message
rust/zerocopy/benches/split_via_unchecked_dynamic_size.rs new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_unchecked_dynamic_size.x86-64 new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/split_via_unchecked_dynamic_size.x86-64.mca new file +63 -0
63 lines not on this page · raw message
rust/zerocopy/benches/transmute.rs new file +16 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/transmute.x86-64 new file +3 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/transmute.x86-64.mca new file +43 -0
43 lines not on this page · raw message
rust/zerocopy/benches/transmute_ref_dynamic_size.rs new file +16 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/transmute_ref_dynamic_size.x86-64 new file +4 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/transmute_ref_dynamic_size.x86-64.mca new file +45 -0
45 lines not on this page · raw message
rust/zerocopy/benches/transmute_ref_static_size.rs new file +15 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/transmute_ref_static_size.x86-64 new file +3 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/transmute_ref_static_size.x86-64.mca new file +43 -0
43 lines not on this page · raw message
rust/zerocopy/benches/try_read_from_bytes.rs new file +7 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_read_from_bytes.x86-64 new file +23 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_read_from_bytes.x86-64.mca new file +79 -0
79 lines not on this page · raw message
rust/zerocopy/benches/try_read_from_prefix.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_read_from_prefix.x86-64 new file +16 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_read_from_prefix.x86-64.mca new file +67 -0
67 lines not on this page · raw message
rust/zerocopy/benches/try_read_from_suffix.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_read_from_suffix.x86-64 new file +18 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_read_from_suffix.x86-64.mca new file +71 -0
71 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.rs new file +7 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.x86-64 new file +24 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_dynamic_padding.x86-64.mca new file +81 -0
81 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.rs new file +7 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.x86-64 new file +22 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_dynamic_size.x86-64.mca new file +79 -0
79 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_bytes_static_size.rs new file +7 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_static_size.x86-64 new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_static_size.x86-64.mca new file +59 -0
59 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64 new file +21 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64.mca new file +75 -0
75 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64 new file +18 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64.mca new file +69 -0
69 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.x86-64 new file +29 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_dynamic_padding.x86-64.mca new file +91 -0
91 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.x86-64 new file +22 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_dynamic_size.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_prefix_static_size.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_static_size.x86-64 new file +15 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_static_size.x86-64.mca new file +63 -0
63 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.rs new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64 new file +30 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64.mca new file +91 -0
91 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.rs new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64 new file +26 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64.mca new file +83 -0
83 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.x86-64 new file +26 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_dynamic_padding.x86-64.mca new file +85 -0
85 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.x86-64 new file +18 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_dynamic_size.x86-64.mca new file +71 -0
71 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_suffix_static_size.rs new file +10 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_static_size.x86-64 new file +16 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_static_size.x86-64.mca new file +67 -0
67 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.rs new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64 new file +32 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64.mca new file +95 -0
95 lines not on this page · raw message
rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.rs new file +13 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64 new file +28 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64.mca new file +87 -0
87 lines not on this page · raw message
rust/zerocopy/benches/try_transmute.rs new file +16 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_transmute.x86-64 new file +9 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_transmute.x86-64.mca new file +55 -0
55 lines not on this page · raw message
rust/zerocopy/benches/try_transmute_ref_dynamic_size.rs new file +18 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_transmute_ref_dynamic_size.x86-64 new file +6 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_transmute_ref_dynamic_size.x86-64.mca new file +49 -0
49 lines not on this page · raw message
rust/zerocopy/benches/try_transmute_ref_static_size.rs new file +17 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_transmute_ref_static_size.x86-64 new file +5 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/try_transmute_ref_static_size.x86-64.mca new file +47 -0
47 lines not on this page · raw message
rust/zerocopy/benches/write_to_dynamic_size.rs new file +9 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_dynamic_size.x86-64 new file +21 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_dynamic_size.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/write_to_prefix_dynamic_size.rs new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_prefix_dynamic_size.x86-64 new file +21 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_prefix_dynamic_size.x86-64.mca new file +77 -0
77 lines not on this page · raw message
rust/zerocopy/benches/write_to_prefix_static_size.rs new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_prefix_static_size.x86-64 new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_prefix_static_size.x86-64.mca new file +57 -0
57 lines not on this page · raw message
rust/zerocopy/benches/write_to_static_size.rs new file +9 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_static_size.x86-64 new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_static_size.x86-64.mca new file +57 -0
57 lines not on this page · raw message
rust/zerocopy/benches/write_to_suffix_dynamic_size.rs new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_suffix_dynamic_size.x86-64 new file +22 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_suffix_dynamic_size.x86-64.mca new file +79 -0
79 lines not on this page · raw message
rust/zerocopy/benches/write_to_suffix_static_size.rs new file +12 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_suffix_static_size.x86-64 new file +11 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/write_to_suffix_static_size.x86-64.mca new file +57 -0
57 lines not on this page · raw message
rust/zerocopy/benches/zero_dynamic_padding.rs new file +9 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/zero_dynamic_padding.x86-64 new file +7 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/zero_dynamic_padding.x86-64.mca new file +51 -0
51 lines not on this page · raw message
rust/zerocopy/benches/zero_dynamic_size.rs new file +9 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/zero_dynamic_size.x86-64 new file +5 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/zero_dynamic_size.x86-64.mca new file +47 -0
47 lines not on this page · raw message
rust/zerocopy/benches/zero_static_size.rs new file +9 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/zero_static_size.x86-64 new file +4 -0
Lines of this file are not shown. View the raw message.
rust/zerocopy/benches/zero_static_size.x86-64.mca new file +45 -0
45 lines not on this page · raw message
rust/zerocopy/rustdoc/style.css new file +55 -0
55 lines not on this page · raw message
rust/zerocopy/src/byte_slice.rs new file +432 -0
432 lines not on this page · raw message
rust/zerocopy/src/byteorder.rs new file +1563 -0
1,563 lines not on this page · raw message
rust/zerocopy/src/deprecated.rs new file +279 -0
279 lines not on this page · raw message
rust/zerocopy/src/error.rs new file +1348 -0
1,348 lines not on this page · raw message
rust/zerocopy/src/impls.rs new file +2387 -0
2,387 lines not on this page · raw message
rust/zerocopy/src/layout.rs new file +2223 -0
2,223 lines not on this page · raw message
rust/zerocopy/src/lib.rs new file +7610 -0
7,610 lines not on this page · raw message
rust/zerocopy/src/macros.rs new file +1823 -0
1,823 lines not on this page · raw message
rust/zerocopy/src/pointer/inner.rs new file +752 -0
752 lines not on this page · raw message
rust/zerocopy/src/pointer/invariant.rs new file +296 -0
296 lines not on this page · raw message
rust/zerocopy/src/pointer/mod.rs new file +408 -0
408 lines not on this page · raw message
rust/zerocopy/src/pointer/ptr.rs new file +1584 -0
1,584 lines not on this page · raw message
rust/zerocopy/src/pointer/transmute.rs new file +520 -0
520 lines not on this page · raw message
rust/zerocopy/src/ref.rs new file +1356 -0
1,356 lines not on this page · raw message
rust/zerocopy/src/split_at.rs new file +1088 -0
1,088 lines not on this page · raw message
rust/zerocopy/src/util/macro_util.rs new file +1308 -0
1,308 lines not on this page · raw message
rust/zerocopy/src/util/macros.rs new file +1065 -0
1,065 lines not on this page · raw message
rust/zerocopy/src/util/mod.rs new file +936 -0
936 lines not on this page · raw message
rust/zerocopy/src/wrappers.rs new file +1032 -0
1,032 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.54.0
Part of the diff is not shown here. View the raw message.
Miguel Ojeda
maintainerPATCH 9/18 rust: zerocopy: add SPDX License Identifiers
In reply to Miguel OjedaOriginally, when the Rust upstream alloc standard library crate was vendored, the SPDX License Identifiers were added to every file so that the license on those was clear. The same happened with the vendoring of proc_macro2, quote and syn. Please see:
commit 057b8d257107 ("rust: adapt alloc crate to the kernel") commit 69942c0a8965 ("rust: syn: add SPDX License Identifiers") commit ddfa1b279d08 ("rust: quote: add SPDX License Identifiers") commit a9acfceb9614 ("rust: proc-macro2: add SPDX License Identifiers")
Thus do the same for the zerocopy crate.
This makes scripts/spdxcheck.py pass: use parentheses like commit 06e9bfc1e57d ("ionic: make spdxcheck.py happy") did since we have two OR operators in the expression (three licenses).
SPDX identifiers are not added to the benches files because they are included in rendered documentation. Nevertheless, the README.md to be added by a later commit mentions the license.
--- rust/zerocopy/rustdoc/style.css | 2 ++ rust/zerocopy/src/byte_slice.rs | 2 ++ rust/zerocopy/src/byteorder.rs | 2 ++ rust/zerocopy/src/deprecated.rs | 2 ++ rust/zerocopy/src/error.rs | 2 ++ rust/zerocopy/src/impls.rs | 2 ++ rust/zerocopy/src/layout.rs | 2 ++ rust/zerocopy/src/lib.rs | 2 ++ rust/zerocopy/src/macros.rs | 2 ++ rust/zerocopy/src/pointer/inner.rs | 2 ++ rust/zerocopy/src/pointer/invariant.rs | 2 ++ rust/zerocopy/src/pointer/mod.rs | 2 ++ rust/zerocopy/src/pointer/ptr.rs | 2 ++ rust/zerocopy/src/pointer/transmute.rs | 2 ++ rust/zerocopy/src/ref.rs | 2 ++ rust/zerocopy/src/split_at.rs | 2 ++ rust/zerocopy/src/util/macro_util.rs | 2 ++ rust/zerocopy/src/util/macros.rs | 2 ++ rust/zerocopy/src/util/mod.rs | 2 ++ rust/zerocopy/src/wrappers.rs | 2 ++ 20 files changed, 40 insertions(+)
rust/zerocopy/rustdoc/style.css +2 -0
@@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT */ + /* Copyright 2026 The Fuchsia Authors
rust/zerocopy/src/byte_slice.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/byteorder.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2019 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/deprecated.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/error.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/impls.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/layout.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/lib.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2018 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/macros.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/pointer/inner.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/pointer/invariant.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/pointer/mod.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2023 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/pointer/ptr.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2023 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/pointer/transmute.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2025 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/ref.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2024 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/split_at.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2025 The Fuchsia Authors // // Licensed under the 2-Clause BSD License <LICENSE-BSD or
rust/zerocopy/src/util/macro_util.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2022 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/util/macros.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2023 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/util/mod.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2023 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy/src/wrappers.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2023 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 10/18 rust: zerocopy: remove float `Display` support
In reply to Miguel OjedaThe kernel builds core with the no_fp_fmt_parse --cfg, which means we do not have support for formatting floating point primitives. However, zerocopy expects those implementations to exist:
error[E0277]: `f32` doesn't implement `core::fmt::Display`
--> rust/zerocopy/src/byteorder.rs:172:29
|
172 | $trait::fmt(&self.get(), f)
| ----------- ^^^^^^^^^^^ the trait `core::fmt::Display` is not implemented for `f32`
| |
| required by a bound introduced by this call
...
907 | / define_type!(
908 | | An,
909 | | "A 32-bit floating point number",
910 | | F32,
... |
922 | | []
923 | | );
| |_- in this macro invocation
|
= help: the following other types implement trait `core::fmt::Display`:
i128
i16
i32
i64
i8
isize
u128
u16
and 4 others
= note: this error originates in the macro `impl_fmt_trait` which comes from the expansion of the macro `define_type` (in Nightly builds, run with -Z macro-backtrace for more info)Thus work around it by skipping those implementations in zerocopy.
Ideally, zerocopy would have the equivalent of no_fp_fmt_parse.
--- rust/zerocopy/src/byteorder.rs | 1 - 1 file changed, 1 deletion(-)
rust/zerocopy/src/byteorder.rs +0 -1
@@ -177,7 +177,6 @@ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {macro_rules! impl_fmt_traits { ($name:ident, $native:ident,"floating point number" ) => { -impl_fmt_trait! ($name, $native,Display ); }; ($name:ident, $native:ident,"unsigned integer" ) => {impl_fmt_traits! ($name, $native, @all_types);
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 11/18 rust: zerocopy: add `README.md`
In reply to Miguel OjedaOriginally, when the Rust upstream alloc standard library crate was vendored in commit 057b8d257107 ("rust: adapt alloc crate to the kernel"), a README.md file was added to explain the provenance and licensing of the source files.
Thus do the same for the zerocopy crate.
--- rust/zerocopy/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 rust/zerocopy/README.md
rust/zerocopy/README.md new file +14 -0
@@ -0,0 +1,14 @@ +# `zerocopy` + +These source files come from the Rust `zerocopy` crate, version v0.8.50 +(released 2026-05-31), hosted in the <https://github.com/google/zerocopy> +repository, licensed under "BSD-2-Clause OR Apache-2.0 OR MIT" and only +modified to add the SPDX license identifiers and to remove `Display` +for `f32` and `f64`. + +For copyright details, please see: + + https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 + https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD + https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE + https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 12/18 rust: zerocopy: enable support in kbuild
In reply to Miguel OjedaWith all the new files in place and ready from the new crate, enable the support for it in the build system.
In addition, skip formatting for this vendored crate.
Finally, there are no generated symbols expected from zerocopy, thus skip adding the exports generation.
--- Makefile | 1 + rust/Makefile | 45 ++++++++++++++++++++++++++----- scripts/Makefile.build | 1 + scripts/generate_rust_analyzer.py | 10 +++++-- 4 files changed, 49 insertions(+), 8 deletions(-)
Makefile +1 -0
@@ -1956,6 +1956,7 @@ rustfmt: -path $(srctree)/rust/proc-macro2 \ -o -path $(srctree)/rust/quote \ -o -path $(srctree)/rust/syn \ + -o -path $(srctree)/rust/zerocopy \ \) -prune -o \ -type f -a -name '*.rs' -a ! -name '*generated*' -print \ | xargs $(RUSTFMT) $(rustfmt_flags)
rust/Makefile +39 -6
114 lines not on this page · raw message
scripts/Makefile.build +1 -0
@@ -329,6 +329,7 @@ rust_common_cmd = \ -Zcrate-attr=no_std \ -Zcrate-attr='feature($(rust_allowed_features))' \ -Zunstable-options --extern pin_init --extern kernel \ + --extern zerocopy \ --crate-type rlib -L $(objtree)/rust/ \ --sysroot=/dev/null \ --out-dir $(dir $@) --emit=dep-info=$(depfile)
scripts/generate_rust_analyzer.py +8 -2
@@ -276,6 +276,12 @@ def generate_crates( [core, compiler_builtins], ) + zerocopy = append_crate( + "zerocopy", + srctree / "rust" / "zerocopy" / "src" / "lib.rs", + [core, compiler_builtins], + ) + def append_crate_with_generated( display_name: str, deps: List[Dependency],
@@ -304,7 +310,7 @@ def generate_crates( bindings = append_crate_with_generated("bindings", [core, ffi, pin_init]) uapi = append_crate_with_generated("uapi", [core, ffi, pin_init]) kernel = append_crate_with_generated( - "kernel", [core, macros, build_error, pin_init, ffi, bindings, uapi] + "kernel", [core, macros, build_error, pin_init, ffi, bindings, uapi, zerocopy] ) scripts = srctree / "scripts"
@@ -349,7 +355,7 @@ def generate_crates( append_crate( crate_name, path, - [core, kernel, pin_init], + [core, kernel, pin_init, zerocopy], cfg=generated_cfg, )
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 13/18 rust: zerocopy-derive: import crate
In reply to Miguel OjedaThis is a subset of the Rust zerocopy-derive crate, version v0.8.50 (released 2026-05-31), licensed under "BSD-2-Clause OR Apache-2.0 OR MIT", from:
https://github.com/google/zerocopy/tree/v0.8.50/zerocopy-derive/src
The files are copied as-is, with no modifications whatsoever (not even adding the SPDX identifiers).
For copyright details, please see:
https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT
The next two patches modify these files as needed for use within the kernel. This patch split allows reviewers to double-check the import and to clearly see the differences introduced.
The following script may be used to verify the contents:
for path in $(cd rust/zerocopy-derive/ && find . -type f); do
curl --silent --show-error --location \
https://github.com/google/zerocopy/raw/v0.8.50/zerocopy-derive/src/$path \
| diff --unified rust/zerocopy-derive/$path - && echo $path: OK
done--- rust/zerocopy-derive/derive/from_bytes.rs | 190 ++++ rust/zerocopy-derive/derive/into_bytes.rs | 162 ++++ rust/zerocopy-derive/derive/known_layout.rs | 348 +++++++ rust/zerocopy-derive/derive/mod.rs | 130 +++ rust/zerocopy-derive/derive/try_from_bytes.rs | 763 ++++++++++++++++ rust/zerocopy-derive/derive/unaligned.rs | 78 ++ rust/zerocopy-derive/lib.rs | 144 +++ rust/zerocopy-derive/repr.rs | 849 ++++++++++++++++++ rust/zerocopy-derive/util.rs | 843 +++++++++++++++++ 9 files changed, 3507 insertions(+) create mode 100644 rust/zerocopy-derive/derive/from_bytes.rs create mode 100644 rust/zerocopy-derive/derive/into_bytes.rs create mode 100644 rust/zerocopy-derive/derive/known_layout.rs create mode 100644 rust/zerocopy-derive/derive/mod.rs create mode 100644 rust/zerocopy-derive/derive/try_from_bytes.rs create mode 100644 rust/zerocopy-derive/derive/unaligned.rs create mode 100644 rust/zerocopy-derive/lib.rs create mode 100644 rust/zerocopy-derive/repr.rs create mode 100644 rust/zerocopy-derive/util.rs
rust/zerocopy-derive/derive/from_bytes.rs new file +190 -0
@@ -0,0 +1,190 @@ +use proc_macro2::{Span ,TokenStream }; +use syn::{ + parse_quote,Data ,DataEnum ,DataStruct ,DataUnion ,Error ,Expr ,ExprLit ,ExprUnary ,Lit ,UnOp , +WherePredicate , +}; + +use crate ::{ + derive::try_from_bytes::derive_try_from_bytes, + repr::{CompoundRepr ,EnumRepr ,Repr ,Spanned }, + util::{enum_size_from_repr,Ctx ,FieldBounds ,ImplBlockBuilder ,Trait ,TraitBound }, +}; +/// Returns `Ok(index)` if variant `index` of the enum has a discriminant of +/// zero. If `Err(bool)` is returned, the boolean is true if the enum has +/// unknown discriminants (e.g. discriminants set to const expressions which we +/// can't evaluate in a proc macro). If the enum has unknown discriminants, then +/// it might have a zero variant that we just can't detect. +pub (crate )fn find_zero_variant (enm: &DataEnum ) ->Result <usize ,bool > { +// Discriminants can be anywhere in the range [i128::MIN, u128::MAX] because +// the discriminant type may be signed or unsigned. Since we only care about +// tracking the discriminant when it's less than or equal to zero, we can +// avoid u128 -> i128 conversions and bounds checking by making the "next +// discriminant" value implicitly negative. +// Technically 64 bits is enough, but 128 is better for future compatibility +// with https://github.com/rust-lang/rust/issues/56071 +let mut next_negative_discriminant =Some (0 ); + +// Sometimes we encounter explicit discriminants that we can't know the +// value of (e.g. a constant expression that requires evaluation). These +// could evaluate to zero or a negative number, but we can't assume that +// they do (no false positives allowed!). So we treat them like strictly- +// positive values that can't result in any zero variants, and track whether +// we've encountered any unknown discriminants. +let mut has_unknown_discriminants =false ; + +for (i, v)in enm.variants.iter ().enumerate () { +match v.discriminant.as_ref () { +// Implicit discriminant +None => { +match next_negative_discriminant.as_mut () { +Some (0 ) =>return Ok (i), +// n is nonzero so subtraction is always safe +Some (n) => *n -=1 , +None => (), + } + } +// Explicit positive discriminant +Some ((_,Expr ::Lit (ExprLit { lit:Lit ::Int (int), .. }))) => { +match int.base10_parse ::<u128 >().ok () { +Some (0 ) =>return Ok (i), +Some (_) => next_negative_discriminant =None , +None => { +// Numbers should never fail to parse, but just in case: + has_unknown_discriminants =true ; + next_negative_discriminant =None ; + } + } + } +// Explicit negative discriminant +Some ((_,Expr ::Unary (ExprUnary { op:UnOp ::Neg (_), expr, .. }))) =>match &**expr { +Expr ::Lit (ExprLit { lit:Lit ::Int (int), .. }) => { +match int.base10_parse ::<u128 >().ok () { +Some (0 ) =>return Ok (i), +// x is nonzero so subtraction is always safe +Some (x) => next_negative_discriminant =Some (x -1 ), +None => { +// Numbers should never fail to parse, but just in +// case: + has_unknown_discriminants =true ; + next_negative_discriminant =None ; + } + } + } +// Unknown negative discriminant (e.g. const repr) + _ => { + has_unknown_discriminants =true ; + next_negative_discriminant =None ; + } + }, +// Unknown discriminant (e.g. const expr) + _ => { + has_unknown_discriminants =true ; + next_negative_discriminant =None ; + } + } + } + +Err (has_unknown_discriminants) +} +pub (crate )fn derive_from_zeros (ctx: &Ctx , top_level:Trait ) ->Result <TokenStream ,Error > { +let try_from_bytes =derive_try_from_bytes (ctx, top_level)?; +let from_zeros =match &ctx.ast.data { +Data ::Struct (strct) =>derive_from_zeros_struct (ctx, strct), +Data ::Enum (enm) =>derive_from_zeros_enum (ctx, enm)?, +Data ::Union (unn) =>derive_from_zeros_union (ctx, unn), + }; +Ok (IntoIterator ::into_iter ([try_from_bytes, from_zeros]).collect ()) +} +pub (crate )fn derive_from_bytes (ctx: &Ctx , top_level:Trait ) ->Result <TokenStream ,Error > { +let from_zeros =derive_from_zeros (ctx, top_level)?; +let from_bytes =match &ctx.ast.data { +Data ::Struct (strct) =>derive_from_bytes_struct (ctx, strct), +Data ::Enum (enm) =>derive_from_bytes_enum (ctx, enm)?, +Data ::Union (unn) =>derive_from_bytes_union (ctx, unn), + }; + +Ok (IntoIterator ::into_iter ([from_zeros, from_bytes]).collect ()) +} +fn derive_from_zeros_struct (ctx: &Ctx , strct: &DataStruct ) ->TokenStream { +ImplBlockBuilder ::new (ctx, strct,Trait ::FromZeros ,FieldBounds ::ALL_SELF ).build () +} +fn derive_from_zeros_enum (ctx: &Ctx , enm: &DataEnum ) ->Result <TokenStream ,Error > { +let repr =EnumRepr ::from_attrs (&ctx.ast.attrs)?; + +// We don't actually care what the repr is; we just care that it's one of +// the allowed ones. +match repr { +Repr ::Compound (Spanned { t:CompoundRepr ::C |CompoundRepr ::Primitive (_), span: _ }, _) => { + } +Repr ::Transparent (_) |Repr ::Compound (Spanned { t:CompoundRepr ::Rust , span: _ }, _) => { +return ctx.error_or_skip ( +Error ::new ( +Span ::call_site (), +"must have #[repr(C)] or #[repr(Int)] attribute in order to guarantee this type's memory layout" , + ), + ); + } + } + +let zero_variant =match find_zero_variant (enm) { +Ok (index) => enm.variants.iter ().nth (index).unwrap (), +// Has unknown variants +Err (true ) => { +return ctx.error_or_skip (Error ::new_spanned ( + &ctx.ast, +"FromZeros only supported on enums with a variant that has a discriminant of `0`\n\ +help: This enum has discriminants which are not literal integers. One of those may \ +define or imply which variant has a discriminant of zero. Use a literal integer to \ +define or imply the variant with a discriminant of zero." , + )); + } +// Does not have unknown variants +Err (false ) => { +return ctx.error_or_skip (Error ::new_spanned ( + &ctx.ast, +"FromZeros only supported on enums with a variant that has a discriminant of `0`" , + )); + } + }; + +let zerocopy_crate = &ctx.zerocopy_crate; +let explicit_bounds = zero_variant + .fields + .iter () + .map (|field| { +let ty = &field.ty; +parse_quote! { #ty: #zerocopy_crate::FromZeros } + }) + .collect ::<Vec <WherePredicate >>(); + +Ok (ImplBlockBuilder ::new (ctx, enm,Trait ::FromZeros ,FieldBounds ::Explicit (explicit_bounds)) + .build ()) +} +fn derive_from_zeros_union (ctx: &Ctx , unn: &DataUnion ) ->TokenStream { +let field_type_trait_bounds =FieldBounds ::All (&[TraitBound ::Slf ]); +ImplBlockBuilder ::new (ctx, unn,Trait ::FromZeros , field_type_trait_bounds).build () +} +fn derive_from_bytes_struct (ctx: &Ctx , strct: &DataStruct ) ->TokenStream { +ImplBlockBuilder ::new (ctx, strct,Trait ::FromBytes ,FieldBounds ::ALL_SELF ).build () +} +fn derive_from_bytes_enum (ctx: &Ctx , enm: &DataEnum ) ->Result <TokenStream ,Error > { +let repr =EnumRepr ::from_attrs (&ctx.ast.attrs)?; + +let variants_required =1usize <<enum_size_from_repr (&repr)?; +if enm.variants.len () != variants_required { +return ctx.error_or_skip (Error ::new_spanned ( + &ctx.ast, +format! ( +"FromBytes only supported on {} enum with {} variants" , + repr.repr_type_name (), + variants_required + ), + )); + } + +Ok (ImplBlockBuilder ::new (ctx, enm,Trait ::FromBytes ,FieldBounds ::ALL_SELF ).build ()) +} +fn derive_from_bytes_union (ctx: &Ctx , unn: &DataUnion ) ->TokenStream { +let field_type_trait_bounds =FieldBounds ::All (&[TraitBound ::Slf ]); +ImplBlockBuilder ::new (ctx, unn,Trait ::FromBytes , field_type_trait_bounds).build () +}
rust/zerocopy-derive/derive/into_bytes.rs new file +162 -0
162 lines not on this page · raw message
rust/zerocopy-derive/derive/known_layout.rs new file +348 -0
348 lines not on this page · raw message
rust/zerocopy-derive/derive/mod.rs new file +130 -0
130 lines not on this page · raw message
rust/zerocopy-derive/derive/try_from_bytes.rs new file +763 -0
763 lines not on this page · raw message
rust/zerocopy-derive/derive/unaligned.rs new file +78 -0
78 lines not on this page · raw message
rust/zerocopy-derive/lib.rs new file +144 -0
144 lines not on this page · raw message
rust/zerocopy-derive/repr.rs new file +849 -0
849 lines not on this page · raw message
rust/zerocopy-derive/util.rs new file +843 -0
336 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.54.0
Part of the diff is not shown here. View the raw message.
Miguel Ojeda
maintainerPATCH 14/18 rust: zerocopy-derive: add SPDX License Identifiers
In reply to Miguel OjedaOriginally, when the Rust upstream alloc standard library crate was vendored, the SPDX License Identifiers were added to every file so that the license on those was clear. The same happened with the vendoring of proc_macro2, quote and syn. Please see:
commit 057b8d257107 ("rust: adapt alloc crate to the kernel") commit 69942c0a8965 ("rust: syn: add SPDX License Identifiers") commit ddfa1b279d08 ("rust: quote: add SPDX License Identifiers") commit a9acfceb9614 ("rust: proc-macro2: add SPDX License Identifiers")
Thus do the same for the zerocopy-derive crate.
This makes scripts/spdxcheck.py pass: use parentheses like commit 06e9bfc1e57d ("ionic: make spdxcheck.py happy") did since we have two OR operators in the expression (three licenses).
--- rust/zerocopy-derive/derive/from_bytes.rs | 2 ++ rust/zerocopy-derive/derive/into_bytes.rs | 2 ++ rust/zerocopy-derive/derive/known_layout.rs | 2 ++ rust/zerocopy-derive/derive/mod.rs | 2 ++ rust/zerocopy-derive/derive/try_from_bytes.rs | 2 ++ rust/zerocopy-derive/derive/unaligned.rs | 2 ++ rust/zerocopy-derive/lib.rs | 2 ++ rust/zerocopy-derive/repr.rs | 2 ++ rust/zerocopy-derive/util.rs | 2 ++ 9 files changed, 18 insertions(+)
rust/zerocopy-derive/derive/from_bytes.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +use proc_macro2::{Span ,TokenStream };use syn::{ parse_quote,Data ,DataEnum ,DataStruct ,DataUnion ,Error ,Expr ,ExprLit ,ExprUnary ,Lit ,UnOp ,
rust/zerocopy-derive/derive/into_bytes.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +use proc_macro2::{Span ,TokenStream };use quote::quote;use syn::{Data ,DataEnum ,DataStruct ,DataUnion ,Error ,Type };
rust/zerocopy-derive/derive/known_layout.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +use proc_macro2::TokenStream ;use quote::quote;use syn::{parse_quote,Data ,Error ,Type };
rust/zerocopy-derive/derive/mod.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +pub mod from_bytes;pub mod into_bytes;pub mod known_layout;
rust/zerocopy-derive/derive/try_from_bytes.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +use proc_macro2::TokenStream ;use quote::quote;use syn::{
rust/zerocopy-derive/derive/unaligned.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +use proc_macro2::{Span ,TokenStream };use syn::{Data ,DataEnum ,DataStruct ,DataUnion ,Error };
rust/zerocopy-derive/lib.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2019 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy-derive/repr.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2019 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
rust/zerocopy-derive/util.rs +2 -0
@@ -1,3 +1,5 @@ +// SPDX-License-Identifier: (BSD-2-Clause OR Apache-2.0) OR MIT +// Copyright 2019 The Fuchsia Authors // // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 15/18 rust: zerocopy-derive: avoid generating non-ASCII identifiers
In reply to Miguel OjedaLinux is built with -Dnon_ascii_idents. However, zerocopy-derive uses a non-ASCII character (ẕ) internally, which in turn triggers the lint when attempting to use derives like FromBytes:
error: identifier contains non-ASCII characters
--> rust/kernel/lib.rs:153:9
|
153 | a: u32,
| ^
|
= note: requested on the command line with `-D non-ascii-idents`This was already noticed by another project using #![deny(non_ascii_idents)] [1]. zerocopy added an #[allow(non_ascii_idents)] [2], but it does not work since, at the moment, the non_ascii_idents lint is a crate_level_only one, and thus allows only work at the crate root level.
Due to this, an issue about relaxing this restriction was created in upstream Rust [3]. So far, there have been no replies.
Thus work around it here by using another prefix. The likelihood of a collision is very small for us, since we control the callers, and this will hopefully be fixed soon at either the zerocopy or the Rust level.
--- rust/zerocopy-derive/derive/try_from_bytes.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rust/zerocopy-derive/derive/try_from_bytes.rs +2 -2
@@ -457,7 +457,7 @@ fn derive_has_field_struct_union(ctx: &Ctx, data: &dyn DataExt) -> TokenStream { } let field_tokens = fields.iter().map(|(vis, ident, _)| { - let ident = ident!(("ẕ{}", ident), ident.span()); + let ident = ident!(("__z{}", ident), ident.span()); quote!( #vis enum #ident {} )
@@ -487,7 +487,7 @@ fn derive_has_field_struct_union(ctx: &Ctx, data: &dyn DataExt) -> TokenStream { }) .build(); let has_fields = fields.iter().map(move |(_, ident, ty)| { - let field_token = ident!(("ẕ{}", ident), ident.span()); + let field_token = ident!(("__z{}", ident), ident.span()); let field: Box<Type> = parse_quote!(#field_token); let field_id: Box<Expr> = parse_quote!({ #zerocopy_crate::ident_id!(#ident) }); let has_field_trait = Trait::HasField {
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 16/18 rust: zerocopy-derive: add `README.md`
In reply to Miguel OjedaOriginally, when the Rust upstream alloc standard library crate was vendored in commit 057b8d257107 ("rust: adapt alloc crate to the kernel"), a README.md file was added to explain the provenance and licensing of the source files.
Thus do the same for the zerocopy-derive crate.
--- rust/zerocopy-derive/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 rust/zerocopy-derive/README.md
rust/zerocopy-derive/README.md new file +14 -0
@@ -0,0 +1,14 @@ +# `zerocopy-derive` + +These source files come from the Rust `zerocopy-derive` crate, version v0.8.50 +(released 2026-05-31), hosted in the <https://github.com/google/zerocopy> +repository, licensed under "BSD-2-Clause OR Apache-2.0 OR MIT" and only +modified to add the SPDX license identifiers and to remove the generation of +non-ASCII identifiers. + +For copyright details, please see: + + https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 + https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD + https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE + https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 17/18 rust: zerocopy-derive: enable support in kbuild
In reply to Miguel OjedaWith all the new files in place and ready from the new crate, enable the support for it in the build system.
In addition, skip formatting for this vendored crate.
--- Makefile | 1 + rust/Makefile | 41 +++++++++++++++++++++++++------ scripts/Makefile.build | 2 +- scripts/generate_rust_analyzer.py | 10 ++++++-- 4 files changed, 43 insertions(+), 11 deletions(-)
Makefile +1 -0
@@ -1957,6 +1957,7 @@ rustfmt: -o -path $(srctree)/rust/quote \ -o -path $(srctree)/rust/syn \ -o -path $(srctree)/rust/zerocopy \ + -o -path $(srctree)/rust/zerocopy-derive \ \) -prune -o \ -type f -a -name '*.rs' -a ! -name '*generated*' -print \ | xargs $(RUSTFMT) $(rustfmt_flags)
rust/Makefile +33 -8
108 lines not on this page · raw message
scripts/Makefile.build +1 -1
@@ -329,7 +329,7 @@ rust_common_cmd = \ -Zcrate-attr=no_std \ -Zcrate-attr='feature($(rust_allowed_features))' \ -Zunstable-options --extern pin_init --extern kernel \ - --extern zerocopy \ + --extern zerocopy --extern zerocopy_derive \ --crate-type rlib -L $(objtree)/rust/ \ --sysroot=/dev/null \ --out-dir $(dir $@) --emit=dep-info=$(depfile)
scripts/generate_rust_analyzer.py +8 -2
@@ -252,6 +252,12 @@ def generate_crates( [std, proc_macro, proc_macro2, quote, syn], ) + zerocopy_derive = append_proc_macro_crate( + "zerocopy_derive", + srctree / "rust" / "zerocopy-derive" / "lib.rs", + [std, proc_macro, proc_macro2, quote, syn], + ) + build_error = append_crate( "build_error", srctree / "rust" / "build_error.rs",
@@ -310,7 +316,7 @@ def generate_crates( bindings = append_crate_with_generated("bindings", [core, ffi, pin_init]) uapi = append_crate_with_generated("uapi", [core, ffi, pin_init]) kernel = append_crate_with_generated( - "kernel", [core, macros, build_error, pin_init, ffi, bindings, uapi, zerocopy] + "kernel", [core, macros, build_error, pin_init, ffi, bindings, uapi, zerocopy, zerocopy_derive] ) scripts = srctree / "scripts"
@@ -355,7 +361,7 @@ def generate_crates( append_crate( crate_name, path, - [core, kernel, pin_init, zerocopy], + [core, kernel, pin_init, zerocopy, zerocopy_derive], cfg=generated_cfg, )
Signature · 1 line
2.54.0
Miguel Ojeda
maintainerPATCH 18/18 gpu: nova-core: firmware: parse `FalconUCodeDescV2` via `zerocopy`
In reply to Miguel OjedaNow that we have zerocopy support, we can avoid some unsafe code.
For instance, for FalconUCodeDescV2, we can replace the unsafe impl FromBytes by safely deriving zerocopy's FromBytes and then calling read_from_prefix.
--- drivers/gpu/nova-core/firmware.rs | 5 +---- drivers/gpu/nova-core/vbios.rs | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/nova-core/firmware.rs +1 -4
@@ -48,7 +48,7 @@ fn request_firmware(/// Structure used to describe some firmwares, notably FWSEC-FRTS. #[repr( C )] -#[derive( Debug , Clone )] +#[derive( Debug , Clone , zerocopy_derive:: FromBytes )] pub (crate )struct FalconUCodeDescV2 {/// Header defined by 'NV_BIT_FALCON_UCODE_DESC_HEADER_VDESC*' in OpenRM. hdr:u32 ,
@@ -84,9 +84,6 @@ pub(crate) struct FalconUCodeDescV2 { pub(crate) alt_dmem_load_size: u32, } -// SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability. -unsafe impl FromBytes for FalconUCodeDescV2 {} -/// Structure used to describe some firmwares, notably FWSEC-FRTS. #[repr( C )] #[derive( Debug , Clone )]
drivers/gpu/nova-core/vbios.rs +2 -2
@@ -1011,8 +1011,8 @@ pub(crate) fn header(&self) -> Result<FalconUCodeDesc> {let data = self.base.data.get (falcon_ucode_offset..).ok_or (EINVAL )?;match ver {2 => { -let v2 =FalconUCodeDescV2 ::from_bytes_copy_prefix (data) - .ok_or (EINVAL )? +let v2 = <FalconUCodeDescV2 as zerocopy::FromBytes >::read_from_prefix (data) + .map_err (|_|EINVAL )? .0 ;Ok (FalconUCodeDesc ::V2 (v2)) }
Signature · 1 line
2.54.0
Re: [PATCH 18/18] gpu: nova-core: firmware: parse `FalconUCodeDescV2` via `zerocopy`
Quoted 7 lines · Miguel Ojeda
Now that we have
zerocopysupport, we can avoid someunsafecode.For instance, for
FalconUCodeDescV2, we can replace theunsafe impl FromBytesby safely derivingzerocopy'sFromBytesand then callingread_from_prefix.Signed-off-by Miguel Ojeda <[email protected]>
Quoted 10 lines
--- drivers/gpu/nova-core/firmware.rs | 5 +---- drivers/gpu/nova-core/vbios.rs | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-)drivers/gpu/nova-core/firmware.rs +0
-0
drivers/gpu/nova-core/firmware.rs fn request_firmware( · line 51
Quoted 5 lines
drivers/gpu/nova-core/firmware.rs +1
-1@@ -48,7 +48,7 @@ fn request_firmware(/// Structure used to describe some firmwares, notably FWSEC-FRTS. #[repr( C )] -#[derive( Debug , Clone )] +#[derive( Debug , Clone , zerocopy_derive:: FromBytes )]
As discussed, it would be nice to re-export this to avoid the zerocopy_derive.
Quoted 18 lines
drivers/gpu/nova-core/firmware.rs +0
-3pub (crate )struct FalconUCodeDescV2 {/// Header defined by 'NV_BIT_FALCON_UCODE_DESC_HEADER_VDESC*' in OpenRM. hdr:u32 ,@@ -84,9 +84,6 @@ pub(crate) struct FalconUCodeDescV2 { pub(crate) alt_dmem_load_size: u32, } -// SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability. -unsafe impl FromBytes for FalconUCodeDescV2 {} -/// Structure used to describe some firmwares, notably FWSEC-FRTS. #[repr( C )] #[derive( Debug , Clone )] drivers/gpu/nova-core/vbios.rs +0
-0
drivers/gpu/nova-core/vbios.rs pub(crate) fn header(&self) -> Result<FalconUCodeDesc> { · line 1014
Quoted 6 lines
drivers/gpu/nova-core/vbios.rs +1
-2@@ -1011,8 +1011,8 @@ pub(crate) fn header(&self) -> Result<FalconUCodeDesc> {let data = self.base.data.get (falcon_ucode_offset..).ok_or (EINVAL )?;match ver {2 => { -let v2 =FalconUCodeDescV2 ::from_bytes_copy_prefix (data) - .ok_or (EINVAL )? +let v2 = <FalconUCodeDescV2 as zerocopy::FromBytes >::read_from_prefix (data)
If we import this as
use zerocopy::FromBytes as _;
we can avoid the qualified syntax and just keep it
let v2 = FalconUCodeDescV2::read_from_prefix(data)
Quoted 6 lines
drivers/gpu/nova-core/vbios.rs +1
-0+ .map_err(|_| EINVAL)? .0 ;Ok (FalconUCodeDesc ::V2 (v2)) }Signature · 1 line
2.54.0
Re: [PATCH 18/18] gpu: nova-core: firmware: parse `FalconUCodeDescV2` via `zerocopy`
In reply to Miguel OjedaQuoted 26 lines · Miguel Ojeda
Now that we have
zerocopysupport, we can avoid someunsafecode.For instance, for
FalconUCodeDescV2, we can replace theunsafe impl FromBytesby safely derivingzerocopy'sFromBytesand then callingread_from_prefix.Signed-off-by Miguel Ojeda <[email protected]>--- drivers/gpu/nova-core/firmware.rs | 5 +---- drivers/gpu/nova-core/vbios.rs | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-)drivers/gpu/nova-core/firmware.rs +1
-1@@ -48,7 +48,7 @@ fn request_firmware(/// Structure used to describe some firmwares, notably FWSEC-FRTS. #[repr( C )] -#[derive( Debug , Clone )] +#[derive( Debug , Clone , zerocopy_derive:: FromBytes )] pub (crate )struct FalconUCodeDescV2 {/// Header defined by 'NV_BIT_FALCON_UCODE_DESC_HEADER_VDESC*' in OpenRM. hdr:u32 ,
drivers/gpu/nova-core/firmware.rs pub(crate) struct FalconUCodeDescV2 { · line 88
Quoted 5 lines
drivers/gpu/nova-core/firmware.rs +0
-2@@ -84,9 +84,6 @@ pub(crate) struct FalconUCodeDescV2 { pub(crate) alt_dmem_load_size: u32, } -// SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability. -unsafe impl FromBytes for FalconUCodeDescV2 {}
I can't wait to remove the many, many instances of this we have in the driver. ToT
Quoted 55 lines · Miguel Ojeda
This patch series introduces support for
zerocopy:Fast, safe, compile error. Pick two.
Zerocopy makes zero-cost memory manipulation effortless. We write
unsafeso you don't have to.It essentially provides derivable traits (e.g.
FromBytes) and macros (e.g.transmute!) for safely converting between byte sequences and other types. Having such support allows us to remove someunsafecode.It is among the most downloaded Rust crates (top #50 recent, top #100 all-time downloads; according to crates.io), and it is also used by the Rust compiler itself.
The series starts with a few preparation commits, then the
zerocopyandzerocopy-derivecrates are added. Finally, an example patch using it is on top, removing oneunsafe impl.I had to adapt the crates slightly (just +2/-3 lines), but both patches could potentially be provided upstream eventually. Please see the commits for details.
In total, it is about ~39k lines added, ~32k without counting
benches/which are just for documentation purposes.See the cover letter for
synfor some more details about depending on third-party crates in commit54e3eae85562("Merge patch series "synsupport"").The codegen of an isolated example function similar to the patch on top is essentially identical. It also turns out that (for that particular case)
zerocopy's version, even underdebug-assertionsenabled, has no remaining panics, unlike a few in the current code (because the compiler can prove the remainingub_checksstatically).So their "fast, safe" does indeed check out -- at least in that case.
P.S. This version ofzerocopyhas already the unstablePtr{,Inner}types -- to play with them, please use:make ... KRUSTFLAGS=--cfg=zerocopy_unstable_ptr
Miguel Ojeda (18):
scripts:generate_rust_analyzer: support passing env vars
rust: kbuild: show the rightquiet_cmd_rustc_procmacrolibrary
rust: kbuild: remove unused variable
rust: kbuild: defineprocmacro-namefunction
rust: kbuild: defineprocmacro-extensionvariable
rust: kbuild: support per-target environment variables
rust: kbuild: supportskip_clippyforrustc_procmacro
rust: zerocopy: import crate
rust: zerocopy: add SPDX License Identifiers
rust: zerocopy: remove floatDisplaysupport
Quoted 8 lines
rust: zerocopy: add
README.md
rust: zerocopy: enable support in kbuild
rust: zerocopy-derive: import crate
rust: zerocopy-derive: add SPDX License Identifiers
rust: zerocopy-derive: avoid generating non-ASCII identifiers
rust: zerocopy-derive: addREADME.md
rust: zerocopy-derive: enable support in kbuild
gpu: nova-core: firmware: parseFalconUCodeDescV2viazerocopy
Cc'ing Jack in his new address -- I took the email from the latest commit he authored in zerocopy from a few weeks ago, but that was not the right email anymore, sorry!
Jack: in case I don't need to send a new version, you can see the series (and instructions on how to reply if needed) at:
https://lore.kernel.org/rust-for-linux/[email protected]/
I will fix the email in the Cc: tags in the commits themselves too.
Joshua, Jack: you may be interested in the two "tweaks" I did to the crates:
rust: zerocopy: remove float Display support
rust: zerocopy-derive: avoid generating non-ASCII identifiers
A double-check that it is good would be great! :) It may be that we can add it upstream somehow (e.g. with a cfg) for a future update when we need to bump zerocopy eventually.
Thanks!
Cheers,
Miguel