From 7ef5cc75cfd3cf93f7edaf2b1b02e557ae16bf7f Mon Sep 17 00:00:00 2001 From: Florian Lohoff Date: Sat, 4 Oct 2008 13:30:01 +0000 Subject: Remove arc references from common libc and add an prom abstraction --- common/Makefile | 4 ++-- common/prom.h | 4 ++++ common/stdio.c | 30 +++++++++++++++--------------- common/stdio.h | 3 +++ 4 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 common/prom.h (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 8a1b06a..3f780f6 100644 --- a/common/Makefile +++ b/common/Makefile @@ -1,6 +1,6 @@ SUBARCH ?= IP22 -CFLAGS += -Wall -O2 -I../arclib -mno-abicalls -G 0 -fno-pic -fno-builtin -I. -DSUBARCH=${SUBARCH} +CFLAGS += -Wall -O2 -mno-abicalls -G 0 -fno-pic -fno-builtin -I. -DSUBARCH=${SUBARCH} HOSTCC = $(CC) HOSTCFLAGS += -Wall -O2 -DSUBARCH=$(SUBARCH) @@ -15,4 +15,4 @@ libc.a: $(OBJECTS) $(AR) -crs $@ $(OBJECTS) clean: - rm -f $(OBJECTS) *~ tags + rm -f $(OBJECTS) $(TARGETS) *~ tags diff --git a/common/prom.h b/common/prom.h new file mode 100644 index 0000000..31852e9 --- /dev/null +++ b/common/prom.h @@ -0,0 +1,4 @@ + +int prom_write(FILE stream, char *buf, unsigned long len, unsigned long *rlen); +int prom_read(FILE stream, char *buf, unsigned long len, unsigned long *rlen); + diff --git a/common/stdio.c b/common/stdio.c index 2d94385..73acbb3 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -4,14 +4,14 @@ #include "string.h" #include "stdio.h" -#include +#include #include -static FILE arc_stdin = ARC_STDIN; -FILE *stdin = &arc_stdin; +static FILE stdin_file = STDIN_FILENO; +FILE *stdin = &stdin_file; -static FILE arc_stdout = ARC_STDOUT; -FILE *stdout = &arc_stdout; +static FILE stdout_file = STDOUT_FILENO; +FILE *stdout = &stdout_file; int fputs(const char *s, FILE * stream) @@ -20,8 +20,8 @@ int fputs(const char *s, FILE * stream) unsigned long count; if (strlen(s) > 0) { - status = ArcWrite(*stream, (char *) s, strlen(s), &count); - if ((status != ESUCCESS) || (count != strlen(s))) + status = prom_write(*stream, (char *) s, strlen(s), &count); + if ((status != 0) || (count != strlen(s))) return EOF; } return 0; @@ -44,8 +44,8 @@ int fgetc(FILE * stream) char ch; unsigned long count; - status = ArcRead(*stream, &ch, sizeof(CHAR), &count); - if ((status != ESUCCESS) || (count != sizeof(CHAR))) + status = prom_read(*stream, &ch, sizeof(char), &count); + if ((status != 0) || (count != sizeof(char))) return EOF; return (int) ch; } @@ -86,15 +86,15 @@ int vfprintf(FILE * stream, const char *format, va_list ap) break; } else { if (format < str) { - LONG status; - ULONG count; - ULONG len = str - format; + long status; + unsigned long count; + unsigned long len = str - format; status = - ArcWrite(*stream, + prom_write(*stream, (char *) format, len, &count); - if ((status != ESUCCESS) + if ((status != 0) || (count != len)) return EOF; count += len; @@ -207,7 +207,7 @@ int vsprintf(char* string, const char *format, va_list ap) break; } else { if (format < str) { - ULONG len = str - format; + unsigned long len = str - format; strncpy(&string[count], (char *) format, len); diff --git a/common/stdio.h b/common/stdio.h index 9ee52d3..d15603e 100644 --- a/common/stdio.h +++ b/common/stdio.h @@ -8,6 +8,9 @@ typedef unsigned long FILE; +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 + #define EOF (-1) extern FILE *stdin; -- cgit v1.2.3