| 1 |
'\" t |
| 2 |
.\" Copyright 2001, Andries E. Brouwer <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH unlocked_stdio 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
getc_unlocked, getchar_unlocked, putc_unlocked, |
| 10 |
putchar_unlocked \- nonlocking stdio functions |
| 11 |
.SH LIBRARY |
| 12 |
Standard C library |
| 13 |
.RI ( libc ,\~ \-lc ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.B #include <stdio.h> |
| 17 |
.P |
| 18 |
.BI "int getc_unlocked(FILE *" stream ); |
| 19 |
.B "int getchar_unlocked(void);" |
| 20 |
.BI "int putc_unlocked(int " c ", FILE *" stream ); |
| 21 |
.BI "int putchar_unlocked(int " c ); |
| 22 |
.P |
| 23 |
.BI "void clearerr_unlocked(FILE *" stream ); |
| 24 |
.BI "int feof_unlocked(FILE *" stream ); |
| 25 |
.BI "int ferror_unlocked(FILE *" stream ); |
| 26 |
.BI "int fileno_unlocked(FILE *" stream ); |
| 27 |
.BI "int fflush_unlocked(FILE *_Nullable " stream ); |
| 28 |
.P |
| 29 |
.BI "int fgetc_unlocked(FILE *" stream ); |
| 30 |
.BI "int fputc_unlocked(int " c ", FILE *" stream ); |
| 31 |
.P |
| 32 |
.BR "size_t fread_unlocked(" "size_t size, size_t n;" |
| 33 |
.BI " void " ptr "[restrict " size " * " n ], |
| 34 |
.BI " size_t " size ", size_t " n , |
| 35 |
.BI " FILE *restrict " stream ); |
| 36 |
.BR "size_t fwrite_unlocked(" "size_t size, size_t n;" |
| 37 |
.BI " const void " ptr "[restrict " size " * " n ], |
| 38 |
.BI " size_t " size ", size_t " n , |
| 39 |
.BI " FILE *restrict " stream ); |
| 40 |
.P |
| 41 |
.BR "char *fgets_unlocked(" "int n;" |
| 42 |
.BI " char " s "[restrict " n "], int " n \ |
| 43 |
", FILE *restrict " stream ); |
| 44 |
.BI "int fputs_unlocked(const char *restrict " s ", FILE *restrict " stream ); |
| 45 |
.P |
| 46 |
.B #include <wchar.h> |
| 47 |
.P |
| 48 |
.BI "wint_t getwc_unlocked(FILE *" stream ); |
| 49 |
.B "wint_t getwchar_unlocked(void);" |
| 50 |
.BI "wint_t fgetwc_unlocked(FILE *" stream ); |
| 51 |
.P |
| 52 |
.BI "wint_t fputwc_unlocked(wchar_t " wc ", FILE *" stream ); |
| 53 |
.BI "wint_t putwc_unlocked(wchar_t " wc ", FILE *" stream ); |
| 54 |
.BI "wint_t putwchar_unlocked(wchar_t " wc ); |
| 55 |
.P |
| 56 |
.BR "wchar_t *fgetws_unlocked(" "int n;" |
| 57 |
.BI " wchar_t " ws "[restrict " n "], int " n , |
| 58 |
.BI " FILE *restrict " stream ); |
| 59 |
.BI "int fputws_unlocked(const wchar_t *restrict " ws , |
| 60 |
.BI " FILE *restrict " stream ); |
| 61 |
.fi |
| 62 |
.P |
| 63 |
.RS -4 |
| 64 |
Feature Test Macro Requirements for glibc (see |
| 65 |
.BR feature_test_macros (7)): |
| 66 |
.RE |
| 67 |
.P |
| 68 |
.BR \%getc_unlocked (), |
| 69 |
.BR \%getchar_unlocked (), |
| 70 |
.BR \%putc_unlocked (), |
| 71 |
.BR \%putchar_unlocked (): |
| 72 |
.nf |
| 73 |
/* glibc >= 2.24: */ _POSIX_C_SOURCE >= 199309L |
| 74 |
|| /* glibc <= 2.23: */ _POSIX_C_SOURCE |
| 75 |
|| /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE |
| 76 |
.fi |
| 77 |
.P |
| 78 |
.BR \%clearerr_unlocked (), |
| 79 |
.BR \%feof_unlocked (), |
| 80 |
.BR \%ferror_unlocked (), |
| 81 |
.BR \%fileno_unlocked (), |
| 82 |
.BR \%fflush_unlocked (), |
| 83 |
.BR \%fgetc_unlocked (), |
| 84 |
.BR \%fputc_unlocked (), |
| 85 |
.BR \%fread_unlocked (), |
| 86 |
.BR \%fwrite_unlocked (): |
| 87 |
.nf |
| 88 |
/* glibc >= 2.19: */ _DEFAULT_SOURCE |
| 89 |
|| /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE |
| 90 |
.fi |
| 91 |
.P |
| 92 |
.BR \%fgets_unlocked (), |
| 93 |
.BR \%fputs_unlocked (), |
| 94 |
.BR \%getwc_unlocked (), |
| 95 |
.BR \%getwchar_unlocked (), |
| 96 |
.BR \%fgetwc_unlocked (), |
| 97 |
.BR \%fputwc_unlocked (), |
| 98 |
.BR \%putwchar_unlocked (), |
| 99 |
.BR \%fgetws_unlocked (), |
| 100 |
.BR \%fputws_unlocked (): |
| 101 |
.nf |
| 102 |
_GNU_SOURCE |
| 103 |
.fi |
| 104 |
.SH DESCRIPTION |
| 105 |
Each of these functions has the same behavior as its counterpart |
| 106 |
without the "_unlocked" suffix, except that they do not use locking |
| 107 |
(they do not set locks themselves, and do not test for the presence |
| 108 |
of locks set by others) and hence are thread-unsafe. |
| 109 |
See |
| 110 |
.BR flockfile (3). |
| 111 |
.SH ATTRIBUTES |
| 112 |
For an explanation of the terms used in this section, see |
| 113 |
.BR attributes (7). |
| 114 |
.TS |
| 115 |
allbox; |
| 116 |
lb lb lbx |
| 117 |
l l l. |
| 118 |
Interface Attribute Value |
| 119 |
T{ |
| 120 |
.na |
| 121 |
.nh |
| 122 |
.BR getc_unlocked (), |
| 123 |
.BR putc_unlocked (), |
| 124 |
.BR clearerr_unlocked (), |
| 125 |
.BR fflush_unlocked (), |
| 126 |
.BR fgetc_unlocked (), |
| 127 |
.BR fputc_unlocked (), |
| 128 |
.BR fread_unlocked (), |
| 129 |
.BR fwrite_unlocked (), |
| 130 |
.BR fgets_unlocked (), |
| 131 |
.BR fputs_unlocked (), |
| 132 |
.BR getwc_unlocked (), |
| 133 |
.BR fgetwc_unlocked (), |
| 134 |
.BR fputwc_unlocked (), |
| 135 |
.BR putwc_unlocked (), |
| 136 |
.BR fgetws_unlocked (), |
| 137 |
.BR fputws_unlocked () |
| 138 |
T} Thread safety T{ |
| 139 |
.na |
| 140 |
.nh |
| 141 |
MT-Safe race:stream |
| 142 |
T} |
| 143 |
T{ |
| 144 |
.na |
| 145 |
.nh |
| 146 |
.BR getchar_unlocked (), |
| 147 |
.BR getwchar_unlocked () |
| 148 |
T} Thread safety T{ |
| 149 |
.na |
| 150 |
.nh |
| 151 |
MT-Unsafe race:stdin |
| 152 |
T} |
| 153 |
T{ |
| 154 |
.na |
| 155 |
.nh |
| 156 |
.BR putchar_unlocked (), |
| 157 |
.BR putwchar_unlocked () |
| 158 |
T} Thread safety T{ |
| 159 |
.na |
| 160 |
.nh |
| 161 |
MT-Unsafe race:stdout |
| 162 |
T} |
| 163 |
T{ |
| 164 |
.na |
| 165 |
.nh |
| 166 |
.BR feof_unlocked (), |
| 167 |
.BR ferror_unlocked (), |
| 168 |
.BR fileno_unlocked () |
| 169 |
T} Thread safety MT-Safe |
| 170 |
.TE |
| 171 |
.SH STANDARDS |
| 172 |
.TP |
| 173 |
.BR getc_unlocked () |
| 174 |
.TQ |
| 175 |
.BR getchar_unlocked () |
| 176 |
.TQ |
| 177 |
.BR putc_unlocked () |
| 178 |
.TQ |
| 179 |
.BR putchar_unlocked () |
| 180 |
POSIX.1-2008. |
| 181 |
.TP |
| 182 |
Others: |
| 183 |
None. |
| 184 |
.SH HISTORY |
| 185 |
.TP |
| 186 |
.BR getc_unlocked () |
| 187 |
.TQ |
| 188 |
.BR getchar_unlocked () |
| 189 |
.TQ |
| 190 |
.BR putc_unlocked () |
| 191 |
.TQ |
| 192 |
.BR putchar_unlocked () |
| 193 |
POSIX.1-2001. |
| 194 |
.\" E.g., in HP-UX 10.0. In HP-UX 10.30 they are called obsolescent, and |
| 195 |
.\" moved to a compatibility library. |
| 196 |
.\" Available in HP-UX 10.0: clearerr_unlocked, fclose_unlocked, |
| 197 |
.\" feof_unlocked, ferror_unlocked, fflush_unlocked, fgets_unlocked, |
| 198 |
.\" fgetwc_unlocked, fgetws_unlocked, fileno_unlocked, fputs_unlocked, |
| 199 |
.\" fputwc_unlocked, fputws_unlocked, fread_unlocked, fseek_unlocked, |
| 200 |
.\" ftell_unlocked, fwrite_unlocked, getc_unlocked, getchar_unlocked, |
| 201 |
.\" getw_unlocked, getwc_unlocked, getwchar_unlocked, putc_unlocked, |
| 202 |
.\" putchar_unlocked, puts_unlocked, putws_unlocked, putw_unlocked, |
| 203 |
.\" putwc_unlocked, putwchar_unlocked, rewind_unlocked, setvbuf_unlocked, |
| 204 |
.\" ungetc_unlocked, ungetwc_unlocked. |
| 205 |
.SH SEE ALSO |
| 206 |
.BR flockfile (3), |
| 207 |
.BR stdio (3) |