diff --git a/include/core/std.h b/include/core/std.h deleted file mode 100644 index c5973cc..0000000 --- a/include/core/std.h +++ /dev/null @@ -1,32 +0,0 @@ -//--- -// gint:core:std - a few standard functions implemented in gint -// -// There are few enough of them that it felt unnecessary to use a full- -// fledged standard library. -//--- - -#ifndef GINT_CORE_STD -#define GINT_CORE_STD - -#include -#include - -/* memcpy() - copy a chunk of memory to a non-overlapping destination */ -void *memcpy(void * restrict dest, const void * restrict src, size_t n); - -/* memset() - fill a chunk of memory with a single byte */ -void *memset(void *dest, int byte, size_t n); - -/* strlen() - length of a NUL-terminated string */ -size_t strlen(const char *str); - -/* strncpy() - copy a string with a size limit*/ -char *strncpy(char *dst, const char *src, size_t n); - -/* vsprintf() - an almost-empty subset of the real one */ -void vsprintf(char *str, const char *format, va_list args); - -/* sprintf() - an almost-empty subset of the real one */ -void sprintf(char *str, const char *format, ...); - -#endif /* GINT_CORE_STD */ diff --git a/include/gint/defs/types.h b/include/gint/defs/types.h index eab3781..75cbb1b 100644 --- a/include/gint/defs/types.h +++ b/include/gint/defs/types.h @@ -14,6 +14,8 @@ /* Fixed-width types for bit fields are quite meaningless */ typedef unsigned int uint; +/* Signed size_t */ +typedef signed int ssize_t; //--- // Structure elements diff --git a/include/gint/std/stdio.h b/include/gint/std/stdio.h new file mode 100644 index 0000000..f9560aa --- /dev/null +++ b/include/gint/std/stdio.h @@ -0,0 +1,25 @@ +//--- +// gint:std:stdio - a few functions provided by gint +//--- + +#ifndef GINT_STD_STDIO +#define GINT_STD_STDIO + +#include +#include + +/* Formatted printing functions + These functions implement most of printf()'s features, except: + * Large parameters (ll) + * Floating-point (%e, %E, %f, %F, %g, %G, %a, %A) */ + +/* Print to string from var args */ +int sprintf(char *str, char const *format, ...); +/* Print to string from va_list */ +int vsprintf(char *str, char const *format, va_list args); +/* Print to string with limited size from var args */ +int snprintf(char *str, size_t n, char const *format, ...); +/* Print to string with limited size from va_list */ +int vsnprintf(char *str, size_t n, char const *format, va_list args); + +#endif /* GINT_STD_STDIO */ diff --git a/include/gint/std/stdlib.h b/include/gint/std/stdlib.h new file mode 100644 index 0000000..6024d28 --- /dev/null +++ b/include/gint/std/stdlib.h @@ -0,0 +1,22 @@ +//--- +// gint:std:stdlib - a few functions provided by gint +//--- + +#ifndef GINT_STD_STDLIB +#define GINT_STD_STDLIB + +#include + +/* malloc(): Allocate dynamic memory */ +void *malloc(size_t size); + +/* free(): Free dynamic memory */ +void free(void *ptr); + +/* calloc(): Allocate and initialize dynamic memory */ +void *calloc(size_t nmemb, size_t size); + +/* realloc(): Reallocate dynamic memory */ +void *realloc(void *ptr, size_t size); + +#endif /* GINT_STD_STDLIB */ diff --git a/include/gint/std/string.h b/include/gint/std/string.h new file mode 100644 index 0000000..8f71dc2 --- /dev/null +++ b/include/gint/std/string.h @@ -0,0 +1,22 @@ +//--- +// 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); + +/* 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); + +#endif /* GINT_STD_STRING */ diff --git a/src/core/bootlog.c b/src/core/bootlog.c index 7eb10ee..8fcd078 100644 --- a/src/core/bootlog.c +++ b/src/core/bootlog.c @@ -3,7 +3,8 @@ //--- #include -#include +#include +#include #include #include diff --git a/src/core/gint.c b/src/core/gint.c index fff389d..98c4459 100644 --- a/src/core/gint.c +++ b/src/core/gint.c @@ -3,7 +3,7 @@ //--- #include -#include +#include #include #include diff --git a/src/core/setup.c b/src/core/setup.c index ff88e54..b1fe5a5 100644 --- a/src/core/setup.c +++ b/src/core/setup.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/cpg/cpg.c b/src/cpg/cpg.c index 3ece5e8..69f22d6 100644 --- a/src/cpg/cpg.c +++ b/src/cpg/cpg.c @@ -4,7 +4,6 @@ #include #include -#include #include #include @@ -123,6 +122,8 @@ static void sh7305_probe(void) #ifdef GINT_BOOT_LOG +#include + static const char *cpg_status(void) { static char status[18]; diff --git a/src/r61524/r61524.c b/src/r61524/r61524.c index ae3242a..4a6af39 100644 --- a/src/r61524/r61524.c +++ b/src/r61524/r61524.c @@ -6,7 +6,6 @@ #include #include #include -#include #ifdef FXCG50 @@ -280,6 +279,8 @@ static void init(void) #ifdef GINT_BOOT_LOG +#include + /* r6524_status() - status string */ static const char *r61524_status(void) { diff --git a/src/render-cg/topti.c b/src/render-cg/topti.c index b737e69..5bef618 100644 --- a/src/render-cg/topti.c +++ b/src/render-cg/topti.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "topti-asm.h"