1UNLOCKED_STDIO(3)          Linux Programmer's Manual         UNLOCKED_STDIO(3)
2
3
4

NAME

6       getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked - non‐
7       locking stdio functions
8

SYNOPSIS

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

DESCRIPTION

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

ATTRIBUTES

75       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
76       tributes(7).
77
78       ┌─────────────────────┬───────────────┬────────────────────────────────┐
79Interface            Attribute     Value                          
80       ├─────────────────────┼───────────────┼────────────────────────────────┤
81getc_unlocked(),     │ Thread safety │ MT-Safe race:stream            │
82putc_unlocked(),     │               │                                │
83clearerr_unlocked(), │               │                                │
84fflush_unlocked(),   │               │                                │
85fgetc_unlocked(),    │               │                                │
86fputc_unlocked(),    │               │                                │
87fread_unlocked(),    │               │                                │
88fwrite_unlocked(),   │               │                                │
89fgets_unlocked(),    │               │                                │
90fputs_unlocked(),    │               │                                │
91getwc_unlocked(),    │               │                                │
92fgetwc_unlocked(),   │               │                                │
93fputwc_unlocked(),   │               │                                │
94putwc_unlocked(),    │               │                                │
95fgetws_unlocked(),   │               │                                │
96fputws_unlocked()    │               │                                │
97       ├─────────────────────┼───────────────┼────────────────────────────────┤
98getchar_unlocked(),  │ Thread safety │ MT-Unsafe race:stdin           │
99getwchar_unlocked()  │               │                                │
100       ├─────────────────────┼───────────────┼────────────────────────────────┤
101putchar_unlocked(),  │ Thread safety │ MT-Unsafe race:stdout          │
102putwchar_unlocked()  │               │                                │
103       ├─────────────────────┼───────────────┼────────────────────────────────┤
104feof_unlocked(),     │ Thread safety │ MT-Safe                        │
105ferror_unlocked(),   │               │                                │
106fileno_unlocked()    │               │                                │
107       └─────────────────────┴───────────────┴────────────────────────────────┘
108

CONFORMING TO

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

SEE ALSO

117       flockfile(3), stdio(3)
118

COLOPHON

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)
Impressum