Module complexities

Matthias Urlichs (smurf@smurf.noris.de)
Thu, 21 Mar 1996 10:41:36 +0100


I have found that, in order to create a module which

- is able to register a symbol table
- which I can compile cleanly (i.e. using only -D__KERNEL__ and -DMODUL=
E)
- figures out for itself whether CONFIG_MODVERSIONS is set or not

, the following contortions are necessary:

#include <linux/config.h>
#ifdef __GENKSYMS__
#include <linux/module.h>
#endif
#ifdef CONFIG_MODVERSIONS
#define MODVERSIONS
#include <linux/modversions.h>
#ifndef CONFIG_MODVERSIONS /* why does modversions clear this? */
#define CONFIG_MODVERSIONS /* I can't get at my own version table witho=
ut it! */
#endif
#endif
#ifndef __GENKSYMS__
#include <linux/module.h>
#endif
#include "symtables"

"symtables" is a file which contains one #include file for each version
file I create (with genksyms). I need to include config.h for
CONFIG_MODVERSIONS. I need to include module.h before modversions.h for
creating the symbol table because _set_ver is cleanly defined in one bu=
t
not in the other. I need things the other way round for compiling the c=
ode
because otherwise register_symtab doesn't get declared with a version
number.

That strikes me as excessively complicated and unlikely to survive the =
next
two kernel revisions. After all, the module code is there for people to
_use_.

The main reason for all this is that I don't want to play games with my
Makefile, the way the kernel does (and is able to). The place where the
current kernel is is defined implicitly by the location /usr/include/li=
nux
(or whereever else your current includes are (cross compilation!)) poin=
ts
to; no further knowledge should be necessary.

I would like to suggest that the above is incorporated into module.h so
that simply compiling with -D__KERNEL__ -DMODULE and including
<linux/module.h> is sufficient to do the same which now is done by the
above code, excluding the last line of course. Unfortunately, I lack th=
e
time to dig through the sequences of include files to either understand
well enough why, for instance, -DEXPORT_SYMTAB is sometimes used by the
kernel source even though the above code shows it's 100% superfluous,
or to go ahead and redo the whole thing in a more understandable way. =
:-(

--=20
You (humans) are,after all, essentially irrational.
-- Spock (Stardate 3220.3)
--=20
Matthias Urlichs \ XLink-POP N=FCrnberg | EMail: urlichs@smurf.=
noris.de
Schleiermacherstra=DFe 12 \ Unix+Linux+Mac | Phone: ...please use =
email.
90491 N=FCrnberg (Germany) \ Consulting+Networking+Programming+etc'i=
ng 42
PGP: 1B 89 E2 1C 43 EA 80 44 15 D2 29 CF C6 C7 E0 DE=20
Click <A HREF=3D"http://smurf.noris.de/~smurf/finger">here</A>.