From 305d6a9e87b8e92f949fecc30a9c4ab77502cbcd Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 27 Feb 2008 02:19:36 +0000 Subject: [PATCH] added concrete implementations of putc(), getc(), getchar() and gets() this is needed for anything that wants to link against real functions, such as libstdc++ git-svn-id: https://svn.aros.org:8080/svn/aros/trunk/AROS@27921 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/clib/getc.c | 54 +++++++++++++++++++++++++++++++ compiler/clib/getchar.c | 53 +++++++++++++++++++++++++++++++ compiler/clib/gets.c | 60 +++++++++++++++++++++++++++++++++++ compiler/clib/include/sys/syscall.def | 4 +++ compiler/clib/mmakefile.src | 4 +++ compiler/clib/putc.c | 54 +++++++++++++++++++++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 compiler/clib/getc.c create mode 100644 compiler/clib/getchar.c create mode 100644 compiler/clib/gets.c create mode 100644 compiler/clib/putc.c diff --git a/compiler/clib/getc.c b/compiler/clib/getc.c new file mode 100644 index 000000000..a8d4a836f --- /dev/null +++ b/compiler/clib/getc.c @@ -0,0 +1,54 @@ +/* + Copyright © 1995-2007, The AROS Development Team. All rights reserved. + $Id$ + + ANSI C function getc(). +*/ + +#include +#include +#include +#include +#include +#include "__errno.h" +#include "__open.h" + +#include +#undef getc + +/***************************************************************************** + + NAME */ +#include + + int getc ( + +/* SYNOPSIS */ + FILE * stream) + +/* FUNCTION + Read one character from the stream. If there is no character + available or an error occurred, the function returns EOF. + + INPUTS + stream - Read from this stream + + RESULT + The character read or EOF on end of file or error. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + fgetc(), fputc(), putc() + + INTERNALS + +******************************************************************************/ +{ + return fgetc(stream); +} /* getc */ + diff --git a/compiler/clib/getchar.c b/compiler/clib/getchar.c new file mode 100644 index 000000000..16f3c671c --- /dev/null +++ b/compiler/clib/getchar.c @@ -0,0 +1,53 @@ +/* + Copyright © 1995-2007, The AROS Development Team. All rights reserved. + $Id$ + + ANSI C function getchar(). +*/ + +#include +#include +#include +#include +#include +#include "__errno.h" +#include "__open.h" + +#include +#undef getchar + +/***************************************************************************** + + NAME */ +#include + + int getchar (void) + +/* SYNOPSIS */ + +/* FUNCTION + Read one character from the standard input stream. If there + is no character available or an error occurred, the function + returns EOF. + + INPUTS + + RESULT + The character read or EOF on end of file or error. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + fgetc(), getc(), fputc(), putc() + + INTERNALS + +******************************************************************************/ +{ + return getc(stdin); +} /* getc */ + diff --git a/compiler/clib/gets.c b/compiler/clib/gets.c new file mode 100644 index 000000000..5ec3fcdd1 --- /dev/null +++ b/compiler/clib/gets.c @@ -0,0 +1,60 @@ +/* + Copyright © 1995-2007, The AROS Development Team. All rights reserved. + $Id$ + + ANSI C function gets(). +*/ + +#include +#include +#include +#include +#include +#include "__open.h" +#include "__errno.h" + +#include +#undef gets + +/***************************************************************************** + + NAME */ +#include + + char * gets ( + +/* SYNOPSIS */ + char * buffer) + +/* FUNCTION + Read one line of characters from the standard input stream into + the buffer. Reading will stop, when a newline ('\n') is encountered, + EOF or when the buffer is full. If a newline is read, then it is + put into the buffer. The last character in the buffer is always + '\0' (Therefore at most size-1 characters can be read in one go). + + INPUTS + buffer - Write characters into this buffer + + RESULT + buffer or NULL in case of an error or EOF. + + NOTES + + EXAMPLE + + BUGS + Never use this function. gets() does not know how large the buffer + is and will continue to store characters past the end of the buffer + if it has not encountered a newline or EOF yet. Use fgets() instead. + + SEE ALSO + fgets() + + INTERNALS + +******************************************************************************/ +{ + return fgets(buffer, BUFSIZ, stdin); +} /* gets */ + diff --git a/compiler/clib/include/sys/syscall.def b/compiler/clib/include/sys/syscall.def index 5d7519b18..e29db5100 100644 --- a/compiler/clib/include/sys/syscall.def +++ b/compiler/clib/include/sys/syscall.def @@ -239,3 +239,7 @@ SYSTEM_CALL (regcomp) SYSTEM_CALL (regerror) SYSTEM_CALL (regexec) SYSTEM_CALL (regfree) +SYSTEM_CALL (putc) +SYSTEM_CALL (getc) +SYSTEM_CALL (getchar) +SYSTEM_CALL (gets) diff --git a/compiler/clib/mmakefile.src b/compiler/clib/mmakefile.src index 46133f96d..5d5b78349 100644 --- a/compiler/clib/mmakefile.src +++ b/compiler/clib/mmakefile.src @@ -175,6 +175,8 @@ SHARED := \ ftruncate \ fwrite \ gcvt \ + getc \ + getchar \ getcwd \ getenv \ getfsstat \ @@ -193,6 +195,7 @@ SHARED := \ getpwent \ getpwnam \ getpwuid \ + gets \ getw \ getloadavg \ gmtime \ @@ -256,6 +259,7 @@ SHARED := \ posix_memalign \ printf \ putenv \ + putc \ puts \ putw \ qsort \ diff --git a/compiler/clib/putc.c b/compiler/clib/putc.c new file mode 100644 index 000000000..8b41b4aef --- /dev/null +++ b/compiler/clib/putc.c @@ -0,0 +1,54 @@ +/* + Copyright © 1995-2003, The AROS Development Team. All rights reserved. + $Id$ + + ANSI C function putc(). +*/ + +#include +#include +#include +#include +#include +#include "__open.h" +#include "__errno.h" + +#include +#undef putc + +/***************************************************************************** + + NAME */ +#include + + int putc ( + +/* SYNOPSIS */ + int c, + FILE * stream) + +/* FUNCTION + Write one character to the specified stream. + + INPUTS + c - The character to output + stream - The character is written to this stream + + RESULT + The character written or EOF on error. + + NOTES + + EXAMPLE + + BUGS + + SEE ALSO + + INTERNALS + +******************************************************************************/ +{ + return fputc(c, stream); +} /* putc */ + -- 2.11.4.GIT