Add syscalls to Blinkenlights and fix bugs

This commit is contained in:
Justine Tunney 2022-05-13 13:31:21 -07:00
parent f6df29cc3d
commit 578cb21591
25 changed files with 187 additions and 108 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/color.internal.h"
#include "libc/log/internal.h"
@ -30,5 +31,6 @@ relegated void __start_fatal(const char *file, int line) {
__restore_tty();
kprintf("%r%serror%s:%s:%d:%s%s: ", !__nocolor ? "\e[J\e[30;101m" : "",
!__nocolor ? "\e[94;49m" : "", file, line,
program_invocation_short_name, !__nocolor ? "\e[0m" : "");
firstnonnull(program_invocation_short_name, "unknown"),
!__nocolor ? "\e[0m" : "");
}

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/log/bsd.h"
#include "libc/log/color.internal.h"
#include "libc/log/internal.h"
@ -23,8 +24,9 @@
#include "libc/stdio/stdio.h"
wontreturn void(verr)(int eval, const char *fmt, va_list va) {
fprintf(stderr, "%s: %s%s%s[%m]: ", program_invocation_name, RED2, "ERROR",
RESET);
fprintf(stderr,
"%s: %s%s%s[%m]: ", firstnonnull(program_invocation_name, "unknown"),
RED2, "ERROR", RESET);
if (fmt) (vfprintf)(stderr, fmt, va);
fprintf(stderr, "\n");
exit(eval);

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/bits.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/strace.internal.h"
#include "libc/calls/struct/stat.h"
@ -96,7 +97,7 @@ void(vflogf)(unsigned level, const char *file, int line, FILE *f,
vflogf_ts.tv_nsec = nsec;
localtime_r(&secs, &tm);
strcpy(iso8601(buf32, &tm), issamesecond ? "+" : ".");
prog = basename(program_invocation_name);
prog = basename(firstnonnull(program_invocation_name, "unknown"));
bufmode = f->bufmode;
if (bufmode == _IOLBF) f->bufmode = _IOFBF;
if ((fprintf)(f, "%r%c%s%06ld:%s:%d:%.*s:%d] ", "FEWIVDNT"[level & 7], buf32,