protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

commit f40b3574ba195bba7b7dfdad44fab8317922b6a2
parent 61aa047b8e685bde0215de3803750384e0915a78
Author: William Casarin <jb55@jb55.com>
Date:   Tue,  6 Jul 2021 12:54:17 -0700

Fix many clang build issues

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/bench.c | 4++--
Msrc/net.c | 1-
Msrc/resource.h | 2+-
Msrc/typedefs.h | 3+++
Dsrc/types.h | 17-----------------
Msrc/wasm.c | 27+--------------------------
6 files changed, 7 insertions(+), 47 deletions(-)

diff --git a/src/bench.c b/src/bench.c @@ -10,7 +10,7 @@ static int bench_wasm(unsigned char *wasm, unsigned long len, int times) { struct wasm_parser p; void *mem; - int ok, arena_size, i, ops = 0; + int arena_size, i, ops = 0; struct wasm_interp interp; struct timespec t1, t2; long nanos, ms; @@ -48,7 +48,7 @@ static int bench_wasm(unsigned char *wasm, unsigned long len, int times) wasm_interp_free(&interp); free(mem); - return ok; + return 1; } int main(int argc, char *argv[]) diff --git a/src/net.c b/src/net.c @@ -8,7 +8,6 @@ #include <sys/types.h> #include <assert.h> -#include <error.h> #include <errno.h> #include <netinet/in.h> #include <arpa/inet.h> diff --git a/src/resource.h b/src/resource.h @@ -2,7 +2,7 @@ #ifndef RESOURCE_H #define RESOURCE_H -#include "types.h" +#include "typedefs.h" #define STATIC_UUID 0x5A51C00000000000 diff --git a/src/typedefs.h b/src/typedefs.h @@ -3,7 +3,10 @@ #define PROTOVERSE_TYPEDEFS_H typedef unsigned char u8; +typedef unsigned int u32; typedef unsigned short u16; +typedef unsigned long long u64; +typedef signed long long s64; #endif /* PROTOVERSE_TYPEDEFS_H */ diff --git a/src/types.h b/src/types.h @@ -1,17 +0,0 @@ - -#ifndef PROTOVERSE_TYPES_H -#define PROTOVERSE_TYPES_H - -typedef unsigned char u8; -typedef signed char s8; - -typedef unsigned short u16; -typedef signed short s16; - -typedef unsigned int u32; -typedef signed int s32; - -typedef unsigned long long u64; -typedef signed long long s64; - -#endif /* PROTOVERSE_TYPES_H */ diff --git a/src/wasm.c b/src/wasm.c @@ -32,20 +32,6 @@ struct val { }; }; -#ifdef DEBUG -static void log_dbg_(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); -} - -#define log_dbg(...) log_dbg_(__VA_ARGS__) -#else -#define log_dbg(...) -#endif - static inline int is_valtype(unsigned char byte) { switch ((enum valtype)byte) { @@ -90,7 +76,7 @@ static void print_val(struct val *val) { switch (val->type) { case i32: printf("%d", val->i32); break; - case i64: printf("%ld", val->i64); break; + case i64: printf("%lld", val->i64); break; case f32: printf("%f", val->f32); break; case f64: printf("%f", val->f64); break; } @@ -116,17 +102,6 @@ static inline int was_section_parsed(struct module *module, return module->parsed & (1 << section); } -static inline int cursor_popbyte(struct cursor *cur, unsigned char *byte) -{ - if (cur->p - 1 < cur->start) - return 0; - - cur->p--; - *byte = *cur->p; - - return 1; -} - static inline int cursor_popval(struct cursor *cur, struct val *val) { return cursor_popdata(cur, (unsigned char*)val, sizeof(*val));