属性

有关本节中使用的术语的说明,请参见attribute(7)。

InterfaceAttributeValue
getc_unlocked(),putc_unlocked(),clearerr_unlocked(),fflush_unlocked(),fgetc_unlocked(),fputc_unlocked(),fread_unlocked(),fwrite_unlocked(),fgets_unlocked(),fputs_unlocked(),getwc_unlocked(),fgetwc_unlocked(),fputwc_unlocked(),putwc_unlocked(),fgetws_unlocked(),fputws_unlocked()Thread safetyMT-Safe race:stream
getchar_unlocked(),getwchar_unlocked()Thread safetyMT-Unsafe race:stdin
putchar_unlocked(),putwchar_unlocked()Thread safetyMT-Unsafe race:stdout
feof_unlocked(),ferror_unlocked(),fileno_unlocked()Thread safetyMT-Safe

语法

#include <stdio.h>

int getc_unlocked(FILE *stream);
int getchar_unlocked(void);
int putc_unlocked(int c, FILE *stream);
int putchar_unlocked(int c);

void clearerr_unlocked(FILE *stream);
int feof_unlocked(FILE *stream);
int ferror_unlocked(FILE *stream);
int fileno_unlocked(FILE *stream);
int fflush_unlocked(FILE *stream);
int fgetc_unlocked(FILE *stream);
int fputc_unlocked(int c, FILE *stream);
size_t fread_unlocked(void *ptr, size_t size, size_t n,
                      FILE *stream);
size_t fwrite_unlocked(const void *ptr, size_t size, size_t n,
                      FILE *stream);

char *fgets_unlocked(char *s, int n, FILE *stream);
int fputs_unlocked(const char *s, FILE *stream);

#include <wchar.h>

wint_t getwc_unlocked(FILE *stream);
wint_t getwchar_unlocked(void);
wint_t fgetwc_unlocked(FILE *stream);
wint_t fputwc_unlocked(wchar_t wc, FILE *stream);
wint_t putwc_unlocked(wchar_t wc, FILE *stream);
wint_t putwchar_unlocked(wchar_t wc);
wchar_t *fgetws_unlocked(wchar_t *ws, int n, FILE *stream);
int fputws_unlocked(const wchar_t *ws, FILE *stream);

glibc的功能测试宏要求(请参阅feature_test_macros(7)):

getc_unlocked(),getchar_unlocked(),putc_unlocked(),putchar_unlocked():

/ *自glibc 2.24起:* / _POSIX_C_SOURCE>= 199309L || / * Glibc版本

clearerr_unlocked(),feof_unlocked(),ferror_unlocked(),fileno_unlocked(),fflush_unlocked(),fgetc_unlocked(),fputc_unlocked(),fread_unlocked(),fwrite_unlocked():

/ *自2.19开始的Glibc:* / _DEFAULT_SOURCE || / * Glibc版本

fgets_unlocked(),fputs_unlocked(),getwc_unlocked(),getwchar_unlocked(),fgetwc_unlocked(),fputwc_unlocked(),putwchar_unlocked(),fgetws_unlocked(),fputws_unlocked():

_GNU_SOURCE

出版信息

这个页面是Linux手册页项目5.08版的一部分。有关项目的说明、有关报告错误的信息以及此页面的最新版本,请访问https://www.kernel.org/doc/man-pages/

名称

getc_unlocked,getchar_unlocked,putc_unlocked,putchar_unlocked-非锁定stdio函数

另外参见

flockfile(3),stdio(3)

UNLOCKED_STDIO - Linux手册页

Linux程序员手册 第3部分
更新日期: 2017-09-15

遵循规范

四个函数getc_unlocked(),getchar_unlocked(),putc_unlocked(),putchar_unlocked()在POSIX.1-2001和POSIX.1-2008中。

非标准的* _unlocked()变体出现在一些UNIX系统上,并且在最近的glibc中可用。可能不应该使用它们。

说明

这些函数中的每个函数均与不带" _unlocked"后缀的函数具有相同的行为,除了它们不使用锁定(它们不设置锁本身,并且不测试其他人设置的锁的存在),因此它们是线程-不安全参见flockfile(3)。

日期:2019-08-20 18:00:26 来源:oir作者:oir