From 76490806069d5f64a9060aff78484ec5f6b82061 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 8 May 2002 19:11:22 +0000 Subject: * libc/stdio/getc_u.c: New file. * libc/stdio/getchar_u.c: New file. * libc/stdio/putc_u.c: New file. * libc/stdio/putchar_u.c: New file. * libc/include/stdio.h: Add declarations for getc_unlocked, getchar_unlocked, putc_unlocked and putchar_unlocked. * libc/stdio/Makefile.am (LIB_SOURCES): Add new files. (CHEWOUT_FILES): Add new files' .def's. * libc/stdio/putchar.c (_putchar_r): Replace __sputc with putc. --- newlib/libc/stdio/Makefile.am | 8 +++++ newlib/libc/stdio/Makefile.in | 26 +++++++++----- newlib/libc/stdio/getc_u.c | 68 ++++++++++++++++++++++++++++++++++++ newlib/libc/stdio/getchar_u.c | 79 ++++++++++++++++++++++++++++++++++++++++++ newlib/libc/stdio/putc_u.c | 69 +++++++++++++++++++++++++++++++++++++ newlib/libc/stdio/putchar.c | 4 +-- newlib/libc/stdio/putchar_u.c | 80 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 324 insertions(+), 10 deletions(-) create mode 100644 newlib/libc/stdio/getc_u.c create mode 100644 newlib/libc/stdio/getchar_u.c create mode 100644 newlib/libc/stdio/putc_u.c create mode 100644 newlib/libc/stdio/putchar_u.c (limited to 'newlib/libc/stdio') diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am index 8010c7203..c859cbfc0 100644 --- a/newlib/libc/stdio/Makefile.am +++ b/newlib/libc/stdio/Makefile.am @@ -33,6 +33,8 @@ LIB_SOURCES = \ fwrite.c \ getc.c \ getchar.c \ + getc_u.c \ + getchar_u.c \ gets.c \ getw.c \ iprintf.c \ @@ -42,6 +44,8 @@ LIB_SOURCES = \ printf.c \ putc.c \ putchar.c \ + putc_u.c \ + putchar_u.c \ puts.c \ putw.c \ refill.c \ @@ -121,6 +125,8 @@ CHEWOUT_FILES = \ fwrite.def \ getc.def \ getchar.def \ + getc_u.def \ + getchar_u.def \ gets.def \ getw.def \ iprintf.def \ @@ -128,6 +134,8 @@ CHEWOUT_FILES = \ perror.def \ putc.def \ putchar.def \ + putc_u.def \ + putchar_u.def \ puts.def \ putw.def \ remove.def \ diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index 6e60de47f..aff17a32a 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -131,6 +131,8 @@ LIB_SOURCES = \ fwrite.c \ getc.c \ getchar.c \ + getc_u.c \ + getchar_u.c \ gets.c \ getw.c \ iprintf.c \ @@ -140,6 +142,8 @@ LIB_SOURCES = \ printf.c \ putc.c \ putchar.c \ + putc_u.c \ + putchar_u.c \ puts.c \ putw.c \ refill.c \ @@ -206,6 +210,8 @@ CHEWOUT_FILES = \ fwrite.def \ getc.def \ getchar.def \ + getc_u.def \ + getchar_u.def \ gets.def \ getw.def \ iprintf.def \ @@ -213,6 +219,8 @@ CHEWOUT_FILES = \ perror.def \ putc.def \ putchar.def \ + putc_u.def \ + putchar_u.def \ puts.def \ putw.def \ remove.def \ @@ -251,8 +259,9 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@findfp.o fiprintf.o flags.o fopen.o fprintf.o \ @USE_LIBTOOL_FALSE@fputc.o fputs.o fread.o freopen.o fscanf.o fseek.o \ @USE_LIBTOOL_FALSE@fsetpos.o ftell.o fvwrite.o fwalk.o fwrite.o getc.o \ -@USE_LIBTOOL_FALSE@getchar.o gets.o getw.o iprintf.o makebuf.o mktemp.o \ -@USE_LIBTOOL_FALSE@perror.o printf.o putc.o putchar.o puts.o putw.o \ +@USE_LIBTOOL_FALSE@getchar.o getc_u.o getchar_u.o gets.o getw.o \ +@USE_LIBTOOL_FALSE@iprintf.o makebuf.o mktemp.o perror.o printf.o \ +@USE_LIBTOOL_FALSE@putc.o putchar.o putc_u.o putchar_u.o puts.o putw.o \ @USE_LIBTOOL_FALSE@refill.o remove.o rename.o rewind.o rget.o scanf.o \ @USE_LIBTOOL_FALSE@setbuf.o setvbuf.o siprintf.o snprintf.o sprintf.o \ @USE_LIBTOOL_FALSE@sscanf.o stdio.o tmpfile.o tmpnam.o ungetc.o \ @@ -268,12 +277,13 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@fopen.lo fprintf.lo fputc.lo fputs.lo fread.lo \ @USE_LIBTOOL_TRUE@freopen.lo fscanf.lo fseek.lo fsetpos.lo ftell.lo \ @USE_LIBTOOL_TRUE@fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \ -@USE_LIBTOOL_TRUE@gets.lo getw.lo iprintf.lo makebuf.lo mktemp.lo \ -@USE_LIBTOOL_TRUE@perror.lo printf.lo putc.lo putchar.lo puts.lo \ -@USE_LIBTOOL_TRUE@putw.lo refill.lo remove.lo rename.lo rewind.lo \ -@USE_LIBTOOL_TRUE@rget.lo scanf.lo setbuf.lo setvbuf.lo siprintf.lo \ -@USE_LIBTOOL_TRUE@snprintf.lo sprintf.lo sscanf.lo stdio.lo tmpfile.lo \ -@USE_LIBTOOL_TRUE@tmpnam.lo ungetc.lo vfscanf.lo vprintf.lo vscanf.lo \ +@USE_LIBTOOL_TRUE@getc_u.lo getchar_u.lo gets.lo getw.lo iprintf.lo \ +@USE_LIBTOOL_TRUE@makebuf.lo mktemp.lo perror.lo printf.lo putc.lo \ +@USE_LIBTOOL_TRUE@putchar.lo putc_u.lo putchar_u.lo puts.lo putw.lo \ +@USE_LIBTOOL_TRUE@refill.lo remove.lo rename.lo rewind.lo rget.lo \ +@USE_LIBTOOL_TRUE@scanf.lo setbuf.lo setvbuf.lo siprintf.lo snprintf.lo \ +@USE_LIBTOOL_TRUE@sprintf.lo sscanf.lo stdio.lo tmpfile.lo tmpnam.lo \ +@USE_LIBTOOL_TRUE@ungetc.lo vfscanf.lo vprintf.lo vscanf.lo \ @USE_LIBTOOL_TRUE@vsnprintf.lo vsprintf.lo vsscanf.lo wbuf.lo wsetup.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/newlib/libc/stdio/getc_u.c b/newlib/libc/stdio/getc_u.c new file mode 100644 index 000000000..877c7f8a0 --- /dev/null +++ b/newlib/libc/stdio/getc_u.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* +FUNCTION +<>---non-thread-safe version of getc (macro) + +INDEX + getc_unlocked + +POSIX_SYNOPSIS + #include + int getc_unlocked(FILE *<[fp]>); + +DESCRIPTION +<> is a non-thread-safe version of <> declared in +<>. <> may only safely be used within a scope +protected by flockfile() (or ftrylockfile()) and funlockfile(). These +functions may safely be used in a multi-threaded program if and only +if they are called while the invoking thread owns the ( FILE *) +object, as is the case after a successful call to the flockfile() or +ftrylockfile() functions. If threads are disabled, then +<> is equivalent to <>. + +RETURNS +See <>. + +PORTABILITY +POSIX 1003.1 requires <>. <> may be +implemented as a macro, so arguments should not have side-effects. + +Supporting OS subroutines required: <>, <>, <>, +<>, <>, <>, <>. */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +#include + +/* + * A subroutine version of the macro getc_unlocked. + */ + +#undef getc_unlocked + +int +getc_unlocked (fp) + register FILE *fp; +{ + /* CHECK_INIT is called (eventually) by __srefill. */ + + return __sgetc (fp); +} diff --git a/newlib/libc/stdio/getchar_u.c b/newlib/libc/stdio/getchar_u.c new file mode 100644 index 000000000..f36f88810 --- /dev/null +++ b/newlib/libc/stdio/getchar_u.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* +FUNCTION +<>---non-thread-safe version of getchar (macro) + +INDEX + getchar_unlocked + +POSIX_SYNOPSIS + #include + int getchar_unlocked(); + +DESCRIPTION +<> is a non-thread-safe version of <> +declared in <>. <> may only safely be used +within a scope protected by flockfile() (or ftrylockfile()) and +funlockfile(). These functions may safely be used in a multi-threaded +program if and only if they are called while the invoking thread owns +the ( FILE *) object, as is the case after a successful call to the +flockfile() or ftrylockfile() functions. If threads are disabled, +then <> is equivalent to <>. + +RETURNS +See <>. + +PORTABILITY +POSIX 1003.1 requires <>. <> may +be implemented as a macro. + +Supporting OS subroutines required: <>, <>, <>, +<>, <>, <>, <>. */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +/* + * A subroutine version of the macro getchar_unlocked. + */ + +#include +#include + +#undef getchar_unlocked + +int +_getchar_unlocked_r (f) + struct _reent *f; +{ + return getc_unlocked (_stdin_r (f)); +} + +#ifndef _REENT_ONLY + +int +getchar_unlocked () +{ + /* CHECK_INIT is called (eventually) by __srefill. */ + + return _getchar_unlocked_r (_REENT); +} + +#endif diff --git a/newlib/libc/stdio/putc_u.c b/newlib/libc/stdio/putc_u.c new file mode 100644 index 000000000..a3c0e0864 --- /dev/null +++ b/newlib/libc/stdio/putc_u.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* +FUNCTION +<>---non-thread-safe version of putc (macro) + +INDEX + putc_unlocked + +POSIX_SYNOPSIS + #include + int putc_unlocked(int <[ch]>, FILE *<[fp]>); + +DESCRIPTION +<> is a non-thread-safe version of <> declared in +<>. <> may only safely be used within a scope +protected by flockfile() (or ftrylockfile()) and funlockfile(). These +functions may safely be used in a multi-threaded program if and only +if they are called while the invoking thread owns the ( FILE *) +object, as is the case after a successful call to the flockfile() or +ftrylockfile() functions. If threads are disabled, then +<> is equivalent to <>. + +RETURNS +See <>. + +PORTABILITY +POSIX 1003.1 requires <>. <> may be +implemented as a macro, so arguments should not have side-effects. + +Supporting OS subroutines required: <>, <>, <>, +<>, <>, <>, <>. */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +#include + +/* + * A subroutine version of the macro putc_unlocked. + */ + +#undef putc_unlocked + +int +putc_unlocked (c, fp) + int c; + register FILE *fp; +{ + /* CHECK_INIT is (eventually) called by __swbuf. */ + + return __sputc (c, fp); +} diff --git a/newlib/libc/stdio/putchar.c b/newlib/libc/stdio/putchar.c index b725a496d..ff207f3d0 100644 --- a/newlib/libc/stdio/putchar.c +++ b/newlib/libc/stdio/putchar.c @@ -65,7 +65,7 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ /* - * A subroutine version of the macro putchar + * A subroutine version of the macro putchar. */ #include @@ -80,7 +80,7 @@ _putchar_r (ptr, c) int c; { _REENT_SMALL_CHECK_INIT(_stdout_r (ptr)); - return __sputc (c, _stdout_r (ptr)); + return putc (c, _stdout_r (ptr)); } #ifndef _REENT_ONLY diff --git a/newlib/libc/stdio/putchar_u.c b/newlib/libc/stdio/putchar_u.c new file mode 100644 index 000000000..3542fe443 --- /dev/null +++ b/newlib/libc/stdio/putchar_u.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* +FUNCTION +<>---non-thread-safe version of putchar (macro) + +INDEX + putchar_unlocked + +POSIX_SYNOPSIS + #include + int putchar_unlocked(int <[ch]>); + +DESCRIPTION +<> is a non-thread-safe version of <> +declared in <>. <> may only safely be used +within a scope protected by flockfile() (or ftrylockfile()) and +funlockfile(). These functions may safely be used in a multi-threaded +program if and only if they are called while the invoking thread owns +the ( FILE *) object, as is the case after a successful call to the +flockfile() or ftrylockfile() functions. If threads are disabled, +then <> is equivalent to <>. + +RETURNS +See <>. + +PORTABILITY +POSIX 1003.1 requires <>. <> may +be implemented as a macro. + +Supporting OS subroutines required: <>, <>, <>, +<>, <>, <>, <>. */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +/* + * A subroutine version of the macro putchar_unlocked. + */ + +#include + +#undef putchar_unlocked + +int +_putchar_unlocked_r (ptr, c) + struct _reent *ptr; + int c; +{ + return putc_unlocked (c, _stdout_r (ptr)); +} + +#ifndef _REENT_ONLY + +int +putchar_unlocked (c) + int c; +{ + /* CHECK_INIT is (eventually) called by __swbuf. */ + + _putchar_unlocked_r (_REENT, c); +} + +#endif -- cgit v1.2.3