From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 21 04:03:57 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 8D69116A4DA for ; Mon, 21 Aug 2006 04:03:57 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id D744943D46 for ; Mon, 21 Aug 2006 04:03:56 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.4/8.13.4) with ESMTP id k7L41Hsf002236; Sun, 20 Aug 2006 22:01:18 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 20 Aug 2006 22:01:24 -0600 (MDT) Message-Id: <20060820.220124.387191884.imp@bsdimp.com> To: rik@inse.ru From: "M. Warner Losh" In-Reply-To: <44E87CCD.30105@inse.ru> References: <44E87CCD.30105@inse.ru> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Sun, 20 Aug 2006 22:01:18 -0600 (MDT) Cc: freebsd-hackers@freebsd.org Subject: Re: global date via module howto X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list 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 04:03:57 -0000 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); Warner : PS. I am working on porting irda support for USB devices from NetBSD. : The current model consists of two layers hw and sw. hw is the usb device : driver. sw is some software layer the same for all device and it is a : child on top of hw 'bus'. To make this working I need to add : DRIVER_MODULE for each 'bus'. To make sw independent from the : bus I need to export _driver and _class structures and put DRIVER_MODULE : in 'bus' code instead of 'child'. Are you sure that you need to do this? I'm pretty sure that you can create a base class irdabus and then derive all the hw modules that implement irdabus from than and all the children will automatically probe. No need to export the driver/class structures. Warner