This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/7] Fix __PTHREAD_MUTEX_HAVE_ELISION -Wundef warning


> So your idea is also to refactor __PTHREAD_MUTEX_HAVE_PREV to use as #if
> ... along with __PTHREAD_MUTEX_HAVE_ELISION then? Both defines are set by
> arch specific headers, so would be the idea to just a generic pthread
> header (or use an existing one) to define them to default values?

I haven't examined that particular set of macros, so I don't have something
specific in mind.  It's just the general rule that we should organize our
macros (including wholesale reshuffling of what we have today, if need be)
so that every use under our control if typo-proof.

For cases like this in general (sysdeps headers making the choices), I
think when it's straightforward enough to simply require that each variant
of the sysdeps header #define the full set to 1/0 explicitly, then that is
the way to go.  Building with -Wundef ensures that if a new macro is added
and some sysdeps file gets out of date, the next person doing a build of
that configuration will notice with loud and obvious -Wundef warnings.  We
should also establish a clear and regimented convention for comments
describing what macros the sysdeps file is obliged to define.

It's entirely plausible that there will be cases where it seems cleaner to
have a generic header that includes a sysdeps one and then uses #ifndef to
provide defaults.  But that style is prone to typo bugs, so it should be a
high burden to say that this is the preferable approach for any given
header and set of macros.  If there are cases where we decide to do that,
it should be treated like the predefines case: a single block of #if hooey,
clearly isolated from all other logic and in an obvious place like near the
beginning of a header, should do all the #ifndef testing in one place that
is easy to verify by eye, does nothing at all but yield a set of
always-defined macros to be tested later with #if, and has a comments
following a clear convention to say what all the macros are.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]