1*dc6df0beSMatthew Dillon /* 2*dc6df0beSMatthew Dillon * Copyright (c) 2008 The DragonFly Project. All rights reserved. 3*dc6df0beSMatthew Dillon * 4*dc6df0beSMatthew Dillon * This code is derived from software contributed to The DragonFly Project 5*dc6df0beSMatthew Dillon * by Matthew Dillon <dillon@backplane.com> 6*dc6df0beSMatthew Dillon * 7*dc6df0beSMatthew Dillon * Redistribution and use in source and binary forms, with or without 8*dc6df0beSMatthew Dillon * modification, are permitted provided that the following conditions 9*dc6df0beSMatthew Dillon * are met: 10*dc6df0beSMatthew Dillon * 11*dc6df0beSMatthew Dillon * 1. Redistributions of source code must retain the above copyright 12*dc6df0beSMatthew Dillon * notice, this list of conditions and the following disclaimer. 13*dc6df0beSMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright 14*dc6df0beSMatthew Dillon * notice, this list of conditions and the following disclaimer in 15*dc6df0beSMatthew Dillon * the documentation and/or other materials provided with the 16*dc6df0beSMatthew Dillon * distribution. 17*dc6df0beSMatthew Dillon * 3. Neither the name of The DragonFly Project nor the names of its 18*dc6df0beSMatthew Dillon * contributors may be used to endorse or promote products derived 19*dc6df0beSMatthew Dillon * from this software without specific, prior written permission. 20*dc6df0beSMatthew Dillon * 21*dc6df0beSMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*dc6df0beSMatthew Dillon * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*dc6df0beSMatthew Dillon * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24*dc6df0beSMatthew Dillon * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25*dc6df0beSMatthew Dillon * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26*dc6df0beSMatthew Dillon * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 27*dc6df0beSMatthew Dillon * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28*dc6df0beSMatthew Dillon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29*dc6df0beSMatthew Dillon * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30*dc6df0beSMatthew Dillon * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31*dc6df0beSMatthew Dillon * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*dc6df0beSMatthew Dillon * SUCH DAMAGE. 33*dc6df0beSMatthew Dillon * 34*dc6df0beSMatthew Dillon * $DragonFly: src/lib/libc/stdio/sreadahead.c,v 1.1 2008/04/15 01:16:14 dillon Exp $ 35*dc6df0beSMatthew Dillon */ 36*dc6df0beSMatthew Dillon /* 37*dc6df0beSMatthew Dillon * This is an externalized internal function that the M4 package needs. 38*dc6df0beSMatthew Dillon * It was easiest just to throw it into lib. 39*dc6df0beSMatthew Dillon */ 40*dc6df0beSMatthew Dillon 41*dc6df0beSMatthew Dillon #include "namespace.h" 42*dc6df0beSMatthew Dillon #include <stdio.h> 43*dc6df0beSMatthew Dillon #include <stdlib.h> 44*dc6df0beSMatthew Dillon #include <string.h> 45*dc6df0beSMatthew Dillon #include "un-namespace.h" 46*dc6df0beSMatthew Dillon 47*dc6df0beSMatthew Dillon #include "local.h" 48*dc6df0beSMatthew Dillon #include "libc_private.h" 49*dc6df0beSMatthew Dillon #include "priv_stdio.h" 50*dc6df0beSMatthew Dillon 51*dc6df0beSMatthew Dillon size_t 52*dc6df0beSMatthew Dillon __sreadahead(FILE *fp) 53*dc6df0beSMatthew Dillon { 54*dc6df0beSMatthew Dillon size_t count; 55*dc6df0beSMatthew Dillon 56*dc6df0beSMatthew Dillon count = fp->pub._r; 57*dc6df0beSMatthew Dillon if (HASUB(fp)) 58*dc6df0beSMatthew Dillon count += fp->_ur; 59*dc6df0beSMatthew Dillon return(count); 60*dc6df0beSMatthew Dillon } 61*dc6df0beSMatthew Dillon 62