-/* Copyright (C) 1993, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>.
As a special exception, if you link the code in this file with
files compiled with a GNU compiler to produce an executable,
CHECK_FILE (fp, NULL);
if (n <= 0)
return NULL;
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
+ if (__glibc_unlikely (n == 1))
+ {
+ /* Another irregular case: since we have to store a NUL byte and
+ there is only room for exactly one byte, we don't have to
+ read anything. */
+ buf[0] = '\0';
+ return buf;
+ }
+ _IO_acquire_lock (fp);
/* This is very tricky since a file descriptor may be in the
non-blocking mode. The error flag doesn't mean much in this
case. We return an error only when there is a new error. */
result = buf;
}
fp->_IO_file_flags |= old_error;
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
+ _IO_release_lock (fp);
return result;
}
weak_alias (_IO_fgets, fgets)
# ifndef _IO_MTSAFE_IO
+strong_alias (_IO_fgets, __fgets_unlocked)
+libc_hidden_def (__fgets_unlocked)
weak_alias (_IO_fgets, fgets_unlocked)
+libc_hidden_weak (fgets_unlocked)
# endif
#endif