int MVM_ext_load(MVMThreadContext *tc, MVMString *lib, MVMString *ext) { MVMString *colon, *prefix, *name; MVMExtRegistry *entry; MVMDLLSym *sym; void (*init)(MVMThreadContext *); MVMROOT2(tc, lib, ext, { colon = MVM_string_ascii_decode_nt( tc, tc->instance->VMString, ":"); prefix = MVM_string_concatenate(tc, lib, colon); name = MVM_string_concatenate(tc, prefix, ext); });
MVMint64 MVM_proc_spawn(MVMThreadContext *tc, MVMString *cmd, MVMString *cwd, MVMObject *env) { MVMint64 result, spawn_result; uv_process_t process = {0}; uv_process_options_t process_options = {0}; int i; char * const cmdin = MVM_string_utf8_encode_C_string(tc, cmd); char * const _cwd = MVM_string_utf8_encode_C_string(tc, cwd); const MVMuint64 size = MVM_repr_elems(tc, env); MVMIter * const iter = (MVMIter *)MVM_iter(tc, env); char **_env = malloc((size + 1) * sizeof(char *)); #ifdef _WIN32 const MVMuint16 acp = GetACP(); /* We should get ACP at runtime. */ char * const _cmd = ANSIToUTF8(acp, getenv("ComSpec")); char *args[3]; args[0] = "/c"; args[1] = cmdin; args[2] = NULL; #else char * const _cmd = "/bin/sh"; char *args[4]; args[0] = "/bin/sh"; args[1] = "-c"; args[2] = cmdin; args[3] = NULL; #endif MVMROOT(tc, iter, { MVMString * const equal = MVM_string_ascii_decode(tc, tc->instance->VMString, STR_WITH_LEN("=")); MVMROOT(tc, equal, { MVMString *env_str; i = 0; while(MVM_iter_istrue(tc, iter)) { MVM_repr_shift_o(tc, (MVMObject *)iter); env_str = MVM_string_concatenate(tc, MVM_iterkey_s(tc, iter), equal); env_str = MVM_string_concatenate(tc, env_str, MVM_repr_get_str(tc, MVM_iterval(tc, iter))); _env[i++] = MVM_string_utf8_encode_C_string(tc, env_str); } _env[size] = NULL; }); });