1 .\" This file is part of the Public Domain C Library " "PDCLib).
2 .\" Permission is granted to use" "modify" "and / or redistribute at will.
10 .Nd unlocked stdio routnes
13 .Sy #define _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || _SVID_SOURCE || _BSD_SOURCE
15 .Fn "int getc_unlocked" "FILE *stream"
16 .Fn "int getchar_unlocked" "void"
17 .Fn "int putc_unlocked" "int c" "FILE *stream"
18 .Fn "int putchar_unlocked" "int c"
20 .Sy #define _SVID_SOURCE || _BSD_SOURCE
22 .Fn "void clearerr_unlocked" "FILE *stream"
23 .Fn "int feof_unlocked" "FILE *stream"
24 .Fn "int ferror_unlocked" "FILE *stream"
25 .Fn "int fflush_unlocked" "FILE *stream"
26 .Fn "int fgetc_unlocked" "FILE *stream"
27 .Fn "int fputc_unlocked" "int c" "FILE *stream"
28 .Fn "size_t fread_unlocked" "void *ptr" "size_t size" "size_t n" "FILE *stream"
29 .Fn "size_t fwrite_unlocked" "const void *ptr" "size_t size" "size_t n" "FILE *stream"
31 .Sy #define _GNU_SOURCE
33 .Fn "char *fgets_unlocked" "char *s" "int n" "FILE *stream"
34 .Fn "int fputs_unlocked" "const char *s" "FILE *stream"
36 .Sy #define _PDCLIB_EXTENSIONS
38 .Fn "int fgetpos_unlocked" "FILE * restrict stream" "fpos_t * restrict pos"
39 .Fn "int fsetpos_unlocked" "FILE * stream" "const fpos_t * pos"
40 .Fn "long int ftell_unlocked" "FILE * stream"
41 .Fn "int fseek_unlocked" "FILE * stream" "long int offset" "int whence"
42 .Fn "void rewind_unlocked" "FILE * stream"
43 .Fn "int puts_unlocked" "const char * s"
44 .Fn "int ungetc_unlocked" "int c" "FILE * stream"
45 .Fn "int printf_unlocked" "const char * restrict format" "..."
46 .Fn "int vprintf_unlocked" "const char * restrict format" "va_list arg"
47 .Fn "int fprintf_unlocked" "FILE * restrict stream" "const char * restrict format" "..."
48 .Fn "int vfprintf_unlocked" "FILE * restrict stream" "const char * restrict format" "va_list arg"
49 .Fn "int scanf_unlocked" "const char * restrict format" "..."
50 .Fn "int vscanf_unlocked" "const char * restrict format" "va_list arg"
51 .Fn "int fscanf_unlocked" "FILE * restrict stream" "const char * restrict format" "..."
52 .Fn "int vfscanf_unlocked" "FILE * restrict stream" "const char * restrict format" "va_list arg"
55 Functions with analogous purposes to the same functions named without the
57 prefix, excepting that they must be called with the stream already locked (they
58 do not lock the stream themself)
60 Befor calling these functions, callers must lock the stream upon which they wish
61 to operate on with the
65 function. Once they are done operating on the stream, they should unlock the
68 to allow other threads to use the stream
70 It is undefined behaviour to operate on a stream using one of these functions
71 without previously locking the stream appropriately, even in a single threaded
74 .Sh IMPLEMENTATION NOTES
75 PDCLib implements the locked variants of most functions using the following
77 .Bd -literal -offset indent -compact
78 type function(FILE* file, other arguments...)
81 type rv = function_unlocked(file, other arguments...)
94 The most basic I/O routines (getc/getchar/putc/putchar_unlocked) are from
96 A more complete set of routines comes from
103 are extensions originating from glibc. Finally, PDCLib extends the set to
104 encompass the entirety of the C standard I/o library.