Date: Fri, 20 Apr 2001 16:09:39 +0200 From: Mark Murray <mark@grondar.za> To: smp@FreeBSD.ORG Subject: Re: Please review - header cleanups Message-ID: <200104201408.f3KE83w16255@gratis.grondar.za> In-Reply-To: <Pine.BSF.4.21.0104200718080.12888-100000@besplex.bde.org> ; from Bruce Evans <bde@zeta.org.au> "Fri, 20 Apr 2001 07:35:24 %2B1000." References: <Pine.BSF.4.21.0104200718080.12888-100000@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Said Bruce Evans <bde@zeta.org.au>: > > Ok so this would be a header with only the "struct mtx { ... };" in it, > > and it would be included in all the headers that need to know the size > > and shape of struct mtx (including sys/mutex.h)? > > --- > diff -c2 mutex_types.h~ mutex_types.h [ snippage of patches ] > This removes all the nested includes of <sys/mutex.h> except the one in > <sys/buf.h> (the inline functions there should probably not be inline). > It only removes a couple of nested includes of <sys/lock.h> (ones related > to <sys/mutex.h>). Nice! :-) This is an excellent base to work off. Thanks! > LINT compiles after adding includes of <sys/mutex.h> (and sometimes > <sys/lock.h>) to "only" about 50 .c files. Many more probably depend > on the pollution in <sys/buf.h> :-(. About 1/2 of the 50 really should > include <sys/mutex.h>. The others mostly use the PROC_* locking macros > in <sys/proc.h> these expand to mtx_lock(), etc. mtx_lock() is another > macro so it can't just be declared. It needs the MPASS() macros from > <sys/lock.h>, so everything that uses the PROC_* macros needs both > <sys/mutex.h> and <sys/lock.h>. Eeew. > > > 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. > > > > I think I prefer 1). > > I've put 2 structs in <sys/mutex_types.h> to test things quickly. Strictly, > struct lock_object belongs in a header by itself. So making a <sys/lock_types.h> seems to be on the cards. > > ONE header to declare _all_/lots_of the "internal" structures? Hmmm... > > See glibc or stddef.h under contrib/gcc. The __need_foo_t stuff selects > the types that will be declared. Ugly, isn't it. Eeew. :-( Now I need a drink... (please don't show be code like that again without warning me!) Seriously - I think I have a pretty good idea now on how to do this. I'll come up with a new patch, and see if I can do something about the PROC_*/mutex entanglement. How bad does a <sys/proc_macros.h> sound? How bad does any <*/*_macros.h> sound (for both macros and inline code) where the header contains approximately _only_ executable stuff as opposed to "pure" declarations? M -- Mark Murray Warning: this .sig is umop ap!sdn 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?200104201408.f3KE83w16255>