From ec3b489b21552b12322b0127d268b475734bc885 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 10 Jul 2020 12:56:06 -0400 Subject: [PATCH] chore: refactor out i64 --- runtime/compiletime/instr.c | 16 ++++++++-------- runtime/compiletime/memory/64bit_nix.c | 16 ++++++++-------- runtime/include/types.h | 1 - runtime/src/env.c | 6 +++--- runtime/src/libc/uvio.c | 4 ++-- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/runtime/compiletime/instr.c b/runtime/compiletime/instr.c index 4c87f21..7ed486a 100644 --- a/runtime/compiletime/instr.c +++ b/runtime/compiletime/instr.c @@ -94,15 +94,15 @@ u64_rem(uint64_t a, uint64_t b) return a % b; } -INLINE i64 -i64_div(i64 a, i64 b) +INLINE int64_t +i64_div(int64_t a, int64_t b) { assert(b && (a != INT64_MIN || b != -1)); return a / b; } -INLINE i64 -i64_rem(i64 a, i64 b) +INLINE int64_t +i64_rem(int64_t a, int64_t b) { assert(b && (a != INT64_MIN || b != -1)); return a % b; @@ -146,11 +146,11 @@ u64_trunc_f32(float f) return (uint64_t)f; } -i64 +int64_t i64_trunc_f32(float f) { assert(INT64_MIN <= f && f <= INT64_MAX); - return (i64)f; + return (int64_t)f; } uint64_t @@ -160,11 +160,11 @@ u64_trunc_f64(double f) return (uint64_t)f; } -i64 +int64_t i64_trunc_f64(double f) { assert(INT64_MIN <= f && f <= INT64_MAX); - return (i64)f; + return (int64_t)f; } // Float => Float truncation functions diff --git a/runtime/compiletime/memory/64bit_nix.c b/runtime/compiletime/memory/64bit_nix.c index 75e12f9..3a4e5ca 100644 --- a/runtime/compiletime/memory/64bit_nix.c +++ b/runtime/compiletime/memory/64bit_nix.c @@ -49,13 +49,13 @@ get_i32(i32 offset) return *(i32 *)address; } -INLINE i64 +INLINE int64_t get_i64(i32 offset) { char *mem_as_chars = (char *)local_sandbox_context_cache.linear_memory_start; void *address = &mem_as_chars[offset]; - return *(i64 *)address; + return *(int64_t *)address; } INLINE i32 @@ -67,13 +67,13 @@ get_global_i32(i32 offset) return *(i32 *)address; } -INLINE i64 +INLINE int64_t get_global_i64(i32 offset) { char *mem_as_chars = (char *)local_sandbox_context_cache.linear_memory_start; void *address = &mem_as_chars[offset]; - return *(i64 *)address; + return *(int64_t *)address; } // Now setting routines @@ -123,12 +123,12 @@ set_i32(i32 offset, i32 v) } INLINE void -set_i64(i32 offset, i64 v) +set_i64(i32 offset, int64_t v) { char *mem_as_chars = (char *)local_sandbox_context_cache.linear_memory_start; void *address = &mem_as_chars[offset]; - *(i64 *)address = v; + *(int64_t *)address = v; } INLINE void @@ -141,12 +141,12 @@ set_global_i32(i32 offset, i32 v) } INLINE void -set_global_i64(i32 offset, i64 v) +set_global_i64(i32 offset, int64_t v) { char *mem_as_chars = (char *)local_sandbox_context_cache.linear_memory_start; void *address = &mem_as_chars[offset]; - *(i64 *)address = v; + *(int64_t *)address = v; } // Table handling functionality diff --git a/runtime/include/types.h b/runtime/include/types.h index 2a97401..6412d11 100644 --- a/runtime/include/types.h +++ b/runtime/include/types.h @@ -41,7 +41,6 @@ typedef unsigned char u8; typedef int16_t i16; typedef uint16_t u16; typedef int32_t i32; -typedef int64_t i64; /* FIXME: per-module configuration? */ #define WASM_PAGE_SIZE (1024 * 64) /* 64KB */ diff --git a/runtime/src/env.c b/runtime/src/env.c index 02bcb9b..f262795 100644 --- a/runtime/src/env.c +++ b/runtime/src/env.c @@ -40,10 +40,10 @@ env_a_and_64(i32 p_off, uint64_t v) } INLINE void -env_a_or_64(i32 p_off, i64 v) +env_a_or_64(i32 p_off, int64_t v) { - assert(sizeof(i64) == sizeof(uint64_t)); - uint64_t *p = worker_thread_get_memory_ptr_void(p_off, sizeof(i64)); + assert(sizeof(int64_t) == sizeof(uint64_t)); + uint64_t *p = worker_thread_get_memory_ptr_void(p_off, sizeof(int64_t)); ck_pr_or_64(p, v); } diff --git a/runtime/src/libc/uvio.c b/runtime/src/libc/uvio.c index 13ccaf2..441c1f4 100644 --- a/runtime/src/libc/uvio.c +++ b/runtime/src/libc/uvio.c @@ -249,7 +249,7 @@ wasm_close(i32 file_descriptor) // What the wasm stat structure looks like struct wasm_stat { - i64 st_dev; + int64_t st_dev; uint64_t st_ino; uint32_t st_nlink; @@ -260,7 +260,7 @@ struct wasm_stat { uint64_t st_rdev; uint64_t st_size; i32 st_blksize; - i64 st_blocks; + int64_t st_blocks; struct { i32 tv_sec;