1UNLOCKED_STDIO(3) Linux Programmer's Manual UNLOCKED_STDIO(3)
2
3
4
6 getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked - non‐
7 locking stdio functions
8
10 #include <stdio.h>
11
12 int getc_unlocked(FILE *stream);
13 int getchar_unlocked(void);
14 int putc_unlocked(int c, FILE *stream);
15 int putchar_unlocked(int c);
16
17 void clearerr_unlocked(FILE *stream);
18 int feof_unlocked(FILE *stream);
19 int ferror_unlocked(FILE *stream);
20 int fileno_unlocked(FILE *stream);
21 int fflush_unlocked(FILE *stream);
22
23 int fgetc_unlocked(FILE *stream);
24 int fputc_unlocked(int c, FILE *stream);
25
26 size_t fread_unlocked(void *restrict ptr, size_t size, size_t n,
27 FILE *restrict stream);
28 size_t fwrite_unlocked(const void *restrict ptr, size_t size, size_t n,
29 FILE *restrict stream);
30
31 char *fgets_unlocked(char *restrict s, int n, FILE *restrict stream);
32 int fputs_unlocked(const char *restrict s, FILE *restrict stream);
33
34 #include <wchar.h>
35
36 wint_t getwc_unlocked(FILE *stream);
37 wint_t getwchar_unlocked(void);
38 wint_t fgetwc_unlocked(FILE *stream);
39
40 wint_t fputwc_unlocked(wchar_t wc, FILE *stream);
41 wint_t putwc_unlocked(wchar_t wc, FILE *stream);
42 wint_t putwchar_unlocked(wchar_t wc);
43
44 wchar_t *fgetws_unlocked(wchar_t *restrict ws, int n,
45 FILE *restrict stream);
46 int fputws_unlocked(const wchar_t *restrict ws,
47 FILE *restrict stream);
48
49 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
50
51 getc_unlocked(), getchar_unlocked(), putc_unlocked(),
52 putchar_unlocked():
53 /* Since glibc 2.24: */ _POSIX_C_SOURCE >= 199309L
54 || /* Glibc <= 2.23: */ _POSIX_C_SOURCE
55 || /* Glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
56
57 clearerr_unlocked(), feof_unlocked(), ferror_unlocked(),
58 fileno_unlocked(), fflush_unlocked(), fgetc_unlocked(),
59 fputc_unlocked(), fread_unlocked(), fwrite_unlocked():
60 /* Glibc since 2.19: */ _DEFAULT_SOURCE
61 || /* Glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
62
63 fgets_unlocked(), fputs_unlocked(), getwc_unlocked(),
64 getwchar_unlocked(), fgetwc_unlocked(), fputwc_unlocked(),
65 putwchar_unlocked(), fgetws_unlocked(), fputws_unlocked():
66 _GNU_SOURCE
67
69 Each of these functions has the same behavior as its counterpart with‐
70 out the "_unlocked" suffix, except that they do not use locking (they
71 do not set locks themselves, and do not test for the presence of locks
72 set by others) and hence are thread-unsafe. See flockfile(3).
73
75 For an explanation of the terms used in this section, see at‐
76 tributes(7).
77
78 ┌─────────────────────┬───────────────┬────────────────────────────────┐
79 │Interface │ Attribute │ Value │
80 ├─────────────────────┼───────────────┼────────────────────────────────┤
81 │getc_unlocked(), │ Thread safety │ MT-Safe race:stream │
82 │putc_unlocked(), │ │ │
83 │clearerr_unlocked(), │ │ │
84 │fflush_unlocked(), │ │ │
85 │fgetc_unlocked(), │ │ │
86 │fputc_unlocked(), │ │ │
87 │fread_unlocked(), │ │ │
88 │fwrite_unlocked(), │ │ │
89 │fgets_unlocked(), │ │ │
90 │fputs_unlocked(), │ │ │
91 │getwc_unlocked(), │ │ │
92 │fgetwc_unlocked(), │ │ │
93 │fputwc_unlocked(), │ │ │
94 │putwc_unlocked(), │ │ │
95 │fgetws_unlocked(), │ │ │
96 │fputws_unlocked() │ │ │
97 ├─────────────────────┼───────────────┼────────────────────────────────┤
98 │getchar_unlocked(), │ Thread safety │ MT-Unsafe race:stdin │
99 │getwchar_unlocked() │ │ │
100 ├─────────────────────┼───────────────┼────────────────────────────────┤
101 │putchar_unlocked(), │ Thread safety │ MT-Unsafe race:stdout │
102 │putwchar_unlocked() │ │ │
103 ├─────────────────────┼───────────────┼────────────────────────────────┤
104 │feof_unlocked(), │ Thread safety │ MT-Safe │
105 │ferror_unlocked(), │ │ │
106 │fileno_unlocked() │ │ │
107 └─────────────────────┴───────────────┴────────────────────────────────┘
108
110 The four functions getc_unlocked(), getchar_unlocked(), putc_un‐
111 locked(), putchar_unlocked() are in POSIX.1-2001 and POSIX.1-2008.
112
113 The nonstandard *_unlocked() variants occur on a few UNIX systems, and
114 are available in recent glibc. They should probably not be used.
115
117 flockfile(3), stdio(3)
118
120 This page is part of release 5.12 of the Linux man-pages project. A
121 description of the project, information about reporting bugs, and the
122 latest version of this page, can be found at
123 https://www.kernel.org/doc/man-pages/.
124
125
126
127 2021-03-22 UNLOCKED_STDIO(3)