Skip to content

Conversation

garyschulte
Copy link
Contributor

@garyschulte garyschulte commented Oct 26, 2021

Use libc c_char references to defer to the platform char implementation rather than using signed char (i8).

This allows us to build on Arm64 platforms where char is unsigned.

ref:

https://stackoverflow.com/questions/47684111/make-string-type-compatible-with-arm/47684200
https://users.rust-lang.org/t/expected-const-i8-found-const-u8-for-c-function-pointer-waiting-for-a-const-char/2441
remacs/remacs#1393
etc.

Otherwise arm64 gets build errors such as:

...
error[E0308]: mismatched types
  --> src/public_interface/eip196/c_api.rs:58:73
   |
58 |     let err_out_i8: &mut [i8] = unsafe { std::slice::from_raw_parts_mut(err, EIP196_PREALLOCATE_FOR_ERROR_BYTES) };
   |                                                                         ^^^ expected `i8`, found `u8`
   |
   = note: expected raw pointer `*mut i8`
              found raw pointer `*mut u8`

              ...

Built and tested on Arm64 linux and x86_64 linux

Signed-off-by: Gary Schulte <pi@raspberrypi>
@garyschulte
Copy link
Contributor Author

@shamatar when you have time would you 👀 ? TIA

@shamatar
Copy link
Member

Oh, that slipped off from my radar. Can you hide libc under feature flag, as it's not required unless there are EIP related features?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants