From 142662f84c5ead2fa123eb70fd225ef52c89a18c Mon Sep 17 00:00:00 2001 From: Max Wash Date: Fri, 24 Jul 2020 10:50:40 +0100 Subject: [PATCH] Stub implementations of some wchar functions --- CMakeLists.txt | 2 +- photon/libc/include/locale.h | 4 ++++ photon/libc/include/stdlib.h | 2 ++ photon/libc/include/wchar.h | 14 ++++++++++++++ photon/libc/wchar/fwide.c | 6 ++++++ photon/libc/wchar/vfwprintf.c | 6 ++++++ photon/libc/wchar/vswprintf.c | 6 ++++++ 7 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 photon/libc/include/locale.h create mode 100644 photon/libc/include/wchar.h create mode 100644 photon/libc/wchar/fwide.c create mode 100644 photon/libc/wchar/vfwprintf.c create mode 100644 photon/libc/wchar/vswprintf.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 024f37c..7b61fc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ set(CMAKE_EXE_LINKER_FLAGS set(malloc_impl dlmalloc) set(photon_libc_sources "") -set(generic_dirs string stdio stdlib errno internal ctype) +set(generic_dirs string stdio stdlib errno internal ctype wchar) message(STATUS "Memory allocator: ${malloc_impl}") diff --git a/photon/libc/include/locale.h b/photon/libc/include/locale.h new file mode 100644 index 0000000..c313dda --- /dev/null +++ b/photon/libc/include/locale.h @@ -0,0 +1,4 @@ +#ifndef LOCALE_H_ +#define LOCALE_H_ + +#endif diff --git a/photon/libc/include/stdlib.h b/photon/libc/include/stdlib.h index a0d4ac7..afeb2e0 100644 --- a/photon/libc/include/stdlib.h +++ b/photon/libc/include/stdlib.h @@ -10,6 +10,8 @@ extern "C" { extern _Noreturn void abort(void); extern _Noreturn void exit(int code); extern void *malloc(size_t sz); +extern void *realloc(void *ptr, size_t sz); +extern void *calloc(size_t n, size_t sz); extern void free(void *ptr); extern int atoi(const char *str); diff --git a/photon/libc/include/wchar.h b/photon/libc/include/wchar.h new file mode 100644 index 0000000..b779b6f --- /dev/null +++ b/photon/libc/include/wchar.h @@ -0,0 +1,14 @@ +#ifndef WCHAR_H_ +#define WCHAR_H_ + +#include +#include + +typedef unsigned int wchar_t; + +extern int fwide(FILE *fp, int mode); + +extern int vfwprintf(FILE *stream, const wchar_t *format, va_list arg); +extern int vswprintf(wchar_t *buf, size_t len, const wchar_t *format, va_list arg); + +#endif diff --git a/photon/libc/wchar/fwide.c b/photon/libc/wchar/fwide.c new file mode 100644 index 0000000..34b7872 --- /dev/null +++ b/photon/libc/wchar/fwide.c @@ -0,0 +1,6 @@ +#include + +int fwide(FILE *fp, int mode) +{ + return 0; +} diff --git a/photon/libc/wchar/vfwprintf.c b/photon/libc/wchar/vfwprintf.c new file mode 100644 index 0000000..348d01c --- /dev/null +++ b/photon/libc/wchar/vfwprintf.c @@ -0,0 +1,6 @@ +#include + +int vfwprintf(FILE *fp, const wchar_t *format, va_list arg) +{ + return 0; +} diff --git a/photon/libc/wchar/vswprintf.c b/photon/libc/wchar/vswprintf.c new file mode 100644 index 0000000..9229c0f --- /dev/null +++ b/photon/libc/wchar/vswprintf.c @@ -0,0 +1,6 @@ +#include + +int vswprintf(wchar_t *buf, size_t len, const wchar_t *format, va_list arg) +{ + return 0; +}