crosvm/data_model
Chirantan Ekbote f1444aaf72 data_model: Implement Send + Sync for IoSliceMut
Pointers in rust don't implement Send or Sync and so any struct that
contains a raw pointer doesn't implement those traits either.  However,
there's nothing inherently unsafe about sending a pointer across thread
boundaries.  The only unsafety comes from actually de-referencing the
pointer, which already requires an unsafe block.

Explicitly implement Send + Sync for IoSliceMut since the iovec
internally holds a *mut c_void, which prevents those traits from being
auto-implemented.  Send + Sync is also implemented by
std::io::IoSliceMut, which is almost exactly the same as our IoSliceMut,
so that can provide some additional reassurance that this is safe.

Also add a missing copyright header in the file.

BUG=none
TEST=unit tests

Change-Id: Ic21fc0de9b29923420f36ab166fec80d4d4cf2e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2571146
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-12-09 14:31:09 +00:00
..
src data_model: Implement Send + Sync for IoSliceMut 2020-12-09 14:31:09 +00:00
Cargo.toml Make VolatileSlice ABI-compatible with iovec 2020-05-25 19:14:07 +00:00