CALLBACK(9)
π 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 bych. The highest IPL at which this callback can be used is specified byipl.callback_head_destroy(ch)β Destroy the callback structure specified bych.
β οΈ 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 bych.ceshould point to the entry structure of the callback object. The callback object itself is specified byobj. The function pointer is specified byfn.callback_unregister(ch, ce)β Unregister the callback function from the structure specified bych. The entry should be passed asce. This function may block. πcallback_run_roundrobin(ch, arg)β Executes all functions registered in the callback structure, specified bych. The functions are executed in round-robin fashion. The value ofargwill be passed to the callback functions.
π₯ CODE REFERENCES π₯
The callback interface is implemented within the file sys/kern/subr_callback.c.
π SEE ALSO π
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
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2009 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms