-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[WIP] Fix memset, memcpy, memmove calls on Pointer type. #4611
Conversation
src/pointer.cr
Outdated
size.to_u32 | ||
end | ||
{% end %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed. LibC::SizeT.new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Intrinsics
method signatures are not associated to LibC::SizeT
.
This PR is short one, without changing of rules of the game.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea what you're talking about. Why spray the definition of size_t all over the codebase when it already exists.
Use LibC::SizeT.new
instead of to_size_t
and you don't need this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need to introduce generic SizeT and OffsetT types, or change Intrinsics
contracts, but it should be discussed and introduced by another PR.
This PR just fixes contract implementation.
88c2200
to
73c3c4b
Compare
Just note that it's short fix for crystal-lang#4589 only.
73c3c4b
to
0417f80
Compare
@@ -242,7 +242,7 @@ struct Pointer(T) | |||
raise ArgumentError.new("Negative count") if count < 0 | |||
|
|||
if self.class == source.class | |||
Intrinsics.memcpy(self.as(Void*), source.as(Void*), (count * sizeof(T)).to_u32, 0_u32, false) | |||
Intrinsics.memcpy(self.as(Void*), source.as(Void*), count * sizeof(T), 0_u32, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea why the CI isn't broken but isn't this passing 32bit ints to something expecting a U64
?
Dislike this as it actually returns a different type depending on the architecture. I'd prefer a SizeT. |
This is a palliative. Will rework using SizeT and OffsetT. |
Sorry, that doesn't solve anything. It still relies on |
So it should be |
@konovod thanks. was fixed with #4624. @ysbaddaden thanks too. |
Just note that it's short fix for #4589 only.
No generic SizeT, OffsetT introduced here.