_stdio.h 15 KB

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