The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации / Документация по FreeBSD / Руководства по FreeBSD на английском

13.3 Using Sysinit

13.3.1 Interface

13.3.1.1 Headers

    <sys/kernel.h>

13.3.1.2 Macros

    SYSINIT(uniquifier, subsystem, order, func, ident)
            SYSUNINIT(uniquifier, subsystem, order, func, ident)

13.3.2 Startup

The SYSINIT() macro creates the necessary sysinit data in Sysinit's startup data set for Sysinit to sort and dispatch a function at system startup and module load. SYSINIT() takes a uniquifier that Sysinit uses identify the particular function dispatch data, the subsystem order, the subsystem element order, the function to call, and the data to pass the function. All functions must take a constant pointer argument.

For example:

    #include <sys/kernel.h>
    
    void foo_null(void *unused)
    {
            foo_doo();
    }
    SYSINIT(foo_null, SI_SUB_FOO, SI_ORDER_FOO, NULL);
    
    struct foo foo_voodoo = {
            FOO_VOODOO;
    }
    
    void foo_arg(void *vdata)
    {
            struct foo *foo = (struct foo *)vdata;
            foo_data(foo);
    }
    SYSINIT(foo_arg, SI_SUB_FOO, SI_ORDER_FOO, foo_voodoo);
         

13.3.3 Shutdown

The SYSUNINIT() macro behaves similarly to the SYSINIT() macro except that it adds the Sysinit data to Sysinit's shutdown data set.

For example:

    #include <sys/kernel.h>
    
    void foo_cleanup(void *unused)
    {
            foo_kill();
    }
    SYSUNINIT(foo_cleanup, SI_SUB_FOO, SI_ORDER_FOO, NULL);
    
    struct foo_stack foo_stack = {
            FOO_STACK_VOODOO;
    }
    
    void foo_flush(void *vdata)
    {
    }
    SYSUNINIT(foo_flush, SI_SUB_FOO, SI_ORDER_FOO, foo_stack);
         

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру