CALLBACK(9)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’– CALLBACK(9) β€” generic callback interface πŸ’–

okay so bestie, this is CALLBACK(9) straight out of the Kernel Developer's Manual, and it's literally the generic callback interface. It's giving "let the lower-level layer run a function from the higher-level layer" energy, and we're gonna get into it. 🫢


🌸 NAME 🌸

callback β€” generic callback interface

✨ SYNOPSIS ✨

#include <sys/callback.h>

void
callback_head_init(struct callback_head *ch, int ipl);

void
callback_head_destroy(struct callback_head *ch);

void
callback_register(struct callback_head *ch, struct callback_entry *ce,
    void *obj, int (*fn)(struct callback_entry *, void *, void *));

void
callback_unregister(struct callback_head *ch,
    struct callback_entry *ce);

int
callback_run_roundrobin(struct callback_head *ch, void *arg);

πŸ’… DESCRIPTION πŸ’…

The generic callback interface lets lower-level layer code execute a registered function β€” or a whole set of functions β€” from the higher-level layer. lowkey iconic behavior. ✨

Registered functions must return one of these constants:

  • CALLBACK_CHAIN_CONTINUE β€” Indicates that the function call was successful. The following functions in the chain will be called.
  • CALLBACK_CHAIN_ABORT β€” Indicates a failure case in the function call. Any following functions in the chain will not be executed.

🫢 FUNCTIONS 🫢

The callback structure callback_head should be initialized and destroyed using the functions described below. This structure contains the list of callback entries and other internal data.

The callback_entry structure is an entry, normally associated with the higher-level object. It contains the internal data of the callback interface.

  • callback_head_init(ch, ipl) β€” Initialize the callback structure specified by ch. The highest IPL at which this callback can be used is specified by ipl.
  • callback_head_destroy(ch) β€” Destroy the callback structure specified by ch.
⚠️ bestie, do not skip this: the caller must unregister all functions before destroying the callback structure. That's a hard requirement, no cap.
  • callback_register(ch, ce, obj, fn) β€” Register the callback function in the callback structure specified by ch. ce should point to the entry structure of the callback object. The callback object itself is specified by obj. The function pointer is specified by fn.
  • callback_unregister(ch, ce) β€” Unregister the callback function from the structure specified by ch. The entry should be passed as ce. This function may block. πŸ‘€
  • callback_run_roundrobin(ch, arg) β€” Executes all functions registered in the callback structure, specified by ch. The functions are executed in round-robin fashion. The value of arg will be passed to the callback functions.

πŸ”₯ CODE REFERENCES πŸ”₯

The callback interface is implemented within the file sys/kern/subr_callback.c.

🌈 SEE ALSO 🌈

intro(9)


mwah πŸ’‹ this page is from Debian, dated October 28, 2009, and it's the CALLBACK(9) manual page. bye bestie 🫢✨

πŸ“¦ where this page comes from