diff --git a/makefile b/makefile index 5bb945a..970d35b 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,6 @@ build: @gcc main.c cmdbuf.c hex.c request.c response.c server.c pvbemu/core/vb.c \ -I include -I pvbemu/core \ -Werror -std=c90 -Wall -Wextra -Wpedantic \ - -Wno-unused-parameter -Wno-unused-function \ -D _POSIX_C_SOURCE=199309L \ -o ./build/rdb clean: diff --git a/pvbemu b/pvbemu index d4ae5f3..5f563e6 160000 --- a/pvbemu +++ b/pvbemu @@ -1 +1 @@ -Subproject commit d4ae5f3909fa8f372ff70d11236cb38e4bd43732 +Subproject commit 5f563e6cac80d799f6c0251f9f601321e3603ea5 diff --git a/server.c b/server.c index b17778c..24da6d3 100644 --- a/server.c +++ b/server.c @@ -69,11 +69,9 @@ const uint32_t SYSTEM_REGISTERS[] = { const uint32_t PC_INDEX = 32 + 13; -/* TODO: this should use userdata */ -static void *SERVER_POINTER; static int onExecute(VB *sim, uint32_t address, const uint16_t *code, int length) { uint32_t i; - RdbServer *srv = SERVER_POINTER; + RdbServer *srv = (RdbServer *)vbGetUserData(sim); (void)sim; (void)code; @@ -120,8 +118,8 @@ void rdbServerInit(RdbServer *srv, VB *sim) { srv->running = false; srv->brkslen = 0; srv->stopreason = stop_reason_none; - SERVER_POINTER = srv; - vbSetCallback(sim, VB_EXECUTE, (void*)(uint64_t)&onExecute); + vbSetUserData(sim, srv); + vbSetExecuteCallback(sim, onExecute); } int rdbServerHandleCommand(RdbServer *srv, CommandBuf *cmd, RdbResponse *res) {