[444] | 1 | /* |
---|
| 2 | * Copyright (c) 1990 The Regents of the University of California. |
---|
| 3 | * All rights reserved. |
---|
| 4 | * |
---|
| 5 | * Redistribution and use in source and binary forms are permitted |
---|
| 6 | * provided that the above copyright notice and this paragraph are |
---|
| 7 | * duplicated in all such forms and that any documentation, |
---|
| 8 | * advertising materials, and other materials related to such |
---|
| 9 | * distribution and use acknowledge that the software was developed |
---|
| 10 | * by the University of California, Berkeley. The name of the |
---|
| 11 | * University may not be used to endorse or promote products derived |
---|
| 12 | * from this software without specific prior written permission. |
---|
| 13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
---|
| 14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
---|
| 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
| 16 | * |
---|
| 17 | * @(#)stdio.h 5.3 (Berkeley) 3/15/86 |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | /* |
---|
| 21 | * NB: to fit things in six character monocase externals, the |
---|
| 22 | * stdio code uses the prefix `__s' for stdio objects, typically |
---|
| 23 | * followed by a three-character attempt at a mnemonic. |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #ifndef _STDIO_H_ |
---|
| 27 | #define _STDIO_H_ |
---|
| 28 | |
---|
| 29 | #include "_ansi.h" |
---|
| 30 | |
---|
| 31 | #define _FSTDIO /* ``function stdio'' */ |
---|
| 32 | |
---|
| 33 | #define __need_size_t |
---|
| 34 | #define __need_NULL |
---|
| 35 | #include <sys/cdefs.h> |
---|
| 36 | #include <stddef.h> |
---|
| 37 | |
---|
| 38 | /* typedef only __gnuc_va_list, used throughout the header */ |
---|
| 39 | #define __need___va_list |
---|
| 40 | #include <stdarg.h> |
---|
| 41 | |
---|
| 42 | /* typedef va_list only when required */ |
---|
| 43 | #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE |
---|
| 44 | #ifdef __GNUC__ |
---|
| 45 | #ifndef _VA_LIST_DEFINED |
---|
| 46 | typedef __gnuc_va_list va_list; |
---|
| 47 | #define _VA_LIST_DEFINED |
---|
| 48 | #endif |
---|
| 49 | #else /* !__GNUC__ */ |
---|
| 50 | #include <stdarg.h> |
---|
| 51 | #endif |
---|
| 52 | #endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */ |
---|
| 53 | |
---|
| 54 | /* |
---|
| 55 | * <sys/reent.h> defines __FILE, _fpos_t. |
---|
| 56 | * They must be defined there because struct _reent needs them (and we don't |
---|
| 57 | * want reent.h to include this file. |
---|
| 58 | */ |
---|
| 59 | |
---|
| 60 | #include <sys/reent.h> |
---|
| 61 | #include <sys/types.h> |
---|
| 62 | |
---|
| 63 | _BEGIN_STD_C |
---|
| 64 | |
---|
| 65 | #if !defined(__FILE_defined) |
---|
| 66 | typedef __FILE FILE; |
---|
| 67 | # define __FILE_defined |
---|
| 68 | #endif |
---|
| 69 | |
---|
| 70 | #ifdef __CYGWIN__ |
---|
| 71 | typedef _fpos64_t fpos_t; |
---|
| 72 | #else |
---|
| 73 | typedef _fpos_t fpos_t; |
---|
| 74 | #ifdef __LARGE64_FILES |
---|
| 75 | typedef _fpos64_t fpos64_t; |
---|
| 76 | #endif |
---|
| 77 | #endif /* !__CYGWIN__ */ |
---|
| 78 | |
---|
| 79 | #include <sys/stdio.h> |
---|
| 80 | |
---|
| 81 | #define __SLBF 0x0001 /* line buffered */ |
---|
| 82 | #define __SNBF 0x0002 /* unbuffered */ |
---|
| 83 | #define __SRD 0x0004 /* OK to read */ |
---|
| 84 | #define __SWR 0x0008 /* OK to write */ |
---|
| 85 | /* RD and WR are never simultaneously asserted */ |
---|
| 86 | #define __SRW 0x0010 /* open for reading & writing */ |
---|
| 87 | #define __SEOF 0x0020 /* found EOF */ |
---|
| 88 | #define __SERR 0x0040 /* found error */ |
---|
| 89 | #define __SMBF 0x0080 /* _buf is from malloc */ |
---|
| 90 | #define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */ |
---|
| 91 | #define __SSTR 0x0200 /* this is an sprintf/snprintf string */ |
---|
| 92 | #define __SOPT 0x0400 /* do fseek() optimisation */ |
---|
| 93 | #define __SNPT 0x0800 /* do not do fseek() optimisation */ |
---|
| 94 | #define __SOFF 0x1000 /* set iff _offset is in fact correct */ |
---|
| 95 | #define __SORD 0x2000 /* true => stream orientation (byte/wide) decided */ |
---|
| 96 | #if defined(__CYGWIN__) |
---|
| 97 | # define __SCLE 0x4000 /* convert line endings CR/LF <-> NL */ |
---|
| 98 | #endif |
---|
| 99 | #define __SL64 0x8000 /* is 64-bit offset large file */ |
---|
| 100 | |
---|
| 101 | /* _flags2 flags */ |
---|
| 102 | #define __SNLK 0x0001 /* stdio functions do not lock streams themselves */ |
---|
| 103 | #define __SWID 0x2000 /* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */ |
---|
| 104 | |
---|
| 105 | /* |
---|
| 106 | * The following three definitions are for ANSI C, which took them |
---|
| 107 | * from System V, which stupidly took internal interface macros and |
---|
| 108 | * made them official arguments to setvbuf(), without renaming them. |
---|
| 109 | * Hence, these ugly _IOxxx names are *supposed* to appear in user code. |
---|
| 110 | * |
---|
| 111 | * Although these happen to match their counterparts above, the |
---|
| 112 | * implementation does not rely on that (so these could be renumbered). |
---|
| 113 | */ |
---|
| 114 | #define _IOFBF 0 /* setvbuf should set fully buffered */ |
---|
| 115 | #define _IOLBF 1 /* setvbuf should set line buffered */ |
---|
| 116 | #define _IONBF 2 /* setvbuf should set unbuffered */ |
---|
| 117 | |
---|
| 118 | #define EOF (-1) |
---|
| 119 | |
---|
| 120 | #ifdef __BUFSIZ__ |
---|
| 121 | #define BUFSIZ __BUFSIZ__ |
---|
| 122 | #else |
---|
| 123 | #define BUFSIZ 1024 |
---|
| 124 | #endif |
---|
| 125 | |
---|
| 126 | #ifdef __FOPEN_MAX__ |
---|
| 127 | #define FOPEN_MAX __FOPEN_MAX__ |
---|
| 128 | #else |
---|
| 129 | #define FOPEN_MAX 20 |
---|
| 130 | #endif |
---|
| 131 | |
---|
| 132 | #ifdef __FILENAME_MAX__ |
---|
| 133 | #define FILENAME_MAX __FILENAME_MAX__ |
---|
| 134 | #else |
---|
| 135 | #define FILENAME_MAX 1024 |
---|
| 136 | #endif |
---|
| 137 | |
---|
| 138 | #ifdef __L_tmpnam__ |
---|
| 139 | #define L_tmpnam __L_tmpnam__ |
---|
| 140 | #else |
---|
| 141 | #define L_tmpnam FILENAME_MAX |
---|
| 142 | #endif |
---|
| 143 | |
---|
| 144 | #if __BSD_VISIBLE || __XSI_VISIBLE |
---|
| 145 | #define P_tmpdir "/tmp" |
---|
| 146 | #endif |
---|
| 147 | |
---|
| 148 | #ifndef SEEK_SET |
---|
| 149 | #define SEEK_SET 0 /* set file offset to offset */ |
---|
| 150 | #endif |
---|
| 151 | #ifndef SEEK_CUR |
---|
| 152 | #define SEEK_CUR 1 /* set file offset to current plus offset */ |
---|
| 153 | #endif |
---|
| 154 | #ifndef SEEK_END |
---|
| 155 | #define SEEK_END 2 /* set file offset to EOF plus offset */ |
---|
| 156 | #endif |
---|
| 157 | |
---|
| 158 | #define TMP_MAX 26 |
---|
| 159 | |
---|
| 160 | #define stdin (_REENT->_stdin) |
---|
| 161 | #define stdout (_REENT->_stdout) |
---|
| 162 | #define stderr (_REENT->_stderr) |
---|
| 163 | |
---|
| 164 | #define _stdin_r(x) ((x)->_stdin) |
---|
| 165 | #define _stdout_r(x) ((x)->_stdout) |
---|
| 166 | #define _stderr_r(x) ((x)->_stderr) |
---|
| 167 | |
---|
| 168 | /* |
---|
| 169 | * Functions defined in ANSI C standard. |
---|
| 170 | */ |
---|
| 171 | |
---|
| 172 | #ifndef __VALIST |
---|
| 173 | #ifdef __GNUC__ |
---|
| 174 | #define __VALIST __gnuc_va_list |
---|
| 175 | #else |
---|
| 176 | #define __VALIST char* |
---|
| 177 | #endif |
---|
| 178 | #endif |
---|
| 179 | |
---|
| 180 | #if __POSIX_VISIBLE |
---|
| 181 | char * ctermid (char *); |
---|
| 182 | #endif |
---|
| 183 | #if __XSI_VISIBLE && __XSI_VISIBLE < 600 |
---|
| 184 | char * cuserid (char *); |
---|
| 185 | #endif |
---|
| 186 | FILE * tmpfile (void); |
---|
| 187 | char * tmpnam (char *); |
---|
| 188 | #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 |
---|
| 189 | char * tempnam (const char *, const char *); |
---|
| 190 | #endif |
---|
| 191 | int fclose (FILE *); |
---|
| 192 | int fflush (FILE *); |
---|
| 193 | FILE * freopen (const char *__restrict, const char *__restrict, FILE *__restrict); |
---|
| 194 | void setbuf (FILE *__restrict, char *__restrict); |
---|
| 195 | int setvbuf (FILE *__restrict, char *__restrict, int, size_t); |
---|
| 196 | int fprintf (FILE *__restrict, const char *__restrict, ...) |
---|
| 197 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 198 | int fscanf (FILE *__restrict, const char *__restrict, ...) |
---|
| 199 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); |
---|
| 200 | int printf (const char *__restrict, ...) |
---|
| 201 | _ATTRIBUTE ((__format__ (__printf__, 1, 2))); |
---|
| 202 | int scanf (const char *__restrict, ...) |
---|
| 203 | _ATTRIBUTE ((__format__ (__scanf__, 1, 2))); |
---|
| 204 | int sscanf (const char *__restrict, const char *__restrict, ...) |
---|
| 205 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); |
---|
| 206 | int vfprintf (FILE *__restrict, const char *__restrict, __VALIST) |
---|
| 207 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 208 | int vprintf (const char *, __VALIST) |
---|
| 209 | _ATTRIBUTE ((__format__ (__printf__, 1, 0))); |
---|
| 210 | int vsprintf (char *__restrict, const char *__restrict, __VALIST) |
---|
| 211 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 212 | int fgetc (FILE *); |
---|
| 213 | char * fgets (char *__restrict, int, FILE *__restrict); |
---|
| 214 | int fputc (int, FILE *); |
---|
| 215 | int fputs (const char *__restrict, FILE *__restrict); |
---|
| 216 | int getc (FILE *); |
---|
| 217 | int getchar (void); |
---|
| 218 | char * gets (char *); |
---|
| 219 | int putc (int, FILE *); |
---|
| 220 | int putchar (int); |
---|
| 221 | int puts (const char *); |
---|
| 222 | int ungetc (int, FILE *); |
---|
| 223 | size_t fread (void *__restrict, size_t _size, size_t _n, FILE *__restrict); |
---|
| 224 | size_t fwrite (const void *__restrict , size_t _size, size_t _n, FILE *); |
---|
| 225 | #ifdef _COMPILING_NEWLIB |
---|
| 226 | int fgetpos (FILE *, _fpos_t *); |
---|
| 227 | #else |
---|
| 228 | int fgetpos (FILE *__restrict, fpos_t *__restrict); |
---|
| 229 | #endif |
---|
| 230 | int fseek (FILE *, long, int); |
---|
| 231 | #ifdef _COMPILING_NEWLIB |
---|
| 232 | int fsetpos (FILE *, const _fpos_t *); |
---|
| 233 | #else |
---|
| 234 | int fsetpos (FILE *, const fpos_t *); |
---|
| 235 | #endif |
---|
| 236 | long ftell ( FILE *); |
---|
| 237 | void rewind (FILE *); |
---|
| 238 | void clearerr (FILE *); |
---|
| 239 | int feof (FILE *); |
---|
| 240 | int ferror (FILE *); |
---|
| 241 | void perror (const char *); |
---|
| 242 | #ifndef _REENT_ONLY |
---|
| 243 | FILE * fopen (const char *__restrict _name, const char *__restrict _type); |
---|
| 244 | int sprintf (char *__restrict, const char *__restrict, ...) |
---|
| 245 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 246 | int remove (const char *); |
---|
| 247 | int rename (const char *, const char *); |
---|
| 248 | #ifdef _COMPILING_NEWLIB |
---|
| 249 | int _rename (const char *, const char *); |
---|
| 250 | #endif |
---|
| 251 | #endif |
---|
| 252 | #if __LARGEFILE_VISIBLE || __POSIX_VISIBLE >= 200112 |
---|
| 253 | #ifdef _COMPILING_NEWLIB |
---|
| 254 | int fseeko (FILE *, _off_t, int); |
---|
| 255 | _off_t ftello (FILE *); |
---|
| 256 | #else |
---|
| 257 | int fseeko (FILE *, off_t, int); |
---|
| 258 | off_t ftello (FILE *); |
---|
| 259 | #endif |
---|
| 260 | #endif |
---|
| 261 | #if __GNU_VISIBLE |
---|
| 262 | int fcloseall (void); |
---|
| 263 | #endif |
---|
| 264 | #ifndef _REENT_ONLY |
---|
| 265 | #if __ISO_C_VISIBLE >= 1999 |
---|
| 266 | int snprintf (char *__restrict, size_t, const char *__restrict, ...) |
---|
| 267 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 268 | int vsnprintf (char *__restrict, size_t, const char *__restrict, __VALIST) |
---|
| 269 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 270 | int vfscanf (FILE *__restrict, const char *__restrict, __VALIST) |
---|
| 271 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); |
---|
| 272 | int vscanf (const char *, __VALIST) |
---|
| 273 | _ATTRIBUTE ((__format__ (__scanf__, 1, 0))); |
---|
| 274 | int vsscanf (const char *__restrict, const char *__restrict, __VALIST) |
---|
| 275 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); |
---|
| 276 | #endif |
---|
| 277 | #if __GNU_VISIBLE |
---|
| 278 | int asprintf (char **__restrict, const char *__restrict, ...) |
---|
| 279 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 280 | int vasprintf (char **, const char *, __VALIST) |
---|
| 281 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 282 | #endif |
---|
| 283 | #if __MISC_VISIBLE /* Newlib-specific */ |
---|
| 284 | int asiprintf (char **, const char *, ...) |
---|
| 285 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 286 | char * asniprintf (char *, size_t *, const char *, ...) |
---|
| 287 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 288 | char * asnprintf (char *__restrict, size_t *__restrict, const char *__restrict, ...) |
---|
| 289 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 290 | #ifndef diprintf |
---|
| 291 | int diprintf (int, const char *, ...) |
---|
| 292 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 293 | #endif |
---|
| 294 | int fiprintf (FILE *, const char *, ...) |
---|
| 295 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 296 | int fiscanf (FILE *, const char *, ...) |
---|
| 297 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); |
---|
| 298 | int iprintf (const char *, ...) |
---|
| 299 | _ATTRIBUTE ((__format__ (__printf__, 1, 2))); |
---|
| 300 | int iscanf (const char *, ...) |
---|
| 301 | _ATTRIBUTE ((__format__ (__scanf__, 1, 2))); |
---|
| 302 | int siprintf (char *, const char *, ...) |
---|
| 303 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 304 | int siscanf (const char *, const char *, ...) |
---|
| 305 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); |
---|
| 306 | int sniprintf (char *, size_t, const char *, ...) |
---|
| 307 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 308 | int vasiprintf (char **, const char *, __VALIST) |
---|
| 309 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 310 | char * vasniprintf (char *, size_t *, const char *, __VALIST) |
---|
| 311 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 312 | char * vasnprintf (char *, size_t *, const char *, __VALIST) |
---|
| 313 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 314 | int vdiprintf (int, const char *, __VALIST) |
---|
| 315 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 316 | int vfiprintf (FILE *, const char *, __VALIST) |
---|
| 317 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 318 | int vfiscanf (FILE *, const char *, __VALIST) |
---|
| 319 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); |
---|
| 320 | int viprintf (const char *, __VALIST) |
---|
| 321 | _ATTRIBUTE ((__format__ (__printf__, 1, 0))); |
---|
| 322 | int viscanf (const char *, __VALIST) |
---|
| 323 | _ATTRIBUTE ((__format__ (__scanf__, 1, 0))); |
---|
| 324 | int vsiprintf (char *, const char *, __VALIST) |
---|
| 325 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 326 | int vsiscanf (const char *, const char *, __VALIST) |
---|
| 327 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); |
---|
| 328 | int vsniprintf (char *, size_t, const char *, __VALIST) |
---|
| 329 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 330 | #endif /* __MISC_VISIBLE */ |
---|
| 331 | #endif /* !_REENT_ONLY */ |
---|
| 332 | |
---|
| 333 | /* |
---|
| 334 | * Routines in POSIX 1003.1:2001. |
---|
| 335 | */ |
---|
| 336 | |
---|
| 337 | #if __POSIX_VISIBLE |
---|
| 338 | #ifndef _REENT_ONLY |
---|
| 339 | FILE * fdopen (int, const char *); |
---|
| 340 | #endif |
---|
| 341 | int fileno (FILE *); |
---|
| 342 | #endif |
---|
| 343 | #if __MISC_VISIBLE || __POSIX_VISIBLE >= 199209 |
---|
| 344 | int pclose (FILE *); |
---|
| 345 | FILE * popen (const char *, const char *); |
---|
| 346 | #endif |
---|
| 347 | |
---|
| 348 | #if __BSD_VISIBLE |
---|
| 349 | void setbuffer (FILE *, char *, int); |
---|
| 350 | int setlinebuf (FILE *); |
---|
| 351 | #endif |
---|
| 352 | |
---|
| 353 | #if __MISC_VISIBLE || (__XSI_VISIBLE && __POSIX_VISIBLE < 200112) |
---|
| 354 | int getw (FILE *); |
---|
| 355 | int putw (int, FILE *); |
---|
| 356 | #endif |
---|
| 357 | #if __MISC_VISIBLE || __POSIX_VISIBLE |
---|
| 358 | int getc_unlocked (FILE *); |
---|
| 359 | int getchar_unlocked (void); |
---|
| 360 | void flockfile (FILE *); |
---|
| 361 | int ftrylockfile (FILE *); |
---|
| 362 | void funlockfile (FILE *); |
---|
| 363 | int putc_unlocked (int, FILE *); |
---|
| 364 | int putchar_unlocked (int); |
---|
| 365 | #endif |
---|
| 366 | |
---|
| 367 | /* |
---|
| 368 | * Routines in POSIX 1003.1:200x. |
---|
| 369 | */ |
---|
| 370 | |
---|
| 371 | #if __POSIX_VISIBLE >= 200809 |
---|
| 372 | # ifndef _REENT_ONLY |
---|
| 373 | # ifndef dprintf |
---|
| 374 | int dprintf (int, const char *__restrict, ...) |
---|
| 375 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 376 | # endif |
---|
| 377 | FILE * fmemopen (void *__restrict, size_t, const char *__restrict); |
---|
| 378 | /* getdelim - see __getdelim for now */ |
---|
| 379 | /* getline - see __getline for now */ |
---|
| 380 | FILE * open_memstream (char **, size_t *); |
---|
| 381 | int vdprintf (int, const char *__restrict, __VALIST) |
---|
| 382 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 383 | # endif |
---|
| 384 | #endif |
---|
| 385 | #if __ATFILE_VISIBLE |
---|
| 386 | int renameat (int, const char *, int, const char *); |
---|
| 387 | # ifdef __CYGWIN__ |
---|
| 388 | int renameat2 (int, const char *, int, const char *, unsigned int); |
---|
| 389 | # endif |
---|
| 390 | #endif |
---|
| 391 | |
---|
| 392 | /* |
---|
| 393 | * Recursive versions of the above. |
---|
| 394 | */ |
---|
| 395 | |
---|
| 396 | int _asiprintf_r (struct _reent *, char **, const char *, ...) |
---|
| 397 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 398 | char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) |
---|
| 399 | _ATTRIBUTE ((__format__ (__printf__, 4, 5))); |
---|
| 400 | char * _asnprintf_r (struct _reent *, char *__restrict, size_t *__restrict, const char *__restrict, ...) |
---|
| 401 | _ATTRIBUTE ((__format__ (__printf__, 4, 5))); |
---|
| 402 | int _asprintf_r (struct _reent *, char **__restrict, const char *__restrict, ...) |
---|
| 403 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 404 | int _diprintf_r (struct _reent *, int, const char *, ...) |
---|
| 405 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 406 | int _dprintf_r (struct _reent *, int, const char *__restrict, ...) |
---|
| 407 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 408 | int _fclose_r (struct _reent *, FILE *); |
---|
| 409 | int _fcloseall_r (struct _reent *); |
---|
| 410 | FILE * _fdopen_r (struct _reent *, int, const char *); |
---|
| 411 | int _fflush_r (struct _reent *, FILE *); |
---|
| 412 | int _fgetc_r (struct _reent *, FILE *); |
---|
| 413 | int _fgetc_unlocked_r (struct _reent *, FILE *); |
---|
| 414 | char * _fgets_r (struct _reent *, char *__restrict, int, FILE *__restrict); |
---|
| 415 | char * _fgets_unlocked_r (struct _reent *, char *__restrict, int, FILE *__restrict); |
---|
| 416 | #ifdef _COMPILING_NEWLIB |
---|
| 417 | int _fgetpos_r (struct _reent *, FILE *__restrict, _fpos_t *__restrict); |
---|
| 418 | int _fsetpos_r (struct _reent *, FILE *, const _fpos_t *); |
---|
| 419 | #else |
---|
| 420 | int _fgetpos_r (struct _reent *, FILE *, fpos_t *); |
---|
| 421 | int _fsetpos_r (struct _reent *, FILE *, const fpos_t *); |
---|
| 422 | #endif |
---|
| 423 | int _fiprintf_r (struct _reent *, FILE *, const char *, ...) |
---|
| 424 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 425 | int _fiscanf_r (struct _reent *, FILE *, const char *, ...) |
---|
| 426 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); |
---|
| 427 | FILE * _fmemopen_r (struct _reent *, void *__restrict, size_t, const char *__restrict); |
---|
| 428 | FILE * _fopen_r (struct _reent *, const char *__restrict, const char *__restrict); |
---|
| 429 | FILE * _freopen_r (struct _reent *, const char *__restrict, const char *__restrict, FILE *__restrict); |
---|
| 430 | int _fprintf_r (struct _reent *, FILE *__restrict, const char *__restrict, ...) |
---|
| 431 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 432 | int _fpurge_r (struct _reent *, FILE *); |
---|
| 433 | int _fputc_r (struct _reent *, int, FILE *); |
---|
| 434 | int _fputc_unlocked_r (struct _reent *, int, FILE *); |
---|
| 435 | int _fputs_r (struct _reent *, const char *__restrict, FILE *__restrict); |
---|
| 436 | int _fputs_unlocked_r (struct _reent *, const char *__restrict, FILE *__restrict); |
---|
| 437 | size_t _fread_r (struct _reent *, void *__restrict, size_t _size, size_t _n, FILE *__restrict); |
---|
| 438 | size_t _fread_unlocked_r (struct _reent *, void *__restrict, size_t _size, size_t _n, FILE *__restrict); |
---|
| 439 | int _fscanf_r (struct _reent *, FILE *__restrict, const char *__restrict, ...) |
---|
| 440 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); |
---|
| 441 | int _fseek_r (struct _reent *, FILE *, long, int); |
---|
| 442 | int _fseeko_r (struct _reent *, FILE *, _off_t, int); |
---|
| 443 | long _ftell_r (struct _reent *, FILE *); |
---|
| 444 | _off_t _ftello_r (struct _reent *, FILE *); |
---|
| 445 | void _rewind_r (struct _reent *, FILE *); |
---|
| 446 | size_t _fwrite_r (struct _reent *, const void *__restrict, size_t _size, size_t _n, FILE *__restrict); |
---|
| 447 | size_t _fwrite_unlocked_r (struct _reent *, const void *__restrict, size_t _size, size_t _n, FILE *__restrict); |
---|
| 448 | int _getc_r (struct _reent *, FILE *); |
---|
| 449 | int _getc_unlocked_r (struct _reent *, FILE *); |
---|
| 450 | int _getchar_r (struct _reent *); |
---|
| 451 | int _getchar_unlocked_r (struct _reent *); |
---|
| 452 | char * _gets_r (struct _reent *, char *); |
---|
| 453 | int _iprintf_r (struct _reent *, const char *, ...) |
---|
| 454 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 455 | int _iscanf_r (struct _reent *, const char *, ...) |
---|
| 456 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); |
---|
| 457 | FILE * _open_memstream_r (struct _reent *, char **, size_t *); |
---|
| 458 | void _perror_r (struct _reent *, const char *); |
---|
| 459 | int _printf_r (struct _reent *, const char *__restrict, ...) |
---|
| 460 | _ATTRIBUTE ((__format__ (__printf__, 2, 3))); |
---|
| 461 | int _putc_r (struct _reent *, int, FILE *); |
---|
| 462 | int _putc_unlocked_r (struct _reent *, int, FILE *); |
---|
| 463 | int _putchar_unlocked_r (struct _reent *, int); |
---|
| 464 | int _putchar_r (struct _reent *, int); |
---|
| 465 | int _puts_r (struct _reent *, const char *); |
---|
| 466 | int _remove_r (struct _reent *, const char *); |
---|
| 467 | int _rename_r (struct _reent *, |
---|
| 468 | const char *_old, const char *_new); |
---|
| 469 | int _scanf_r (struct _reent *, const char *__restrict, ...) |
---|
| 470 | _ATTRIBUTE ((__format__ (__scanf__, 2, 3))); |
---|
| 471 | int _siprintf_r (struct _reent *, char *, const char *, ...) |
---|
| 472 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 473 | int _siscanf_r (struct _reent *, const char *, const char *, ...) |
---|
| 474 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); |
---|
| 475 | int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) |
---|
| 476 | _ATTRIBUTE ((__format__ (__printf__, 4, 5))); |
---|
| 477 | int _snprintf_r (struct _reent *, char *__restrict, size_t, const char *__restrict, ...) |
---|
| 478 | _ATTRIBUTE ((__format__ (__printf__, 4, 5))); |
---|
| 479 | int _sprintf_r (struct _reent *, char *__restrict, const char *__restrict, ...) |
---|
| 480 | _ATTRIBUTE ((__format__ (__printf__, 3, 4))); |
---|
| 481 | int _sscanf_r (struct _reent *, const char *__restrict, const char *__restrict, ...) |
---|
| 482 | _ATTRIBUTE ((__format__ (__scanf__, 3, 4))); |
---|
| 483 | char * _tempnam_r (struct _reent *, const char *, const char *); |
---|
| 484 | FILE * _tmpfile_r (struct _reent *); |
---|
| 485 | char * _tmpnam_r (struct _reent *, char *); |
---|
| 486 | int _ungetc_r (struct _reent *, int, FILE *); |
---|
| 487 | int _vasiprintf_r (struct _reent *, char **, const char *, __VALIST) |
---|
| 488 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 489 | char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __VALIST) |
---|
| 490 | _ATTRIBUTE ((__format__ (__printf__, 4, 0))); |
---|
| 491 | char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __VALIST) |
---|
| 492 | _ATTRIBUTE ((__format__ (__printf__, 4, 0))); |
---|
| 493 | int _vasprintf_r (struct _reent *, char **, const char *, __VALIST) |
---|
| 494 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 495 | int _vdiprintf_r (struct _reent *, int, const char *, __VALIST) |
---|
| 496 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 497 | int _vdprintf_r (struct _reent *, int, const char *__restrict, __VALIST) |
---|
| 498 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 499 | int _vfiprintf_r (struct _reent *, FILE *, const char *, __VALIST) |
---|
| 500 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 501 | int _vfiscanf_r (struct _reent *, FILE *, const char *, __VALIST) |
---|
| 502 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); |
---|
| 503 | int _vfprintf_r (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST) |
---|
| 504 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 505 | int _vfscanf_r (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST) |
---|
| 506 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); |
---|
| 507 | int _viprintf_r (struct _reent *, const char *, __VALIST) |
---|
| 508 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 509 | int _viscanf_r (struct _reent *, const char *, __VALIST) |
---|
| 510 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); |
---|
| 511 | int _vprintf_r (struct _reent *, const char *__restrict, __VALIST) |
---|
| 512 | _ATTRIBUTE ((__format__ (__printf__, 2, 0))); |
---|
| 513 | int _vscanf_r (struct _reent *, const char *__restrict, __VALIST) |
---|
| 514 | _ATTRIBUTE ((__format__ (__scanf__, 2, 0))); |
---|
| 515 | int _vsiprintf_r (struct _reent *, char *, const char *, __VALIST) |
---|
| 516 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 517 | int _vsiscanf_r (struct _reent *, const char *, const char *, __VALIST) |
---|
| 518 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); |
---|
| 519 | int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __VALIST) |
---|
| 520 | _ATTRIBUTE ((__format__ (__printf__, 4, 0))); |
---|
| 521 | int _vsnprintf_r (struct _reent *, char *__restrict, size_t, const char *__restrict, __VALIST) |
---|
| 522 | _ATTRIBUTE ((__format__ (__printf__, 4, 0))); |
---|
| 523 | int _vsprintf_r (struct _reent *, char *__restrict, const char *__restrict, __VALIST) |
---|
| 524 | _ATTRIBUTE ((__format__ (__printf__, 3, 0))); |
---|
| 525 | int _vsscanf_r (struct _reent *, const char *__restrict, const char *__restrict, __VALIST) |
---|
| 526 | _ATTRIBUTE ((__format__ (__scanf__, 3, 0))); |
---|
| 527 | |
---|
| 528 | /* Other extensions. */ |
---|
| 529 | |
---|
| 530 | int fpurge (FILE *); |
---|
| 531 | ssize_t __getdelim (char **, size_t *, int, FILE *); |
---|
| 532 | ssize_t __getline (char **, size_t *, FILE *); |
---|
| 533 | |
---|
| 534 | #if __MISC_VISIBLE |
---|
| 535 | void clearerr_unlocked (FILE *); |
---|
| 536 | int feof_unlocked (FILE *); |
---|
| 537 | int ferror_unlocked (FILE *); |
---|
| 538 | int fileno_unlocked (FILE *); |
---|
| 539 | int fflush_unlocked (FILE *); |
---|
| 540 | int fgetc_unlocked (FILE *); |
---|
| 541 | int fputc_unlocked (int, FILE *); |
---|
| 542 | size_t fread_unlocked (void *__restrict, size_t _size, size_t _n, FILE *__restrict); |
---|
| 543 | size_t fwrite_unlocked (const void *__restrict , size_t _size, size_t _n, FILE *); |
---|
| 544 | #endif |
---|
| 545 | |
---|
| 546 | #if __GNU_VISIBLE |
---|
| 547 | char * fgets_unlocked (char *__restrict, int, FILE *__restrict); |
---|
| 548 | int fputs_unlocked (const char *__restrict, FILE *__restrict); |
---|
| 549 | #endif |
---|
| 550 | |
---|
| 551 | #ifdef __LARGE64_FILES |
---|
| 552 | #if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB) |
---|
| 553 | FILE * fdopen64 (int, const char *); |
---|
| 554 | FILE * fopen64 (const char *, const char *); |
---|
| 555 | FILE * freopen64 (const char *, const char *, FILE *); |
---|
| 556 | _off64_t ftello64 (FILE *); |
---|
| 557 | _off64_t fseeko64 (FILE *, _off64_t, int); |
---|
| 558 | int fgetpos64 (FILE *, _fpos64_t *); |
---|
| 559 | int fsetpos64 (FILE *, const _fpos64_t *); |
---|
| 560 | FILE * tmpfile64 (void); |
---|
| 561 | |
---|
| 562 | FILE * _fdopen64_r (struct _reent *, int, const char *); |
---|
| 563 | FILE * _fopen64_r (struct _reent *,const char *, const char *); |
---|
| 564 | FILE * _freopen64_r (struct _reent *, const char *, const char *, FILE *); |
---|
| 565 | _off64_t _ftello64_r (struct _reent *, FILE *); |
---|
| 566 | _off64_t _fseeko64_r (struct _reent *, FILE *, _off64_t, int); |
---|
| 567 | int _fgetpos64_r (struct _reent *, FILE *, _fpos64_t *); |
---|
| 568 | int _fsetpos64_r (struct _reent *, FILE *, const _fpos64_t *); |
---|
| 569 | FILE * _tmpfile64_r (struct _reent *); |
---|
| 570 | #endif /* !__CYGWIN__ */ |
---|
| 571 | #endif /* __LARGE64_FILES */ |
---|
| 572 | |
---|
| 573 | /* |
---|
| 574 | * Routines internal to the implementation. |
---|
| 575 | */ |
---|
| 576 | |
---|
| 577 | int __srget_r (struct _reent *, FILE *); |
---|
| 578 | int __swbuf_r (struct _reent *, int, FILE *); |
---|
| 579 | |
---|
| 580 | /* |
---|
| 581 | * Stdio function-access interface. |
---|
| 582 | */ |
---|
| 583 | |
---|
| 584 | #if __BSD_VISIBLE |
---|
| 585 | # ifdef __LARGE64_FILES |
---|
| 586 | FILE *funopen (const void *__cookie, |
---|
| 587 | int (*__readfn)(void *__c, char *__buf, |
---|
| 588 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 589 | int (*__writefn)(void *__c, const char *__buf, |
---|
| 590 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 591 | _fpos64_t (*__seekfn)(void *__c, _fpos64_t __off, int __whence), |
---|
| 592 | int (*__closefn)(void *__c)); |
---|
| 593 | FILE *_funopen_r (struct _reent *, const void *__cookie, |
---|
| 594 | int (*__readfn)(void *__c, char *__buf, |
---|
| 595 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 596 | int (*__writefn)(void *__c, const char *__buf, |
---|
| 597 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 598 | _fpos64_t (*__seekfn)(void *__c, _fpos64_t __off, int __whence), |
---|
| 599 | int (*__closefn)(void *__c)); |
---|
| 600 | # else |
---|
| 601 | FILE *funopen (const void *__cookie, |
---|
| 602 | int (*__readfn)(void *__cookie, char *__buf, |
---|
| 603 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 604 | int (*__writefn)(void *__cookie, const char *__buf, |
---|
| 605 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 606 | fpos_t (*__seekfn)(void *__cookie, fpos_t __off, int __whence), |
---|
| 607 | int (*__closefn)(void *__cookie)); |
---|
| 608 | FILE *_funopen_r (struct _reent *, const void *__cookie, |
---|
| 609 | int (*__readfn)(void *__cookie, char *__buf, |
---|
| 610 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 611 | int (*__writefn)(void *__cookie, const char *__buf, |
---|
| 612 | _READ_WRITE_BUFSIZE_TYPE __n), |
---|
| 613 | fpos_t (*__seekfn)(void *__cookie, fpos_t __off, int __whence), |
---|
| 614 | int (*__closefn)(void *__cookie)); |
---|
| 615 | # endif /* !__LARGE64_FILES */ |
---|
| 616 | |
---|
| 617 | # define fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \ |
---|
| 618 | (fpos_t (*)())0, (int (*)())0) |
---|
| 619 | # define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \ |
---|
| 620 | (fpos_t (*)())0, (int (*)())0) |
---|
| 621 | #endif /* __BSD_VISIBLE */ |
---|
| 622 | |
---|
| 623 | #if __GNU_VISIBLE |
---|
| 624 | typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n); |
---|
| 625 | typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf, |
---|
| 626 | size_t __n); |
---|
| 627 | # ifdef __LARGE64_FILES |
---|
| 628 | typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off, |
---|
| 629 | int __whence); |
---|
| 630 | # else |
---|
| 631 | typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence); |
---|
| 632 | # endif /* !__LARGE64_FILES */ |
---|
| 633 | typedef int cookie_close_function_t(void *__cookie); |
---|
| 634 | typedef struct |
---|
| 635 | { |
---|
| 636 | /* These four struct member names are dictated by Linux; hopefully, |
---|
| 637 | they don't conflict with any macros. */ |
---|
| 638 | cookie_read_function_t *read; |
---|
| 639 | cookie_write_function_t *write; |
---|
| 640 | cookie_seek_function_t *seek; |
---|
| 641 | cookie_close_function_t *close; |
---|
| 642 | } cookie_io_functions_t; |
---|
| 643 | FILE *fopencookie (void *__cookie, |
---|
| 644 | const char *__mode, cookie_io_functions_t __functions); |
---|
| 645 | FILE *_fopencookie_r (struct _reent *, void *__cookie, |
---|
| 646 | const char *__mode, cookie_io_functions_t __functions); |
---|
| 647 | #endif /* __GNU_VISIBLE */ |
---|
| 648 | |
---|
| 649 | #ifndef __CUSTOM_FILE_IO__ |
---|
| 650 | /* |
---|
| 651 | * The __sfoo macros are here so that we can |
---|
| 652 | * define function versions in the C library. |
---|
| 653 | */ |
---|
| 654 | #define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++)) |
---|
| 655 | |
---|
| 656 | #ifdef __SCLE |
---|
| 657 | /* For a platform with CR/LF, additional logic is required by |
---|
| 658 | __sgetc_r which would otherwise simply be a macro; therefore we |
---|
| 659 | use an inlined function. The function is only meant to be inlined |
---|
| 660 | in place as used and the function body should never be emitted. |
---|
| 661 | |
---|
| 662 | There are two possible means to this end when compiling with GCC, |
---|
| 663 | one when compiling with a standard C99 compiler, and for other |
---|
| 664 | compilers we're just stuck. At the moment, this issue only |
---|
| 665 | affects the Cygwin target, so we'll most likely be using GCC. */ |
---|
| 666 | |
---|
| 667 | _ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p); |
---|
| 668 | |
---|
| 669 | _ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p) |
---|
| 670 | { |
---|
| 671 | int __c = __sgetc_raw_r(__ptr, __p); |
---|
| 672 | if ((__p->_flags & __SCLE) && (__c == '\r')) |
---|
| 673 | { |
---|
| 674 | int __c2 = __sgetc_raw_r(__ptr, __p); |
---|
| 675 | if (__c2 == '\n') |
---|
| 676 | __c = __c2; |
---|
| 677 | else |
---|
| 678 | ungetc(__c2, __p); |
---|
| 679 | } |
---|
| 680 | return __c; |
---|
| 681 | } |
---|
| 682 | #else |
---|
| 683 | #define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p) |
---|
| 684 | #endif |
---|
| 685 | |
---|
| 686 | #ifdef __GNUC__ |
---|
| 687 | _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { |
---|
| 688 | #ifdef __SCLE |
---|
| 689 | if ((_p->_flags & __SCLE) && _c == '\n') |
---|
| 690 | __sputc_r (_ptr, '\r', _p); |
---|
| 691 | #endif |
---|
| 692 | if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) |
---|
| 693 | return (*_p->_p++ = _c); |
---|
| 694 | else |
---|
| 695 | return (__swbuf_r(_ptr, _c, _p)); |
---|
| 696 | } |
---|
| 697 | #else |
---|
| 698 | /* |
---|
| 699 | * This has been tuned to generate reasonable code on the vax using pcc |
---|
| 700 | */ |
---|
| 701 | #define __sputc_raw_r(__ptr, __c, __p) \ |
---|
| 702 | (--(__p)->_w < 0 ? \ |
---|
| 703 | (__p)->_w >= (__p)->_lbfsize ? \ |
---|
| 704 | (*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \ |
---|
| 705 | (int)*(__p)->_p++ : \ |
---|
| 706 | __swbuf_r(__ptr, '\n', __p) : \ |
---|
| 707 | __swbuf_r(__ptr, (int)(__c), __p) : \ |
---|
| 708 | (*(__p)->_p = (__c), (int)*(__p)->_p++)) |
---|
| 709 | #ifdef __SCLE |
---|
| 710 | #define __sputc_r(__ptr, __c, __p) \ |
---|
| 711 | ((((__p)->_flags & __SCLE) && ((__c) == '\n')) \ |
---|
| 712 | ? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \ |
---|
| 713 | __sputc_raw_r((__ptr), (__c), (__p))) |
---|
| 714 | #else |
---|
| 715 | #define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p) |
---|
| 716 | #endif |
---|
| 717 | #endif |
---|
| 718 | |
---|
| 719 | #define __sfeof(p) ((int)(((p)->_flags & __SEOF) != 0)) |
---|
| 720 | #define __sferror(p) ((int)(((p)->_flags & __SERR) != 0)) |
---|
| 721 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) |
---|
| 722 | #define __sfileno(p) ((p)->_file) |
---|
| 723 | |
---|
| 724 | #ifndef __cplusplus |
---|
| 725 | #ifndef _REENT_SMALL |
---|
| 726 | #define feof(p) __sfeof(p) |
---|
| 727 | #define ferror(p) __sferror(p) |
---|
| 728 | #define clearerr(p) __sclearerr(p) |
---|
| 729 | |
---|
| 730 | #if __MISC_VISIBLE |
---|
| 731 | #define feof_unlocked(p) __sfeof(p) |
---|
| 732 | #define ferror_unlocked(p) __sferror(p) |
---|
| 733 | #define clearerr_unlocked(p) __sclearerr(p) |
---|
| 734 | #endif /* __MISC_VISIBLE */ |
---|
| 735 | #endif /* _REENT_SMALL */ |
---|
| 736 | |
---|
| 737 | #if 0 /* __POSIX_VISIBLE - FIXME: must initialize stdio first, use fn */ |
---|
| 738 | #define fileno(p) __sfileno(p) |
---|
| 739 | #endif |
---|
| 740 | |
---|
| 741 | static __inline int |
---|
| 742 | _getchar_unlocked(void) |
---|
| 743 | { |
---|
| 744 | struct _reent *_ptr; |
---|
| 745 | |
---|
| 746 | _ptr = _REENT; |
---|
| 747 | return (__sgetc_r(_ptr, _stdin_r(_ptr))); |
---|
| 748 | } |
---|
| 749 | |
---|
| 750 | static __inline int |
---|
| 751 | _putchar_unlocked(int _c) |
---|
| 752 | { |
---|
| 753 | struct _reent *_ptr; |
---|
| 754 | |
---|
| 755 | _ptr = _REENT; |
---|
| 756 | return (__sputc_r(_ptr, _c, _stdout_r(_ptr))); |
---|
| 757 | } |
---|
| 758 | |
---|
| 759 | #ifdef __SINGLE_THREAD__ |
---|
| 760 | #define getc(_p) __sgetc_r(_REENT, _p) |
---|
| 761 | #define putc(_c, _p) __sputc_r(_REENT, _c, _p) |
---|
| 762 | #define getchar() _getchar_unlocked() |
---|
| 763 | #define putchar(_c) _putchar_unlocked(_c) |
---|
| 764 | #endif /* __SINGLE_THREAD__ */ |
---|
| 765 | |
---|
| 766 | #if __MISC_VISIBLE || __POSIX_VISIBLE |
---|
| 767 | #define getchar_unlocked() _getchar_unlocked() |
---|
| 768 | #define putchar_unlocked(_c) _putchar_unlocked(_c) |
---|
| 769 | #endif |
---|
| 770 | #endif /* __cplusplus */ |
---|
| 771 | |
---|
| 772 | #if __MISC_VISIBLE |
---|
| 773 | /* fast always-buffered version, true iff error */ |
---|
| 774 | #define fast_putc(x,p) (--(p)->_w < 0 ? \ |
---|
| 775 | __swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0)) |
---|
| 776 | #endif |
---|
| 777 | |
---|
| 778 | #if __GNU_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600) |
---|
| 779 | #define L_cuserid 9 /* posix says it goes in stdio.h :( */ |
---|
| 780 | #endif |
---|
| 781 | #if __POSIX_VISIBLE |
---|
| 782 | #define L_ctermid 16 |
---|
| 783 | #endif |
---|
| 784 | |
---|
| 785 | #else /* __CUSTOM_FILE_IO__ */ |
---|
| 786 | |
---|
| 787 | #define getchar() getc(stdin) |
---|
| 788 | #define putchar(x) putc(x, stdout) |
---|
| 789 | |
---|
| 790 | #if __MISC_VISIBLE || __POSIX_VISIBLE |
---|
| 791 | #define getchar_unlocked() getc_unlocked(stdin) |
---|
| 792 | #define putchar_unlocked(x) putc_unlocked(x, stdout) |
---|
| 793 | #endif |
---|
| 794 | |
---|
| 795 | #endif /* !__CUSTOM_FILE_IO__ */ |
---|
| 796 | |
---|
| 797 | _END_STD_C |
---|
| 798 | |
---|
| 799 | #if __SSP_FORTIFY_LEVEL > 0 |
---|
| 800 | #include <ssp/stdio.h> |
---|
| 801 | #endif |
---|
| 802 | |
---|
| 803 | #endif /* _STDIO_H_ */ |
---|