1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

libio: Implement internal function __libc_readline_unlocked

This is a variant of fgets which fails with ERANGE if the
buffer is too small, and the buffer length is given as an
argument of type size_t.

This function will be useful for implementing NSS file reading
operations.  Compared to a direct implementation using the public API,
it avoids an lseek system call in case the line terminator can be
found in the internal read buffer.
This commit is contained in:
Florian Weimer
2018-07-06 16:53:48 +02:00
parent 397c54c1af
commit 3f5e3f5d06
10 changed files with 471 additions and 9 deletions

View File

@@ -24,11 +24,15 @@
This exception applies to code released by its copyright holders
in files containing the exception. */
/* We need to disable the redirect for __fseeko64 for the alias
definitions below to work. */
#define __fseeko64 __fseeko64_disable
#include "libioP.h"
#include "stdio.h"
int
fseeko (FILE *fp, off_t offset, int whence)
__fseeko (FILE *fp, off_t offset, int whence)
{
int result;
CHECK_FILE (fp, -1);
@@ -37,7 +41,11 @@ fseeko (FILE *fp, off_t offset, int whence)
_IO_release_lock (fp);
return result;
}
weak_alias (__fseeko, fseeko)
#ifdef __OFF_T_MATCHES_OFF64_T
weak_alias (fseeko, fseeko64)
weak_alias (__fseeko, fseeko64)
# undef __fseeko64
strong_alias (__fseeko, __fseeko64)
libc_hidden_ver (__fseeko, __fseeko64)
#endif