mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
libc: split standard headers properly
Since Memallox's newlib port is currently unstable, gint has to provide some standard functions on its own. Instead of a single <gint/std.h> header, this commit makes a gint/std directory containing headers under standard names.
This commit is contained in:
parent
bbe51f9a34
commit
d9c32b2b05
11 changed files with 80 additions and 37 deletions
|
@ -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 <gint/defs/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* 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 */
|
|
@ -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
|
||||
|
|
25
include/gint/std/stdio.h
Normal file
25
include/gint/std/stdio.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
//---
|
||||
// gint:std:stdio - a few <stdio.h> functions provided by gint
|
||||
//---
|
||||
|
||||
#ifndef GINT_STD_STDIO
|
||||
#define GINT_STD_STDIO
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* 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 */
|
22
include/gint/std/stdlib.h
Normal file
22
include/gint/std/stdlib.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
//---
|
||||
// gint:std:stdlib - a few <stdlib.h> functions provided by gint
|
||||
//---
|
||||
|
||||
#ifndef GINT_STD_STDLIB
|
||||
#define GINT_STD_STDLIB
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* 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 */
|
22
include/gint/std/string.h
Normal file
22
include/gint/std/string.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
//---
|
||||
// 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);
|
||||
|
||||
/* 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 */
|
|
@ -3,7 +3,8 @@
|
|||
//---
|
||||
|
||||
#include <gint/defs/types.h>
|
||||
#include <core/std.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <gint/std/stdio.h>
|
||||
#include <core/mmu.h>
|
||||
|
||||
#include <gint/hardware.h>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//---
|
||||
|
||||
#include <gint/gint.h>
|
||||
#include <core/std.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <gint/hardware.h>
|
||||
#include <gint/mpu/intc.h>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <gint/gint.h>
|
||||
#include <gint/drivers.h>
|
||||
#include <core/std.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <core/setup.h>
|
||||
#include <gint/hardware.h>
|
||||
#include <gint/mpu/intc.h>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <gint/drivers.h>
|
||||
#include <gint/clock.h>
|
||||
#include <core/std.h>
|
||||
|
||||
#include <gint/hardware.h>
|
||||
#include <gint/mpu/cpg.h>
|
||||
|
@ -123,6 +122,8 @@ static void sh7305_probe(void)
|
|||
|
||||
#ifdef GINT_BOOT_LOG
|
||||
|
||||
#include <gint/std/stdio.h>
|
||||
|
||||
static const char *cpg_status(void)
|
||||
{
|
||||
static char status[18];
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <gint/hardware.h>
|
||||
#include <gint/drivers.h>
|
||||
#include <gint/dma.h>
|
||||
#include <core/std.h>
|
||||
|
||||
#ifdef FXCG50
|
||||
|
||||
|
@ -280,6 +279,8 @@ static void init(void)
|
|||
|
||||
#ifdef GINT_BOOT_LOG
|
||||
|
||||
#include <gint/std/stdio.h>
|
||||
|
||||
/* r6524_status() - status string */
|
||||
static const char *r61524_status(void)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <gint/defs/types.h>
|
||||
#include <gint/defs/attributes.h>
|
||||
#include <gint/display.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <display/common.h>
|
||||
#include "topti-asm.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue