-
Notifications
You must be signed in to change notification settings - Fork 166
Comments
Conversation
gumb0
commented
Sep 26, 2019
I think it certainly looks simpler without additional free functions
include/evmc/evmc.h
Outdated
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 think for a 4 byte saving this complicates matters too much for bindings, such as go or rust.
chfast
commented
Sep 27, 2019
Risks:
- In theory, union memory layout is not binary compatible across different compilers / compilers versions.
- Not everything FFI/bindings support unions. E.g. Go will represent this union as bytes.
- Using the same memory space for different purposes.
A more conservative variant is to place the scratchpad after create_address.
37df91a to
13915dd
Compare
chfast
commented
Sep 28, 2019
Update version: create_address separated from the scratchpad.
Still union is used - this is the easiest way to make sure the scratchpad is aligned memory (fix needed for 32-bit arch). However, using unions still might be not ideal for bindings.
Alternatively, we can define scratchpad as uint8_t scratchpad[32 + 4] and then add helpers like:
uint64_t* get_scratchpad_as_words(result*)
{
(uint64_t*)&result->scratchpad[4];
}
axic
commented
Sep 28, 2019
Added the size tests to Rust too.
6865374 to
cddddb7
Compare
axic
commented
Nov 5, 2019
@chfast how about this PR? The current version seems to be good, at least from the C and Rust perspectives.
chfast
commented
Nov 5, 2019
Not now. I have some other ideas in this subject.
The idea behind this is the following: