_stdio.h 15 KB

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