scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit d13b1476f5273e9fb3a13fd7eb432d47612033c1
parent 7c2fa317e86146c72d5548cc69a4b36752df33e1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 13 Jun 2020 18:34:49 +0200

libc: Add arch/cdefs.h

This new header contains all the common definitions of the
architecture in only one file. It makes easier to port to
new architectures and to fix errors.

Diffstat:
Ainclude/bits/amd64/arch/cdefs.h | 30++++++++++++++++++++++++++++++
Dinclude/bits/amd64/arch/stddef.h | 14--------------
Minclude/bits/amd64/arch/stdio.h | 5-----
Minclude/bits/amd64/arch/stdlib.h | 10----------
Minclude/bits/amd64/arch/string.h | 5-----
Minclude/bits/amd64/arch/time.h | 7+------
Ainclude/bits/arm32/arch/cdefs.h | 30++++++++++++++++++++++++++++++
Dinclude/bits/arm32/arch/stddef.h | 9---------
Minclude/bits/arm32/arch/stdio.h | 5-----
Minclude/bits/arm32/arch/stdlib.h | 10----------
Minclude/bits/arm32/arch/string.h | 5-----
Minclude/bits/arm32/arch/time.h | 5-----
Ainclude/bits/arm64/arch/cdefs.h | 30++++++++++++++++++++++++++++++
Dinclude/bits/arm64/arch/stddef.h | 9---------
Minclude/bits/arm64/arch/stdio.h | 5-----
Minclude/bits/arm64/arch/stdlib.h | 10----------
Minclude/bits/arm64/arch/string.h | 5-----
Minclude/bits/arm64/arch/time.h | 5-----
Ainclude/bits/i386/arch/cdefs.h | 30++++++++++++++++++++++++++++++
Dinclude/bits/i386/arch/stddef.h | 14--------------
Minclude/bits/i386/arch/stdio.h | 5-----
Minclude/bits/i386/arch/stdlib.h | 5-----
Minclude/bits/i386/arch/string.h | 4----
Minclude/bits/i386/arch/time.h | 5-----
Ainclude/bits/ppc32/arch/cdefs.h | 30++++++++++++++++++++++++++++++
Dinclude/bits/ppc32/arch/stddef.h | 9---------
Minclude/bits/ppc32/arch/stdio.h | 5-----
Minclude/bits/ppc32/arch/stdlib.h | 10----------
Minclude/bits/ppc32/arch/string.h | 5-----
Minclude/bits/ppc32/arch/time.h | 5-----
Ainclude/bits/z80/arch/cdefs.h | 30++++++++++++++++++++++++++++++
Dinclude/bits/z80/arch/stddef.h | 14--------------
Minclude/bits/z80/arch/stdio.h | 5-----
Minclude/bits/z80/arch/stdlib.h | 10----------
Minclude/bits/z80/arch/string.h | 4----
Minclude/bits/z80/arch/time.h | 5-----
Minclude/locale.h | 5++---
Minclude/stddef.h | 10+++++-----
Minclude/stdio.h | 7+++----
Minclude/stdlib.h | 8++++----
Minclude/string.h | 7+++----
Minclude/time.h | 7+++----
42 files changed, 201 insertions(+), 237 deletions(-)

diff --git a/include/bits/amd64/arch/cdefs.h b/include/bits/amd64/arch/cdefs.h @@ -0,0 +1,30 @@ +#ifdef _NEED_SIZET +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif +#undef _NEED_SIZET +#endif + +#ifdef _NEED_PTRDIFFT +#ifndef _PTRDIFFT +typedef long ptrdiff_t; +#define _PTRDIFFT +#endif +#undef _NEED_PTRDIFFT +#endif + +#ifdef _NEED_NULL +#ifndef NULL +#define NULL ((void *) 0) +#endif +#undef _NEED_NULL +#endif + +#ifdef _NEED_WCHART +#ifndef _WCHART +typedef int wchar_t; +#define _WCHART +#endif +#undef _NEED_WCHART +#endif diff --git a/include/bits/amd64/arch/stddef.h b/include/bits/amd64/arch/stddef.h @@ -1,14 +0,0 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#ifndef _WCHAR_T -typedef int wchar_t; -#define _WCHAR_T -#endif - -#ifndef _PTRDIFF_T -typedef long ptrdiff_t; -#define _PTRDIFF_T -#endif diff --git a/include/bits/amd64/arch/stdio.h b/include/bits/amd64/arch/stdio.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define BUFSIZ 512 #define FILENAME_MAX 256 #define FOPEN_MAX 16 diff --git a/include/bits/amd64/arch/stdlib.h b/include/bits/amd64/arch/stdlib.h @@ -1,14 +1,4 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 -#ifndef _WCHAR_T -typedef int wchar_t; -#define _WCHAR_T -#endif - #define _ALIGNTYPE long double diff --git a/include/bits/amd64/arch/string.h b/include/bits/amd64/arch/string.h @@ -1,6 +1 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define __NUMCHARS 128 diff --git a/include/bits/amd64/arch/time.h b/include/bits/amd64/arch/time.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define _MAXYEAR 9999 -typedef long int time_t; +typedef long time_t; diff --git a/include/bits/arm32/arch/cdefs.h b/include/bits/arm32/arch/cdefs.h @@ -0,0 +1,30 @@ +#ifdef _NEED_SIZET +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif +#undef _NEED_SIZET +#endif + +#ifdef _NEED_PTRDIFFT +#ifndef _PTRDIFFT +typedef long ptrdiff_t; +#define _PTRDIFFT +#endif +#undef _NEED_PTRDIFFT +#endif + +#ifdef _NEED_NULL +#ifndef NULL +#define NULL ((void *) 0) +#endif +#undef _NEED_NULL +#endif + +#ifdef _NEED_WCHART +#ifndef _WCHART +typedef int wchar_t; +#define _WCHART +#endif +#undef _NEED_WCHART +#endif diff --git a/include/bits/arm32/arch/stddef.h b/include/bits/arm32/arch/stddef.h @@ -1,9 +0,0 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - -#ifndef _PTRDIFF_T -typedef long ptrdiff_t; -#define _PTRDIFF_T -#endif diff --git a/include/bits/arm32/arch/stdio.h b/include/bits/arm32/arch/stdio.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define BUFSIZ 512 #define FILENAME_MAX 256 #define FOPEN_MAX 16 diff --git a/include/bits/arm32/arch/stdlib.h b/include/bits/arm32/arch/stdlib.h @@ -1,14 +1,4 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 -#ifndef _WCHAR_T -typedef int wchar_t; // TODO -#define _WCHAR_T -#endif - #define _ALIGNTYPE long double diff --git a/include/bits/arm32/arch/string.h b/include/bits/arm32/arch/string.h @@ -1,6 +1 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define __NUMCHARS 128 diff --git a/include/bits/arm32/arch/time.h b/include/bits/arm32/arch/time.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define _MAXYEAR 9999 typedef long int time_t; diff --git a/include/bits/arm64/arch/cdefs.h b/include/bits/arm64/arch/cdefs.h @@ -0,0 +1,30 @@ +#ifdef _NEED_SIZET +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif +#undef _NEED_SIZET +#endif + +#ifdef _NEED_PTRDIFFT +#ifndef _PTRDIFFT +typedef long ptrdiff_t; +#define _PTRDIFFT +#endif +#undef _NEED_PTRDIFFT +#endif + +#ifdef _NEED_NULL +#ifndef NULL +#define NULL ((void *) 0) +#endif +#undef _NEED_NULL +#endif + +#ifdef _NEED_WCHART +#ifndef _WCHART +typedef int wchar_t; +#define _WCHART +#endif +#undef _NEED_WCHART +#endif diff --git a/include/bits/arm64/arch/stddef.h b/include/bits/arm64/arch/stddef.h @@ -1,9 +0,0 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#ifndef _PTRDIFF_T -typedef long ptrdiff_t; -#define _PTRDIFF_T -#endif diff --git a/include/bits/arm64/arch/stdio.h b/include/bits/arm64/arch/stdio.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define BUFSIZ 512 #define FILENAME_MAX 256 #define FOPEN_MAX 16 diff --git a/include/bits/arm64/arch/stdlib.h b/include/bits/arm64/arch/stdlib.h @@ -1,14 +1,4 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 -#ifndef _WCHAR_T -typedef int wchar_t; -#define _WCHAR_T -#endif - #define _ALIGNTYPE long double diff --git a/include/bits/arm64/arch/string.h b/include/bits/arm64/arch/string.h @@ -1,6 +1 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define __NUMCHARS 128 diff --git a/include/bits/arm64/arch/time.h b/include/bits/arm64/arch/time.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define _MAXYEAR 9999 typedef long int time_t; diff --git a/include/bits/i386/arch/cdefs.h b/include/bits/i386/arch/cdefs.h @@ -0,0 +1,30 @@ +#ifdef _NEED_SIZET +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif +#undef _NEED_SIZET +#endif + +#ifdef _NEED_PTRDIFFT +#ifndef _PTRDIFFT +typedef long ptrdiff_t; +#define _PTRDIFFT +#endif +#undef _NEED_PTRDIFFT +#endif + +#ifdef _NEED_NULL +#ifndef NULL +#define NULL ((void *) 0) +#endif +#undef _NEED_NULL +#endif + +#ifdef _NEED_WCHART +#ifndef _WCHART +typedef int wchar_t; +#define _WCHART +#endif +#undef _NEED_WCHART +#endif diff --git a/include/bits/i386/arch/stddef.h b/include/bits/i386/arch/stddef.h @@ -1,14 +0,0 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#ifndef _WCHAR_T -typedef int wchar_t; -#define _WCHAR_T -#endif - -#ifndef _PTRDIFF_T -typedef long ptrdiff_t; -#define _PTRDIFF_T -#endif diff --git a/include/bits/i386/arch/stdio.h b/include/bits/i386/arch/stdio.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define BUFSIZ 512 #define FILENAME_MAX 256 #define FOPEN_MAX 16 diff --git a/include/bits/i386/arch/stdlib.h b/include/bits/i386/arch/stdlib.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 diff --git a/include/bits/i386/arch/string.h b/include/bits/i386/arch/string.h @@ -1,5 +1 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#endif - #define __NUMCHARS 128 diff --git a/include/bits/i386/arch/time.h b/include/bits/i386/arch/time.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - #define _MAXYEAR 2037 typedef long int time_t; diff --git a/include/bits/ppc32/arch/cdefs.h b/include/bits/ppc32/arch/cdefs.h @@ -0,0 +1,30 @@ +#ifdef _NEED_SIZET +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif +#undef _NEED_SIZET +#endif + +#ifdef _NEED_PTRDIFFT +#ifndef _PTRDIFFT +typedef long ptrdiff_t; +#define _PTRDIFFT +#endif +#undef _NEED_PTRDIFFT +#endif + +#ifdef _NEED_NULL +#ifndef NULL +#define NULL ((void *) 0) +#endif +#undef _NEED_NULL +#endif + +#ifdef _NEED_WCHART +#ifndef _WCHART +typedef int wchar_t; +#define _WCHART +#endif +#undef _NEED_WCHART +#endif diff --git a/include/bits/ppc32/arch/stddef.h b/include/bits/ppc32/arch/stddef.h @@ -1,9 +0,0 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - -#ifndef _PTRDIFF_T -typedef long ptrdiff_t; -#define _PTRDIFF_T -#endif diff --git a/include/bits/ppc32/arch/stdio.h b/include/bits/ppc32/arch/stdio.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define BUFSIZ 512 #define FILENAME_MAX 256 #define FOPEN_MAX 16 diff --git a/include/bits/ppc32/arch/stdlib.h b/include/bits/ppc32/arch/stdlib.h @@ -1,14 +1,4 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 -#ifndef _WCHAR_T -typedef int wchar_t; // TODO -#define _WCHAR_T -#endif - #define _ALIGNTYPE long double diff --git a/include/bits/ppc32/arch/string.h b/include/bits/ppc32/arch/string.h @@ -1,6 +1 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define __NUMCHARS 128 diff --git a/include/bits/ppc32/arch/time.h b/include/bits/ppc32/arch/time.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned int size_t; -#define _SIZET -#endif - #define _MAXYEAR 9999 typedef long int time_t; diff --git a/include/bits/z80/arch/cdefs.h b/include/bits/z80/arch/cdefs.h @@ -0,0 +1,30 @@ +#ifdef _NEED_SIZET +#ifndef _SIZET +typedef unsigned short size_t; +#define _SIZET +#endif +#undef _NEED_SIZET +#endif + +#ifdef _NEED_PTRDIFFT +#ifndef _PTRDIFFT +typedef short ptrdiff_t; +#define _PTRDIFFT +#endif +#undef _NEED_PTRDIFFT +#endif + +#ifdef _NEED_NULL +#ifndef NULL +#define NULL ((void *) 0) +#endif +#undef _NEED_NULL +#endif + +#ifdef _NEED_WCHART +#ifndef _WCHART +typedef int wchar_t; +#define _WCHART +#endif +#undef _NEED_WCHART +#endif diff --git a/include/bits/z80/arch/stddef.h b/include/bits/z80/arch/stddef.h @@ -1,14 +0,0 @@ -#ifndef _SIZET -typedef unsigned size_t; -#define _SIZET -#endif - -#ifndef _WCHAR_T -typedef short wchar_t; -#define _WCHAR_T -#endif - -#ifndef _PTRDIFF_T -typedef short ptrdiff_t; -#define _PTRDIFF_T -#endif diff --git a/include/bits/z80/arch/stdio.h b/include/bits/z80/arch/stdio.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned size_t; -#define _SIZET -#endif - #define BUFSIZ 512 #define FILENAME_MAX 256 #define FOPEN_MAX 16 diff --git a/include/bits/z80/arch/stdlib.h b/include/bits/z80/arch/stdlib.h @@ -1,14 +1,4 @@ -#ifndef _SIZET -typedef unsigned size_t; -#define _SIZET -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 -#ifndef _WCHAR_T -typedef short wchar_t; -#define _WCHAR_T -#endif - #define _ALIGNTYPE int diff --git a/include/bits/z80/arch/string.h b/include/bits/z80/arch/string.h @@ -1,5 +1 @@ -#ifndef _SIZET -typedef unsigned size_t; -#endif - #define __NUMCHARS 128 diff --git a/include/bits/z80/arch/time.h b/include/bits/z80/arch/time.h @@ -1,8 +1,3 @@ -#ifndef _SIZET -typedef unsigned size_t; -#define _SIZET -#endif - #define _MAXYEAR 2037 typedef long time_t; diff --git a/include/locale.h b/include/locale.h @@ -1,9 +1,8 @@ #ifndef _LOCALE_H #define _LOCALE_H -#ifndef NULL -#define NULL ((void *) 0) -#endif +#define _NEED_NULL +#include <arch/cdefs.h> #define LC_ALL 0 #define LC_COLLATE 1 diff --git a/include/stddef.h b/include/stddef.h @@ -1,11 +1,11 @@ #ifndef _STDDEF_H #define _STDDEF_H -#include <arch/stddef.h> - -#ifndef NULL -#define NULL ((void *) 0) -#endif +#define _NEED_SIZET +#define _NEED_WCHAR_T +#define _NEED_PTRDIFFT +#define _NEED_NULL +#include <arch/cdefs.h> #define offsetof(st, m) ((size_t)&(((st *)0)->m)) diff --git a/include/stdio.h b/include/stdio.h @@ -1,16 +1,15 @@ #ifndef _STDIO_H #define _STDIO_H +#define _NEED_NULL +#define _NEED_SIZET +#include <arch/cdefs.h> #include <arch/stdio.h> #ifndef FOPEN_MAX #define FOPEN_MAX 12 #endif -#ifndef NULL -#define NULL ((void *) 0) -#endif - #define EOF -1 #define SEEK_SET 0 #define SEEK_CUR 1 diff --git a/include/stdlib.h b/include/stdlib.h @@ -1,12 +1,12 @@ #ifndef _STDLIB_H #define _STDLIB_H +#define _NEED_NULL +#define _NEED_SIZET +#define _NEED_WCHART +#include <arch/cdefs.h> #include <arch/stdlib.h> -#ifndef NULL -#define NULL ((void *) 0) -#endif - #define _ATEXIT_MAX 32 #define MB_CUR_MAX 1 diff --git a/include/string.h b/include/string.h @@ -1,12 +1,11 @@ #ifndef _STRING_H #define _STRING_H +#define _NEED_SIZET +#define _NEED_NULL +#include <arch/cdefs.h> #include <arch/string.h> -#ifndef NULL -#define NULL ((void *) 0) -#endif - extern void *memcpy(void * restrict s1, const void * restrict s2, size_t n); extern void *memmove(void *s1, const void *s2, size_t n); extern char *strcpy(char * restrict s1, const char * restrict s2); diff --git a/include/time.h b/include/time.h @@ -1,12 +1,11 @@ #ifndef _TIME_H #define _TIME_H +#define _NEED_SIZET +#define _NEED_NULL +#include <arch/cdefs.h> #include <arch/time.h> -#ifndef NULL -#define NULL ((void *) 0) -#endif - #define CLOCKS_PER_SEC 1000000 typedef long int clock_t;