Re: [PATCH 01/10] thread-utils: macros to unconditionally compile pthreads API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 27, 2018 at 10:15 AM Jeff King <peff@xxxxxxxx> wrote:
>
> On Sat, Oct 27, 2018 at 09:40:13AM +0200, Duy Nguyen wrote:
>
> > > 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.
>
> Ah, yeah, you're right, I was mixing up the thread id and the key in my
> head. I think it would just be an array of void pointers, with
> pthread_key_create() returning an static index.

We could redefine pthread_key_t as "void *" though, then
_setspecific(key, data) is key = data; But there will be more changes
in index-pack.c to take advantage of it. I took a stab but couldn't
figure out fast enough where _setspecific(.., &nothread_data) should
be called in NO_PTHREADS mode (to simplify get_thread_data() to just a
wrapper of _getspecific) and got bored. It could be a micro project
for someone really wants to learn about index-pack.c
-- 
Duy



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux