diff --git a/LibC/signal.h b/LibC/signal.h index cb3b7599af..f13cf62c27 100644 --- a/LibC/signal.h +++ b/LibC/signal.h @@ -10,6 +10,7 @@ typedef __sighandler_t sighandler_t; typedef uint32_t sigset_t; typedef void siginfo_t; +typedef uint32_t sig_atomic_t; struct sigaction { union { diff --git a/LibC/stdio.cpp b/LibC/stdio.cpp index 378036ff2b..5153983047 100644 --- a/LibC/stdio.cpp +++ b/LibC/stdio.cpp @@ -268,11 +268,16 @@ int fprintf(FILE* stream, const char* fmt, ...) return ret; } +int vprintf(const char* fmt, va_list ap) +{ + return printf_internal(stdout_putch, nullptr, fmt, ap); +} + int printf(const char* fmt, ...) { va_list ap; va_start(ap, fmt); - int ret = printf_internal(stdout_putch, nullptr, fmt, ap); + int ret = vprintf(fmt, ap); va_end(ap); return ret; } diff --git a/LibC/stdio.h b/LibC/stdio.h index f9c5ca0611..b52b0f5680 100644 --- a/LibC/stdio.h +++ b/LibC/stdio.h @@ -50,6 +50,7 @@ int feof(FILE*); int fflush(FILE*); size_t fread(void* ptr, size_t size, size_t nmemb, FILE*); size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE*); +int vprintf(const char* fmt, va_list); int vfprintf(FILE*, const char* fmt, va_list); int vsprintf(char* buffer, const char* fmt, va_list); int vsnprintf(char* buffer, size_t, const char* fmt, va_list); diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp index 671f6517cc..b5a179ac98 100644 --- a/LibC/stdlib.cpp +++ b/LibC/stdlib.cpp @@ -252,4 +252,14 @@ int abs(int i) return i < 0 ? -i : i; } +long int random() +{ + return rand(); +} + +void srandom(unsigned seed) +{ + srand(seed); +} + } diff --git a/LibC/stdlib.h b/LibC/stdlib.h index 7af51814ae..028e9d4a91 100644 --- a/LibC/stdlib.h +++ b/LibC/stdlib.h @@ -26,5 +26,8 @@ int abs(int); int rand(); void srand(unsigned seed); +long int random(); +void srandom(unsigned seed); + __END_DECLS diff --git a/LibC/string.cpp b/LibC/string.cpp index 6923a17a4c..c5284fa936 100644 --- a/LibC/string.cpp +++ b/LibC/string.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include extern "C" { @@ -51,6 +52,14 @@ size_t strlen(const char* str) return len; } +char* strdup(const char* str) +{ + size_t len = strlen(str); + char* new_str = (char*)malloc(len); + strcpy(new_str, str); + return new_str; +} + int strcmp(const char* s1, const char* s2) { while (*s1 == *s2++)