Re: [PATCH] compat: Allow static initializer for pthreads on Windows
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Oct 28, 2016, 20:49 UTC
- Message-ID
- <ab4c8148-2124-f08d-a770-e4f4e49a1c15@kdbg.org>
- In-Reply-To
- <xmqqr370z07v.fsf@gitster.mtv.corp.google.com>
Am 28.10.2016 um 22:29 schrieb Junio C Hamano:
Show 16 quoted lines
> Johannes Sixt <j6t@kdbg.org> writes: > >> Another problem with the proposed patch is that there is no >> declaration for attr_start() before the call in compat/mingw.c. We >> would have to move the declaration of attr_start() to cache.h (for >> example), because #including attr.h in compat/mingw.c is plainly >> wrong. However, it would not be a major offense to #include attr.h in >> common-main.c. But when we do that, we can certainly spare the few >> cycles to call pthread_mutex_init. > > That sounds like a good argument to have it in common-main.c. > > Would it mean that the code that defines the mutex needs to have > #ifdef that defines a no-op attr_start() and defines the mutex with > PTHREAD_MUTEX_INITILIZER with #else that just defines the mutex > without initializatin, with the real attr_start(), though?
No. My intent was to call pthread_mutex_init for all platforms. We already call open("/dev/null") unconditionally on every program startup. The few cycles spent in pthread_mutex_init should be the least of our worries.
-- Hannes