std: remove the malloc impl and string header

This commit is contained in:
Lephe 2021-06-07 21:52:52 +02:00
parent 3a6165f026
commit fc6fb9dc09
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 2 additions and 80 deletions

View File

@ -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

View File

@ -1,43 +1,2 @@
//---
// gint:std:string - a few <string.h> functions provided by gint
//---
#ifndef GINT_STD_STRING
#define GINT_STD_STRING
#include <stddef.h>
/* 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 <string.h>

View File

@ -1,36 +0,0 @@
//---
// gint:std:malloc - Standard memory allocation functions
//---
#include <gint/kmalloc.h>
#include <gint/std/string.h>
/* 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);
}