diff --git a/runtime/Makefile b/runtime/Makefile index 628f275..ecd7251 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -11,12 +11,13 @@ LDFLAGS = -Wl,--export-dynamic -ldl -lm USE_MEM = USE_MEM_VM CFLAGS = ${OPTFLAGS} -D${USE_MEM} -I${INC} -pthread CFLAGS += -DX86_64 -CFLAGS += -DDEBUG +#CFLAGS += -DDEBUG CFLAGS += -D_GNU_SOURCE #CFLAGS += -DNOSTDIO -CFLAGS += -DUSE_UVIO -#CFLAGS += -DUSE_SYSCALL -#CFLAGS += -DPREEMPT_DISABLE +CFLAGS += -DSTANDALONE +#CFLAGS += -DUSE_UVIO +CFLAGS += -DUSE_SYSCALL +CFLAGS += -DPREEMPT_DISABLE MAKE= make --no-print-directory diff --git a/runtime/src/main.c b/runtime/src/main.c index 5acb519..f4a8d21 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -26,6 +26,7 @@ usage(char *cmd) int main(int argc, char* argv[]) { +#ifndef STANDALONE int i = 0, rtthd_ret[SBOX_NCORES] = { 0 }; pthread_t rtthd[SBOX_NCORES]; @@ -97,4 +98,15 @@ main(int argc, char* argv[]) // runtime threads run forever!! so join should not return!! printf("\nOh no..!! This can't be happening..!!\n"); exit(-1); +#else /* STANDALONE */ + arch_context_init(&base_context, 0, 0); + uv_loop_init(&uvio); + + /* in current dir! */ + struct module *m = module_alloc(argv[1], argv[1], 0, 0, 0, 0, 0, 0); + assert(m); + struct sandbox *s = sandbox_alloc(m, argv[1]); + + exit(0); +#endif } diff --git a/runtime/src/module.c b/runtime/src/module.c index 9b68862..6f0c9ba 100644 --- a/runtime/src/module.c +++ b/runtime/src/module.c @@ -108,7 +108,9 @@ module_alloc(char *modname, char *modpath, u32 udp_port, i32 nargs, i32 nrets, u module_indirect_table = cache_tbl; mod->udpport = udp_port; module_add(mod); +#ifndef STANDALONE module_io_init(mod); +#endif return mod; diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 3c3ac85..ea3a107 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -106,16 +106,19 @@ sandbox_schedule(void) void sandbox_wakeup(sandbox_t *s) { +#ifndef STANDALONE debuglog("[%p: %s]\n", s, s->mod->name); // perhaps 2 lists in the sandbox to make sure sandbox is either in runlist or waitlist.. assert(ps_list_singleton_d(s)); s->state = SANDBOX_RUNNABLE; ps_list_head_append_d(&runq, s); +#endif } void sandbox_block(void) { +#ifndef STANDALONE // perhaps 2 lists in the sandbox to make sure sandbox is either in runlist or waitlist.. softint_disable(); struct sandbox *c = sandbox_current(); @@ -125,6 +128,9 @@ sandbox_block(void) c->state = SANDBOX_BLOCKED; struct sandbox *s = sandbox_schedule(); sandbox_switch(s); +#else + uv_run(runtime_uvio(), UV_RUN_DEFAULT); +#endif } void __attribute__((noinline)) __attribute__((noreturn)) @@ -172,6 +178,7 @@ sandbox_run_func(void *data) void sandbox_run(struct sandbox *s) { +#ifndef STANDALONE // for now, a pull model... // sandbox_run adds to the global ready queue.. // each sandboxing thread pulls off of that global ready queue.. @@ -180,12 +187,16 @@ sandbox_run(struct sandbox *s) pthread_mutex_lock(&glbq_mtx); ps_list_head_append_d(&glbq, s); pthread_mutex_unlock(&glbq_mtx); +#else + sandbox_switch(s); +#endif } // perhaps respond to request void sandbox_exit(void) { +#ifndef STANDALONE struct sandbox *curr = sandbox_current(); assert(curr); @@ -195,6 +206,9 @@ sandbox_exit(void) curr->state = SANDBOX_RETURNED; // TODO: free resources here? or only from main? sandbox_switch(sandbox_schedule()); +#else + sandbox_switch(NULL); +#endif } void *