sys/param.h: fix MAXOFF_T on ILP32
[unleashed.git] / include / stdio.h
blobbdbe78a59431c5076a16bbb8c954b425a2861adf
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * User-visible pieces of the ANSI C standard I/O package.
34 #ifndef _STDIO_H
35 #define _STDIO_H
37 #include <sys/feature_tests.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 #ifdef __cplusplus
45 #endif
47 #include <iso/stdio_iso.h>
50 * If feature test macros are set that enable interfaces that use types
51 * defined in <sys/types.h>, get those types by doing the include.
53 * Note that in asking for the interfaces associated with this feature test
54 * macro one also asks for definitions of the POSIX types.
58 * Allow global visibility for symbols defined in
59 * C++ "std" namespace in <iso/stdio_iso.h>.
61 #if __cplusplus >= 199711L
62 using std::FILE;
63 using std::size_t;
64 using std::fpos_t;
65 using std::remove;
66 using std::rename;
67 using std::tmpfile;
68 using std::tmpnam;
69 using std::fclose;
70 using std::fflush;
71 using std::fopen;
72 using std::freopen;
73 using std::setbuf;
74 using std::setvbuf;
75 using std::fprintf;
76 using std::fscanf;
77 using std::printf;
78 using std::scanf;
79 using std::sprintf;
80 using std::sscanf;
81 using std::vfprintf;
82 using std::vprintf;
83 using std::vsprintf;
84 using std::fgetc;
85 using std::fgets;
86 using std::fputc;
87 using std::fputs;
88 using std::getc;
89 using std::getchar;
90 using std::gets;
91 using std::putc;
92 using std::putchar;
93 using std::puts;
94 using std::ungetc;
95 using std::fread;
96 using std::fwrite;
97 using std::fgetpos;
98 using std::fseek;
99 using std::fsetpos;
100 using std::ftell;
101 using std::rewind;
102 using std::clearerr;
103 using std::feof;
104 using std::ferror;
105 using std::perror;
106 #ifndef _LP64
107 using std::__filbuf;
108 using std::__flsbuf;
109 #endif /* _LP64 */
110 #endif /* __cplusplus >= 199711L */
113 * This header needs to be included here because it relies on the global
114 * visibility of FILE and size_t in the C++ environment.
116 #include <iso/stdio_c99.h>
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
122 #ifndef _OFF_T
123 #define _OFF_T
124 #if defined(_LP64)
125 typedef long off_t;
126 #else
127 typedef __longlong_t off_t;
128 #endif
129 typedef off_t off64_t;
130 #endif /* _OFF_T */
132 #ifdef _LP64
133 typedef fpos_t fpos64_t;
134 #else
135 typedef __longlong_t fpos64_t;
136 #endif
139 * XPG4 requires that va_list be defined in <stdio.h> "as described in
140 * <stdarg.h>". ANSI-C and POSIX require that the namespace of <stdio.h>
141 * not be polluted with this name.
143 #if defined(_XPG4) && !defined(_VA_LIST)
144 #define _VA_LIST
145 typedef __va_list va_list;
146 #endif /* defined(_XPG4 && !defined(_VA_LIST) */
148 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
149 defined(__XOPEN_OR_POSIX)
151 #define L_ctermid 9
153 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
154 #if !defined(_XPG6) || defined(__EXTENSIONS__)
155 #define L_cuserid 9
156 #endif
158 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
160 #if defined(__EXTENSIONS__) || \
161 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
162 defined(_XOPEN_SOURCE)
164 #define P_tmpdir "/var/tmp/"
165 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
167 #ifndef _STDIO_ALLOCATE
168 extern unsigned char _sibuf[], _sobuf[];
169 #endif
171 #ifndef _LP64
172 extern unsigned char *_bufendtab[];
173 extern FILE *_lastbuf;
174 #endif
176 #ifndef _SSIZE_T
177 #define _SSIZE_T
178 #if defined(_LP64) || defined(_I32LPx)
179 typedef long ssize_t; /* size of something in bytes or -1 */
180 #else
181 typedef int ssize_t; /* (historical version) */
182 #endif
183 #endif /* !_SSIZE_T */
185 extern char *tmpnam_r(char *);
187 #if defined(__EXTENSIONS__) || \
188 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
189 extern int fcloseall(void);
190 extern void setbuffer(FILE *, char *, size_t);
191 extern int setlinebuf(FILE *);
192 /* PRINTFLIKE2 */
193 extern int asprintf(char **, const char *, ...);
194 /* PRINTFLIKE2 */
195 extern int vasprintf(char **, const char *, __va_list);
196 #endif
198 #if defined(__EXTENSIONS__) || \
199 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
200 /* || defined(_XPG7) */
201 extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
202 int, FILE *_RESTRICT_KYWD);
203 extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
204 FILE *_RESTRICT_KYWD);
205 #endif /* __EXTENSIONS__ ... */
208 * The following are known to POSIX and XOPEN, but not to ANSI-C.
210 #if defined(__EXTENSIONS__) || \
211 !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)
213 extern FILE *fdopen(int, const char *);
214 extern char *ctermid(char *);
215 extern int fileno(FILE *);
217 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
220 * The following are known to POSIX.1c, but not to ANSI-C or XOPEN.
222 extern void flockfile(FILE *);
223 extern int ftrylockfile(FILE *);
224 extern void funlockfile(FILE *);
225 extern int getc_unlocked(FILE *);
226 extern int getchar_unlocked(void);
227 extern int putc_unlocked(int, FILE *);
228 extern int putchar_unlocked(int);
231 * The following are known to XOPEN, but not to ANSI-C or POSIX.
233 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
234 defined(_XOPEN_SOURCE)
235 extern FILE *popen(const char *, const char *);
236 extern char *tempnam(const char *, const char *);
237 extern int pclose(FILE *);
238 #if !defined(_XOPEN_SOURCE)
239 extern int getsubopt(char **, char *const *, char **);
240 #endif /* !defined(_XOPEN_SOURCE) */
242 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
243 #if !defined(_XPG6) || defined(__EXTENSIONS__)
244 extern char *cuserid(char *);
245 extern int getopt(int, char *const *, const char *);
246 extern char *optarg;
247 extern int optind, opterr, optopt;
248 extern int getw(FILE *);
249 extern int putw(int, FILE *);
250 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
252 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
254 extern int fseeko(FILE *, off_t, int);
255 extern off_t ftello(FILE *);
257 /* FIXME: source compat: these syms are aliases to non-64 vers in libc */
258 int fseeko64(FILE *, off_t, int);
259 off_t ftello64(FILE *);
261 #define getchar_unlocked() getc_unlocked(stdin)
262 #define putchar_unlocked(x) putc_unlocked((x), stdout)
264 #ifdef __cplusplus
266 #endif
268 #endif /* _STDIO_H */