From: Duy Nguyen Date: Sat, 27 Oct 2018 07:40:13 GMT Subject: Re: [PATCH 01/10] thread-utils: macros to unconditionally compile pthreads API Message-ID: In-Reply-To: <20181027073125.GB26685@sigill.intra.peff.net> On Sat, Oct 27, 2018 at 9:31 AM Jeff King wrote: > > +#define pthread_setspecific(key, data) > > +#define pthread_getspecific(key) NULL > > We expect to be able to store a void pointer here and get it back, which > should work even for a single thread. Do we need something like: > > extern void *pthread_specific_data; > > #define pthread_setspecific(key, data) do { \ > pthread_specific_data = data; \ > } while(0) > > void pthread_getspecific(key) pthread_specific_data The data is per key though so a correct implementation may involve a hashmap or a list. It does simplify index-pack which has to fall back to nothread_data when pthreads is not available. But with index-pack being the only call site that can take advantage of this (run-command.c probably will use real pthreads library anyway), I'm not sure if it's worth really implementing these functions. -- Duy