diff options
author | turret <turret@duck.com> | 2023-11-19 19:13:40 -0600 |
---|---|---|
committer | turret <turret@duck.com> | 2023-11-19 19:13:40 -0600 |
commit | 40bff7788865b519b79b1ee7eb9851914010ffb4 (patch) | |
tree | b11af475d4eb933acb2d610c555d6715f76def4e /init/log.c | |
parent | a8b2282eb88f24c3c5f461e1557fa2cf76ebc251 (diff) | |
download | discord-bot-skeleton-40bff7788865b519b79b1ee7eb9851914010ffb4.tar.gz discord-bot-skeleton-40bff7788865b519b79b1ee7eb9851914010ffb4.tar.bz2 discord-bot-skeleton-40bff7788865b519b79b1ee7eb9851914010ffb4.zip |
misc: minor bugs and comments
sprinkle a little bit of commenting throughout the codebase. hopefully
i dont regret what i've written
- clone: bottom of stack is passed through
- print: write newline at end of message
- initcall: functions return void type
very basic net startup. hopefully i dont regret implementing the
websocket protocol myself in a language as holy as C.
Diffstat (limited to 'init/log.c')
-rw-r--r-- | init/log.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -28,6 +28,8 @@ int print(const char *fmt, ...) fmt += 2; } + /* we essentially print the user's raw input to its own buffer, + later we will parse it and print out ANSI colors and what not */ char buf[512]; va_list ap; @@ -42,13 +44,20 @@ int print(const char *fmt, ...) break; } - /* spin lock, at the cost of architecture portability */ + /* spin lock, at the cost of architecture portability + concurrency is something that we need to adjust for, and the + console will be scrambled and unreadable if we allow writing all + at the same time. I considered simply writing all at once, but + ended up just not caring enough to the point where spinlocks + prevail. */ __asm__(".spin_lock:"); __asm__("mov rax, 1"); __asm__("xchg rax, [console_lock]"); __asm__("test rax, rax"); __asm__("jnz .spin_lock"); + /* we want to support stuff without colons, but frankly I havent + tested this at time of writing. will find out later */ if(buf[colon] == ':') { writeputs(ANSI_RESET); writeputs(colors[loglevel]); @@ -63,6 +72,7 @@ int print(const char *fmt, ...) writeputs(buf); } writeputs(ANSI_RESET); + write(STDOUT_FILENO, "\n", 1); console_lock = 0; return 0; |