const byte* runtime_getenv(const char *s) { int32 i, j; intgo len; const byte *v, *bs; String* envv; int32 envc; bs = (const byte*)s; len = runtime_findnull(bs); envv = (String*)syscall_Envs.__values; envc = syscall_Envs.__count; for(i=0; i<envc; i++){ if(envv[i].len <= len) continue; v = (const byte*)envv[i].str; for(j=0; j<len; j++) if(bs[j] != v[j]) goto nomatch; if(v[len] != '=') goto nomatch; return v+len+1; nomatch:; } return nil; }
String runtime_getenv(const char *s) { int32 i, j; intgo len; const byte *v, *bs; Slice envs; String* envv; int32 envc; String ret; bs = (const byte*)s; len = runtime_findnull(bs); envs = runtime_get_envs(); envv = (String*)envs.__values; envc = envs.__count; for(i=0; i<envc; i++){ if(envv[i].len <= len) continue; v = (const byte*)envv[i].str; for(j=0; j<len; j++) if(bs[j] != v[j]) goto nomatch; if(v[len] != '=') goto nomatch; ret.str = v+len+1; ret.len = envv[i].len-len-1; return ret; nomatch:; } ret.str = nil; ret.len = 0; return ret; }
static void runtime_prints(const char *s) { Slice sl; // Use memcpy to avoid const-cast warning. memcpy(&sl.__values, &s, sizeof(char*)); sl.__count = runtime_findnull((const byte*)s); sl.__capacity = sl.__count; gwrite(sl); }
void runtime_parsedebugvars(void) { const byte *p; intgo i, n; p = runtime_getenv("GODEBUG"); if(p == nil) return; for(;;) { for(i=0; i<(intgo)nelem(dbgvar); i++) { n = runtime_findnull((const byte*)dbgvar[i].name); if(runtime_mcmp(p, dbgvar[i].name, n) == 0 && p[n] == '=') *dbgvar[i].value = runtime_atoi(p+n+1); } p = (const byte *)runtime_strstr((const char *)p, ","); if(p == nil) break; p++; } }
void runtime_prints(const char *s) { gwrite(s, runtime_findnull((const byte*)s)); }