Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Apr 2001 09:37:18 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Mark Murray <mark@grondar.za>, smp@FreeBSD.org
Subject:   Re: Please review - header cleanups
Message-ID:  <Pine.BSF.4.21.0104190843520.4850-100000@besplex.bde.org>
In-Reply-To: <XFMail.010418091359.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 18 Apr 2001, John Baldwin wrote:

> On 18-Apr-01 Mark Murray wrote:
> > My change is, I believe, in agreement with the first paragraph
> > of http://people.freebsd.org/~jasone/smp/ "Project Goal" in that
> > it achieves _something_ in the quest of de-threading the chain of
> >#includes. Not the whole story, perhaps, but a step in that direction.
> 
> Well, I put that up there because I was under the impression that nested
> includes were to be avoided at all costs based on previous discussions with
> Bruce.  It seems now that Bruce was more just trying to discourage the practice
> but not condemning those particular cases as the alternatives were worse.
> In the case of determing if headers should use nested #includes, etc. I defer
> to Bruce as he is more authoritative in this area.

It's nested includes of primary headers (ones that declare standard
kernel or application interfaces) that should be avoided.  Nested
includes of secondary headers (ones that declare only common implementation
details, e.g., <sys/cdefs.h> and <machine/ansi.h>, or a carefully
selected (small) set of primary interfaces, e.g., <sys/timespec.h>)
are OK.  Including secondary headers, especially lots of little ones,
still gives lots of includes, but shouldn't give nearly as many symbols
if the secondary headers are properly implemented, since the secondary
headers need not depend on as many other headers.

Possible implementations:
1) Do the same things as are planned for `struct timespec': use a tiny
   header that declares just `struct mtx' and include this header as
   necessary.
2) Do the same things as are done for size_t: define a macro that declares
   `struct mtx' in a not so tiny secondary header; include this header and
   expand it as necessary.  This is uglier than (1), but doesn't require
   so many headers.
3) Combination/variation of on (1)-(2): conditionally declare various
   structs and types in a not so tiny secondary header; include this
   header with only the required declarations selected.  This method is
   used in glibc.  This is not as ugly as (2), but I think it is slower
   than both (1) and (2).

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0104190843520.4850-100000>