Make improvements

- Add GetCpuCount() API to redbean
- Add unix.gmtime() API to redbean
- Add unix.readlink() API to redbean
- Add unix.localtime() API to redbean
- Perfect the new redbean UNIX module APIs
- Integrate with Linux clock_gettime() vDSO
- Run Lua garbage collector when malloc() fails
- Fix another regression quirk with linenoise repl
- Fix GetProgramExecutableName() for systemwide installs
- Fix a build flake with test/libc/mem/test.mk SRCS list
This commit is contained in:
Justine Tunney 2022-04-25 21:16:05 -07:00
parent 860ea18a87
commit d57b81aac7
51 changed files with 3096 additions and 1395 deletions

View file

@ -62,17 +62,17 @@ char *GetInterpreterExecutableName(char *p, size_t n) {
} else if ((rc = sys_readlinkat(AT_FDCWD, "/proc/curproc/file", p, n - 1)) >
0) {
errno = e;
p[n] = 0;
p[rc] = 0;
return p;
} else if (IsFreebsd() || IsNetbsd()) {
cmd[0] = 1 /* CTL_KERN */;
cmd[1] = 14 /* KERN_PROC */;
if (IsFreebsd()) {
cmd[2] = 12 /* KERN_PROC_PATHNAME */;
} else {
cmd[2] = 5 /* KERN_PROC_PATHNAME */;
}
cmd[3] = -1; /* current process */
cmd[0] = 1; // CTL_KERN
cmd[1] = 14; // KERN_PROC
if (IsFreebsd()) { //
cmd[2] = 12; // KERN_PROC_PATHNAME
} else { //
cmd[2] = 5; // KERN_PROC_PATHNAME
} //
cmd[3] = -1; // current process
if (sysctl(cmd, ARRAYLEN(cmd), p, &n, 0, 0) != -1) {
errno = e;
return p;

View file

@ -324,8 +324,8 @@ textstartup void __printargs(const char *prologue) {
PRINT(" ☼ %s = %#s", "kTmpPath", kTmpPath);
PRINT(" ☼ %s = %#s", "kNtSystemDirectory", kNtSystemDirectory);
PRINT(" ☼ %s = %#s", "kNtWindowsDirectory", kNtWindowsDirectory);
PRINT(" ☼ %s = %#s", "program_executable_name", GetProgramExecutableName());
PRINT(" ☼ %s = %#s", "GetInterpreterExecutableName()",
PRINT(" ☼ %s = %#s", "GetProgramExecutableName", GetProgramExecutableName());
PRINT(" ☼ %s = %#s", "GetInterpreterExecutableName",
GetInterpreterExecutableName(path, sizeof(path)));
PRINT(" ☼ %s = %p", "RSP", __builtin_frame_address(0));
PRINT(" ☼ %s = %p", "GetStackAddr()", GetStackAddr(0));

View file

@ -14,7 +14,6 @@ extern char **__argv; /* CRT */
extern char **__envp; /* CRT */
extern unsigned long *__auxv; /* CRT */
extern intptr_t __oldstack; /* CRT */
extern char program_executable_name[]; /* RII */
extern char *program_invocation_name; /* RII */
extern char *program_invocation_short_name; /* RII */
extern int g_ftrace; /* CRT */

View file

@ -219,9 +219,6 @@ __msabi static textwindows wontreturn void WinMainNew(const char16_t *cmdline) {
}
}
env16 = GetEnvironmentStrings();
for (char16_t *e = env16; *e; e += StrLen16(e) + 1) {
NTTRACE("GetEnvironmentStrings() → %!#hs", e);
}
NTTRACE("WinMainNew() loading environment");
GetDosEnviron(env16, wa->envblock, ARRAYLEN(wa->envblock) - 8, wa->envp,
ARRAYLEN(wa->envp) - 1);