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). The type argument can take these three values:
    • FSETLOCKING_INTERNAL β€” perform implicit locking around every operation on the given stream (except for the *_unlocked ones). This is the default βœ…
    • FSETLOCKING_BYCALLER β€” the caller will take care of the locking (possibly using flockfile(3) in case there's more than one thread πŸ‘―), and the stdio routines will not do locking until the state is reset to FSETLOCKING_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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms