You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like this mapping from the rust enum to the c++ bitflag is not correct?
The Rust enum AiFlags does not map directly to any specific C++ enum value because Rust's AiFlags::AiPassive has an explicit discriminant of 0, while in the C++ code, __WASI_AIFLAGS_AI_PASSIVE has an implicit discriminant of 1 (since it's defined as 1ULL << 0). In other words, the Rust enum AiFlags is zero-based, while the C++ enum __wasi_aiflags_t is one-based. Therefore, there is no direct mapping between them.
However, I'm guessing "this just works" for AiPassive because in the context of getaddrinfo, the AI_PASSIVE flag is defined to have a value of 0 in POSIX, so it's possible that AiFlags::AiPassive could be used to represent __WASI_AIFLAGS_AI_PASSIVE with a value of 0 in C++.
However, the other enum values will therefore map incorrectly as it currently stands... I'm not very good at either C++ or Rust, but can anyone validate that this is correct?
and in fact either the rust enum needs to change to be indexed starting from 1, not 0 or the bit flags should change to:
__WASI_AIFLAGS_AI_PASSIVE = 0 << 0
__WASI_AIFLAGS_AI_CANONNAME = 1 << 0
and so on.
If I look at the WasiAddrInfo struct overall, it has the following information: size = 40, align = 4 but the __wasi_addrinfo_t struct in C++ has size = 28, align = 4.
I would expect these to be the same? Should the rust code or host code be treated as correct?
The text was updated successfully, but these errors were encountered:
Hi,
I'm comparing the sockets client code here:
wasmedge_wasi_socket/src/socket.rs
Line 61 in 7685fa0
with the host functions in the engine here:
https://github.com/WasmEdge/WasmEdge/blob/0bbc4f7d28f8bdbd37175a174f15d4f9a61953f7/thirdparty/wasi/api.hpp#L1759
It looks like this mapping from the rust enum to the c++ bitflag is not correct?
The Rust enum AiFlags does not map directly to any specific C++ enum value because Rust's AiFlags::AiPassive has an explicit discriminant of 0, while in the C++ code, __WASI_AIFLAGS_AI_PASSIVE has an implicit discriminant of 1 (since it's defined as 1ULL << 0). In other words, the Rust enum AiFlags is zero-based, while the C++ enum __wasi_aiflags_t is one-based. Therefore, there is no direct mapping between them.
However, I'm guessing "this just works" for AiPassive because in the context of getaddrinfo, the AI_PASSIVE flag is defined to have a value of 0 in POSIX, so it's possible that AiFlags::AiPassive could be used to represent __WASI_AIFLAGS_AI_PASSIVE with a value of 0 in C++.
However, the other enum values will therefore map incorrectly as it currently stands... I'm not very good at either C++ or Rust, but can anyone validate that this is correct?
and in fact either the rust enum needs to change to be indexed starting from 1, not 0 or the bit flags should change to:
__WASI_AIFLAGS_AI_PASSIVE = 0 << 0
__WASI_AIFLAGS_AI_CANONNAME = 1 << 0
and so on.
If I look at the WasiAddrInfo struct overall, it has the following information: size = 40, align = 4 but the __wasi_addrinfo_t struct in C++ has size = 28, align = 4.
I would expect these to be the same? Should the rust code or host code be treated as correct?
The text was updated successfully, but these errors were encountered: