scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 47e3a55868b27696777f41692ef3bdde1388166d
parent 6b24fc832cf3aa5ff29c06951326bbc140ab0c45
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 16 Feb 2017 16:59:22 +0100

[libc] Make stdlib.h portable between architectures

Diffstat:
Alibc/include/amd64-sysv/arch/stdlib.h | 14++++++++++++++
Dlibc/include/amd64-sysv/stdlib.h | 56--------------------------------------------------------
Alibc/include/i386-sysv/arch/stdlib.h | 14++++++++++++++
Dlibc/include/i386-sysv/stdlib.h | 56--------------------------------------------------------
Alibc/include/qbe/arch/stdlib.h | 14++++++++++++++
Dlibc/include/qbe/stdlib.h | 56--------------------------------------------------------
Alibc/include/stdlib.h | 45+++++++++++++++++++++++++++++++++++++++++++++
Alibc/include/z80/arch/stdlib.h | 14++++++++++++++
Dlibc/include/z80/stdlib.h | 56--------------------------------------------------------
9 files changed, 101 insertions(+), 224 deletions(-)

diff --git a/libc/include/amd64-sysv/arch/stdlib.h b/libc/include/amd64-sysv/arch/stdlib.h @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ + +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 +#define RAND_MAX 32767 diff --git a/libc/include/amd64-sysv/stdlib.h b/libc/include/amd64-sysv/stdlib.h @@ -1,56 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDLIB_H -#define _STDLIB_H - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#define EXIT_FAILURE 1 -#define EXIT_SUCCESS 0 -#define RAND_MAX 32767 - -extern double atof(const char *ptr); -extern int atoi(const char *s); -extern long atol(const char *s); -extern long long atoll(const char *s); - -extern float strtof(const char *s, char **end); -extern double strtod(const char *s, char **end); -extern long double strtold(const char *s, char **end); - -extern long strtol(const char *s, char **end, int base); -extern long long strtoll(const char *s, char **end, int base); -extern unsigned long stroul(const char *s, char **end, int base); -extern unsigned long long stroull(const char *s, char **end, int base); - -extern void *calloc(size_t nitems, size_t size); -extern void free(void *ptr); -extern void *realloc(void *ptr, size_t size); - -extern void abort(void); -extern int atexit(void (*func)(void)); -extern void exit(int status); -extern char *getenv(const char *name); -extern int system(const char *cmd); - -extern void *bsearch(const void *key, - const void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); -extern void qsort(void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); - -extern void abs(int x); -/* div_t div(int num, int denom); */ -extern long labs(long int x); -/* ldiv_t ldiv(long int number, long int denom); */ - -extern int rand(void); -extern void srand(unsigned seed); - -#endif diff --git a/libc/include/i386-sysv/arch/stdlib.h b/libc/include/i386-sysv/arch/stdlib.h @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ + +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 +#define RAND_MAX 32767 diff --git a/libc/include/i386-sysv/stdlib.h b/libc/include/i386-sysv/stdlib.h @@ -1,56 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDLIB_H -#define _STDLIB_H - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#define EXIT_FAILURE 1 -#define EXIT_SUCCESS 0 -#define RAND_MAX 32767 - -extern double atof(const char *ptr); -extern int atoi(const char *s); -extern long atol(const char *s); -extern long long atoll(const char *s); - -extern float strtof(const char *s, char **end); -extern double strtod(const char *s, char **end); -extern long double strtold(const char *s, char **end); - -extern long strtol(const char *s, char **end, int base); -extern long long strtoll(const char *s, char **end, int base); -extern unsigned long stroul(const char *s, char **end, int base); -extern unsigned long long stroull(const char *s, char **end, int base); - -extern void *calloc(size_t nitems, size_t size); -extern void free(void *ptr); -extern void *realloc(void *ptr, size_t size); - -extern void abort(void); -extern int atexit(void (*func)(void)); -extern void exit(int status); -extern char *getenv(const char *name); -extern int system(const char *cmd); - -extern void *bsearch(const void *key, - const void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); -extern void qsort(void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); - -extern void abs(int x); -/* div_t div(int num, int denom); */ -extern long labs(long int x); -/* ldiv_t ldiv(long int number, long int denom); */ - -extern int rand(void); -extern void srand(unsigned seed); - -#endif diff --git a/libc/include/qbe/arch/stdlib.h b/libc/include/qbe/arch/stdlib.h @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ + +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 +#define RAND_MAX 32767 diff --git a/libc/include/qbe/stdlib.h b/libc/include/qbe/stdlib.h @@ -1,56 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDLIB_H -#define _STDLIB_H - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#define EXIT_FAILURE 1 -#define EXIT_SUCCESS 0 -#define RAND_MAX 32767 - -extern double atof(const char *ptr); -extern int atoi(const char *s); -extern long atol(const char *s); -extern long long atoll(const char *s); - -extern float strtof(const char *s, char **end); -extern double strtod(const char *s, char **end); -extern long double strtold(const char *s, char **end); - -extern long strtol(const char *s, char **end, int base); -extern long long strtoll(const char *s, char **end, int base); -extern unsigned long stroul(const char *s, char **end, int base); -extern unsigned long long stroull(const char *s, char **end, int base); - -extern void *calloc(size_t nitems, size_t size); -extern void free(void *ptr); -extern void *realloc(void *ptr, size_t size); - -extern void abort(void); -extern int atexit(void (*func)(void)); -extern void exit(int status); -extern char *getenv(const char *name); -extern int system(const char *cmd); - -extern void *bsearch(const void *key, - const void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); -extern void qsort(void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); - -extern void abs(int x); -/* div_t div(int num, int denom); */ -extern long labs(long int x); -/* ldiv_t ldiv(long int number, long int denom); */ - -extern int rand(void); -extern void srand(unsigned seed); - -#endif diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h @@ -0,0 +1,45 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef _STDLIB_H +#define _STDLIB_H + +#include <arch/stdlib.h> + +extern double atof(const char *ptr); +extern int atoi(const char *s); +extern long atol(const char *s); +extern long long atoll(const char *s); + +extern float strtof(const char *s, char **end); +extern double strtod(const char *s, char **end); +extern long double strtold(const char *s, char **end); + +extern long strtol(const char *s, char **end, int base); +extern long long strtoll(const char *s, char **end, int base); +extern unsigned long stroul(const char *s, char **end, int base); +extern unsigned long long stroull(const char *s, char **end, int base); + +extern void *calloc(size_t nitems, size_t size); +extern void free(void *ptr); +extern void *realloc(void *ptr, size_t size); + +extern void abort(void); +extern int atexit(void (*func)(void)); +extern void exit(int status); +extern char *getenv(const char *name); +extern int system(const char *cmd); + +extern void *bsearch(const void *key, + const void *base, size_t nitems, size_t size, + int (*cmp)(const void *, const void *)); +extern void qsort(void *base, size_t nitems, size_t size, + int (*cmp)(const void *, const void *)); + +extern void abs(int x); +/* div_t div(int num, int denom); */ +extern long labs(long int x); +/* ldiv_t ldiv(long int number, long int denom); */ + +extern int rand(void); +extern void srand(unsigned seed); + +#endif diff --git a/libc/include/z80/arch/stdlib.h b/libc/include/z80/arch/stdlib.h @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ + +#ifndef _SIZET +typedef unsigned size_t; +#define _SIZET +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 +#define RAND_MAX 32767 diff --git a/libc/include/z80/stdlib.h b/libc/include/z80/stdlib.h @@ -1,56 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDLIB_H -#define _STDLIB_H - -#ifndef _SIZET -typedef unsigned size_t; -#define _SIZET -#endif - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#define EXIT_FAILURE 1 -#define EXIT_SUCCESS 0 -#define RAND_MAX 32767 - -extern double atof(const char *ptr); -extern int atoi(const char *s); -extern long atol(const char *s); -extern long long atoll(const char *s); - -extern float strtof(const char *s, char **end); -extern double strtod(const char *s, char **end); -extern long double strtold(const char *s, char **end); - -extern long strtol(const char *s, char **end, int base); -extern long long strtoll(const char *s, char **end, int base); -extern unsigned long stroul(const char *s, char **end, int base); -extern unsigned long long stroull(const char *s, char **end, int base); - -extern void *calloc(size_t nitems, size_t size); -extern void free(void *ptr); -extern void *realloc(void *ptr, size_t size); - -extern void abort(void); -extern int atexit(void (*func)(void)); -extern void exit(int status); -extern char *getenv(const char *name); -extern int system(const char *cmd); - -extern void *bsearch(const void *key, - const void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); -extern void qsort(void *base, size_t nitems, size_t size, - int (*cmp)(const void *, const void *)); - -extern void abs(int x); -/* div_t div(int num, int denom); */ -extern long labs(long int x); -/* ldiv_t ldiv(long int number, long int denom); */ - -extern int rand(void); -extern void srand(unsigned seed); - -#endif