KLUA_MOD_REGISTER(9)

πŸ“¦ version 11.0, in nixpkgs unstable

okay bestie, welcome to KLUA_MOD_REGISTER(9) β€” a Kernel Developer's Manual page, and it's giving kernel Lua bindings energy πŸ’…βœ¨

🌸 NAME 🌸

klua_mod_register, klua_mod_unregister β€” Lua kernel bindings. periodt.

✨ SYNOPSIS ✨

#include <sys/lua.h>

void
klua_mod_register(const char *name, lua_CFunction open);

void
klua_mod_unregister(const char *name);

πŸ¦‹ DESCRIPTION πŸ¦‹

The Lua kernel bindings are here to give Lua scripts functionality they normally don't get from the language itself β€” for example, access to core kernel functionality. How? By utilizing the lua_modules functionality. iykyk πŸ’«

The lua_module structure is declared like this, bestie:

struct lua_module {
        char                    mod_name[LUA_MAX_MODNAME];
        lua_CFunction           open;
        int                     refcount;
        LIST_ENTRY(lua_module)  mod_next;
};
  • mod_name β€” defines the unique name of a module.
  • open β€” a C function must use the standard Lua protocol to communicate with Lua; this part is maintained with the open element in the standard Lua way.
  • refcount β€” protects the module from being unloaded whilst still in use. literally the safety girl 🫢
  • mod_next β€” the last parameter, used for the standard container LIST(3).

The klua_mod_register() function registers a new function that's made available to the lua(9) device and to Lua code using the require directive. That require directive can be called from luactl(8) and the kernel Lua version. The name parameter is a unique identifier of the kernel Lua module. open points to a function used in the C to Lua binding, defined with the appropriate standard Lua API. slay πŸ”₯

Once registered, a C function can be unregistered with the klua_mod_unregister() function. This function takes as its parameter the unique literal identifier of the extending module. no cap.

🌈 EXAMPLES 🌈

A set of example modules is available in the src/sys/modules/examples directory hierarchy. go look, bestie 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

lua(1), luac(1), intro(3lua), lua(4), klua_close(9), klua_lock(9), klua_newstate(9), klua_unlock(9), kluaL_newstate(9), intro(9lua).

πŸ’œ AUTHORS πŸ’œ

Kamil Rytarowski <kamil@NetBSD.org>.


okay that's the whole page, bestie πŸ’– this one came from Debian, dated April 15, 2017, and it lives in the KLUA_MOD_REGISTER(9) manual slot β€” mwah βœ¨πŸŽ€

πŸ“¦ where this page comes from