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