Re: [AD] Get thread id

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Fri Aug 17, 2012, Dimitris Zenios wrote:
> Btw looking at SDL source code SDL does
> 
> typedef unsigned long SDL_threadID;
> 
> SDL_threadID
> SDL_ThreadID(void)
> {
>     return ((SDL_threadID) pthread_self());
> }
> 
> 
> SDL assumes is safe to cast pthread_self to a number.Maybe we should
> change uint32_t to uint64_t
> 

While I'm sure that could work it feels kinda icky. What about using gettid? 
(or if not available, `syscall(__NR_gettid)`).

> On Fri, Aug 17, 2012 at 4:07 PM, Dimitris Zenios
> 
> <dimitris.zenios@xxxxxxxxxx> wrote:
> > What if we change (uint32_t)pthread_self to (uint32_t)getpid();
> > 
> > On Fri, Aug 17, 2012 at 3:53 PM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
> >> On Fri, 17 Aug 2012 15:15:23 +0300, Dimitris Zenios 
<dimitris.zenios@xxxxxxxxxx> wrote:
> >>> Patch to add al_get_thread_id.
> >> 
> >> The pthread implementation is not portable:
> >>     POSIX.1 allows an implementation wide freedom in choosing the type
> >>     used to represent a thread ID; for example, representation using
> >>     either an arithmetic type or a structure is permitted.
> >> 
> >> It could also be wider than 32-bits.
> >> 
> >> Peter
> >> 
> >> ------------------------------------------------------------------------
> >> ------ Live Security Virtual Conference
> >> Exclusive live event will cover all the ways today's security and
> >> threat landscape has changed and how IT managers can respond.
> >> Discussions will include endpoint security, mobile security and the
> >> latest in malware threats.
> >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ --
> >> https://lists.sourceforge.net/lists/listinfo/alleg-developers
> 
> ---------------------------------------------------------------------------
> --- Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/