chore: refactor out u64

main
Sean McBride 4 years ago
parent 95ce981247
commit 407a20d22a

@ -29,8 +29,8 @@ rotr_u32(u32 n, u32 c_u32)
return (n >> c) | (n << ((-c) & mask));
}
INLINE u64
rotl_u64(u64 n, u64 c_u64)
INLINE uint64_t
rotl_u64(uint64_t n, uint64_t c_u64)
{
// WASM requires a modulus here (usually a single bitwise op, but it means we need no assert)
unsigned int c = c_u64 % (CHAR_BIT * sizeof(n));
@ -40,8 +40,8 @@ rotl_u64(u64 n, u64 c_u64)
return (n << c) | (n >> ((-c) & mask));
}
INLINE u64
rotr_u64(u64 n, u64 c_u64)
INLINE uint64_t
rotr_u64(uint64_t n, uint64_t c_u64)
{
// WASM requires a modulus here (usually a single bitwise op, but it means we need no assert)
unsigned int c = c_u64 % (CHAR_BIT * sizeof(n));
@ -80,15 +80,15 @@ i32_rem(i32 a, i32 b)
return a % b;
}
INLINE u64
u64_div(u64 a, u64 b)
INLINE uint64_t
u64_div(uint64_t a, uint64_t b)
{
assert(b);
return a / b;
}
INLINE u64
u64_rem(u64 a, u64 b)
INLINE uint64_t
u64_rem(uint64_t a, uint64_t b)
{
assert(b);
return a % b;
@ -139,11 +139,11 @@ i32_trunc_f64(double f)
return (i32)f;
}
u64
uint64_t
u64_trunc_f32(float f)
{
assert(0 <= f && f <= UINT64_MAX);
return (u64)f;
return (uint64_t)f;
}
i64
@ -153,11 +153,11 @@ i64_trunc_f32(float f)
return (i64)f;
}
u64
uint64_t
u64_trunc_f64(double f)
{
assert(0 <= f && f <= UINT64_MAX);
return (u64)f;
return (uint64_t)f;
}
i64

@ -10,7 +10,7 @@ struct module {
void * dynamic_library_handle; /* Handle to the *.so of the serverless function */
i32 argument_count;
u32 stack_size; /* a specification? */
u64 max_memory; /* perhaps a specification of the module. (max 4GB) */
uint64_t max_memory; /* perhaps a specification of the module. (max 4GB) */
u32 relative_deadline_us;
u32 reference_count; /* ref count how many instances exist here. */
struct indirect_table_entry indirect_table[INDIRECT_TABLE_SIZE];

@ -11,7 +11,7 @@
* UNIX time in ms). This is used to maintain a read replica of the highest
* priority element that can be used to maintain a read replica
* @param element
* @returns priority (a u64)
* @returns priority (a uint64_t)
*/
typedef uint64_t (*priority_queue_get_priority_fn_t)(void *element);

@ -35,18 +35,18 @@ struct sandbox {
u32 sandbox_size; /* The struct plus enough buffer to hold the request or response (sized off largest) */
void *linear_memory_start; /* after sandbox struct */
void * linear_memory_start; /* after sandbox struct */
u32 linear_memory_size; /* from after sandbox struct */
u64 linear_memory_max_size;
uint64_t linear_memory_max_size;
void *stack_start;
u32 stack_size;
arch_context_t ctxt; /* register context for context switch. */
u64 total_time;
u64 start_time;
u64 absolute_deadline;
uint64_t total_time;
uint64_t start_time;
uint64_t absolute_deadline;
struct module *module; /* the module this is an instance of */

@ -14,8 +14,8 @@ struct sandbox_request {
char * arguments;
int socket_descriptor;
struct sockaddr *socket_address;
u64 start_time; /* cycles */
u64 absolute_deadline; /* cycles */
uint64_t start_time; /* cycles */
uint64_t absolute_deadline; /* cycles */
};
typedef struct sandbox_request sandbox_request_t;
@ -33,7 +33,7 @@ DEQUE_PROTOTYPE(sandbox, sandbox_request_t *);
*/
static inline sandbox_request_t *
sandbox_request_allocate(struct module *module, char *arguments, int socket_descriptor,
const struct sockaddr *socket_address, u64 start_time)
const struct sockaddr *socket_address, uint64_t start_time)
{
sandbox_request_t *sandbox_request = (sandbox_request_t *)malloc(sizeof(sandbox_request_t));
assert(sandbox_request);

@ -43,7 +43,6 @@ typedef uint16_t u16;
typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
/* FIXME: per-module configuration? */
#define WASM_PAGE_SIZE (1024 * 64) /* 64KB */

@ -27,13 +27,13 @@ env___unmapself(u32 base, u32 size)
}
i32
env_a_ctz_64(u64 x)
env_a_ctz_64(uint64_t x)
{
return __builtin_ctzll(x);
}
INLINE void
env_a_and_64(i32 p_off, u64 v)
env_a_and_64(i32 p_off, uint64_t v)
{
uint64_t *p = worker_thread_get_memory_ptr_void(p_off, sizeof(uint64_t));
ck_pr_and_64(p, v);

@ -250,15 +250,15 @@ wasm_close(i32 file_descriptor)
// What the wasm stat structure looks like
struct wasm_stat {
i64 st_dev;
u64 st_ino;
uint64_t st_ino;
u32 st_nlink;
u32 st_mode;
u32 st_uid;
u32 st_gid;
u32 __pad0;
u64 st_rdev;
u64 st_size;
uint64_t st_rdev;
uint64_t st_size;
i32 st_blksize;
i64 st_blocks;
@ -689,7 +689,7 @@ wasm_geteuid()
#define SYS_GET_TIME 228
struct wasm_time_spec {
u64 sec;
uint64_t sec;
u32 nanosec;
};

@ -159,7 +159,7 @@ module_new(char *name, char *path, i32 argument_count, u32 stack_size, u32 max_m
module->argument_count = argument_count;
module->stack_size = round_up_to_page(stack_size == 0 ? WASM_STACK_SIZE : stack_size);
module->max_memory = max_memory == 0 ? ((u64)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory;
module->max_memory = max_memory == 0 ? ((uint64_t)WASM_PAGE_SIZE * WASM_MAX_PAGES) : max_memory;
module->relative_deadline_us = relative_deadline_us;
module->socket_descriptor = -1;
module->port = port;

@ -74,7 +74,7 @@ listener_thread_main(void *dummy)
LISTENER_THREAD_MAX_EPOLL_EVENTS, -1);
/* Capture Start Time to calculate absolute deadline */
u64 start_time = __getcycles();
uint64_t start_time = __getcycles();
for (int i = 0; i < request_count; i++) {
if (epoll_events[i].events & EPOLLERR) {
perror("epoll_wait");

Loading…
Cancel
Save