Browse Source
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.pull/1/head
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 */ |
@ -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 */ |
@ -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 */ |
@ -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 */ |
Loading…
Reference in new issue