static _IO_size_t _IO_file_xsgetn_maybe_mmap (_IO_FILE *fp, void *data, _IO_size_t n) { /* We only get here if this is the first attempt to read something. Decide which operations to use and then punt to the chosen one. */ decide_maybe_mmap (fp); return _IO_XSGETN (fp, data, n); }
static _IO_size_t _IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n) { _IO_size_t have; char *read_ptr = fp->_IO_read_ptr; char *s = (char *) data; have = fp->_IO_read_end - fp->_IO_read_ptr; if (have < n) { if (__glibc_unlikely (_IO_in_backup (fp))) { #ifdef _LIBC s = __mempcpy (s, read_ptr, have); #else memcpy (s, read_ptr, have); s += have; #endif n -= have; _IO_switch_to_main_get_area (fp); read_ptr = fp->_IO_read_ptr; have = fp->_IO_read_end - fp->_IO_read_ptr; } if (have < n) { /* Check that we are mapping all of the file, in case it grew. */ if (__glibc_unlikely (mmap_remap_check (fp))) /* We punted mmap, so complete with the vanilla code. */ return s - (char *) data + _IO_XSGETN (fp, data, n); read_ptr = fp->_IO_read_ptr; have = fp->_IO_read_end - read_ptr; } } if (have < n) fp->_flags |= _IO_EOF_SEEN; if (have != 0) { have = MIN (have, n); #ifdef _LIBC s = __mempcpy (s, read_ptr, have); #else memcpy (s, read_ptr, have); s += have; #endif fp->_IO_read_ptr = read_ptr + have; } return s - (char *) data; }
_IO_size_t _IO_sgetn (_IO_FILE *fp, void *data, _IO_size_t n) { /* FIXME handle putback buffer here! */ return _IO_XSGETN (fp, data, n); }