stdio.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020: #ifndef _STDIO_H
021: # error "Never include <bits/stdio.h> directly; use <stdio.h> instead."
022: #endif
023:
024: #ifndef __extern_inline
025: # define __STDIO_INLINE inline
026: #else
027: # define __STDIO_INLINE __extern_inline
028: #endif
029:
030:
031: #ifdef __USE_EXTERN_INLINES
032:
033:
034: # if !(__USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline)
035:
036: __STDIO_INLINE int
037: vprintf (__const char *__restrict __fmt, _G_va_list __arg)
038: {
039: return vfprintf (stdout, __fmt, __arg);
040: }
041: # endif
042:
043:
044: __STDIO_INLINE int
045: getchar (void)
046: {
047: return _IO_getc (stdin);
048: }
049:
050:
051: # ifdef __USE_MISC
052:
053: __STDIO_INLINE int
054: fgetc_unlocked (FILE *__fp)
055: {
056: return _IO_getc_unlocked (__fp);
057: }
058: # endif
059:
060:
061: # if defined __USE_POSIX || defined __USE_MISC
062:
063: __STDIO_INLINE int
064: getc_unlocked (FILE *__fp)
065: {
066: return _IO_getc_unlocked (__fp);
067: }
068:
069:
070: __STDIO_INLINE int
071: getchar_unlocked (void)
072: {
073: return _IO_getc_unlocked (stdin);
074: }
075: # endif
076:
077:
078:
079: __STDIO_INLINE int
080: putchar (int __c)
081: {
082: return _IO_putc (__c, stdout);
083: }
084:
085:
086: # ifdef __USE_MISC
087:
088: __STDIO_INLINE int
089: fputc_unlocked (int __c, FILE *__stream)
090: {
091: return _IO_putc_unlocked (__c, __stream);
092: }
093: # endif
094:
095:
096: # if defined __USE_POSIX || defined __USE_MISC
097:
098: __STDIO_INLINE int
099: putc_unlocked (int __c, FILE *__stream)
100: {
101: return _IO_putc_unlocked (__c, __stream);
102: }
103:
104:
105: __STDIO_INLINE int
106: putchar_unlocked (int __c)
107: {
108: return _IO_putc_unlocked (__c, stdout);
109: }
110: # endif
111:
112:
113: # ifdef __USE_GNU
114:
115: __STDIO_INLINE _IO_ssize_t
116: getline (char **__lineptr, size_t *__n, FILE *__stream)
117: {
118: return __getdelim (__lineptr, __n, '\n', __stream);
119: }
120: # endif
121:
122:
123: # ifdef __USE_MISC
124:
125: __STDIO_INLINE int
126: __NTH (feof_unlocked (FILE *__stream))
127: {
128: return _IO_feof_unlocked (__stream);
129: }
130:
131:
132: __STDIO_INLINE int
133: __NTH (ferror_unlocked (FILE *__stream))
134: {
135: return _IO_ferror_unlocked (__stream);
136: }
137: # endif
138:
139: #endif
140:
141:
142: #if defined __USE_MISC && defined __GNUC__ && defined __OPTIMIZE__ \
143: && !defined __cplusplus
144:
145: # define fread_unlocked(ptr, size, n, stream) \
146: (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n) \
147: && (size_t) (size) * (size_t) (n) <= 8 \
148: && (size_t) (size) != 0) \
149: ? ({ char *__ptr = (char *) (ptr); \
150: FILE *__stream = (stream); \
151: size_t __cnt; \
152: for (__cnt = (size_t) (size) * (size_t) (n); \
153: __cnt > 0; --__cnt) \
154: { \
155: int __c = _IO_getc_unlocked (__stream); \
156: if (__c == EOF) \
157: break; \
158: *__ptr++ = __c; \
159: } \
160: ((size_t) (size) * (size_t) (n) - __cnt) \
161: / (size_t) (size); }) \
162: : (((__builtin_constant_p (size) && (size_t) (size) == 0) \
163: || (__builtin_constant_p (n) && (size_t) (n) == 0)) \
164: \
165: ? ((void) (ptr), (void) (stream), (void) (size), \
166: (void) (n), (size_t) 0) \
167: : fread_unlocked (ptr, size, n, stream))))
168:
169: # define fwrite_unlocked(ptr, size, n, stream) \
170: (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n) \
171: && (size_t) (size) * (size_t) (n) <= 8 \
172: && (size_t) (size) != 0) \
173: ? ({ const char *__ptr = (const char *) (ptr); \
174: FILE *__stream = (stream); \
175: size_t __cnt; \
176: for (__cnt = (size_t) (size) * (size_t) (n); \
177: __cnt > 0; --__cnt) \
178: if (_IO_putc_unlocked (*__ptr++, __stream) == EOF) \
179: break; \
180: ((size_t) (size) * (size_t) (n) - __cnt) \
181: / (size_t) (size); }) \
182: : (((__builtin_constant_p (size) && (size_t) (size) == 0) \
183: || (__builtin_constant_p (n) && (size_t) (n) == 0)) \
184: \
185: ? ((void) (ptr), (void) (stream), (void) (size), \
186: (void) (n), (size_t) 0) \
187: : fwrite_unlocked (ptr, size, n, stream))))
188: #endif
189:
190:
191: #undef __STDIO_INLINE
192:
© Andrew Scott 2006 -
2025,
All Rights Reserved