# SYS/SYS.D - Misc internalized support (for speed) # public class Sys { #%doc # # The bcopy we all know and love, with bounds-checking and cast # limitations (you can't synthesize structures containing lvalues, # pointers, or references with it). # public internal void bcopy(const void *s, void *d, size_t); #%doc # # This issues the C exit(), killing the process and all of its # theads. # public internal void exit(int code); #% # # This terminates the program, killing the process and all of its # theads, and core-dumping if DebugOpt is set in the runtime. # public internal void abort(); #%doc # # Execs a program. Rune provides a number of additional helper # functions (written in Rune) for other forms. Rune will automatically # clear O_CLOEXEC on descriptors 0, 1, and 2. Any other descriptors # will depend on their O_CLOEXEC status. Note that by default any # new descriptors opened by a Rune program set O_CLOEXEC by default. # #public internal int execve(const char *path, # const char **argv, const char **envp); #%doc # # Get or modify the current environment. Similar to the C calls # but setenv() always overwrites. # public internal char *getenv(const char *name); public internal void setenv(const char *name, const char *value); public internal int unsetenv(const char *name); } global int inpanic; public void Sys.panic(const char *ctl, ...) { Fs fs; # XXX implement va_list and ... passing. # if (inpanic) # abort(); # inpanic = 1; fs.setfd(2); fs.write(ctl, Str.strlen(ctl)); fs.write("\n", 1); abort(); }