switch to non-zero PTHREAD_*_INITIALIZER

Konstantin Belousov kostikbel at gmail.com
Mon Feb 11 10:38:17 UTC 2019


On Mon, Feb 11, 2019 at 09:43:42AM +0000, Poul-Henning Kamp wrote:
> Right now most of our PTHREAD_*_INITIALIZER macros are defined as NULL.
> 
> This is a bad choice from a code quality point of view, because it means
> that
> 
> 	pthread_t my_mutex;
> 
> and
> 
> 	pthread_t my_mutes = PTHREAD_MUTEX_INITIALIZER;
> 
> act the same, which they are not.
> 
> I suggest that we should change the macros to a non-NULL value, and
> add a check for NULL values which emit a warning about the lack of
> initialization.
> 
> Comments ?

This would make the startup (or more) of current binaries too noisy and
perhaps even break the applications that depend on specific output from
the subordinate processes.

I wanted to reorganize static initializizers for some time, esp. to add
specific initializers like RECURSIVE_NP and similar. This requires more
changes in libthr, particular to the shared and destroyed mutexes canary
values, which is quite delicate thing to do.  So far I did not spend time
on this.


More information about the freebsd-arch mailing list