1 /* 2 * CDDL HEADER START 3 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1988 AT&T */ 28 /* All Rights Reserved */ 29 30 /* 31 * An application should not include this header directly. Instead it 32 * should be included only through the inclusion of other Sun headers. 33 * 34 * The contents of this header is limited to identifiers specified in the 35 * C Standard. Any new identifiers specified in future amendments to the 36 * C Standard must be placed in this header. If these new identifiers 37 * are required to also be in the C++ Standard "std" namespace, then for 38 * anything other than macro definitions, corresponding "using" directives 39 * must also be added to <stdio.h>. 40 */ 41 42 /* 43 * User-visible pieces of the ANSI C standard I/O package. 44 */ 45 46 #ifndef _ISO_STDIO_ISO_H 47 #define _ISO_STDIO_ISO_H 48 49 #include <sys/feature_tests.h> 50 #include <sys/va_list.h> 51 #include <stdio_tag.h> 52 #include <stdio_impl.h> 53 54 /* 55 * If feature test macros are set that enable interfaces that use types 56 * defined in <sys/types.h>, get those types by doing the include. 57 * 58 * Note that in asking for the interfaces associated with this feature test 59 * macro one also asks for definitions of the POSIX types. 60 */ 61 62 #ifdef __cplusplus 63 extern "C" { 64 #endif 65 66 #if !defined(_LP64) && (_FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE)) 67 /* 68 * The following typedefs are adopted from ones in <sys/types.h> (with leading 69 * underscores added to avoid polluting the ANSI C name space). See the 70 * commentary there for further explanation. 71 */ 72 #if defined(_LONGLONG_TYPE) 73 typedef long long __longlong_t; 74 #else 75 /* used to reserve space and generate alignment */ 76 typedef union { 77 double _d; 78 int _l[2]; 79 } __longlong_t; 80 #endif 81 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE) */ 82 83 #if __cplusplus >= 199711L 84 namespace std { 85 #endif 86 87 #if !defined(_FILEDEFED) || __cplusplus >= 199711L 88 #define _FILEDEFED 89 typedef __FILE FILE; 90 #endif 91 92 #if !defined(_SIZE_T) || __cplusplus >= 199711L 93 #define _SIZE_T 94 #if defined(_LP64) || defined(_I32LPx) 95 typedef unsigned long size_t; /* size of something in bytes */ 96 #else 97 typedef unsigned int size_t; /* (historical version) */ 98 #endif 99 #endif /* !_SIZE_T */ 100 101 #if defined(_LP64) || _FILE_OFFSET_BITS == 32 102 typedef long fpos_t; 103 #else 104 typedef __longlong_t fpos_t; 105 #endif 106 107 #if __cplusplus >= 199711L 108 } 109 #endif /* end of namespace std */ 110 111 #ifndef NULL 112 #if defined(_LP64) 113 #define NULL 0L 114 #else 115 #define NULL 0 116 #endif 117 #endif 118 119 #define BUFSIZ 1024 120 121 /* 122 * The value of _NFILE is defined in the Processor Specific ABI. The value 123 * is chosen for historical reasons rather than for truly processor related 124 * attribute. Note that the SPARC Processor Specific ABI uses the common 125 * UNIX historical value of 20 so it is allowed to fall through. 126 */ 127 #if defined(__i386) 128 #define _NFILE 60 /* initial number of streams: Intel x86 ABI */ 129 #else 130 #define _NFILE 20 /* initial number of streams: SPARC ABI and default */ 131 #endif 132 133 #define _SBFSIZ 8 /* compatibility with shared libs */ 134 135 #define _IOFBF 0000 /* full buffered */ 136 #define _IOLBF 0100 /* line buffered */ 137 #define _IONBF 0004 /* not buffered */ 138 #define _IOEOF 0020 /* EOF reached on read */ 139 #define _IOERR 0040 /* I/O error from system */ 140 141 #define _IOREAD 0001 /* currently reading */ 142 #define _IOWRT 0002 /* currently writing */ 143 #define _IORW 0200 /* opened for reading and writing */ 144 #define _IOMYBUF 0010 /* stdio malloc()'d buffer */ 145 146 #ifndef EOF 147 #define EOF (-1) 148 #endif 149 150 #define FOPEN_MAX _NFILE 151 #define FILENAME_MAX 1024 /* max # of characters in a path name */ 152 153 #define SEEK_SET 0 154 #define SEEK_CUR 1 155 #define SEEK_END 2 156 #define TMP_MAX 17576 /* 26 * 26 * 26 */ 157 158 #define L_tmpnam 25 /* (sizeof(P_tmpdir) + 15) */ 159 160 #if defined(__STDC__) 161 extern __FILE __iob[_NFILE]; 162 #define stdin (&__iob[0]) 163 #define stdout (&__iob[1]) 164 #define stderr (&__iob[2]) 165 #else 166 extern __FILE _iob[_NFILE]; 167 #define stdin (&_iob[0]) 168 #define stdout (&_iob[1]) 169 #define stderr (&_iob[2]) 170 #endif /* __STDC__ */ 171 172 #if __cplusplus >= 199711L 173 namespace std { 174 #endif 175 176 #if !defined(_LP64) && !defined(_LONGLONG_TYPE) 177 178 #ifdef __PRAGMA_REDEFINE_EXTNAME 179 #pragma redefine_extname fprintf _fprintf_c89 180 #pragma redefine_extname printf _printf_c89 181 #pragma redefine_extname sprintf _sprintf_c89 182 #pragma redefine_extname vfprintf _vfprintf_c89 183 #pragma redefine_extname vprintf _vprintf_c89 184 #pragma redefine_extname vsprintf _vsprintf_c89 185 #pragma redefine_extname fscanf _fscanf_c89 186 #pragma redefine_extname scanf _scanf_c89 187 #pragma redefine_extname sscanf _sscanf_c89 188 #else 189 #define fprintf _fprintf_c89 190 #define printf _printf_c89 191 #define sprintf _sprintf_c89 192 #define vfprintf _vfprintf_c89 193 #define vprintf _vprintf_c89 194 #define vsprintf _vsprintf_c89 195 #define fscanf _fscanf_c89 196 #define scanf _scanf_c89 197 #define sscanf _sscanf_c89 198 #endif 199 200 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */ 201 202 #if defined(__STDC__) 203 204 extern int remove(const char *); 205 extern int rename(const char *, const char *); 206 extern FILE *tmpfile(void); 207 extern char *tmpnam(char *); 208 extern int fclose(FILE *); 209 extern int fflush(FILE *); 210 extern FILE *fopen(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); 211 extern FILE *freopen(const char *_RESTRICT_KYWD, 212 const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD); 213 extern void setbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD); 214 extern int setvbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD, int, 215 size_t); 216 /* PRINTFLIKE2 */ 217 extern int fprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); 218 /* SCANFLIKE2 */ 219 extern int fscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); 220 /* PRINTFLIKE1 */ 221 extern int printf(const char *_RESTRICT_KYWD, ...); 222 /* SCANFLIKE1 */ 223 extern int scanf(const char *_RESTRICT_KYWD, ...); 224 /* PRINTFLIKE2 */ 225 extern int sprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...); 226 /* SCANFLIKE2 */ 227 extern int sscanf(const char *_RESTRICT_KYWD, 228 const char *_RESTRICT_KYWD, ...); 229 extern int vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 230 __va_list); 231 extern int vprintf(const char *_RESTRICT_KYWD, __va_list); 232 extern int vsprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 233 __va_list); 234 extern int fgetc(FILE *); 235 extern char *fgets(char *_RESTRICT_KYWD, int, FILE *_RESTRICT_KYWD); 236 extern int fputc(int, FILE *); 237 extern int fputs(const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD); 238 #if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \ 239 __cplusplus < 199711L 240 extern int getc(FILE *); 241 extern int putc(int, FILE *); 242 #endif 243 #if (__cplusplus >= 199711L && defined(_REENTRANT)) || \ 244 __cplusplus < 199711L 245 extern int getchar(void); 246 extern int putchar(int); 247 #endif 248 extern char *gets(char *); 249 extern int puts(const char *); 250 extern int ungetc(int, FILE *); 251 extern size_t fread(void *_RESTRICT_KYWD, size_t, size_t, 252 FILE *_RESTRICT_KYWD); 253 extern size_t fwrite(const void *_RESTRICT_KYWD, size_t, size_t, 254 FILE *_RESTRICT_KYWD); 255 #if !defined(__lint) || defined(_LP64) || _FILE_OFFSET_BITS == 32 256 extern int fgetpos(FILE *_RESTRICT_KYWD, fpos_t *_RESTRICT_KYWD); 257 extern int fsetpos(FILE *, const fpos_t *); 258 #endif 259 extern int fseek(FILE *, long, int); 260 extern long ftell(FILE *); 261 extern void rewind(FILE *); 262 #if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \ 263 __cplusplus < 199711L 264 extern void clearerr(FILE *); 265 extern int feof(FILE *); 266 extern int ferror(FILE *); 267 #endif 268 extern void perror(const char *); 269 270 #ifndef _LP64 271 extern int __filbuf(FILE *); 272 extern int __flsbuf(int, FILE *); 273 #endif /* _LP64 */ 274 275 #else /* !defined __STDC__ */ 276 277 extern int remove(); 278 extern int rename(); 279 extern FILE *tmpfile(); 280 extern char *tmpnam(); 281 extern int fclose(); 282 extern int fflush(); 283 extern FILE *fopen(); 284 extern FILE *freopen(); 285 extern void setbuf(); 286 extern int setvbuf(); 287 extern int fprintf(); 288 extern int fscanf(); 289 extern int printf(); 290 extern int scanf(); 291 extern int sprintf(); 292 extern int sscanf(); 293 extern int vfprintf(); 294 extern int vprintf(); 295 extern int vsprintf(); 296 extern int fgetc(); 297 extern char *fgets(); 298 extern int fputc(); 299 extern int fputs(); 300 extern int getc(); 301 extern int getchar(); 302 extern char *gets(); 303 extern int putc(); 304 extern int putchar(); 305 extern int puts(); 306 extern int ungetc(); 307 extern size_t fread(); 308 extern size_t fwrite(); 309 extern int fgetpos(); 310 extern int fseek(); 311 extern int fsetpos(); 312 extern long ftell(); 313 extern void rewind(); 314 extern void clearerr(); 315 extern int feof(); 316 extern int ferror(); 317 extern void perror(); 318 319 #ifndef _LP64 320 extern int _filbuf(); 321 extern int _flsbuf(); 322 #endif /* _LP64 */ 323 324 #endif /* __STDC__ */ 325 326 #if __cplusplus >= 199711L 327 } 328 #endif /* end of namespace std */ 329 330 #if !defined(__lint) 331 332 #if !defined(_REENTRANT) && !defined(_LP64) 333 334 #ifdef __STDC__ 335 #if __cplusplus >= 199711L 336 namespace std { 337 inline int getc(FILE *_p) { 338 return (--_p->_cnt < 0 ? __filbuf(_p) : (int)*_p->_ptr++); } 339 inline int putc(int _x, FILE *_p) { 340 return (--_p->_cnt < 0 ? __flsbuf(_x, _p) 341 : (int)(*_p->_ptr++ = (unsigned char) _x)); } 342 } 343 #else /* __cplusplus >= 199711L */ 344 #define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++) 345 #define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \ 346 : (int)(*(p)->_ptr++ = (unsigned char) (x))) 347 #endif /* __cplusplus >= 199711L */ 348 #else /* __STDC__ */ 349 #define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int)*(p)->_ptr++) 350 #define putc(x, p) (--(p)->_cnt < 0 ? _flsbuf((x), (p)) : \ 351 (int)(*(p)->_ptr++ = (unsigned char) (x))) 352 #endif /* __STDC__ */ 353 354 #endif /* !defined(_REENTRANT) && !defined(_LP64) */ 355 356 #ifndef _REENTRANT 357 358 #if __cplusplus >= 199711L 359 namespace std { 360 inline int getchar() { return getc(stdin); } 361 inline int putchar(int _x) { return putc(_x, stdout); } 362 } 363 #else 364 #define getchar() getc(stdin) 365 #define putchar(x) putc((x), stdout) 366 #endif /* __cplusplus >= 199711L */ 367 368 #ifndef _LP64 369 #if __cplusplus >= 199711L 370 namespace std { 371 inline void clearerr(FILE *_p) { _p->_flag &= ~(_IOERR | _IOEOF); } 372 inline int feof(FILE *_p) { return _p->_flag & _IOEOF; } 373 inline int ferror(FILE *_p) { return _p->_flag & _IOERR; } 374 } 375 #else /* __cplusplus >= 199711L */ 376 #define clearerr(p) ((void)((p)->_flag &= ~(_IOERR | _IOEOF))) 377 #define feof(p) ((p)->_flag & _IOEOF) 378 #define ferror(p) ((p)->_flag & _IOERR) 379 #endif /* __cplusplus >= 199711L */ 380 #endif /* _LP64 */ 381 382 #endif /* _REENTRANT */ 383 384 #endif /* !defined(__lint) */ 385 386 #ifdef __cplusplus 387 } 388 #endif 389 390 #endif /* _ISO_STDIO_ISO_H */ 391