stdio_ext(3)
π stdio_ext(3) β Library Functions Manual π
okay bestie, come sit with me because we're about to get up close and personal with the guts of stdio πβ¨ This is stdio_ext(3), and no cap, it's the page for all the little double-underscore besties that peek inside your FILE structure. We're not supposed to touch the internals normally, but these functions said "actually, hold my matcha" π΅π
πΈ NAME πΈ
__fbufsize, __flbf, __fpending, __fpurge, __freadable, __freading, __fsetlocking, __fwritable, __fwriting, _flushlbf β literally interfaces to the stdio FILE structure π«Ά
π LIBRARY π
Standard C library (libc, -lc) β yes queen, it ships with your libc π
β¨ SYNOPSIS β¨
#include <stdio.h>
#include <stdio_ext.h>
size_t __fbufsize(FILE *stream);
size_t __fpending(FILE *stream);
int __flbf(FILE *stream);
int __freadable(FILE *stream);
int __fwritable(FILE *stream);
int __freading(FILE *stream);
int __fwriting(FILE *stream);
int __fsetlocking(FILE *stream, int type);
void _flushlbf(void);
void __fpurge(FILE *stream);
π¦ DESCRIPTION π¦
So here's the lore π Solaris introduced routines that let you portably access the internals of the FILE structure, and glibc was like "not me also implementing these" and did it anyway. Iconic behaviour, honestly π
__fbufsize()β returns the size of the buffer currently used by the given stream. Exactly that many bytes of buffer, no more no less π«__fpending()β returns the number of characters in the output buffer. Careful though bestie π¨: for wide-oriented streams the unit is wide characters</>, not plain chars. And this one is undefined on buffers in reading mode, or that were opened read-only β so don't even try it, it's giving undefined behaviour π__flbf()β returns nonzero if the stream is line-buffered, and zero otherwise. Simple, clean, slays πΈ__freadable()β returns nonzero if the stream allows reading, and zero otherwise π__fwritable()β returns nonzero if the stream allows writing, and zero otherwise ποΈ__freading()β returns nonzero if the stream is read-only, or if the last operation on the stream was a read operation, and zero otherwise π__fwriting()β returns nonzero if the stream is write-only (or append-only), or if the last operation on the stream was a write operation, and zero otherwise ποΈ__fsetlocking()β this is the main character right here π it lets you pick the desired type of locking on the stream, and it returns the current type (so you can also just ask without changing anything). Thetypeargument can take these three values:FSETLOCKING_INTERNALβ perform implicit locking around every operation on the given stream (except for the*_unlockedones). This is the default βFSETLOCKING_BYCALLERβ the caller will take care of the locking (possibly usingflockfile(3)in case there's more than one thread π―), and the stdio routines will not do locking until the state is reset toFSETLOCKING_INTERNAL. So like, you're on your own, bestie π«‘FSETLOCKING_QUERYβ don't change the type of locking. (Only return it.) A pure vibe check, no changes made π
_flushlbf()β flushes all line-buffered streams. (Presumably so that output to a terminal is forced out, say before reading keyboard input. Which, yeah, makes so much sense π)__fpurge()β discards the contents of the stream's buffer ποΈ yeet, gone, bye
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7) π
__fbufsize(),__fpending(),__fpurge(),__fsetlocking()β Thread safety:MT-Safe race:streamβ οΈ__flbf(),__freadable(),__freading(),__fwritable(),__fwriting(),_flushlbf()β Thread safety:MT-Safeβ
π SEE ALSO π
and that's the whole page, bestie, we ate and left absolutely no crumbs πβ¨ this was stdio_ext(3) from Linux man-pages 6.20, dated 2026-02-08 β go be an icon with your streams, ily, mwah ππ¦ π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2001, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms