Skip to content

Commit d1a577e

Browse files
committed
feat(zephyr): v4.4 migration fixes/improvements
Zephyr v4.4 has stricter compiler policies. This commit fixes following: - fix implicit casting errors - fix IPV6 related typos/variables/structures - fix zephyr fd relevant implicit casting Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
1 parent 11eb206 commit d1a577e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

core/iwasm/aot/arch/aot_reloc_thumb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
438438
| ((lower & 0x7000) >> 4) | (lower & 0x00ff);
439439
offset = (offset ^ 0x8000) - 0x8000;
440440

441-
offset += (symbol_addr + reloc_addend);
441+
offset += ((intptr_t)symbol_addr + reloc_addend);
442442

443443
if (reloc_type == R_ARM_THM_MOVT_PREL
444444
|| reloc_type == R_ARM_THM_MOVW_PREL_NC)

core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,15 +2215,15 @@ wasmtime_ssp_poll_oneoff(wasm_exec_env_t exec_env, struct fd_table *curfds,
22152215
__WASI_RIGHT_POLL_FD_READWRITE, 0);
22162216
if (error == 0) {
22172217

2218-
// Temporary workaround (see PR#4377)
2219-
#ifdef BH_PLATFORM_ZEPHYR
2220-
os_file_handle tfd = fos[i]->file_handle->fd;
2221-
#else
2218+
// Temporary workaround (see PR#4377)
22222219
os_file_handle tfd = fos[i]->file_handle;
2223-
#endif
22242220
// Proper file descriptor on which we can poll().
22252221
pfds[i] = (os_poll_file_handle){
2222+
#ifdef BH_PLATFORM_ZEPHYR
2223+
.fd = tfd->fd,
2224+
#else
22262225
.fd = tfd,
2226+
#endif
22272227
.events = s->u.type == __WASI_EVENTTYPE_FD_READ
22282228
? POLLIN
22292229
: POLLOUT,

core/shared/platform/zephyr/zephyr_socket.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ textual_addr_to_sockaddr(const char *textual, int port, struct sockaddr *out,
2424
{
2525
struct sockaddr_in *v4;
2626
#ifdef IPPROTO_IPV6
27-
struct sockaddr_in *v6;
27+
struct sockaddr_in6 *v6;
2828
#endif
2929

3030
assert(textual);
@@ -38,11 +38,11 @@ textual_addr_to_sockaddr(const char *textual, int port, struct sockaddr *out,
3838
}
3939

4040
#ifdef IPPROTO_IPV6
41-
v6 = (struct sockaddr_in *)out;
41+
v6 = (struct sockaddr_in6 *)out;
4242
if (zsock_inet_pton(AF_INET6, textual, &v6->sin6_addr.s6_addr) == 1) {
4343
v6->sin6_family = AF_INET6;
4444
v6->sin6_port = htons(port);
45-
*out_len = sizeof(struct sockaddr_in);
45+
*out_len = sizeof(struct sockaddr_in6);
4646
return true;
4747
}
4848
#endif
@@ -67,7 +67,7 @@ sockaddr_to_bh_sockaddr(const struct sockaddr *sockaddr,
6767
#ifdef IPPROTO_IPV6
6868
case AF_INET6:
6969
{
70-
struct sockaddr_in *addr = (struct sockaddr_in *)sockaddr;
70+
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)sockaddr;
7171
size_t i;
7272

7373
bh_sockaddr->port = ntohs(addr->sin6_port);
@@ -245,7 +245,7 @@ os_socket_bind(bh_socket_t socket, const char *host, int *port)
245245
}
246246
else {
247247
#ifdef IPPROTO_IPV6
248-
*port = ntohs(((struct sockaddr_in *)&addr)->sin6_port);
248+
*port = ntohs(((struct sockaddr_in6 *)&addr)->sin6_port);
249249
#else
250250
return BHT_ERROR;
251251
#endif
@@ -906,10 +906,10 @@ os_socket_set_ip_add_membership(bh_socket_t socket,
906906
((uint16_t *)mreq.ipv6mr_multiaddr.s6_addr)[i] =
907907
imr_multiaddr->ipv6[i];
908908
}
909-
mreq.ipv6mr_interface = imr_interface;
909+
mreq.ipv6mr_ifindex = imr_interface;
910910

911-
if (setsockopt(socket->fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq,
912-
sizeof(mreq))
911+
if (zsock_setsockopt(socket->fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
912+
&mreq, sizeof(mreq))
913913
!= 0) {
914914
return BHT_ERROR;
915915
}
@@ -947,7 +947,7 @@ os_socket_set_ip_drop_membership(bh_socket_t socket,
947947
((uint16_t *)mreq.ipv6mr_multiaddr.s6_addr)[i] =
948948
imr_multiaddr->ipv6[i];
949949
}
950-
mreq.ipv6mr_interface = imr_interface;
950+
mreq.ipv6mr_ifindex = imr_interface;
951951

952952
if (zsock_setsockopt(socket->fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP,
953953
&mreq, sizeof(mreq))

0 commit comments

Comments
 (0)