From patchwork Mon Mar 7 16:14:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 11231 Received: (qmail 117701 invoked by alias); 7 Mar 2016 16:14:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 117689 invoked by uid 89); 7 Mar 2016 16:14:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 spammy=Allocate, errno, 5541, devices X-HELO: mx1.redhat.com From: Florian Weimer X-Enigmail-Draft-Status: N1110 To: GNU C Library Subject: [PATCH COMMITTED] libio: Clean up _IO_file_doallocate and _IO_wfile_doallocate Message-ID: <56DDA8CB.5040704@redhat.com> Date: Mon, 7 Mar 2016 17:14:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 This is the non-controversial clean-up part of the patch discussed here: Florian 2016-03-07 Florian Weimer * libio/filedoalloc.c (isatty): Remove. (local_isatty): Add comment. Call __isatty directly. (_IO_file_doallocate): Update comment. Assume _LIBC. * libio/wfiledoalloc.c (isatty): Remove. (_IO_wfile_doallocate): Update comment. diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c index b51e910..4f9d738 100644 --- a/libio/filedoalloc.c +++ b/libio/filedoalloc.c @@ -55,41 +55,24 @@ /* Modified for GNU iostream by Per Bothner 1991, 1992. */ -#ifndef _POSIX_SOURCE -# define _POSIX_SOURCE -#endif #include "libioP.h" -#include +#include #include #include #include -#ifdef _LIBC -# undef isatty -# define isatty(Fd) __isatty (Fd) - -# include -#endif - - +/* Return the result of isatty, without changing errno. */ static int local_isatty (int fd) { int save_errno = errno; - int res = isatty (fd); + int res = __isatty (fd); __set_errno (save_errno); return res; } - -/* - * Allocate a file buffer, or switch to unbuffered I/O. - * Per the ANSI C standard, ALL tty devices default to line buffered. - * - * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek - * optimisation) right after the _fstat() that finds the buffer size. - */ - +/* Allocate a file buffer, or switch to unbuffered I/O. Streams for + TTY devices default to line buffered. */ int _IO_file_doallocate (_IO_FILE *fp) { @@ -97,15 +80,6 @@ _IO_file_doallocate (_IO_FILE *fp) char *p; struct stat64 st; -#ifndef _LIBC - /* If _IO_cleanup_registration_needed is non-zero, we should call the - function it points to. This is to make sure _IO_cleanup gets called - on exit. We call it from _IO_file_doallocate, since that is likely - to get called by any program that does buffered I/O. */ - if (__glibc_unlikely (_IO_cleanup_registration_needed != NULL)) - (*_IO_cleanup_registration_needed) (); -#endif - size = _IO_BUFSIZ; if (fp->_fileno >= 0 && __builtin_expect (_IO_SYSSTAT (fp, &st), 0) >= 0) { diff --git a/libio/wfiledoalloc.c b/libio/wfiledoalloc.c index 28c10b6..333b036 100644 --- a/libio/wfiledoalloc.c +++ b/libio/wfiledoalloc.c @@ -55,28 +55,10 @@ /* Modified for GNU iostream by Per Bothner 1991, 1992. */ -#ifndef _POSIX_SOURCE -# define _POSIX_SOURCE -#endif #include "libioP.h" -#include -#include #include -#include - -#ifdef _LIBC -# undef isatty -# define isatty(Fd) __isatty (Fd) -#endif - -/* - * Allocate a file buffer, or switch to unbuffered I/O. - * Per the ANSI C standard, ALL tty devices default to line buffered. - * - * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek - * optimisation) right after the _fstat() that finds the buffer size. - */ +/* Allocate a file buffer, or switch to unbuffered I/O. */ int _IO_wfile_doallocate (_IO_FILE *fp) {