kfifo_init(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– kfifo_init β€” like, the kernel API manual page, bestie πŸ’–

okay so you found your way to kfifo_init(9) and honestly? proud of you. this is a kernel API manual page, and we're about to make it make sense. no cap.


✨ NAME ✨

kfifo_init β€” initialize a fifo using a preallocated buffer πŸŽ€

like, you already have the buffer, and this macro is the one that goes "slay, let's hook it up."


πŸ¦‹ SYNOPSIS πŸ¦‹

kfifo_init (fifo , buffer , size );

that's the whole vibe. three args, no drama.


🌸 ARGUMENTS 🌸

  • fifo β€” the fifo to assign the buffer 🫢 this is the one getting the glow-up.
  • buffer β€” the preallocated buffer to be used ✨ you bring your own, that's the whole point.
  • size β€” the size of the internal buffer, this have to be a power of 2 πŸ’… yes, exactly like that, it have to be a power of 2. non-negotiable, the math said so.

🌈 DESCRIPTION 🌈

This macro initializes a fifo using a preallocated buffer. main character macro behavior, honestly β€” it doesn't allocate anything, it just takes your buffer and makes it official.

The number of elements will be rounded-up to a power of 2. πŸ”₯ so if you were out here thinking your size was gonna stay exactly as you typed it… nope, it's getting rounded up, that's just the rules.

Return 0 if no error, otherwise an error code. Simple as. πŸ’€

ngl, remember the power-of-2 thing. future you will thank present you. 🧚

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/linux/kfifo.h β€” and like, the entire kfifo cinematic universe:


and that's the page, bestie πŸŽ€ this one lives in ./include/linux, October 2026 edition β€” go forth and round up to powers of 2 πŸ’œβœ¨

πŸ“¦ where this page comes from