Use local functions for module_init and module_exit.
[ksplice.git] / kmodsrc / primary.c
blobeb1443107f2c2941511d953e3cfcc2aed357b348
1 /* Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License, version 2.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
14 * 02110-1301, USA.
17 #ifdef KSPLICE_STANDALONE
18 #include "ksplice.h"
19 #else
20 #include <linux/ksplice.h>
21 #endif
23 MODULE_LICENSE("GPL v2");
25 #undef _STR
26 #define _STR(x) #x
27 #undef STR
28 #define STR(x) _STR(x)
30 #define _PASTE(x, y) x##y
31 #define PASTE(x, y) _PASTE(x, y)
32 #define KSPLICE_UNIQ(s) PASTE(s##_, KSPLICE_ID)
34 extern const struct ksplice_reloc ksplice_relocs[], ksplice_relocs_end[];
35 extern const struct ksplice_size ksplice_sizes[], ksplice_sizes_end[];
36 extern struct ksplice_patch ksplice_patches[], ksplice_patches_end[];
37 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
38 extern struct paravirt_patch_site parainstructions[], parainstructions_end[];
39 #endif
41 LIST_HEAD(reloc_addrmaps);
42 LIST_HEAD(reloc_namevals);
43 LIST_HEAD(safety_records);
45 static int debug;
46 module_param(debug, int, 0600);
48 #define pack KSPLICE_UNIQ(pack)
49 struct module_pack pack = {
50 .name = "ksplice_" STR(KSPLICE_ID),
51 #ifdef KSPLICE_TARGET
52 .target = STR(KSPLICE_TARGET),
53 #else
54 .target = NULL,
55 #endif
56 .map_printk = MAP_PRINTK,
57 .primary = THIS_MODULE,
58 .primary_relocs = ksplice_relocs,
59 .primary_relocs_end = ksplice_relocs_end,
60 .primary_sizes = ksplice_sizes,
61 .primary_sizes_end = ksplice_sizes_end,
62 .patches = ksplice_patches,
63 .patches_end = ksplice_patches_end,
64 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
65 .primary_parainstructions = parainstructions,
66 .primary_parainstructions_end = parainstructions_end,
67 #endif
68 .reloc_addrmaps = &reloc_addrmaps,
69 .reloc_namevals = &reloc_namevals,
70 .safety_records = &safety_records,
72 EXPORT_SYMBOL_GPL(pack);
74 static int init_primary(void)
76 pack.debug = debug;
77 return 0;
80 static void cleanup_primary(void)
82 cleanup_ksplice_module(&pack);
85 #define helper_init_module KSPLICE_UNIQ(helper_init_module)
86 int helper_init_module(void)
88 return init_ksplice_module(&pack);
90 EXPORT_SYMBOL_GPL(helper_init_module);
92 module_init(init_primary);
93 module_exit(cleanup_primary);