From bdce40092d1afa3d1ce9d759e35147c64be0b12c Mon Sep 17 00:00:00 2001 From: flysand7 Date: Fri, 28 Jul 2023 20:16:09 +1100 Subject: [PATCH] try cuik? --- build.py | 2 ++ include/cia-def.h | 8 +++++--- include/ctype.h | 0 include/string.h | 3 +++ src/windows/cia-init.c | 22 ++++++++++++++++++++++ src/windows/crt-entry.c | 2 ++ 6 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 include/ctype.h create mode 100644 include/string.h diff --git a/build.py b/build.py index 67ed216..750905d 100755 --- a/build.py +++ b/build.py @@ -200,6 +200,8 @@ def assemble(src, out): sys.exit(code) def compile(srcs, out, extra_flags = ''): + if cc == 'cuik' and out.endswith('.o'): + out = out[:-2] flags = cc_flags_str + ' ' + extra_flags + ' '.join(args.cflags) inputs = ' '.join(map(quote, srcs)) cmdline = f'{cc} {flags} {inputs} -o {quote(out)}' diff --git a/include/cia-def.h b/include/cia-def.h index 0f81d92..9d67464 100644 --- a/include/cia-def.h +++ b/include/cia-def.h @@ -42,9 +42,11 @@ typedef unsigned int uint32_t; #endif // stdbool.h -typedef _Bool bool; -#define true ((bool)1) -#define false ((bool)0) +#if !defined(__bool_true_false_are_defined) + typedef _Bool bool; + #define true ((bool)1) + #define false ((bool)0) +#endif // Short type definitions typedef int8_t i8; diff --git a/include/ctype.h b/include/ctype.h new file mode 100644 index 0000000..e69de29 diff --git a/include/string.h b/include/string.h new file mode 100644 index 0000000..55103d5 --- /dev/null +++ b/include/string.h @@ -0,0 +1,3 @@ + +void memset(void *dest, int ch, size_t length); +int _wcsicmp(uint16_t *s1, uint16_t *s2); diff --git a/src/windows/cia-init.c b/src/windows/cia-init.c index da0f549..c9475ab 100644 --- a/src/windows/cia-init.c +++ b/src/windows/cia-init.c @@ -4,3 +4,25 @@ static void _fileapi_init(); void _cia_init() { _fileapi_init(); } + +void memset(void *dest, int ch, size_t length) { + u8 *bytes = dest; + for(int i = 0; i != length; ++i) { + bytes[i] = ch; + } +} + +int _wcsicmp(uint16_t *s1, uint16_t *s2) { + while(*s1 != 0 && *s2 != 0) { + if(*s1 != *s2) { + return *s1 - *s2; + } + } + if(*s1 == 0 && *s2 != 0) { + return -1; + } + if(*s1 != 0 && *s2 == 0) { + return 1; + } + return 0; +} \ No newline at end of file diff --git a/src/windows/crt-entry.c b/src/windows/crt-entry.c index a3ae248..d1fb253 100644 --- a/src/windows/crt-entry.c +++ b/src/windows/crt-entry.c @@ -60,3 +60,5 @@ void __security_check_cookie(u64 retrieved) { ExitProcess(1); } } + +