diff options
author | Florian Lohoff <flo@rfc822.org> | 2008-10-04 13:30:01 +0000 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2009-04-26 15:26:25 +0200 |
commit | 7ef5cc75cfd3cf93f7edaf2b1b02e557ae16bf7f (patch) | |
tree | 1e06945ff9a265fd75d27de5eb57e00d4b45fbf3 /common | |
parent | f67b21c9ea33de6070de851762fb84b002ae523b (diff) |
Remove arc references from common libc and add an prom abstraction
Diffstat (limited to 'common')
-rw-r--r-- | common/Makefile | 4 | ||||
-rw-r--r-- | common/prom.h | 4 | ||||
-rw-r--r-- | common/stdio.c | 30 | ||||
-rw-r--r-- | common/stdio.h | 3 |
4 files changed, 24 insertions, 17 deletions
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 <arc.h> +#include <prom.h> #include <stdarg.h> -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; |