tools/llvm: Do not build with symbols
[minix3.git] / lib / libc / stdio / local.h
blob6b9c50763adc11b3f5d3f63647b92dfb18c5e1de
1 /* $NetBSD: local.h,v 1.37 2013/10/04 20:49:16 christos Exp $ */
3 /*-
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Chris Torek.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 * @(#)local.h 8.3 (Berkeley) 7/3/94
37 #include "wcio.h"
38 #include "fileext.h"
40 #include <limits.h>
41 #include <stdarg.h>
42 #include <stdbool.h>
45 * Information local to this implementation of stdio,
46 * in particular, macros and private variables.
49 extern int __sflush(FILE *);
50 extern FILE *__sfp(void);
51 extern void __sfpinit(FILE *);
52 extern int __srefill(FILE *);
53 extern ssize_t __sread(void *, void *, size_t);
54 extern ssize_t __swrite(void *, const void *, size_t);
55 extern off_t __sseek(void *, off_t, int);
56 extern int __sclose(void *);
57 extern void __sinit(void);
58 extern void _cleanup(void);
59 extern void (*__cleanup)(void);
60 extern void __smakebuf(FILE *);
61 extern int __swhatbuf(FILE *, size_t *, int *);
62 extern int _fwalk(int (*)(FILE *));
63 extern char *_mktemp(char *);
64 extern int __swsetup(FILE *);
65 extern int __sflags(const char *, int *);
66 extern int __svfscanf(FILE * __restrict, const char * __restrict,
67 va_list) __scanflike(2, 0);
68 extern int __svfscanf_l(FILE * __restrict, locale_t,
69 const char * __restrict, va_list) __scanflike(3, 0);
70 extern int __svfscanf_unlocked_l(FILE * __restrict, locale_t,
71 const char * __restrict, va_list) __scanflike(3, 0);
72 extern int __vfprintf_unlocked_l(FILE * __restrict, locale_t,
73 const char * __restrict, va_list) __printflike(3, 0);
76 extern int __sdidinit;
78 extern int __gettemp(char *, int *, int);
80 extern wint_t __fgetwc_unlock(FILE *);
81 extern wint_t __fputwc_unlock(wchar_t, FILE *);
83 extern ssize_t __getdelim(char **__restrict, size_t *__restrict, int,
84 FILE *__restrict);
85 extern char *__fgetstr(FILE * __restrict, size_t * __restrict, int);
86 extern int __vfwprintf_unlocked_l(FILE *, locale_t, const wchar_t *, va_list);
87 extern int __vfwscanf_unlocked_l(FILE * __restrict, locale_t,
88 const wchar_t * __restrict, va_list);
91 * Return true iff the given FILE cannot be written now.
93 #define cantwrite(fp) \
94 ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
95 __swsetup(fp))
98 * Test whether the given stdio file has an active ungetc buffer;
99 * release such a buffer, without restoring ordinary unread data.
101 #define HASUB(fp) (_UB(fp)._base != NULL)
102 #define FREEUB(fp) { \
103 if (_UB(fp)._base != (fp)->_ubuf) \
104 free((char *)_UB(fp)._base); \
105 _UB(fp)._base = NULL; \
109 * test for an fgetln() buffer.
111 #define FREELB(fp) { \
112 free(_EXT(fp)->_fgetstr_buf); \
113 _EXT(fp)->_fgetstr_buf = NULL; \
114 _EXT(fp)->_fgetstr_len = 0; \
117 extern void __flockfile_internal(FILE *, int);
118 extern void __funlockfile_internal(FILE *, int);
120 extern char *__gets(char *);
123 * Detect if the current file position fits in a long int.
126 static __inline bool
127 __long_overflow(off_t pos)
129 return (pos < LONG_MIN) || (pos > LONG_MAX);