From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 21 23:08:13 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A386016A4DF for ; Mon, 21 Aug 2006 23:08:13 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 449D343D49 for ; Mon, 21 Aug 2006 23:08:12 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (qn4os27q3hw7mdxg@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id k7LN89fj026697; Mon, 21 Aug 2006 16:08:09 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id k7LN88ff026696; Mon, 21 Aug 2006 16:08:08 -0700 (PDT) (envelope-from jmg) Date: Mon, 21 Aug 2006 16:08:08 -0700 From: John-Mark Gurney To: "M. Warner Losh" Message-ID: <20060821230808.GC99774@funkthat.com> Mail-Followup-To: "M. Warner Losh" , rik@inse.ru, freebsd-hackers@freebsd.org References: <44E87CCD.30105@inse.ru> <20060820.220124.387191884.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060820.220124.387191884.imp@bsdimp.com> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: freebsd-hackers@freebsd.org, rik@inse.ru Subject: Re: global date via module howto X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2006 23:08:13 -0000 Warner Losh wrote this message on Sun, Aug 20, 2006 at 22:01 -0600: > In message: <44E87CCD.30105@inse.ru> > Roman Kurakin 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."