don't bother resolving onbld python module deps
[unleashed.git] / include / stdio.h
blob2c588858d861a94f3d0ae6cfecdb621bc1d83475
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
44 * Do all of our 'redefine_extname' processing before
45 * declarations of the associated functions are seen.
46 * This is necessary to keep gcc happy.
48 #if defined(__PRAGMA_REDEFINE_EXTNAME)
50 /* large file compilation environment setup */
51 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
52 #pragma redefine_extname fopen fopen64
53 #pragma redefine_extname freopen freopen64
54 #pragma redefine_extname tmpfile tmpfile64
55 #pragma redefine_extname fgetpos fgetpos64
56 #pragma redefine_extname fsetpos fsetpos64
57 #if defined(_LARGEFILE_SOURCE)
58 #pragma redefine_extname fseeko fseeko64
59 #pragma redefine_extname ftello ftello64
60 #endif /* _LARGEFILE_SOURCE */
61 #endif /* !defined(_LP64) && _FILE_OFFSET_BITS == 64 */
63 /* In the LP64 compilation environment, all APIs are already large file */
64 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
65 #pragma redefine_extname fopen64 fopen
66 #pragma redefine_extname freopen64 freopen
67 #pragma redefine_extname tmpfile64 tmpfile
68 #pragma redefine_extname fgetpos64 fgetpos
69 #pragma redefine_extname fsetpos64 fsetpos
70 #if defined(_LARGEFILE_SOURCE)
71 #pragma redefine_extname fseeko64 fseeko
72 #pragma redefine_extname ftello64 ftello
73 #endif /* _LARGEFILE_SOURCE */
74 #endif /* defined(_LP64) && defined(_LARGEFILE64_SOURCE) */
76 #endif /* __PRAGMA_REDEFINE_EXTNAME */
78 #ifdef __cplusplus
80 #endif
82 #include <iso/stdio_iso.h>
85 * If feature test macros are set that enable interfaces that use types
86 * defined in <sys/types.h>, get those types by doing the include.
88 * Note that in asking for the interfaces associated with this feature test
89 * macro one also asks for definitions of the POSIX types.
93 * Allow global visibility for symbols defined in
94 * C++ "std" namespace in <iso/stdio_iso.h>.
96 #if __cplusplus >= 199711L
97 using std::FILE;
98 using std::size_t;
99 using std::fpos_t;
100 using std::remove;
101 using std::rename;
102 using std::tmpfile;
103 using std::tmpnam;
104 using std::fclose;
105 using std::fflush;
106 using std::fopen;
107 using std::freopen;
108 using std::setbuf;
109 using std::setvbuf;
110 using std::fprintf;
111 using std::fscanf;
112 using std::printf;
113 using std::scanf;
114 using std::sprintf;
115 using std::sscanf;
116 using std::vfprintf;
117 using std::vprintf;
118 using std::vsprintf;
119 using std::fgetc;
120 using std::fgets;
121 using std::fputc;
122 using std::fputs;
123 using std::getc;
124 using std::getchar;
125 using std::gets;
126 using std::putc;
127 using std::putchar;
128 using std::puts;
129 using std::ungetc;
130 using std::fread;
131 using std::fwrite;
132 using std::fgetpos;
133 using std::fseek;
134 using std::fsetpos;
135 using std::ftell;
136 using std::rewind;
137 using std::clearerr;
138 using std::feof;
139 using std::ferror;
140 using std::perror;
141 #ifndef _LP64
142 using std::__filbuf;
143 using std::__flsbuf;
144 #endif /* _LP64 */
145 #endif /* __cplusplus >= 199711L */
148 * This header needs to be included here because it relies on the global
149 * visibility of FILE and size_t in the C++ environment.
151 #include <iso/stdio_c99.h>
153 #ifdef __cplusplus
154 extern "C" {
155 #endif
157 #if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
158 #ifndef _OFF_T
159 #define _OFF_T
160 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
161 typedef long off_t;
162 #else
163 typedef __longlong_t off_t;
164 #endif
165 #ifdef _LARGEFILE64_SOURCE
166 #ifdef _LP64
167 typedef off_t off64_t;
168 #else
169 typedef __longlong_t off64_t;
170 #endif
171 #endif /* _LARGEFILE64_SOURCE */
172 #endif /* _OFF_T */
173 #endif /* _LARGEFILE_SOURCE */
175 #ifdef _LARGEFILE64_SOURCE
176 #ifdef _LP64
177 typedef fpos_t fpos64_t;
178 #else
179 typedef __longlong_t fpos64_t;
180 #endif
181 #endif /* _LARGEFILE64_SOURCE */
184 * XPG4 requires that va_list be defined in <stdio.h> "as described in
185 * <stdarg.h>". ANSI-C and POSIX require that the namespace of <stdio.h>
186 * not be polluted with this name.
188 #if defined(_XPG4) && !defined(_VA_LIST)
189 #define _VA_LIST
190 typedef __va_list va_list;
191 #endif /* defined(_XPG4 && !defined(_VA_LIST) */
193 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
194 defined(__XOPEN_OR_POSIX)
196 #define L_ctermid 9
198 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
199 #if !defined(_XPG6) || defined(__EXTENSIONS__)
200 #define L_cuserid 9
201 #endif
203 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
205 #if defined(__EXTENSIONS__) || \
206 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
207 defined(_XOPEN_SOURCE)
209 #define P_tmpdir "/var/tmp/"
210 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
212 #ifndef _STDIO_ALLOCATE
213 extern unsigned char _sibuf[], _sobuf[];
214 #endif
216 /* large file compilation environment setup */
217 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
218 #if !defined(__PRAGMA_REDEFINE_EXTNAME)
219 extern FILE *fopen64(const char *, const char *);
220 extern FILE *freopen64(const char *, const char *, FILE *);
221 extern FILE *tmpfile64(void);
222 extern int fgetpos64(FILE *, fpos_t *);
223 extern int fsetpos64(FILE *, const fpos_t *);
224 #define fopen fopen64
225 #define freopen freopen64
226 #define tmpfile tmpfile64
227 #define fgetpos fgetpos64
228 #define fsetpos fsetpos64
229 #ifdef _LARGEFILE_SOURCE
230 #define fseeko fseeko64
231 #define ftello ftello64
232 #endif
233 #endif /* !__PRAGMA_REDEFINE_EXTNAME */
234 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
236 #ifndef _LP64
237 extern unsigned char *_bufendtab[];
238 extern FILE *_lastbuf;
239 #endif
241 /* In the LP64 compilation environment, all APIs are already large file */
242 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
243 #if !defined(__PRAGMA_REDEFINE_EXTNAME)
244 #define fopen64 fopen
245 #define freopen64 freopen
246 #define tmpfile64 tmpfile
247 #define fgetpos64 fgetpos
248 #define fsetpos64 fsetpos
249 #ifdef _LARGEFILE_SOURCE
250 #define fseeko64 fseeko
251 #define ftello64 ftello
252 #endif
253 #endif /* !__PRAGMA_REDEFINE_EXTNAME */
254 #endif /* _LP64 && _LARGEFILE64_SOURCE */
256 #ifndef _SSIZE_T
257 #define _SSIZE_T
258 #if defined(_LP64) || defined(_I32LPx)
259 typedef long ssize_t; /* size of something in bytes or -1 */
260 #else
261 typedef int ssize_t; /* (historical version) */
262 #endif
263 #endif /* !_SSIZE_T */
265 extern char *tmpnam_r(char *);
267 #if defined(__EXTENSIONS__) || \
268 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
269 extern int fcloseall(void);
270 extern void setbuffer(FILE *, char *, size_t);
271 extern int setlinebuf(FILE *);
272 /* PRINTFLIKE2 */
273 extern int asprintf(char **, const char *, ...);
274 /* PRINTFLIKE2 */
275 extern int vasprintf(char **, const char *, __va_list);
276 #endif
278 #if defined(__EXTENSIONS__) || \
279 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
280 /* || defined(_XPG7) */
281 extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
282 int, FILE *_RESTRICT_KYWD);
283 extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
284 FILE *_RESTRICT_KYWD);
285 #endif /* __EXTENSIONS__ ... */
288 * The following are known to POSIX and XOPEN, but not to ANSI-C.
290 #if defined(__EXTENSIONS__) || \
291 !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)
293 extern FILE *fdopen(int, const char *);
294 extern char *ctermid(char *);
295 extern int fileno(FILE *);
297 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
300 * The following are known to POSIX.1c, but not to ANSI-C or XOPEN.
302 extern void flockfile(FILE *);
303 extern int ftrylockfile(FILE *);
304 extern void funlockfile(FILE *);
305 extern int getc_unlocked(FILE *);
306 extern int getchar_unlocked(void);
307 extern int putc_unlocked(int, FILE *);
308 extern int putchar_unlocked(int);
311 * The following are known to XOPEN, but not to ANSI-C or POSIX.
313 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
314 defined(_XOPEN_SOURCE)
315 extern FILE *popen(const char *, const char *);
316 extern char *tempnam(const char *, const char *);
317 extern int pclose(FILE *);
318 #if !defined(_XOPEN_SOURCE)
319 extern int getsubopt(char **, char *const *, char **);
320 #endif /* !defined(_XOPEN_SOURCE) */
322 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
323 #if !defined(_XPG6) || defined(__EXTENSIONS__)
324 extern char *cuserid(char *);
325 extern int getopt(int, char *const *, const char *);
326 extern char *optarg;
327 extern int optind, opterr, optopt;
328 extern int getw(FILE *);
329 extern int putw(int, FILE *);
330 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
332 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
335 * The following are defined as part of the Large File Summit interfaces.
337 #if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
338 extern int fseeko(FILE *, off_t, int);
339 extern off_t ftello(FILE *);
340 #endif
343 * The following are defined as part of the transitional Large File Summit
344 * interfaces.
346 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
347 !defined(__PRAGMA_REDEFINE_EXTNAME))
348 extern FILE *fopen64(const char *, const char *);
349 extern FILE *freopen64(const char *, const char *, FILE *);
350 extern FILE *tmpfile64(void);
351 extern int fgetpos64(FILE *, fpos64_t *);
352 extern int fsetpos64(FILE *, const fpos64_t *);
353 extern int fseeko64(FILE *, off64_t, int);
354 extern off64_t ftello64(FILE *);
355 #endif
357 #define getchar_unlocked() getc_unlocked(stdin)
358 #define putchar_unlocked(x) putc_unlocked((x), stdout)
360 #ifdef __cplusplus
362 #endif
364 #endif /* _STDIO_H */