aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libkogata
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2016-07-15 22:39:04 +0200
committerAlex Auvolat <alex@adnab.me>2016-07-15 22:39:04 +0200
commit7a1ea510a9fc43ccbc257601b149a90920332e13 (patch)
tree75ac252bb8ce029c62d6834e4ca927f59eaf5769 /src/lib/libkogata
parentd415aca695956c79110c88fa58c12bf55c0e2163 (diff)
downloadkogata-7a1ea510a9fc43ccbc257601b149a90920332e13.tar.gz
kogata-7a1ea510a9fc43ccbc257601b149a90920332e13.zip
Add Lua source, not compiled yet as libc/libm functions remain unimplemented
Diffstat (limited to 'src/lib/libkogata')
-rw-r--r--src/lib/libkogata/bam.lua4
-rw-r--r--src/lib/libkogata/debug.c4
-rw-r--r--src/lib/libkogata/stdio.c22
3 files changed, 14 insertions, 16 deletions
diff --git a/src/lib/libkogata/bam.lua b/src/lib/libkogata/bam.lua
deleted file mode 100644
index 1e69e5d..0000000
--- a/src/lib/libkogata/bam.lua
+++ /dev/null
@@ -1,4 +0,0 @@
-local source = Collect('src/lib/libkogata/*.c')
-local obj = Compile(user_settings, source)
-
-libkogata = {obj, common_libc, common_libalgo, common_libkogata}
diff --git a/src/lib/libkogata/debug.c b/src/lib/libkogata/debug.c
index ac3e0e2..847ecca 100644
--- a/src/lib/libkogata/debug.c
+++ b/src/lib/libkogata/debug.c
@@ -4,13 +4,13 @@
#include <syscall.h>
-void panic(const char* msg, const char* file, int line) {
+void sys_panic(const char* msg, const char* file, int line) {
dbg_printf("PANIC in user process\n %s\n at %s:%d\n", msg, file, line);
exit(-1);
while(true);
}
-void panic_assert(const char* assert, const char* file, int line) {
+void sys_panic_assert(const char* assert, const char* file, int line) {
dbg_printf("ASSERT FAILED in user process\n %s\n at %s:%d\n", assert, file, line);
exit(-1);
while(true);
diff --git a/src/lib/libkogata/stdio.c b/src/lib/libkogata/stdio.c
index e62aa30..94dec22 100644
--- a/src/lib/libkogata/stdio.c
+++ b/src/lib/libkogata/stdio.c
@@ -7,7 +7,7 @@
fd_t stdio = 1;
-int getc() {
+int getchar() {
char chr;
size_t sz = read(stdio, 0, 1, &chr);
ASSERT(sz == 1);
@@ -15,39 +15,41 @@ int getc() {
}
-void putc(int c) {
+int putchar(int c) {
char chr = c;
write(stdio, 0, 1, &chr);
+ return 0; //TODO what?
}
-void puts(char* s) {
- write(stdio, 0, strlen(s), s);
+int puts(const char* s) {
+ // TODO return EOF on error
+ return write(stdio, 0, strlen(s), s);
}
void getline(char* buf, size_t l) {
size_t i = 0;
while (true) {
- int c = getc();
+ int c = getchar();
if (c == '\n') {
- putc('\n');
+ putchar('\n');
buf[i] = 0;
break;
} else if (c == '\b') {
if (i > 0) {
i--;
- putc('\b');
+ putchar('\b');
}
} else if (c >= ' ') {
buf[i] = c;
if (i < l-1) {
i++;
- putc(c);
+ putchar(c);
}
}
}
}
-void printf(char* fmt, ...) {
+int printf(const char* fmt, ...) {
va_list ap;
char buffer[256];
@@ -55,7 +57,7 @@ void printf(char* fmt, ...) {
vsnprintf(buffer, 256, fmt, ap);
va_end(ap);
- puts(buffer);
+ return puts(buffer);
}
/* vim: set ts=4 sw=4 tw=0 noet :*/