Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[runtime] Remove internal memcpy p/invoke #8890

Merged
merged 2 commits into from
Jun 19, 2020

Conversation

spouliot
Copy link
Contributor

  • Replace memcpy with Buffer.MemoryCopy
  • Add cecil-based test to make sure we're not p/invoke into it again (nor any other MS banned API)
  • Remove memcpy from xtro ignore file

* Replace `memcpy` with `Buffer.MemoryCopy`
* Add cecil-based test to make sure we're not p/invoke into it again (nor any other MS banned API)
* Remove `memcpy` from xtro ignore file
@spouliot spouliot requested a review from dalexsoto as a code owner June 18, 2020 16:08
@spouliot spouliot added the not-notes-worthy Ignore for release notes label Jun 18, 2020
fixed (byte* arrAddr = &Maps[i].Value [0])
Runtime.memcpy (bufferEnd, (IntPtr) arrAddr, 128);
fixed (void* arrAddr = &Maps[i].Value [0])
Buffer.MemoryCopy ((void*) bufferEnd, arrAddr, 128, 128);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer.MemoryCopy has the source/destination parameters reversed wrt memcpy, but they're the same order here.

A simpler change would have been to implement Runtime.memcpy using Buffer.MemoryCopy 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, I wanted the name to disappear :)

Runtime.memcpy (bufferEnd, (IntPtr) arrAddr, controlsSize * connectionParams.NumControlTransforms);
unsafe {
fixed (void* arrAddr = &Controls[0])
Buffer.MemoryCopy ((void*) bufferEnd, arrAddr, controlsSize * connectionParams.NumControlTransforms, controlsSize * connectionParams.NumControlTransforms);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer.MemoryCopy has the source/destination parameters reversed wrt memcpy, but they're the same order here.

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

1 tests failed, 87 tests passed.

Failed tests

  • monotouch-test/watchOS 32-bits - simulator/Debug: Failed Known issue: HE0038)

@spouliot spouliot merged commit 76a61f1 into xamarin:main Jun 19, 2020
@spouliot spouliot deleted the remove-memcpy-pinvoke branch June 19, 2020 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-notes-worthy Ignore for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants