1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH UNLOCKED_STDIO 3 2021-03-22 "" "Linux Programmer's Manual"
27 getc_unlocked, getchar_unlocked, putc_unlocked,
28 putchar_unlocked \- nonlocking stdio functions
33 .BI "int getc_unlocked(FILE *" stream );
34 .B "int getchar_unlocked(void);"
35 .BI "int putc_unlocked(int " c ", FILE *" stream );
36 .BI "int putchar_unlocked(int " c );
38 .BI "void clearerr_unlocked(FILE *" stream );
39 .BI "int feof_unlocked(FILE *" stream );
40 .BI "int ferror_unlocked(FILE *" stream );
41 .BI "int fileno_unlocked(FILE *" stream );
42 .BI "int fflush_unlocked(FILE *" stream );
44 .BI "int fgetc_unlocked(FILE *" stream );
45 .BI "int fputc_unlocked(int " c ", FILE *" stream );
47 .BI "size_t fread_unlocked(void *restrict " ptr ", size_t " size ", size_t " n ,
48 .BI " FILE *restrict " stream );
49 .BI "size_t fwrite_unlocked(const void *restrict " ptr ", size_t " size \
51 .BI " FILE *restrict " stream );
53 .BI "char *fgets_unlocked(char *restrict " s ", int " n \
54 ", FILE *restrict " stream );
55 .BI "int fputs_unlocked(const char *restrict " s ", FILE *restrict " stream );
59 .BI "wint_t getwc_unlocked(FILE *" stream );
60 .B "wint_t getwchar_unlocked(void);"
61 .BI "wint_t fgetwc_unlocked(FILE *" stream );
63 .BI "wint_t fputwc_unlocked(wchar_t " wc ", FILE *" stream );
64 .BI "wint_t putwc_unlocked(wchar_t " wc ", FILE *" stream );
65 .BI "wint_t putwchar_unlocked(wchar_t " wc );
67 .BI "wchar_t *fgetws_unlocked(wchar_t *restrict " ws ", int " n ,
68 .BI " FILE *restrict " stream );
69 .BI "int fputws_unlocked(const wchar_t *restrict " ws ,
70 .BI " FILE *restrict " stream );
74 Feature Test Macro Requirements for glibc (see
75 .BR feature_test_macros (7)):
81 .BR getchar_unlocked (),
83 .BR putchar_unlocked ():
85 /* Since glibc 2.24: */ _POSIX_C_SOURCE >= 199309L
86 || /* Glibc <= 2.23: */ _POSIX_C_SOURCE
87 || /* Glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
90 .BR clearerr_unlocked (),
92 .BR ferror_unlocked (),
93 .BR fileno_unlocked (),
94 .BR fflush_unlocked (),
95 .BR fgetc_unlocked (),
96 .BR fputc_unlocked (),
97 .BR fread_unlocked (),
98 .BR fwrite_unlocked ():
100 /* Glibc since 2.19: */ _DEFAULT_SOURCE
101 || /* Glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
104 .BR fgets_unlocked (),
105 .BR fputs_unlocked (),
106 .BR getwc_unlocked (),
107 .BR getwchar_unlocked (),
108 .BR fgetwc_unlocked (),
109 .BR fputwc_unlocked (),
110 .BR putwchar_unlocked (),
111 .BR fgetws_unlocked (),
112 .BR fputws_unlocked ():
119 Each of these functions has the same behavior as its counterpart
120 without the "_unlocked" suffix, except that they do not use locking
121 (they do not set locks themselves, and do not test for the presence
122 of locks set by others) and hence are thread-unsafe.
126 For an explanation of the terms used in this section, see
134 Interface Attribute Value
136 .BR getc_unlocked (),
137 .BR putc_unlocked (),
138 .BR clearerr_unlocked (),
139 .BR fflush_unlocked (),
140 .BR fgetc_unlocked (),
141 .BR fputc_unlocked (),
142 .BR fread_unlocked (),
143 .BR fwrite_unlocked (),
144 .BR fgets_unlocked (),
145 .BR fputs_unlocked (),
146 .BR getwc_unlocked (),
147 .BR fgetwc_unlocked (),
148 .BR fputwc_unlocked (),
149 .BR putwc_unlocked (),
150 .BR fgetws_unlocked (),
151 .BR fputws_unlocked ()
156 .BR getchar_unlocked (),
157 .BR getwchar_unlocked ()
162 .BR putchar_unlocked (),
163 .BR putwchar_unlocked ()
165 MT-Unsafe race:stdout
168 .BR feof_unlocked (),
169 .BR ferror_unlocked (),
170 .BR fileno_unlocked ()
171 T} Thread safety MT-Safe
178 .BR getc_unlocked (),
179 .BR getchar_unlocked (),
180 .BR putc_unlocked (),
181 .BR putchar_unlocked ()
182 are in POSIX.1-2001 and POSIX.1-2008.
186 variants occur on a few UNIX systems, and are available in recent glibc.
187 .\" E.g., in HP-UX 10.0. In HP-UX 10.30 they are called obsolescent, and
188 .\" moved to a compatibility library.
189 .\" Available in HP-UX 10.0: clearerr_unlocked, fclose_unlocked,
190 .\" feof_unlocked, ferror_unlocked, fflush_unlocked, fgets_unlocked,
191 .\" fgetwc_unlocked, fgetws_unlocked, fileno_unlocked, fputs_unlocked,
192 .\" fputwc_unlocked, fputws_unlocked, fread_unlocked, fseek_unlocked,
193 .\" ftell_unlocked, fwrite_unlocked, getc_unlocked, getchar_unlocked,
194 .\" getw_unlocked, getwc_unlocked, getwchar_unlocked, putc_unlocked,
195 .\" putchar_unlocked, puts_unlocked, putws_unlocked, putw_unlocked,
196 .\" putwc_unlocked, putwchar_unlocked, rewind_unlocked, setvbuf_unlocked,
197 .\" ungetc_unlocked, ungetwc_unlocked.
198 They should probably not be used.