Merge commit 'e8921a52c53ee69f7b65f054d9b2e886139daa59'
[unleashed.git] / include / iso / stdio_iso.h
blobf105ff2f53652df1847ac62b2e4915082dfe01c0
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright 2014 PALO, Richard.
26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 /* Copyright (c) 1988 AT&T */
31 /* All Rights Reserved */
34 * An application should not include this header directly. Instead it
35 * should be included only through the inclusion of other Sun headers.
37 * The contents of this header is limited to identifiers specified in the
38 * C Standard. Any new identifiers specified in future amendments to the
39 * C Standard must be placed in this header. If these new identifiers
40 * are required to also be in the C++ Standard "std" namespace, then for
41 * anything other than macro definitions, corresponding "using" directives
42 * must also be added to <stdio.h>.
46 * User-visible pieces of the ANSI C standard I/O package.
49 #ifndef _ISO_STDIO_ISO_H
50 #define _ISO_STDIO_ISO_H
52 #include <sys/feature_tests.h>
53 #include <sys/null.h>
54 #include <sys/va_list.h>
55 #include <stdio_tag.h>
56 #include <stdio_impl.h>
59 * If feature test macros are set that enable interfaces that use types
60 * defined in <sys/types.h>, get those types by doing the include.
62 * Note that in asking for the interfaces associated with this feature test
63 * macro one also asks for definitions of the POSIX types.
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
70 #if !defined(_LP64) && (_FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE))
72 * The following typedefs are adopted from ones in <sys/types.h> (with leading
73 * underscores added to avoid polluting the ANSI C name space). See the
74 * commentary there for further explanation.
76 #if defined(_LONGLONG_TYPE)
77 typedef long long __longlong_t;
78 #else
79 /* used to reserve space and generate alignment */
80 typedef union {
81 double _d;
82 int _l[2];
83 } __longlong_t;
84 #endif
85 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE) */
87 #if __cplusplus >= 199711L
88 namespace std {
89 #endif
91 #if !defined(_FILEDEFED) || __cplusplus >= 199711L
92 #define _FILEDEFED
93 typedef __FILE FILE;
94 #endif
96 #if !defined(_SIZE_T) || __cplusplus >= 199711L
97 #define _SIZE_T
98 #if defined(_LP64) || defined(_I32LPx)
99 typedef unsigned long size_t; /* size of something in bytes */
100 #else
101 typedef unsigned int size_t; /* (historical version) */
102 #endif
103 #endif /* !_SIZE_T */
105 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
106 typedef long fpos_t;
107 #else
108 typedef __longlong_t fpos_t;
109 #endif
111 #if __cplusplus >= 199711L
113 #endif /* end of namespace std */
115 #define BUFSIZ 1024
118 * The value of _NFILE is defined in the Processor Specific ABI. The value
119 * is chosen for historical reasons rather than for truly processor related
120 * attribute. Note that the SPARC Processor Specific ABI uses the common
121 * UNIX historical value of 20 so it is allowed to fall through.
123 #if defined(__i386)
124 #define _NFILE 60 /* initial number of streams: Intel x86 ABI */
125 #else
126 #define _NFILE 20 /* initial number of streams: SPARC ABI and default */
127 #endif
129 #define _SBFSIZ 8 /* compatibility with shared libs */
131 #define _IOFBF 0000 /* full buffered */
132 #define _IOLBF 0100 /* line buffered */
133 #define _IONBF 0004 /* not buffered */
134 #define _IOEOF 0020 /* EOF reached on read */
135 #define _IOERR 0040 /* I/O error from system */
137 #define _IOREAD 0001 /* currently reading */
138 #define _IOWRT 0002 /* currently writing */
139 #define _IORW 0200 /* opened for reading and writing */
140 #define _IOMYBUF 0010 /* stdio malloc()'d buffer */
142 #ifndef EOF
143 #define EOF (-1)
144 #endif
146 #define FOPEN_MAX _NFILE
147 #define FILENAME_MAX 1024 /* max # of characters in a path name */
149 #define SEEK_SET 0
150 #define SEEK_CUR 1
151 #define SEEK_END 2
152 #define TMP_MAX 17576 /* 26 * 26 * 26 */
154 #define L_tmpnam 25 /* (sizeof(P_tmpdir) + 15) */
156 extern __FILE *__stdinp;
157 extern __FILE *__stdoutp;
158 extern __FILE *__stderrp;
160 #define stdin __stdinp
161 #define stdout __stdoutp
162 #define stderr __stderrp
164 #if __cplusplus >= 199711L
165 namespace std {
166 #endif
168 #if !defined(_LP64) && !defined(_LONGLONG_TYPE)
170 #ifdef __PRAGMA_REDEFINE_EXTNAME
171 #pragma redefine_extname fprintf _fprintf_c89
172 #pragma redefine_extname printf _printf_c89
173 #pragma redefine_extname sprintf _sprintf_c89
174 #pragma redefine_extname vfprintf _vfprintf_c89
175 #pragma redefine_extname vprintf _vprintf_c89
176 #pragma redefine_extname vsprintf _vsprintf_c89
177 #pragma redefine_extname fscanf _fscanf_c89
178 #pragma redefine_extname scanf _scanf_c89
179 #pragma redefine_extname sscanf _sscanf_c89
180 #else
181 #define fprintf _fprintf_c89
182 #define printf _printf_c89
183 #define sprintf _sprintf_c89
184 #define vfprintf _vfprintf_c89
185 #define vprintf _vprintf_c89
186 #define vsprintf _vsprintf_c89
187 #define fscanf _fscanf_c89
188 #define scanf _scanf_c89
189 #define sscanf _sscanf_c89
190 #endif
192 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */
194 extern int remove(const char *);
195 extern int rename(const char *, const char *);
196 extern FILE *tmpfile(void);
197 extern char *tmpnam(char *);
198 extern int fclose(FILE *);
199 extern int fflush(FILE *);
200 extern FILE *fopen(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
201 extern FILE *freopen(const char *_RESTRICT_KYWD,
202 const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
203 extern void setbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
204 extern int setvbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD, int,
205 size_t);
206 /* PRINTFLIKE2 */
207 extern int fprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
208 /* SCANFLIKE2 */
209 extern int fscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
210 /* PRINTFLIKE1 */
211 extern int printf(const char *_RESTRICT_KYWD, ...);
212 /* SCANFLIKE1 */
213 extern int scanf(const char *_RESTRICT_KYWD, ...);
214 /* PRINTFLIKE2 */
215 extern int sprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
216 /* SCANFLIKE2 */
217 extern int sscanf(const char *_RESTRICT_KYWD,
218 const char *_RESTRICT_KYWD, ...);
219 extern int vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
220 __va_list);
221 extern int vprintf(const char *_RESTRICT_KYWD, __va_list);
222 extern int vsprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
223 __va_list);
224 extern int fgetc(FILE *);
225 extern char *fgets(char *_RESTRICT_KYWD, int, FILE *_RESTRICT_KYWD);
226 extern int fputc(int, FILE *);
227 extern int fputs(const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
228 extern int getc(FILE *);
229 extern int putc(int, FILE *);
230 extern int getchar(void);
231 extern int putchar(int);
234 * ISO/IEC C11 removed gets from the standard library. Therefore if a strict C11
235 * environment has been requested, we remove it.
237 #if !defined(_STDC_C11) || defined(__EXTENSIONS__)
238 extern char *gets(char *);
239 #endif
240 extern int puts(const char *);
241 extern int ungetc(int, FILE *);
242 extern size_t fread(void *_RESTRICT_KYWD, size_t, size_t,
243 FILE *_RESTRICT_KYWD);
244 extern size_t fwrite(const void *_RESTRICT_KYWD, size_t, size_t,
245 FILE *_RESTRICT_KYWD);
246 #if !defined(__lint) || defined(_LP64) || _FILE_OFFSET_BITS == 32
247 extern int fgetpos(FILE *_RESTRICT_KYWD, fpos_t *_RESTRICT_KYWD);
248 extern int fsetpos(FILE *, const fpos_t *);
249 #endif
250 extern int fseek(FILE *, long, int);
251 extern long ftell(FILE *);
252 extern void rewind(FILE *);
253 extern void clearerr(FILE *);
254 extern int feof(FILE *);
255 extern int ferror(FILE *);
256 extern void perror(const char *);
258 #ifndef _LP64
259 extern int __filbuf(FILE *);
260 extern int __flsbuf(int, FILE *);
261 #endif /* _LP64 */
263 #if __cplusplus >= 199711L
265 #endif /* end of namespace std */
267 #ifdef __cplusplus
269 #endif
271 #endif /* _ISO_STDIO_ISO_H */