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

Fix return type in memcpy FFI signature #52

Merged
merged 1 commit into from Jun 16, 2023

Conversation

amesgen
Copy link
Contributor

@amesgen amesgen commented Jun 15, 2023

Consider the signature of memcpy (e.g. from here):

void *memcpy(void *restrict dest, const void *restrict src, size_t n);

Note that the return type is void *, a pointer, and not void. Hence, this PR changes the return type from IO () to IO (Ptr a); was e.g. done here in the very similar code in array.

This will probably not change anything on most platform; concrete motivation is that compiling regex-tdfa using the GHC 9.6 WASM backend did yield a link-time warning:

wasm-ld: warning: function signature mismatch: memcpy
>>> defined as (i32, i32, i32) -> void in [...]/lib/libHSregex-tdfa-1.3.2.1-[...].a(Engine.o)
>>> defined as (i32, i32, i32) -> i32 in [...]/share/wasi-sysroot/lib/wasm32-wasi/libc.a(memcpy.o)

@andreasabel andreasabel added the re: compilation warning Concerning warnings emitted during build label Jun 16, 2023
@andreasabel
Copy link
Member

Thanks, makes sense!

@andreasabel andreasabel added this to the 1.3.2.2 milestone Jun 16, 2023
@andreasabel andreasabel merged commit df44f7a into haskell-hvr:master Jun 16, 2023
14 checks passed
@andreasabel
Copy link
Member

This will go into the next release (too minor to warrant its own release, I'd say).

@amesgen amesgen deleted the memcpy-ret-sig branch June 16, 2023 11:00
phadej added a commit to phadej/regex-tdfa that referenced this pull request Jun 17, 2023
I noticed unsafeCoerce# in haskell-hvr#52
and it look scary.

With this small change we see what the target type of coercion,
which makes it slightly less scary.
phadej added a commit to phadej/regex-tdfa that referenced this pull request Jun 17, 2023
I noticed unsafeCoerce# in haskell-hvr#52
and it look scary.

With this small change we see what the target type of coercion,
which makes it slightly less scary.

Especially as we use `unsafeCoerce` (without the hash),
so we don't (accidentally) coerce between difference runtime reps.
@phadej phadej mentioned this pull request Jun 17, 2023
andreasabel pushed a commit that referenced this pull request Jun 18, 2023
I noticed unsafeCoerce# in #52
and it look scary.

With this small change we see what the target type of coercion,
which makes it slightly less scary.

Especially as we use `unsafeCoerce` (without the hash),
so we don't (accidentally) coerce between difference runtime reps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: compilation warning Concerning warnings emitted during build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants