scc

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

commit 6b24fc832cf3aa5ff29c06951326bbc140ab0c45
parent 5f4f7787a0f6b602aa66d8b43f98f184d824d922
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 16 Feb 2017 16:41:03 +0100

[libc] Make stdio.h portable between architectures

Almost all the code of stdio.h is portable between the
different architectures, and only a few bits are
architecture dependant. A good solution is to put
every dependant bit in a arch/stdio.h file, and
share the rest between the different architectures.

Diffstat:
Minc/sysincludes.def.h | 1+
Alibc/include/amd64-sysv/arch/stdio.h | 18++++++++++++++++++
Dlibc/include/amd64-sysv/stdio.h | 79-------------------------------------------------------------------------------
Alibc/include/i386-sysv/arch/stdio.h | 18++++++++++++++++++
Dlibc/include/i386-sysv/stdio.h | 79-------------------------------------------------------------------------------
Alibc/include/qbe/arch/stdio.h | 18++++++++++++++++++
Dlibc/include/qbe/stdio.h | 79-------------------------------------------------------------------------------
Alibc/include/stdio.h | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alibc/include/z80/arch/stdio.h | 18++++++++++++++++++
Dlibc/include/z80/stdio.h | 79-------------------------------------------------------------------------------
Mlibc/src/Makefile | 2++
11 files changed, 141 insertions(+), 316 deletions(-)

diff --git a/inc/sysincludes.def.h b/inc/sysincludes.def.h @@ -1,6 +1,7 @@ char *sysincludes[] = { PREFIX "/include/scc/" , PREFIX "/include/scc/" ARCH "/", + PREFIX "/include/scc/" ARCH "/arch/", /* configure below your standard sys include paths */ PREFIX "/include/", PREFIX "/local/include/", diff --git a/libc/include/amd64-sysv/arch/stdio.h b/libc/include/amd64-sysv/arch/stdio.h @@ -0,0 +1,18 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif + +#define BUFSIZ 512 +#define FILENAME_MAX 256 +#define FOPEN_MAX 16 + +#define TMP_MAX 25 +#define L_tmpnam 256 + +typedef struct _FILE FILE; diff --git a/libc/include/amd64-sysv/stdio.h b/libc/include/amd64-sysv/stdio.h @@ -1,79 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDIO_H -#define _STDIO_H - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#define EOF -1 -#define BUFSIZ 512 -#define FILENAME_MAX 256 -#define FOPEN_MAX 16 -#define _IOFBF 0 -#define _IOLBF 1 -#define _IONBF 2 -#define L_tmpnam 256 -#define SEEK_CUR 0 -#define SEEK_END 1 -#define SEEK_SET 2 -#define TMP_MAX 25 - -typedef struct _FILE FILE; - -extern FILE *fopen(const char *, const char *mode); -extern FILE *freopen(const char *path, const char *mode, FILE *fp); -extern int fclose(FILE *fp); - -extern int fflush(FILE *fp); -extern void setbuf(FILE *fp, char *buf); -extern int setvbuf(FILE *fp, char *buf, size_t size); - -extern size_t fread(void *ptr, size_t size, size_t n, FILE *fp); -extern size_t fwrite(const void *ptr, size_t size, size_t n, FILE *fp); - -extern int fgetc(FILE *fp); -extern int getc(FILE *fp); -extern int getchar(void); - -extern int fputc(int c, FILE *fp); -extern int putc(int c, FILE *fp); -extern int putchar(int c); - -extern char *fgets(char *s, int size, FILE *fp); -extern char *gets(char *s); - -extern int fputs(char *s, FILE *fp); -extern int puts(char *s); - -extern int scanf(const char *fmt, ...); -extern int fscanf(FILE *fp, const char *fmt, ...); -extern int sscanf(char *s, const char *fmt, ...); - -extern int printf(const char *fmt, ...); -extern int fprintf(FILE *fp, const char *fmt, ...); -extern int sprintf(char *s, const char *fmt, ...); -extern int snprintf(char *s, size_t size, const char *fmt, ...); - -extern void perror(const char *s); - -extern long ftell(FILE *fp); -extern long fseek(FILE *fp); -extern void rewind(FILE *fp); - -extern void clearerr(FILE *fp); -extern int feof(FILE *fp); -extern int ferror(FILE *fp); - -extern int remove(const char *name); -extern int rename(const char *old, const char *new); -extern FILE *tmpfile(void); -extern FILE *tmpnam(char *s); - -extern FILE *stdin, *stdout, *stderr; -#endif diff --git a/libc/include/i386-sysv/arch/stdio.h b/libc/include/i386-sysv/arch/stdio.h @@ -0,0 +1,18 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif + +#define BUFSIZ 512 +#define FILENAME_MAX 256 +#define FOPEN_MAX 16 + +#define TMP_MAX 25 +#define L_tmpnam 256 + +typedef struct _FILE FILE; diff --git a/libc/include/i386-sysv/stdio.h b/libc/include/i386-sysv/stdio.h @@ -1,79 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDIO_H -#define _STDIO_H - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#define EOF -1 -#define BUFSIZ 512 -#define FILENAME_MAX 256 -#define FOPEN_MAX 16 -#define _IOFBF 0 -#define _IOLBF 1 -#define _IONBF 2 -#define L_tmpnam 256 -#define SEEK_CUR 0 -#define SEEK_END 1 -#define SEEK_SET 2 -#define TMP_MAX 25 - -typedef struct _FILE FILE; - -extern FILE *fopen(const char *, const char *mode); -extern FILE *freopen(const char *path, const char *mode, FILE *fp); -extern int fclose(FILE *fp); - -extern int fflush(FILE *fp); -extern void setbuf(FILE *fp, char *buf); -extern int setvbuf(FILE *fp, char *buf, size_t size); - -extern size_t fread(void *ptr, size_t size, size_t n, FILE *fp); -extern size_t fwrite(const void *ptr, size_t size, size_t n, FILE *fp); - -extern int fgetc(FILE *fp); -extern int getc(FILE *fp); -extern int getchar(void); - -extern int fputc(int c, FILE *fp); -extern int putc(int c, FILE *fp); -extern int putchar(int c); - -extern char *fgets(char *s, int size, FILE *fp); -extern char *gets(char *s); - -extern int fputs(char *s, FILE *fp); -extern int puts(char *s); - -extern int scanf(const char *fmt, ...); -extern int fscanf(FILE *fp, const char *fmt, ...); -extern int sscanf(char *s, const char *fmt, ...); - -extern int printf(const char *fmt, ...); -extern int fprintf(FILE *fp, const char *fmt, ...); -extern int sprintf(char *s, const char *fmt, ...); -extern int snprintf(char *s, size_t size, const char *fmt, ...); - -extern void perror(const char *s); - -extern long ftell(FILE *fp); -extern long fseek(FILE *fp); -extern void rewind(FILE *fp); - -extern void clearerr(FILE *fp); -extern int feof(FILE *fp); -extern int ferror(FILE *fp); - -extern int remove(const char *name); -extern int rename(const char *old, const char *new); -extern FILE *tmpfile(void); -extern FILE *tmpnam(char *s); - -extern FILE *stdin, *stdout, *stderr; -#endif diff --git a/libc/include/qbe/arch/stdio.h b/libc/include/qbe/arch/stdio.h @@ -0,0 +1,18 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef _SIZET +typedef unsigned long size_t; +#define _SIZET +#endif + +#define BUFSIZ 512 +#define FILENAME_MAX 256 +#define FOPEN_MAX 16 + +#define TMP_MAX 25 +#define L_tmpnam 256 + +typedef struct _FILE FILE; diff --git a/libc/include/qbe/stdio.h b/libc/include/qbe/stdio.h @@ -1,79 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDIO_H -#define _STDIO_H - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#ifndef _SIZET -typedef unsigned long size_t; -#define _SIZET -#endif - -#define EOF -1 -#define BUFSIZ 512 -#define FILENAME_MAX 256 -#define FOPEN_MAX 16 -#define _IOFBF 0 -#define _IOLBF 1 -#define _IONBF 2 -#define L_tmpnam 256 -#define SEEK_CUR 0 -#define SEEK_END 1 -#define SEEK_SET 2 -#define TMP_MAX 25 - -typedef struct _FILE FILE; - -extern FILE *fopen(const char *, const char *mode); -extern FILE *freopen(const char *path, const char *mode, FILE *fp); -extern int fclose(FILE *fp); - -extern int fflush(FILE *fp); -extern void setbuf(FILE *fp, char *buf); -extern int setvbuf(FILE *fp, char *buf, size_t size); - -extern size_t fread(void *ptr, size_t size, size_t n, FILE *fp); -extern size_t fwrite(const void *ptr, size_t size, size_t n, FILE *fp); - -extern int fgetc(FILE *fp); -extern int getc(FILE *fp); -extern int getchar(void); - -extern int fputc(int c, FILE *fp); -extern int putc(int c, FILE *fp); -extern int putchar(int c); - -extern char *fgets(char *s, int size, FILE *fp); -extern char *gets(char *s); - -extern int fputs(char *s, FILE *fp); -extern int puts(char *s); - -extern int scanf(const char *fmt, ...); -extern int fscanf(FILE *fp, const char *fmt, ...); -extern int sscanf(char *s, const char *fmt, ...); - -extern int printf(const char *fmt, ...); -extern int fprintf(FILE *fp, const char *fmt, ...); -extern int sprintf(char *s, const char *fmt, ...); -extern int snprintf(char *s, size_t size, const char *fmt, ...); - -extern void perror(const char *s); - -extern long ftell(FILE *fp); -extern long fseek(FILE *fp); -extern void rewind(FILE *fp); - -extern void clearerr(FILE *fp); -extern int feof(FILE *fp); -extern int ferror(FILE *fp); - -extern int remove(const char *name); -extern int rename(const char *old, const char *new); -extern FILE *tmpfile(void); -extern FILE *tmpnam(char *s); - -extern FILE *stdin, *stdout, *stderr; -#endif diff --git a/libc/include/stdio.h b/libc/include/stdio.h @@ -0,0 +1,66 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef _STDIO_H +#define _STDIO_H + +#include <arch/stdio.h> + +#define EOF -1 +#define _IOFBF 0 +#define _IOLBF 1 +#define _IONBF 2 +#define SEEK_CUR 0 +#define SEEK_END 1 +#define SEEK_SET 2 + + +extern FILE *fopen(const char *, const char *mode); +extern FILE *freopen(const char *path, const char *mode, FILE *fp); +extern int fclose(FILE *fp); + +extern int fflush(FILE *fp); +extern void setbuf(FILE *fp, char *buf); +extern int setvbuf(FILE *fp, char *buf, size_t size); + +extern size_t fread(void *ptr, size_t size, size_t n, FILE *fp); +extern size_t fwrite(const void *ptr, size_t size, size_t n, FILE *fp); + +extern int fgetc(FILE *fp); +extern int getc(FILE *fp); +extern int getchar(void); + +extern int fputc(int c, FILE *fp); +extern int putc(int c, FILE *fp); +extern int putchar(int c); + +extern char *fgets(char *s, int size, FILE *fp); +extern char *gets(char *s); + +extern int fputs(char *s, FILE *fp); +extern int puts(char *s); + +extern int scanf(const char *fmt, ...); +extern int fscanf(FILE *fp, const char *fmt, ...); +extern int sscanf(char *s, const char *fmt, ...); + +extern int printf(const char *fmt, ...); +extern int fprintf(FILE *fp, const char *fmt, ...); +extern int sprintf(char *s, const char *fmt, ...); +extern int snprintf(char *s, size_t size, const char *fmt, ...); + +extern void perror(const char *s); + +extern long ftell(FILE *fp); +extern long fseek(FILE *fp); +extern void rewind(FILE *fp); + +extern void clearerr(FILE *fp); +extern int feof(FILE *fp); +extern int ferror(FILE *fp); + +extern int remove(const char *name); +extern int rename(const char *old, const char *new); +extern FILE *tmpfile(void); +extern FILE *tmpnam(char *s); + +extern FILE *stdin, *stdout, *stderr; +#endif diff --git a/libc/include/z80/arch/stdio.h b/libc/include/z80/arch/stdio.h @@ -0,0 +1,18 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef _SIZET +typedef unsigned size_t; +#define _SIZET +#endif + +#define BUFSIZ 512 +#define FILENAME_MAX 256 +#define FOPEN_MAX 16 + +#define TMP_MAX 25 +#define L_tmpnam 256 + +typedef struct _FILE FILE; diff --git a/libc/include/z80/stdio.h b/libc/include/z80/stdio.h @@ -1,79 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#ifndef _STDIO_H -#define _STDIO_H - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#ifndef _SIZET -typedef unsigned size_t; -#define _SIZET -#endif - -#define EOF -1 -#define BUFSIZ 512 -#define FILENAME_MAX 256 -#define FOPEN_MAX 16 -#define _IOFBF 0 -#define _IOLBF 1 -#define _IONBF 2 -#define L_tmpnam 256 -#define SEEK_CUR 0 -#define SEEK_END 1 -#define SEEK_SET 2 -#define TMP_MAX 25 - -typedef struct _FILE FILE; - -extern FILE *fopen(const char *, const char *mode); -extern FILE *freopen(const char *path, const char *mode, FILE *fp); -extern int fclose(FILE *fp); - -extern int fflush(FILE *fp); -extern void setbuf(FILE *fp, char *buf); -extern int setvbuf(FILE *fp, char *buf, size_t size); - -extern size_t fread(void *ptr, size_t size, size_t n, FILE *fp); -extern size_t fwrite(const void *ptr, size_t size, size_t n, FILE *fp); - -extern int fgetc(FILE *fp); -extern int getc(FILE *fp); -extern int getchar(void); - -extern int fputc(int c, FILE *fp); -extern int putc(int c, FILE *fp); -extern int putchar(int c); - -extern char *fgets(char *s, int size, FILE *fp); -extern char *gets(char *s); - -extern int fputs(char *s, FILE *fp); -extern int puts(char *s); - -extern int scanf(const char *fmt, ...); -extern int fscanf(FILE *fp, const char *fmt, ...); -extern int sscanf(char *s, const char *fmt, ...); - -extern int printf(const char *fmt, ...); -extern int fprintf(FILE *fp, const char *fmt, ...); -extern int sprintf(char *s, const char *fmt, ...); -extern int snprintf(char *s, size_t size, const char *fmt, ...); - -extern void perror(const char *s); - -extern long ftell(FILE *fp); -extern long fseek(FILE *fp); -extern void rewind(FILE *fp); - -extern void clearerr(FILE *fp); -extern int feof(FILE *fp); -extern int ferror(FILE *fp); - -extern int remove(const char *name); -extern int rename(const char *old, const char *new); -extern FILE *tmpfile(void); -extern FILE *tmpnam(char *s); - -extern FILE *stdin, *stdout, *stderr; -#endif diff --git a/libc/src/Makefile b/libc/src/Makefile @@ -1,3 +1,5 @@ +# See LICENSE file for copyright and license details. +.POSIX: LIBCOBJ = assert.o