Archived
Fix strict aliasing warnings
This commit is contained in:
@@ -766,10 +766,10 @@ m3ApiRawFunction(m3_wasi_generic_fd_pread)
|
||||
|
||||
#if defined(M3_COMPILER_MSVC)
|
||||
if (iovs_len > 32) m3ApiReturn(UVWASI_EINVAL);
|
||||
uvwasi_ciovec_t iovs[32];
|
||||
uvwasi_iovec_t iovs[32];
|
||||
#else
|
||||
if (iovs_len > 128) m3ApiReturn(UVWASI_EINVAL);
|
||||
uvwasi_ciovec_t iovs[iovs_len];
|
||||
uvwasi_iovec_t iovs[iovs_len];
|
||||
#endif
|
||||
|
||||
for (uvwasi_size_t i = 0; i < iovs_len; ++i) {
|
||||
@@ -781,7 +781,7 @@ m3ApiRawFunction(m3_wasi_generic_fd_pread)
|
||||
|
||||
uvwasi_size_t num_read;
|
||||
|
||||
uvwasi_errno_t ret = uvwasi_fd_pread(&uvwasi, fd, (const uvwasi_iovec_t *) iovs, iovs_len, offset, &num_read);
|
||||
uvwasi_errno_t ret = uvwasi_fd_pread(&uvwasi, fd, iovs, iovs_len, offset, &num_read);
|
||||
|
||||
WASI_TRACE("fd:%d | nread:%d", fd, num_read);
|
||||
|
||||
@@ -802,10 +802,10 @@ m3ApiRawFunction(m3_wasi_generic_fd_read)
|
||||
|
||||
#if defined(M3_COMPILER_MSVC)
|
||||
if (iovs_len > 32) m3ApiReturn(UVWASI_EINVAL);
|
||||
uvwasi_ciovec_t iovs[32];
|
||||
uvwasi_iovec_t iovs[32];
|
||||
#else
|
||||
if (iovs_len > 128) m3ApiReturn(UVWASI_EINVAL);
|
||||
uvwasi_ciovec_t iovs[iovs_len];
|
||||
uvwasi_iovec_t iovs[iovs_len];
|
||||
#endif
|
||||
uvwasi_size_t num_read;
|
||||
uvwasi_errno_t ret;
|
||||
@@ -817,7 +817,7 @@ m3ApiRawFunction(m3_wasi_generic_fd_read)
|
||||
//fprintf(stderr, "> fd_read fd:%d iov%d.len:%d\n", fd, i, iovs[i].buf_len);
|
||||
}
|
||||
|
||||
ret = uvwasi_fd_read(&uvwasi, fd, (const uvwasi_iovec_t *) iovs, iovs_len, &num_read);
|
||||
ret = uvwasi_fd_read(&uvwasi, fd, iovs, iovs_len, &num_read);
|
||||
|
||||
WASI_TRACE("fd:%d | nread:%d", fd, num_read);
|
||||
|
||||
|
||||
+3
-3
@@ -99,18 +99,18 @@ void EmitWord_impl (IM3CodePage i_page, void * i_word)
|
||||
|
||||
void EmitWord32 (IM3CodePage i_page, const u32 i_word)
|
||||
{ d_m3Assert (i_page->info.lineIndex+1 <= i_page->info.numLines);
|
||||
* ((u32 *) & i_page->code [i_page->info.lineIndex++]) = i_word;
|
||||
memcpy (& i_page->code[i_page->info.lineIndex++], & i_word, sizeof(i_word));
|
||||
}
|
||||
|
||||
void EmitWord64 (IM3CodePage i_page, const u64 i_word)
|
||||
{
|
||||
#if M3_SIZEOF_PTR == 4
|
||||
d_m3Assert (i_page->info.lineIndex+2 <= i_page->info.numLines);
|
||||
* ((u64 *) & i_page->code [i_page->info.lineIndex]) = i_word;
|
||||
memcpy (& i_page->code[i_page->info.lineIndex], & i_word, sizeof(i_word));
|
||||
i_page->info.lineIndex += 2;
|
||||
#else
|
||||
d_m3Assert (i_page->info.lineIndex+1 <= i_page->info.numLines);
|
||||
* ((u64 *) & i_page->code [i_page->info.lineIndex]) = i_word;
|
||||
memcpy (& i_page->code[i_page->info.lineIndex], & i_word, sizeof(i_word));
|
||||
i_page->info.lineIndex += 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
+8
-12
@@ -679,7 +679,8 @@ M3Result PushConst (IM3Compilation o, u64 i_word, u8 i_type)
|
||||
{
|
||||
if (IsSlotAllocated (o, slot) and IsSlotAllocated (o, slot + 1))
|
||||
{
|
||||
u64 constant = * (u64 *) & o->constants [slot - o->slotFirstConstIndex];
|
||||
u64 constant;
|
||||
memcpy (&constant, &o->constants [slot - o->slotFirstConstIndex], sizeof (constant));
|
||||
|
||||
if (constant == i_word)
|
||||
{
|
||||
@@ -700,9 +701,9 @@ _ (Push (o, i_type, slot));
|
||||
{
|
||||
u64 constant;
|
||||
if (is64BitType) {
|
||||
constant = * (u64 *) & o->constants [i];
|
||||
memcpy(&constant, & o->constants [i], sizeof(u64));
|
||||
} else {
|
||||
constant = * (u32 *) & o->constants [i];
|
||||
memcpy(&constant, & o->constants [i], sizeof(u32));
|
||||
}
|
||||
if (constant == i_word)
|
||||
{
|
||||
@@ -739,15 +740,10 @@ _ (PushAllocatedSlotAndEmit (o, i_type));
|
||||
|
||||
d_m3Assert(constTableIndex < d_m3MaxConstantTableSize);
|
||||
|
||||
if (is64BitType)
|
||||
{
|
||||
u64 * constant = (u64 *) & o->constants [constTableIndex];
|
||||
* constant = i_word;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 * constant = (u32 *) & o->constants [constTableIndex];
|
||||
* constant = (u32) i_word;
|
||||
if (is64BitType) {
|
||||
memcpy (& o->constants [constTableIndex], &i_word, sizeof(u64));
|
||||
} else {
|
||||
memcpy (& o->constants [constTableIndex], &i_word, sizeof(u32));
|
||||
}
|
||||
|
||||
_ (Push (o, i_type, slot));
|
||||
|
||||
Reference in New Issue
Block a user