root / Whitix / branches / hybrid / include / init.h

Revision 463, 1.8 kB (checked in by mwhitworth, 5 months ago)

Define CoreInit, FsInit, ..., to correspond to ModuleInit if a module.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19#ifndef INIT_H
20#define INIT_H
21
22#include <module.h>
23#include <typedefs.h>
24
25#ifndef MODULE
26
27#define __init __attribute__ ((section (".init.text")))
28#define __initdata __attribute__ ((section ("init.data")))
29#define __exit __attribute__ ((section (".exit.text"))
30
31typedef int (*InitCall)();
32typedef void (*ExitCall)();
33
34#define ATTR_USED __attribute__((used))
35
36#define DeclareInitCall(level,func) \
37        static InitCall __initcall_##func ATTR_USED \
38        __attribute__((__section__(".initcall" level ".init")))=func
39
40#define CoreInit(func) DeclareInitCall("1",func)
41#define FsInit(func) DeclareInitCall("2",func)
42#define NetInit(func) DeclareInitCall("2",func)
43#define DeviceInit(func) DeclareInitCall("3",func)
44#define SubSysInit(func) DeclareInitCall("4", func)
45
46#else
47
48/* If the file is a module, its Init function is equivalent to a ModuleInit. */
49#define CoreInit(func) ModuleInit(func)
50#define FsInit(func) ModuleInit(func)
51#define NetInit(func) ModuleInit(func)
52#define DeviceInit(func) ModuleInit(func)
53#define SubSysInit(func) ModuleInit(func)
54
55#endif
56
57
58#endif
Note: See TracBrowser for help on using the browser.