diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1d93a15 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ + +GNUFLAGS=-Werror -Wall -Iinc -Isrc/win +CLFLAGS=/I:inc /I:src/win /link /incremental:no /subsystem:windows /nodefaultlib kernel32.lib + +CC=clang +CFLAGS=$(GNUFLAGS) +LDFLAGS=/nologo /nodefaultlib /entry:mainCRTStartup + +SRC_DIR := src +OBJ_DIR := bin +SRC_FILES := $(wildcard $(SRC_DIR)/code/*.c) $(wildcard $(SRC_DIR)/win/*.c) +OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.obj,$(SRC_FILES)) + +ciabatta.lib: $(OBJ_FILES) + lib $(LDFLAGS) /out:$@ $^ + +$(OBJ_DIR)/%.obj: $(SRC_DIR)/%.c + $(CC) $(CFLAGS) -c -o $@ $< + +.PHONY: ciabatta.lib diff --git a/inc/stdlib.h b/inc/stdlib.h index 7833aa4..3813e09 100644 --- a/inc/stdlib.h +++ b/inc/stdlib.h @@ -101,11 +101,11 @@ void qsort( ); // Multibyte strings -// int mblen(const char *s, size_t n); -// int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n); -// int wctomb(char *s, wchar_t wchar); -// size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n); -// size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n); +int mblen (const char *s, size_t n); +int mbtowc (wchar_t *restrict pwc, const char *restrict s, size_t n); +size_t mbstowcs(wchar_t *restrict pwcs, const char *restrict s, size_t n); +int wctomb (char *s, wchar_t wchar); +size_t wcstombs(char *restrict s, const wchar_t *restrict pwcs, size_t n); // #ifdef __STDC_WANT_LIB_EXT1__ // typedef void (*constraint_handler_t)(const char * restrict msg, void * restrict ptr, errno_t error); diff --git a/src/code/stdlib/multibyte.c b/src/code/stdlib/multibyte.c new file mode 100644 index 0000000..561617b --- /dev/null +++ b/src/code/stdlib/multibyte.c @@ -0,0 +1,23 @@ + +#include + +int mblen(const char *s, size_t n) { + return mbtowc((wchar_t*)0, s, n); +} + +int mbtowc(wchar_t *restrict pwc, const char *restrict s, size_t n) { + +} + +size_t mbstowcs(wchar_t *restrict pwcs, const char *restrict s, size_t n) { + +} + +int wctomb(char *s, wchar_t wchar) { + +} + +size_t wcstombs(char *restrict s, const wchar_t *restrict pwcs, size_t n) { + +} +