From owner-freebsd-hackers Wed Jan 14 17:07:41 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA24843 for hackers-outgoing; Wed, 14 Jan 1998 17:07:41 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from parkplace.cet.co.jp (parkplace.cet.co.jp [202.32.64.1]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA24627 for ; Wed, 14 Jan 1998 17:05:19 -0800 (PST) (envelope-from michaelh@cet.co.jp) Received: from localhost (michaelh@localhost) by parkplace.cet.co.jp (8.8.8/CET-v2.2) with SMTP id BAA22683; Thu, 15 Jan 1998 01:04:01 GMT Date: Thu, 15 Jan 1998 10:04:01 +0900 (JST) From: Michael Hancock To: Joel Ray Holveck cc: freebsd-hackers@FreeBSD.ORG Subject: Re: sharable static arrays? In-Reply-To: <199801140430.WAA03884@detlev.UUCP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk On Tue, 13 Jan 1998, Joel Ray Holveck wrote: > Are arrays declared const shared across multiple invocations of a > program? > > That is, if I have an array > const int foo[8192] = {...}; > then will each instance of the invocation separately allocate 16k for > an array that's never going to change, and exists as it is in the > executable? It depends on how it's defined and scoped. Try different combinations of defining "const int foo" and move them around your foo.c file. Try these: Module scope Function scope Function scope and defined static Then run nm on the a.out and look for foo. If there's a big T or little t in front of it then the storage is in text which is mapped read-only and shared. Regards, Mike Hancock > Cheers, > joelh > > -- > Joel Ray Holveck - joelh@gnu.org - http://www.wp.com/piquan > Fourth law of programming: > Anything that can go wrong wi > sendmail: segmentation violation - core dumped > -- michaelh@cet.co.jp http://www.cet.co.jp CET Inc., Daiichi Kasuya BLDG 8F 2-5-12, Higashi Shinbashi, Minato-ku, Tokyo 105 Japan Tel: +81-3-3437-1761 Fax: +81-3-3437-1766