Date: Mon, 21 Aug 2006 16:08:08 -0700 From: John-Mark Gurney <gurney_j@resnet.uoregon.edu> To: "M. Warner Losh" <imp@bsdimp.com> Cc: freebsd-hackers@freebsd.org, rik@inse.ru Subject: Re: global date via module howto Message-ID: <20060821230808.GC99774@funkthat.com> In-Reply-To: <20060820.220124.387191884.imp@bsdimp.com> References: <44E87CCD.30105@inse.ru> <20060820.220124.387191884.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Warner Losh wrote this message on Sun, Aug 20, 2006 at 22:01 -0600: > In message: <44E87CCD.30105@inse.ru> > Roman Kurakin <rik@inse.ru> writes: > : I have the following problem: > : module A > : int x; > : > : module B > : extern int x; > : > : Module A is loaded, module B can't be loaded cause of unknow 'x'. > : What should I do to make x global? > > Better to make module B depend on module A. Making it global is > generally a bad idea. > > in module A: > MODULE_VERSION(A, 1); > > In module B: > MODULE_DEPEND(B, A, 1, 1, 1); Our modules do special work to hide all global symbols, so this is necessary, unless you add special hacks to the Makefile of module A... It's better to mark the dependancy, since it really does depend upon that, since if A doesn't exist, and you try to load B, you'll still get a symbol not found... The dependancy has the advantage of autoloading module A when you load module B, so that you don't have to type as much... For my bktrau HDTV driver, I only have to load iic, bktrau, and bktr, as each are their own modules, and the i2c bus module automaticly gets brought in by either iic or bktr (as each depend upon the i2c bus)... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060821230808.GC99774>