uClibc_stdio.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. /* Copyright (C) 2002-2004 Manuel Novoa III <mjn3@codepoet.org>
  2. *
  3. * GNU Library General Public License (LGPL) version 2 or later.
  4. *
  5. * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
  6. */
  7. #ifndef _STDIO_H
  8. #error Always include <stdio.h> rather than <bits/uClibc_stdio.h>
  9. #endif
  10. /**********************************************************************/
  11. #define __STDIO_BUFFERS
  12. /* ANSI/ISO mandate at least 256. */
  13. #if defined(__UCLIBC_HAS_STDIO_BUFSIZ_NONE__)
  14. /* Fake this because some apps use stdio.h BUFSIZ. */
  15. #define __STDIO_BUFSIZ 256
  16. #undef __STDIO_BUFFERS
  17. #elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_256__)
  18. #define __STDIO_BUFSIZ 256
  19. #elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_512__)
  20. #define __STDIO_BUFSIZ 512
  21. #elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_1024__)
  22. #define __STDIO_BUFSIZ 1024
  23. #elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_2048__)
  24. #define __STDIO_BUFSIZ 2048
  25. #elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_4096__)
  26. #define __STDIO_BUFSIZ 4096
  27. #elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_8192__)
  28. #define __STDIO_BUFSIZ 8192
  29. #else
  30. #error config seems to be out of sync regarding bufsiz options
  31. #endif
  32. #ifdef __UCLIBC_HAS_STDIO_BUFSIZ_NONE__
  33. #define __STDIO_BUILTIN_BUF_SIZE 0
  34. #else /* __UCLIBC_HAS_STDIO_BUFSIZ_NONE__ */
  35. #if defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE__)
  36. #define __STDIO_BUILTIN_BUF_SIZE 0
  37. #elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4__)
  38. #define __STDIO_BUILTIN_BUF_SIZE 4
  39. #elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8__)
  40. #define __STDIO_BUILTIN_BUF_SIZE 8
  41. #else
  42. #error config seems to be out of sync regarding builtin buffer size
  43. #endif
  44. #endif
  45. #if defined(__STDIO_BUFFERS) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__) || defined(__UCLIBC_HAS_THREADS__)
  46. #define __STDIO_HAS_OPENLIST 1
  47. #else
  48. #undef __STDIO_HAS_OPENLIST
  49. #endif
  50. /**********************************************************************/
  51. /* Make sure defines related to large files are consistent. */
  52. #ifdef _LIBC
  53. #ifdef __UCLIBC_HAS_LFS__
  54. #undef __USE_LARGEFILE
  55. #undef __USE_LARGEFILE64
  56. #undef __USE_FILE_OFFSET64
  57. /* If we're actually building uClibc with large file support, only define... */
  58. #define __USE_LARGEFILE64 1
  59. #endif /* __UCLIBC_HAS_LFS__ */
  60. #else /* not _LIBC */
  61. #ifndef __UCLIBC_HAS_LFS__
  62. #if defined(__LARGEFILE64_SOURCE) || defined(__USE_LARGEFILE64) || defined(__USE_FILE_OFFSET64)
  63. #error Sorry... uClibc was built without large file support!
  64. #endif
  65. #endif /* __UCLIBC_HAS_LFS__ */
  66. #endif /* _LIBC */
  67. /**********************************************************************/
  68. #ifdef __UCLIBC_HAS_WCHAR__
  69. #define __need_wchar_t
  70. #include <stddef.h>
  71. /* Note: we don't really need mbstate for 8-bit locales. We do for UTF-8.
  72. * For now, always use it. */
  73. #define __STDIO_MBSTATE
  74. #define __need_mbstate_t
  75. #include <wchar.h>
  76. #endif
  77. /**********************************************************************/
  78. /* Currently unimplemented/untested */
  79. /* #define __STDIO_FLEXIBLE_SETVBUF */
  80. #ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__
  81. #define __STDIO_GETC_MACRO
  82. #endif
  83. #ifdef __UCLIBC_HAS_STDIO_PUTC_MACRO__
  84. #define __STDIO_PUTC_MACRO
  85. #endif
  86. /* These are consistency checks on the different options */
  87. #ifndef __STDIO_BUFFERS
  88. #undef __STDIO_GETC_MACRO
  89. #undef __STDIO_PUTC_MACRO
  90. #endif
  91. #ifdef __BCC__
  92. #undef __UCLIBC_HAS_LFS__
  93. #endif
  94. #ifndef __UCLIBC_HAS_LFS__
  95. #undef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__
  96. #endif
  97. /**********************************************************************/
  98. #include <bits/uClibc_mutex.h>
  99. /* user_locking
  100. * 0 : do auto locking/unlocking
  101. * 1 : user does locking/unlocking
  102. * 2 : initial state prior to thread initialization
  103. * with no auto locking/unlocking
  104. *
  105. * When threading is initialized, walk the stdio open stream list
  106. * and do "if (user_locking == 2) user_locking = 0;".
  107. *
  108. * This way, we avoid calling the weak lock/unlock functions.
  109. */
  110. #define __STDIO_AUTO_THREADLOCK_VAR \
  111. __UCLIBC_MUTEX_AUTO_LOCK_VAR(__infunc_user_locking)
  112. #define __STDIO_AUTO_THREADLOCK(__stream) \
  113. __UCLIBC_IO_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \
  114. (__stream)->__user_locking)
  115. #define __STDIO_AUTO_THREADUNLOCK(__stream) \
  116. __UCLIBC_IO_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking)
  117. #define __STDIO_ALWAYS_THREADLOCK(__stream) \
  118. __UCLIBC_IO_MUTEX_LOCK((__stream)->__lock)
  119. #define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
  120. __UCLIBC_IO_MUTEX_UNLOCK((__stream)->__lock)
  121. #define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \
  122. __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock)
  123. #define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \
  124. __UCLIBC_IO_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock)
  125. #define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \
  126. __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock)
  127. #ifdef __UCLIBC_HAS_THREADS__
  128. #define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1)
  129. #else
  130. #define __STDIO_SET_USER_LOCKING(__stream) ((void)0)
  131. #endif
  132. #ifdef __UCLIBC_HAS_THREADS__
  133. #ifdef __USE_STDIO_FUTEXES__
  134. #define STDIO_INIT_MUTEX(M) _IO_lock_init(M)
  135. #else
  136. #define STDIO_INIT_MUTEX(M) __stdio_init_mutex(& M)
  137. #endif
  138. #endif
  139. /**********************************************************************/
  140. #define __STDIO_IOFBF 0 /* Fully buffered. */
  141. #define __STDIO_IOLBF 1 /* Line buffered. */
  142. #define __STDIO_IONBF 2 /* No buffering. */
  143. typedef struct {
  144. __off_t __pos;
  145. #ifdef __STDIO_MBSTATE
  146. __mbstate_t __mbstate;
  147. #endif
  148. #ifdef __UCLIBC_HAS_WCHAR__
  149. int __mblen_pending;
  150. #endif
  151. } __STDIO_fpos_t;
  152. #ifdef __UCLIBC_HAS_LFS__
  153. typedef struct {
  154. __off64_t __pos;
  155. #ifdef __STDIO_MBSTATE
  156. __mbstate_t __mbstate;
  157. #endif
  158. #ifdef __UCLIBC_HAS_WCHAR__
  159. int __mblen_pending;
  160. #endif
  161. } __STDIO_fpos64_t;
  162. #endif
  163. /**********************************************************************/
  164. #ifdef __UCLIBC_HAS_LFS__
  165. typedef __off64_t __offmax_t; /* TODO -- rename this? */
  166. #else
  167. typedef __off_t __offmax_t; /* TODO -- rename this? */
  168. #endif
  169. /**********************************************************************/
  170. #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
  171. typedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __bufsize);
  172. typedef __ssize_t __io_write_fn(void *__cookie,
  173. __const char *__buf, size_t __bufsize);
  174. /* NOTE: GLIBC difference!!! -- fopencookie seek function
  175. * For glibc, the type of pos is always (__off64_t *) but in our case
  176. * it is type (__off_t *) when the lib is built without large file support.
  177. */
  178. typedef int __io_seek_fn(void *__cookie, __offmax_t *__pos, int __whence);
  179. typedef int __io_close_fn(void *__cookie);
  180. typedef struct {
  181. __io_read_fn *read;
  182. __io_write_fn *write;
  183. __io_seek_fn *seek;
  184. __io_close_fn *close;
  185. } _IO_cookie_io_functions_t;
  186. #if defined(_LIBC) || defined(_GNU_SOURCE)
  187. typedef __io_read_fn cookie_read_function_t;
  188. typedef __io_write_fn cookie_write_function_t;
  189. typedef __io_seek_fn cookie_seek_function_t;
  190. typedef __io_close_fn cookie_close_function_t;
  191. typedef _IO_cookie_io_functions_t cookie_io_functions_t;
  192. #endif
  193. #endif
  194. /**********************************************************************/
  195. struct __STDIO_FILE_STRUCT {
  196. unsigned short __modeflags;
  197. /* There could be a hole here, but modeflags is used most.*/
  198. #ifdef __UCLIBC_HAS_WCHAR__
  199. unsigned char __ungot_width[2]; /* 0: current (building) char; 1: scanf */
  200. /* Move the following futher down to avoid problems with getc/putc
  201. * macros breaking shared apps when wchar config support is changed. */
  202. /* wchar_t ungot[2]; */
  203. #else /* __UCLIBC_HAS_WCHAR__ */
  204. unsigned char __ungot[2];
  205. #endif /* __UCLIBC_HAS_WCHAR__ */
  206. int __filedes;
  207. #ifdef __STDIO_BUFFERS
  208. unsigned char *__bufstart; /* pointer to buffer */
  209. unsigned char *__bufend; /* pointer to 1 past end of buffer */
  210. unsigned char *__bufpos;
  211. unsigned char *__bufread; /* pointer to 1 past last buffered read char */
  212. #ifdef __STDIO_GETC_MACRO
  213. unsigned char *__bufgetc_u; /* 1 past last readable by getc_unlocked */
  214. #endif /* __STDIO_GETC_MACRO */
  215. #ifdef __STDIO_PUTC_MACRO
  216. unsigned char *__bufputc_u; /* 1 past last writeable by putc_unlocked */
  217. #endif /* __STDIO_PUTC_MACRO */
  218. #endif /* __STDIO_BUFFERS */
  219. #ifdef __STDIO_HAS_OPENLIST
  220. struct __STDIO_FILE_STRUCT *__nextopen;
  221. #endif
  222. #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
  223. void *__cookie;
  224. _IO_cookie_io_functions_t __gcs;
  225. #endif
  226. #ifdef __UCLIBC_HAS_WCHAR__
  227. wchar_t __ungot[2];
  228. #endif
  229. #ifdef __STDIO_MBSTATE
  230. __mbstate_t __state;
  231. #endif
  232. #ifdef __UCLIBC_HAS_XLOCALE__
  233. void *__unused; /* Placeholder for codeset binding. */
  234. #endif
  235. #ifdef __UCLIBC_HAS_THREADS__
  236. int __user_locking;
  237. __UCLIBC_IO_MUTEX(__lock);
  238. #endif
  239. /* Everything after this is unimplemented... and may be trashed. */
  240. #if __STDIO_BUILTIN_BUF_SIZE > 0
  241. unsigned char __builtinbuf[__STDIO_BUILTIN_BUF_SIZE];
  242. #endif /* __STDIO_BUILTIN_BUF_SIZE > 0 */
  243. };
  244. /***********************************************************************/
  245. /* Having ungotten characters implies the stream is reading.
  246. * The scheme used here treats the least significant 2 bits of
  247. * the stream's modeflags member as follows:
  248. * 0 0 Not currently reading.
  249. * 0 1 Reading, but no ungetc() or scanf() push back chars.
  250. * 1 0 Reading with one ungetc() char (ungot[1] is 1)
  251. * or one scanf() pushed back char (ungot[1] is 0).
  252. * 1 1 Reading with both an ungetc() char and a scanf()
  253. * pushed back char. Note that this must be the result
  254. * of a scanf() push back (in ungot[0]) _followed_ by
  255. * an ungetc() call (in ungot[1]).
  256. *
  257. * Notes:
  258. * scanf() can NOT use ungetc() to push back characters.
  259. * (See section 7.19.6.2 of the C9X rationale -- WG14/N897.)
  260. */
  261. #define __MASK_READING 0x0003U /* (0x0001 | 0x0002) */
  262. #define __FLAG_READING 0x0001U
  263. #define __FLAG_UNGOT 0x0002U
  264. #define __FLAG_EOF 0x0004U
  265. #define __FLAG_ERROR 0x0008U
  266. #define __FLAG_WRITEONLY 0x0010U
  267. #define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */
  268. #define __FLAG_WRITING 0x0040U
  269. #define __FLAG_NARROW 0x0080U
  270. #define __FLAG_FBF 0x0000U /* must be 0 */
  271. #define __FLAG_LBF 0x0100U
  272. #define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */
  273. #define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */
  274. #define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */
  275. #define __FLAG_WIDE 0x0800U
  276. /* available slot 0x1000U */
  277. #define __FLAG_FREEFILE 0x2000U
  278. #define __FLAG_FREEBUF 0x4000U
  279. #define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */
  280. #define __FLAG_FAILED_FREOPEN __FLAG_LARGEFILE
  281. /* Note: In no-buffer mode, it would be possible to pack the necessary
  282. * flags into one byte. Since we wouldn't be buffering and there would
  283. * be no support for wchar, the only flags we would need would be:
  284. * 2 bits : ungot count
  285. * 2 bits : eof + error
  286. * 2 bits : readonly + writeonly
  287. * 1 bit : freefile
  288. * 1 bit : appending
  289. * So, for a very small system (< 128 files) we might have a
  290. * 4-byte FILE struct of:
  291. * unsigned char flags;
  292. * signed char filedes;
  293. * unsigned char ungot[2];
  294. */
  295. /**********************************************************************
  296. * PROTOTYPES OF INTERNAL FUNCTIONS
  297. **********************************************************************/
  298. #if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
  299. extern void _stdio_init(void) attribute_hidden;
  300. extern void _stdio_term(void) attribute_hidden;
  301. #ifdef __STDIO_HAS_OPENLIST
  302. extern struct __STDIO_FILE_STRUCT *_stdio_openlist;
  303. #ifdef __UCLIBC_HAS_THREADS__
  304. __UCLIBC_IO_MUTEX_EXTERN(_stdio_openlist_add_lock);
  305. #ifdef __STDIO_BUFFERS
  306. __UCLIBC_IO_MUTEX_EXTERN(_stdio_openlist_del_lock);
  307. extern volatile int _stdio_openlist_use_count; /* _stdio_openlist_del_lock */
  308. extern int _stdio_openlist_del_count; /* _stdio_openlist_del_lock */
  309. #endif
  310. extern int _stdio_user_locking;
  311. extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) attribute_hidden;
  312. #endif
  313. #endif
  314. #endif
  315. /**********************************************************************/
  316. #define __CLEARERR_UNLOCKED(__stream) \
  317. ((void)((__stream)->__modeflags &= ~(__FLAG_EOF|__FLAG_ERROR)))
  318. #define __FEOF_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_EOF)
  319. #define __FERROR_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_ERROR)
  320. #ifdef __UCLIBC_HAS_THREADS__
  321. # define __CLEARERR(__stream) (clearerr)(__stream)
  322. # define __FERROR(__stream) (ferror)(__stream)
  323. # define __FEOF(__stream) (feof)(__stream)
  324. #else
  325. # define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream)
  326. # define __FERROR(__stream) __FERROR_UNLOCKED(__stream)
  327. # define __FEOF(__stream) __FEOF_UNLOCKED(__stream)
  328. #endif
  329. extern int __fgetc_unlocked(FILE *__stream);
  330. libc_hidden_proto(__fgetc_unlocked)
  331. extern int __fputc_unlocked(int __c, FILE *__stream);
  332. libc_hidden_proto(__fputc_unlocked)
  333. /* First define the default definitions.
  334. They are overridden below as necessary. */
  335. #define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream))
  336. #define __FGETC(__stream) (fgetc)((__stream))
  337. #define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream))
  338. #define __GETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream))
  339. #define __GETC(__stream) (fgetc)((__stream))
  340. #define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
  341. #define __FPUTC(__c, __stream) (fputc)((__c),(__stream))
  342. #define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream))
  343. #define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream))
  344. #define __PUTC(__c, __stream) (fputc)((__c),(__stream))
  345. #ifdef __STDIO_GETC_MACRO
  346. extern FILE *__stdin; /* For getchar() macro. */
  347. # undef __GETC_UNLOCKED_MACRO
  348. # define __GETC_UNLOCKED_MACRO(__stream) \
  349. ( ((__stream)->__bufpos < (__stream)->__bufgetc_u) \
  350. ? (*(__stream)->__bufpos++) \
  351. : __fgetc_unlocked(__stream) )
  352. # if 0
  353. /* Classic macro approach. getc{_unlocked} can have side effects. */
  354. # undef __GETC_UNLOCKED
  355. # define __GETC_UNLOCKED(__stream) __GETC_UNLOCKED_MACRO((__stream))
  356. # ifndef __UCLIBC_HAS_THREADS__
  357. # undef __GETC
  358. # define __GETC(__stream) __GETC_UNLOCKED_MACRO((__stream))
  359. # endif
  360. # else
  361. /* Using gcc extension for safety and additional inlining. */
  362. # undef __FGETC_UNLOCKED
  363. # define __FGETC_UNLOCKED(__stream) \
  364. (__extension__ ({ \
  365. FILE *__S = (__stream); \
  366. __GETC_UNLOCKED_MACRO(__S); \
  367. }) )
  368. # undef __GETC_UNLOCKED
  369. # define __GETC_UNLOCKED(__stream) __FGETC_UNLOCKED((__stream))
  370. # ifdef __UCLIBC_HAS_THREADS__
  371. # undef __FGETC
  372. # define __FGETC(__stream) \
  373. (__extension__ ({ \
  374. FILE *__S = (__stream); \
  375. ((__S->__user_locking ) \
  376. ? __GETC_UNLOCKED_MACRO(__S) \
  377. : (fgetc)(__S)); \
  378. }) )
  379. # undef __GETC
  380. # define __GETC(__stream) __FGETC((__stream))
  381. # else
  382. # undef __FGETC
  383. # define __FGETC(__stream) __FGETC_UNLOCKED((__stream))
  384. # undef __GETC
  385. # define __GETC(__stream) __FGETC_UNLOCKED((__stream))
  386. # endif
  387. # endif
  388. #else
  389. #endif /* __STDIO_GETC_MACRO */
  390. #ifdef __STDIO_PUTC_MACRO
  391. extern FILE *__stdout; /* For putchar() macro. */
  392. # undef __PUTC_UNLOCKED_MACRO
  393. # define __PUTC_UNLOCKED_MACRO(__c, __stream) \
  394. ( ((__stream)->__bufpos < (__stream)->__bufputc_u) \
  395. ? (*(__stream)->__bufpos++) = (__c) \
  396. : __fputc_unlocked((__c),(__stream)) )
  397. # if 0
  398. /* Classic macro approach. putc{_unlocked} can have side effects.*/
  399. # undef __PUTC_UNLOCKED
  400. # define __PUTC_UNLOCKED(__c, __stream) \
  401. __PUTC_UNLOCKED_MACRO((__c), (__stream))
  402. # ifndef __UCLIBC_HAS_THREADS__
  403. # undef __PUTC
  404. # define __PUTC(__c, __stream) __PUTC_UNLOCKED_MACRO((__c), (__stream))
  405. # endif
  406. # else
  407. /* Using gcc extension for safety and additional inlining. */
  408. # undef __FPUTC_UNLOCKED
  409. # define __FPUTC_UNLOCKED(__c, __stream) \
  410. (__extension__ ({ \
  411. FILE *__S = (__stream); \
  412. __PUTC_UNLOCKED_MACRO((__c),__S); \
  413. }) )
  414. # undef __PUTC_UNLOCKED
  415. # define __PUTC_UNLOCKED(__c, __stream) __FPUTC_UNLOCKED((__c), (__stream))
  416. # ifdef __UCLIBC_HAS_THREADS__
  417. # undef __FPUTC
  418. # define __FPUTC(__c, __stream) \
  419. (__extension__ ({ \
  420. FILE *__S = (__stream); \
  421. ((__S->__user_locking) \
  422. ? __PUTC_UNLOCKED_MACRO((__c),__S) \
  423. : (fputc)((__c),__S)); \
  424. }) )
  425. # undef __PUTC
  426. # define __PUTC(__c, __stream) __FPUTC((__c), (__stream))
  427. # else
  428. # undef __FPUTC
  429. # define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream))
  430. # undef __PUTC
  431. # define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream))
  432. # endif
  433. # endif
  434. #endif /* __STDIO_PUTC_MACRO */