* 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.
This commit is contained in:
Thomas Fitzsimmons 2002-05-08 19:11:22 +00:00
parent 96bff22c5d
commit 7649080606
9 changed files with 343 additions and 13 deletions

View File

@ -1,3 +1,15 @@
2002-05-08 Thomas Fitzsimmons <fitzsim@redhat.com>
* 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.
Wed May 8 17:47:35 2002 J"orn Rennecke <joern.rennecke@superh.com>
* libc/machine/sh/memset.S (memset, __SHMEDIA__ code):

View File

@ -222,9 +222,13 @@ FILE * _EXFUN(popen, (const char *, const char *));
int _EXFUN(putw, (int, FILE *));
void _EXFUN(setbuffer, (FILE *, char *, int));
int _EXFUN(setlinebuf, (FILE *));
void _EXFUN(flockfile, (FILE *));
int _EXFUN(ftrylockfile, (FILE *));
void _EXFUN(funlockfile, (FILE *));
int _EXFUN(getc_unlocked, (FILE *));
int _EXFUN(getchar_unlocked, (void));
void _EXFUN(flockfile, (FILE *));
int _EXFUN(ftrylockfile, (FILE *));
void _EXFUN(funlockfile, (FILE *));
int _EXFUN(putc_unlocked, (int, FILE *));
int _EXFUN(putchar_unlocked, (int));
#endif
/*

View File

@ -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 \

View File

@ -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)

View File

@ -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
<<getc_unlocked>>---non-thread-safe version of getc (macro)
INDEX
getc_unlocked
POSIX_SYNOPSIS
#include <stdio.h>
int getc_unlocked(FILE *<[fp]>);
DESCRIPTION
<<getc_unlocked>> is a non-thread-safe version of <<getc>> declared in
<<stdio.h>>. <<getc_unlocked>> 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
<<getc_unlocked>> is equivalent to <<getc>>.
RETURNS
See <<getc>>.
PORTABILITY
POSIX 1003.1 requires <<getc_unlocked>>. <<getc_unlocked>> may be
implemented as a macro, so arguments should not have side-effects.
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
/*
* 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);
}

View File

@ -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
<<getchar_unlocked>>---non-thread-safe version of getchar (macro)
INDEX
getchar_unlocked
POSIX_SYNOPSIS
#include <stdio.h>
int getchar_unlocked();
DESCRIPTION
<<getchar_unlocked>> is a non-thread-safe version of <<getchar>>
declared in <<stdio.h>>. <<getchar_unlocked>> 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 <<getchar_unlocked>> is equivalent to <<getchar>>.
RETURNS
See <<getchar>>.
PORTABILITY
POSIX 1003.1 requires <<getchar_unlocked>>. <<getchar_unlocked>> may
be implemented as a macro.
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. */
#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 <stdio.h>
#include <reent.h>
#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

View File

@ -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
<<putc_unlocked>>---non-thread-safe version of putc (macro)
INDEX
putc_unlocked
POSIX_SYNOPSIS
#include <stdio.h>
int putc_unlocked(int <[ch]>, FILE *<[fp]>);
DESCRIPTION
<<putc_unlocked>> is a non-thread-safe version of <<putc>> declared in
<<stdio.h>>. <<putc_unlocked>> 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
<<putc_unlocked>> is equivalent to <<putc>>.
RETURNS
See <<putc>>.
PORTABILITY
POSIX 1003.1 requires <<putc_unlocked>>. <<putc_unlocked>> may be
implemented as a macro, so arguments should not have side-effects.
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
/*
* 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);
}

View File

@ -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 <stdio.h>
@ -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

View File

@ -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
<<putchar_unlocked>>---non-thread-safe version of putchar (macro)
INDEX
putchar_unlocked
POSIX_SYNOPSIS
#include <stdio.h>
int putchar_unlocked(int <[ch]>);
DESCRIPTION
<<putchar_unlocked>> is a non-thread-safe version of <<putchar>>
declared in <<stdio.h>>. <<putchar_unlocked>> 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 <<putchar_unlocked>> is equivalent to <<putchar>>.
RETURNS
See <<putchar>>.
PORTABILITY
POSIX 1003.1 requires <<putchar_unlocked>>. <<putchar_unlocked>> may
be implemented as a macro.
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. */
#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 <stdio.h>
#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