_stdio.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. /* Copyright (C) 2004-2005 Manuel Novoa III <mjn3@codepoet.org>
  2. *
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. *
  5. * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
  6. */
  7. #ifndef __STDIO_H_I
  8. #define __STDIO_H_I 1
  9. #include <features.h>
  10. #include <assert.h>
  11. #include <errno.h>
  12. #include <fcntl.h>
  13. #include <limits.h>
  14. #include <signal.h>
  15. #include <stdint.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdarg.h>
  20. #include <unistd.h>
  21. #ifdef __UCLIBC_HAS_WCHAR__
  22. #include <wchar.h>
  23. #endif
  24. #include <bits/uClibc_mutex.h>
  25. #define __STDIO_THREADLOCK_OPENLIST_ADD \
  26. __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_add_lock)
  27. #define __STDIO_THREADUNLOCK_OPENLIST_ADD \
  28. __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_add_lock)
  29. #ifdef __STDIO_BUFFERS
  30. #define __STDIO_THREADLOCK_OPENLIST_DEL \
  31. __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_del_lock)
  32. #define __STDIO_THREADUNLOCK_OPENLIST_DEL \
  33. __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_del_lock)
  34. #ifdef __UCLIBC_HAS_THREADS__
  35. extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) attribute_hidden;
  36. extern volatile int _stdio_openlist_use_count attribute_hidden; /* _stdio_openlist_del_lock */
  37. #define __STDIO_OPENLIST_INC_USE \
  38. do { \
  39. __STDIO_THREADLOCK_OPENLIST_DEL; \
  40. ++_stdio_openlist_use_count; \
  41. __STDIO_THREADUNLOCK_OPENLIST_DEL; \
  42. } while (0)
  43. extern void _stdio_openlist_dec_use(void) attribute_hidden;
  44. #define __STDIO_OPENLIST_DEC_USE \
  45. _stdio_openlist_dec_use()
  46. extern int _stdio_openlist_del_count attribute_hidden; /* _stdio_openlist_del_lock */
  47. #define __STDIO_OPENLIST_INC_DEL_CNT \
  48. do { \
  49. __STDIO_THREADLOCK_OPENLIST_DEL; \
  50. ++_stdio_openlist_del_count; \
  51. __STDIO_THREADUNLOCK_OPENLIST_DEL; \
  52. } while (0)
  53. #define __STDIO_OPENLIST_DEC_DEL_CNT \
  54. do { \
  55. __STDIO_THREADLOCK_OPENLIST_DEL; \
  56. --_stdio_openlist_del_count; \
  57. __STDIO_THREADUNLOCK_OPENLIST_DEL; \
  58. } while (0)
  59. #endif /* __UCLIBC_HAS_THREADS__ */
  60. #endif /* __STDIO_BUFFERS */
  61. #ifndef __STDIO_THREADLOCK_OPENLIST_DEL
  62. #define __STDIO_THREADLOCK_OPENLIST_DEL ((void)0)
  63. #endif
  64. #ifndef __STDIO_THREADUNLOCK_OPENLIST_DEL
  65. #define __STDIO_THREADUNLOCK_OPENLIST_DEL ((void)0)
  66. #endif
  67. #ifndef __STDIO_OPENLIST_INC_USE
  68. #define __STDIO_OPENLIST_INC_USE ((void)0)
  69. #endif
  70. #ifndef __STDIO_OPENLIST_DEC_USE
  71. #define __STDIO_OPENLIST_DEC_USE ((void)0)
  72. #endif
  73. #ifndef __STDIO_OPENLIST_INC_DEL_CNT
  74. #define __STDIO_OPENLIST_INC_DEL_CNT ((void)0)
  75. #endif
  76. #ifndef __STDIO_OPENLIST_DEC_DEL_CNT
  77. #define __STDIO_OPENLIST_DEC_DEL_CNT ((void)0)
  78. #endif
  79. #define __UNDEFINED_OR_NONPORTABLE ((void)0)
  80. /**********************************************************************/
  81. #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
  82. #define __STDIO_STREAM_GLIBC_CUSTOM_FILEDES (-2)
  83. #define __STDIO_STREAM_IS_CUSTOM(S) \
  84. ((S)->__filedes == __STDIO_STREAM_GLIBC_CUSTOM_FILEDES)
  85. #define __STDIO_STREAM_CUSTOM_IO_FUNC(S, NAME, RC, ARGS...) \
  86. if (__STDIO_STREAM_IS_CUSTOM((S))) { \
  87. _IO_cookie_file_t *cfile = (_IO_cookie_file_t *) (S); \
  88. return (cfile->__gcs.NAME == NULL) ? (RC) : \
  89. cfile->__gcs.NAME(cfile->__cookie, ##ARGS); \
  90. }
  91. typedef struct {
  92. struct __STDIO_FILE_STRUCT __fp;
  93. void *__cookie;
  94. _IO_cookie_io_functions_t __gcs;
  95. } _IO_cookie_file_t;
  96. #else /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
  97. #undef __STDIO_STREAM_GLIBC_CUSTOM_FILEDES
  98. #define __STDIO_STREAM_IS_CUSTOM(S) (0)
  99. #define __STDIO_STREAM_CUSTOM_IO_FUNC(S, NAME, RC, ARGS...)
  100. #endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
  101. extern int __stdio_seek(FILE *stream, register __offmax_t *pos, int whence) attribute_hidden;
  102. static inline ssize_t __READ(FILE *stream, char *buf, size_t bufsize)
  103. {
  104. __STDIO_STREAM_CUSTOM_IO_FUNC(stream, read, -1, buf, bufsize);
  105. return read(stream->__filedes, buf, bufsize);
  106. }
  107. static inline ssize_t __WRITE(FILE *stream, const char *buf, size_t bufsize)
  108. {
  109. __STDIO_STREAM_CUSTOM_IO_FUNC(stream, write, -1, buf, bufsize);
  110. return write(stream->__filedes, buf, bufsize);
  111. }
  112. static inline int __SEEK(FILE *stream, register __offmax_t *pos, int whence)
  113. {
  114. __STDIO_STREAM_CUSTOM_IO_FUNC(stream, seek, -1, pos, whence);
  115. return __stdio_seek(stream, pos, whence);
  116. }
  117. static inline int __CLOSE(FILE *stream)
  118. {
  119. __STDIO_STREAM_CUSTOM_IO_FUNC(stream, close, 0);
  120. return close(stream->__filedes);
  121. }
  122. /**********************************************************************/
  123. #ifdef __UCLIBC_HAS_WCHAR__
  124. #define __STDIO_STREAM_TRANS_TO_WRITE(S,O) __stdio_trans2w_o((S), (O))
  125. #define __STDIO_STREAM_TRANS_TO_READ(S,O) __stdio_trans2r_o((S), (O))
  126. #else
  127. #define __STDIO_STREAM_TRANS_TO_WRITE(S,O) __stdio_trans2w((S))
  128. #define __STDIO_STREAM_TRANS_TO_READ(S,O) __stdio_trans2r((S))
  129. #endif
  130. /**********************************************************************/
  131. #define __STDIO_STREAM_IS_READING(S) ((S)->__modeflags & __MASK_READING)
  132. #define __STDIO_STREAM_IS_WRITING(S) ((S)->__modeflags & __FLAG_WRITING)
  133. #define __STDIO_STREAM_SET_READING(S) ((S)->__modeflags |= __FLAG_READING)
  134. #define __STDIO_STREAM_SET_WRITING(S) ((S)->__modeflags |= __FLAG_WRITING)
  135. #define __STDIO_STREAM_IS_READING_OR_READONLY(S) \
  136. ((S)->__modeflags & (__MASK_READING|__FLAG_READONLY))
  137. #define __STDIO_STREAM_IS_WRITING_OR_WRITEONLY(S) \
  138. ((S)->__modeflags & (__FLAG_WRITING|__FLAG_WRITEONLY))
  139. #define __STDIO_STREAM_IS_READONLY(S) ((S)->__modeflags & __FLAG_READONLY)
  140. #define __STDIO_STREAM_IS_WRITEONLY(S) ((S)->__modeflags & __FLAG_WRITEONLY)
  141. /**********************************************************************/
  142. #ifdef __UCLIBC_HAS_WCHAR__
  143. #define __STDIO_STREAM_IS_NARROW_WRITING(S) \
  144. (((S)->__modeflags & (__FLAG_WRITING|__FLAG_NARROW)) \
  145. == (__FLAG_WRITING|__FLAG_NARROW))
  146. #define __STDIO_STREAM_IS_WIDE_WRITING(S) \
  147. (((S)->__modeflags & (__FLAG_WRITING|__FLAG_WIDE)) \
  148. == (__FLAG_WRITING|__FLAG_WIDE))
  149. #if (__FLAG_NARROW <= __MASK_READING)
  150. #error assumption violated regarding __FLAG_NARROW
  151. #endif
  152. #define __STDIO_STREAM_IS_NARROW_READING(S) \
  153. (((S)->__modeflags & (__MASK_READING|__FLAG_NARROW)) > __FLAG_NARROW)
  154. #define __STDIO_STREAM_IS_WIDE_READING(S) \
  155. (((S)->__modeflags & (__MASK_READING|__FLAG_WIDE)) > __FLAG_WIDE)
  156. #define __STDIO_STREAM_IS_NARROW(S) ((S)->__modeflags & __FLAG_NARROW)
  157. #define __STDIO_STREAM_IS_WIDE(S) ((S)->__modeflags & __FLAG_WIDE)
  158. #define __STDIO_STREAM_SET_NARROW(S) \
  159. ((void)((S)->__modeflags |= __FLAG_NARROW))
  160. #define __STDIO_STREAM_SET_WIDE(S) \
  161. ((void)((S)->__modeflags |= __FLAG_WIDE))
  162. #else
  163. #define __STDIO_STREAM_IS_NARROW_WRITING(S) __STDIO_STREAM_IS_WRITING(S)
  164. #define __STDIO_STREAM_IS_NARROW_READING(S) __STDIO_STREAM_IS_READING(S)
  165. #define __STDIO_STREAM_IS_NARROW(S) (1)
  166. #define __STDIO_STREAM_IS_WIDE(S) (0)
  167. #define __STDIO_STREAM_SET_NARROW(S) ((void)0)
  168. #define __STDIO_STREAM_SET_WIDE(S) ((void)0)
  169. #endif
  170. /**********************************************************************/
  171. #define __STDIO_STREAM_SET_EOF(S) \
  172. ((void)((S)->__modeflags |= __FLAG_EOF))
  173. #define __STDIO_STREAM_SET_ERROR(S) \
  174. ((void)((S)->__modeflags |= __FLAG_ERROR))
  175. #define __STDIO_STREAM_CLEAR_EOF(S) \
  176. ((void)((S)->__modeflags &= ~__FLAG_EOF))
  177. #define __STDIO_STREAM_CLEAR_ERROR(S) \
  178. ((void)((S)->__modeflags &= ~__FLAG_ERROR))
  179. #define __STDIO_STREAM_CLEAR_READING_AND_UNGOTS(S) \
  180. ((void)((S)->__modeflags &= ~__MASK_READING))
  181. #define __STDIO_STREAM_CLEAR_WRITING(S) \
  182. ((void)((S)->__modeflags &= ~__FLAG_WRITING))
  183. #ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__
  184. # define __STDIO_STREAM_DISABLE_GETC(S) \
  185. ((void)((S)->__bufgetc_u = (S)->__bufstart))
  186. # define __STDIO_STREAM_ENABLE_GETC(S) \
  187. ((void)((S)->__bufgetc_u = (S)->__bufread))
  188. # define __STDIO_STREAM_CAN_USE_BUFFER_GET(S) \
  189. ((S)->__bufpos < (S)->__bufgetc_u)
  190. #else
  191. # define __STDIO_STREAM_DISABLE_GETC(S) ((void)0)
  192. # define __STDIO_STREAM_ENABLE_GETC(S) ((void)0)
  193. # define __STDIO_STREAM_CAN_USE_BUFFER_GET(S) (0)
  194. #endif
  195. #ifdef __UCLIBC_HAS_STDIO_PUTC_MACRO__
  196. # define __STDIO_STREAM_DISABLE_PUTC(S) \
  197. ((void)((S)->__bufputc_u = (S)->__bufstart))
  198. # define __STDIO_STREAM_ENABLE_PUTC(S) \
  199. ((void)((S)->__bufputc_u = (S)->__bufend))
  200. # define __STDIO_STREAM_CAN_USE_BUFFER_ADD(S) \
  201. ((S)->__bufpos < (S)->__bufputc_u)
  202. #else
  203. # define __STDIO_STREAM_DISABLE_PUTC(S) ((void)0)
  204. # define __STDIO_STREAM_ENABLE_PUTC(S) ((void)0)
  205. # define __STDIO_STREAM_CAN_USE_BUFFER_ADD(S) (0)
  206. #endif
  207. /**********************************************************************/
  208. #ifdef __STDIO_BUFFERS
  209. #define __STDIO_STREAM_FREE_BUFFER(S) \
  210. do { if ((S)->__modeflags & __FLAG_FREEBUF) \
  211. free((S)->__bufstart); } while (0)
  212. #else
  213. #define __STDIO_STREAM_FREE_BUFFER(S) ((void)0)
  214. #endif
  215. #define __STDIO_STREAM_FREE_FILE(S) \
  216. do { if ((S)->__modeflags & __FLAG_FREEFILE) \
  217. free((S)); } while (0)
  218. #ifdef __UCLIBC_HAS_LFS__
  219. #define __STDIO_WHEN_LFS(E) E
  220. #else
  221. #define __STDIO_WHEN_LFS(E) ((void)0)
  222. #endif
  223. /**********************************************************************/
  224. /* The following return 0 on success. */
  225. #ifdef __STDIO_BUFFERS
  226. /* Assume stream in valid writing state. Do not reset writing flag
  227. * or disble putc macro unless error. */
  228. /* Should we assume that buffer is not empty to avoid a check? */
  229. extern size_t __stdio_wcommit(FILE *__restrict stream) attribute_hidden;
  230. /* Remember to fail if at EOF! */
  231. extern size_t __stdio_rfill(FILE *__restrict stream) attribute_hidden;
  232. extern size_t __stdio_fwrite(const unsigned char *__restrict buffer,
  233. size_t bytes, FILE *__restrict stream) attribute_hidden;
  234. #else
  235. #define __stdio_fwrite(B,N,S) __stdio_WRITE((S),(B),(N))
  236. #endif
  237. extern size_t __stdio_WRITE(FILE *stream, const unsigned char *buf,
  238. size_t bufsize) attribute_hidden;
  239. extern size_t __stdio_READ(FILE *stream, unsigned char *buf,
  240. size_t bufsize) attribute_hidden;
  241. extern int __stdio_trans2r(FILE *__restrict stream) attribute_hidden;
  242. extern int __stdio_trans2w(FILE *__restrict stream) attribute_hidden;
  243. extern int __stdio_trans2r_o(FILE *__restrict stream, int oflag) attribute_hidden;
  244. extern int __stdio_trans2w_o(FILE *__restrict stream, int oflag) attribute_hidden;
  245. extern uintmax_t _load_inttype(int desttype, register const void *src, int uflag) attribute_hidden;
  246. extern void _store_inttype(void *dest, int desttype, uintmax_t val) attribute_hidden;
  247. /**********************************************************************/
  248. #ifdef __STDIO_BUFFERS
  249. #define __STDIO_STREAM_IS_FBF(S) (!((S)->__modeflags & __MASK_BUFMODE))
  250. #define __STDIO_STREAM_IS_LBF(S) ((S)->__modeflags & __FLAG_LBF)
  251. #define __STDIO_STREAM_IS_NBF(S) ((S)->__modeflags & __FLAG_NBF)
  252. #define __STDIO_STREAM_BUFFER_SIZE(S) ((S)->__bufend - (S)->__bufstart)
  253. /* Valid when writing... */
  254. #define __STDIO_STREAM_BUFFER_ADD(S,C) (*(S)->__bufpos++ = (C))
  255. #define __STDIO_STREAM_BUFFER_UNADD(S) (--(S)->__bufpos)
  256. #define __STDIO_STREAM_BUFFER_WAVAIL(S) ((S)->__bufend - (S)->__bufpos)
  257. #define __STDIO_STREAM_BUFFER_WUSED(S) ((S)->__bufpos - (S)->__bufstart)
  258. #define __STDIO_COMMIT_WRITE_BUFFER(S) __stdio_wcommit((S))
  259. #ifdef __UCLIBC_HAS_WCHAR__
  260. #define __STDIO_STREAM_IS_NARROW_FBF(S) \
  261. (!((S)->__modeflags & (__MASK_BUFMODE|__FLAG_WIDE)))
  262. #else
  263. #define __STDIO_STREAM_IS_NARROW_FBF(S) __STDIO_STREAM_IS_FBF((S))
  264. #endif
  265. /* Valid when reading... */
  266. #define __STDIO_STREAM_BUFFER_RAVAIL(S) ((S)->__bufread - (S)->__bufpos)
  267. #define __STDIO_STREAM_BUFFER_GET(S) (*(S)->__bufpos++)
  268. #define __STDIO_FILL_READ_BUFFER(S) __stdio_rfill((S))
  269. #define __STDIO_STREAM_INIT_BUFREAD_BUFPOS(S) \
  270. (S)->__bufread = (S)->__bufpos = (S)->__bufstart
  271. #define __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES (-3)
  272. #define __STDIO_STREAM_FAKE_VSSCANF_FILEDES (-3)
  273. #define __STDIO_STREAM_FAKE_VSWPRINTF_FILEDES (-4)
  274. #define __STDIO_STREAM_FAKE_VSWSCANF_FILEDES (-4)
  275. #define __STDIO_STREAM_IS_FAKE_VSNPRINTF(S) \
  276. ((S)->__filedes == __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES)
  277. #define __STDIO_STREAM_IS_FAKE_VSSCANF(S) \
  278. ((S)->__filedes == __STDIO_STREAM_FAKE_VSSCANF_FILEDES)
  279. #define __STDIO_STREAM_IS_FAKE_VSWPRINTF(S) \
  280. ((S)->__filedes == __STDIO_STREAM_FAKE_VSWPRINTF_FILEDES)
  281. #define __STDIO_STREAM_IS_FAKE_VSWSCANF(S) \
  282. ((S)->__filedes == __STDIO_STREAM_FAKE_VSWSCANF_FILEDES)
  283. #else /* __STDIO_BUFFERS */
  284. #define __STDIO_STREAM_IS_FBF(S) (0)
  285. #define __STDIO_STREAM_IS_LBF(S) (0)
  286. #define __STDIO_STREAM_IS_NBF(S) (1)
  287. #define __STDIO_STREAM_BUFFER_SIZE(S) (0)
  288. #define __STDIO_STREAM_BUFFER_ADD(S,C) ((void)0)
  289. #define __STDIO_STREAM_BUFFER_UNADD(S) ((void)0)
  290. #define __STDIO_STREAM_BUFFER_WAVAIL(S) (0)
  291. #define __STDIO_STREAM_BUFFER_WUSED(S) (0)
  292. #define __STDIO_COMMIT_WRITE_BUFFER(S) (0)
  293. #define __STDIO_STREAM_IS_NARROW_FBF(S) (0)
  294. #define __STDIO_STREAM_BUFFER_RAVAIL(S) (0)
  295. #define __STDIO_STREAM_BUFFER_GET(S) (EOF)
  296. #define __STDIO_FILL_READ_BUFFER(S) (0)
  297. #define __STDIO_STREAM_INIT_BUFREAD_BUFPOS(S) ((void)0)
  298. #undef __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES
  299. #undef __STDIO_STREAM_FAKE_VSSCANF_FILEDES
  300. #undef __STDIO_STREAM_FAKE_VSWPRINTF_FILEDES
  301. #define __STDIO_STREAM_IS_FAKE_VSNPRINTF(S) (0)
  302. #define __STDIO_STREAM_IS_FAKE_VSSCANF(S) (0)
  303. #undef __STDIO_STREAM_IS_FAKE_VSWPRINTF
  304. #undef __STDIO_STREAM_IS_FAKE_VSWSCANF
  305. # ifdef __USE_OLD_VFPRINTF__
  306. # define __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES_NB (-2)
  307. # define __STDIO_STREAM_IS_FAKE_VSNPRINTF_NB(S) \
  308. ((S)->__filedes == __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES_NB)
  309. # endif
  310. # ifndef __UCLIBC_HAS_WCHAR__
  311. # define __STDIO_STREAM_FAKE_VSSCANF_FILEDES_NB (-2)
  312. # define __STDIO_STREAM_IS_FAKE_VSSCANF_NB(S) \
  313. ((S)->__filedes == __STDIO_STREAM_FAKE_VSSCANF_FILEDES_NB)
  314. # endif
  315. #endif /* __STDIO_BUFFERS */
  316. /**********************************************************************/
  317. extern int __stdio_adjust_position(FILE *__restrict stream, __offmax_t *pos) attribute_hidden;
  318. #ifdef __STDIO_HAS_OPENLIST
  319. /* Uses an implementation hack!!! */
  320. #define __STDIO_FLUSH_LBF_STREAMS \
  321. fflush_unlocked((FILE *) &_stdio_openlist)
  322. #else
  323. #define __STDIO_FLUSH_LBF_STREAMS ((void)0)
  324. #endif
  325. #ifdef NDEBUG
  326. #define __STDIO_STREAM_VALIDATE(S) ((void)0)
  327. #else
  328. extern void _stdio_validate_FILE(const FILE *stream) attribute_hidden;
  329. #define __STDIO_STREAM_VALIDATE(S) _stdio_validate_FILE((S))
  330. #endif
  331. #ifdef __STDIO_MBSTATE
  332. #define __COPY_MBSTATE(dest,src) \
  333. ((void)((dest)->__mask = (src)->__mask, (dest)->__wc = (src)->__wc))
  334. #define __INIT_MBSTATE(dest) ((void)((dest)->__mask = 0))
  335. #else
  336. #define __COPY_MBSTATE(dest,src) ((void)0)
  337. #define __INIT_MBSTATE(dest) ((void)0)
  338. #endif
  339. /**********************************************************************/
  340. extern FILE *_stdio_fopen(intptr_t fname_or_mode, const char *__restrict mode,
  341. FILE *__restrict stream, int filedes) attribute_hidden;
  342. #ifdef __UCLIBC_HAS_WCHAR__
  343. extern size_t _wstdio_fwrite(const wchar_t *__restrict ws,
  344. size_t n, FILE *__restrict stream) attribute_hidden;
  345. #endif
  346. /**********************************************************************/
  347. extern int _vfprintf_internal (FILE * __restrict stream,
  348. const char * __restrict format,
  349. va_list arg) attribute_hidden;
  350. #ifdef __UCLIBC_HAS_WCHAR__
  351. extern int _vfwprintf_internal (FILE * __restrict stream,
  352. const wchar_t * __restrict format,
  353. va_list arg) attribute_hidden;
  354. #endif
  355. /**********************************************************************/
  356. /* Only use the macro below if you know fp is a valid FILE for a valid fd.
  357. * This is _not_ true for custom streams! */
  358. #define __FILENO_UNLOCKED(fp) ((fp)->__filedes)
  359. #define __FEOF_OR_FERROR_UNLOCKED(stream) \
  360. ((stream)->__modeflags & (__FLAG_EOF|__FLAG_ERROR))
  361. #if defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
  362. #define __STDIO_HAS_VSNPRINTF 1
  363. #endif
  364. #endif /* __STDIO_H_I */