haskell-hvr / regex-tdfa

Pure Haskell Tagged DFA Backend for "Text.Regex" (regex-base)
http://hackage.haskell.org/package/regex-tdfa
Other
38 stars 10 forks source link

Fix return type in `memcpy` FFI signature #52

Closed amesgen closed 1 year ago

amesgen commented 1 year ago

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 commented 1 year ago

Thanks, makes sense!

andreasabel commented 1 year ago

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