On Thu, Oct 27, 2016 at 10:01:02AM -0700, Stefan Beller wrote: > > That function can > > be called from main() of platforms that cannot statically initialize > > mutices, > > By main you mean the main() in common-main.c or cmd_main in git.c ? Any setup or initialization for library functions needs to go in main() of common-main.c. Otherwise, only builtins get it, and external programs are left to segfault (or whatever). > Those both look like the wrong place. Of course it would work adding it > there, but it smells like a maintenance nightmare. I agree it's ugly, but I suspect it would work OK in practice. We don't have that many mutexes and initializing them is cheap. Languages like C++ have non-constant initializers, and the compiler takes care of running the startup code before main() begins. There's no portable way to do that in C, but our cmd_main() is roughly the same thing. I still prefer the lazy initialization if it can work without incurring measurable overhead. That's the normal way to do things in C; the only complication here is the thread safety. -Peff