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