diff options
author | Alex Auvolat <alex@adnab.me> | 2016-07-15 22:39:04 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2016-07-15 22:39:04 +0200 |
commit | 7a1ea510a9fc43ccbc257601b149a90920332e13 (patch) | |
tree | 75ac252bb8ce029c62d6834e4ca927f59eaf5769 /src/common | |
parent | d415aca695956c79110c88fa58c12bf55c0e2163 (diff) | |
download | kogata-7a1ea510a9fc43ccbc257601b149a90920332e13.tar.gz kogata-7a1ea510a9fc43ccbc257601b149a90920332e13.zip |
Add Lua source, not compiled yet as libc/libm functions remain unimplemented
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/bam.lua | 8 | ||||
-rw-r--r-- | src/common/include/ctype.h | 18 | ||||
-rw-r--r-- | src/common/include/debug.h | 8 | ||||
-rw-r--r-- | src/common/include/malloc.h | 1 | ||||
-rw-r--r-- | src/common/include/string.h | 9 | ||||
-rw-r--r-- | src/common/libalgo/bam.lua | 3 | ||||
-rw-r--r-- | src/common/libc/bam.lua | 3 | ||||
-rw-r--r-- | src/common/libc/ctype.c | 3 | ||||
-rw-r--r-- | src/common/libc/string.c | 5 | ||||
-rw-r--r-- | src/common/libkogata/bam.lua | 3 |
10 files changed, 48 insertions, 13 deletions
diff --git a/src/common/bam.lua b/src/common/bam.lua new file mode 100644 index 0000000..8b302fa --- /dev/null +++ b/src/common/bam.lua @@ -0,0 +1,8 @@ +local function lib(name) + local source = Collect('src/common/' .. name .. '/*.c') + return Compile(common_settings, source) +end + +common_libalgo = lib('libalgo') +common_libc = lib('libc') +common_libkogata = lib('libkogata') diff --git a/src/common/include/ctype.h b/src/common/include/ctype.h new file mode 100644 index 0000000..9808c9f --- /dev/null +++ b/src/common/include/ctype.h @@ -0,0 +1,18 @@ +#pragma once + +int isalnum(int c); +int isalpha(int c); +int isdigit(int c); +int isxdigit(int c); +int isspace(int c); +int isprint(int c); +int isupper(int c); +int islower(int c); +int ispunct(int c); +int isgraph(int c); +int iscntrl(int c); + +int toupper(int c); +int tolower(int c); + +/* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/debug.h b/src/common/include/debug.h index 285343c..2db5a80 100644 --- a/src/common/include/debug.h +++ b/src/common/include/debug.h @@ -3,14 +3,14 @@ #include <stddef.h> #include <stdint.h> -void panic(const char* message, const char* file, int line) +void sys_panic(const char* message, const char* file, int line) __attribute__((__noreturn__)); -void panic_assert(const char* assertion, const char* file, int line) +void sys_panic_assert(const char* assertion, const char* file, int line) __attribute__((__noreturn__)); -#define PANIC(s) panic(s, __FILE__, __LINE__); -#define ASSERT(s) { if (!(s)) panic_assert(#s, __FILE__, __LINE__); } +#define PANIC(s) sys_panic(s, __FILE__, __LINE__); +#define ASSERT(s) { if (!(s)) sys_panic_assert(#s, __FILE__, __LINE__); } void dbg_print(const char* str); void dbg_printf(const char* format, ...); diff --git a/src/common/include/malloc.h b/src/common/include/malloc.h index ec29d69..e55c25e 100644 --- a/src/common/include/malloc.h +++ b/src/common/include/malloc.h @@ -8,5 +8,6 @@ void* malloc(size_t sz); void free(void* ptr); void* calloc(size_t nmemb, size_t sz); +void* realloc(void* ptr, size_t sz); /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/string.h b/src/common/include/string.h index e655f2c..d38bbb6 100644 --- a/src/common/include/string.h +++ b/src/common/include/string.h @@ -20,4 +20,13 @@ int strncmp(const char *s1, const char *s2, size_t n); char *strdup(const char* str); char *strndup(const char* str, size_t count); +//TODO +int strcoll(const char *s1, const char *s2); +size_t strspn(const char *s, const char *accept); +char *strstr(const char *haystack, const char *needle); +char* strerror(int errnum); +char *strpbrk(const char *s, const char *accept); +void *memchr(const void *s, int c, size_t n); + + /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/libalgo/bam.lua b/src/common/libalgo/bam.lua deleted file mode 100644 index 3b164a8..0000000 --- a/src/common/libalgo/bam.lua +++ /dev/null @@ -1,3 +0,0 @@ -local source = Collect('src/common/libalgo/*.c') - -common_libalgo = Compile(common_settings, source) diff --git a/src/common/libc/bam.lua b/src/common/libc/bam.lua deleted file mode 100644 index cee2ec4..0000000 --- a/src/common/libc/bam.lua +++ /dev/null @@ -1,3 +0,0 @@ -local source = Collect('src/common/libc/*.c') - -common_libc = Compile(common_settings, source) diff --git a/src/common/libc/ctype.c b/src/common/libc/ctype.c new file mode 100644 index 0000000..56daa6b --- /dev/null +++ b/src/common/libc/ctype.c @@ -0,0 +1,3 @@ +#include <ctype.h> + +// TODO diff --git a/src/common/libc/string.c b/src/common/libc/string.c index d2a5f2f..90cea34 100644 --- a/src/common/libc/string.c +++ b/src/common/libc/string.c @@ -144,4 +144,9 @@ char *strndup(const char* str, size_t count) { return ret; } +int strcoll(const char *s1, const char *s2) { + // TODO locale handling + return strcmp(s1, s2); +} + /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/libkogata/bam.lua b/src/common/libkogata/bam.lua deleted file mode 100644 index 30cf9eb..0000000 --- a/src/common/libkogata/bam.lua +++ /dev/null @@ -1,3 +0,0 @@ -local source = Collect('src/common/libkogata/*.c') - -common_libkogata = Compile(common_settings, source) |