From fc6fb9dc096a3df1991c8c534af49870abf857b3 Mon Sep 17 00:00:00 2001 From: Lephe Date: Mon, 7 Jun 2021 21:52:52 +0200 Subject: [PATCH] std: remove the malloc impl and string header --- CMakeLists.txt | 1 - include/gint/std/string.h | 45 ++------------------------------------- src/std/malloc.c | 36 ------------------------------- 3 files changed, 2 insertions(+), 80 deletions(-) delete mode 100644 src/std/malloc.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c20e79c..ce6ab95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,6 @@ set(SOURCES_COMMON src/rtc/rtc.c src/rtc/rtc_ticks.c src/spu/spu.c - src/std/malloc.c src/tmu/inth-etmu.s src/tmu/inth-tmu.s src/tmu/sleep.c diff --git a/include/gint/std/string.h b/include/gint/std/string.h index 127afcb..bb87752 100644 --- a/include/gint/std/string.h +++ b/include/gint/std/string.h @@ -1,43 +1,2 @@ -//--- -// gint:std:string - a few functions provided by gint -//--- - -#ifndef GINT_STD_STRING -#define GINT_STD_STRING - -#include - -/* memcpy(): Copy a chunk of memory to a non-overlapping destination */ -void *memcpy(void * __restrict dest, void const * __restrict src, size_t n); - -/* memset(): Fill a chunk of memory with a single byte */ -void *memset(void *dest, int byte, size_t n); - -/* memcmp(): Compare two chunks of memory */ -int memcmp(void const *s1, void const *s2, size_t n); - -/* memmove(): Copy a chunk of memory to a possibly overlapping destination */ -void *memmove(void *dest, void const *src, size_t n); - -/* strlen(): Length of a NUL-terminated string */ -size_t strlen(char const *str); - -/* strncpy(): Copy a string with a size limit */ -char *strncpy(char *dst, char const *src, size_t n); - -/* strcat(): Concatenation a string to a pre-allocated space */ -char *strcat(char *dest, const char *src); - -/* strcmp(): Compare NUL-terminated strings */ -int strcmp(char const *s1, char const *s2); - -/* strchr(): Find the first occurrence of a character in a string */ -char *strchr(char const *s, int c); - -/* strrchr(): Find the last occurrence of a character in a string */ -char *strrchr(char const *s, int c); - -/* strchrnul(): Like strchr(), but returns end-of-string instead of NUL */ -char *strchrnul(char const *s, int c); - -#endif /* GINT_STD_STRING */ +/* Now provided by fxlibc. */ +#include diff --git a/src/std/malloc.c b/src/std/malloc.c deleted file mode 100644 index f7a5286..0000000 --- a/src/std/malloc.c +++ /dev/null @@ -1,36 +0,0 @@ -//--- -// gint:std:malloc - Standard memory allocation functions -//--- - -#include -#include - -/* malloc(): Allocate dynamic memory */ -void *malloc(size_t size) -{ - return kmalloc(size, NULL); -} - -/* free(): Free dynamic memory */ -void free(void *ptr) -{ - kfree(ptr); -} - -/* calloc(): Allocate and initialize dynamic memory */ -void *calloc(size_t nmemb, size_t size) -{ - uint64_t total = (uint64_t)nmemb * (uint64_t)size; - if(total >= 1ull << 32) return NULL; - size = total; - - void *ptr = malloc(size); - if(ptr) memset(ptr, 0, size); - return ptr; -} - -/* realloc(): Reallocate dynamic memory */ -void *realloc(void *ptr, size_t size) -{ - return krealloc(ptr, size); -}