[Python-Dev] pthreads question: typedef ??? pthread_t and hacky return statements (original) (raw)

Fredrik Lundh fredrik@pythonware.com
Fri, 18 Aug 2000 12:42:54 +0200


trent mick wrote:

return (long) *(long *) &threadid;

from what I can tell, pthread_t is a pointer under OSF/1.

I've been using OSF/1 since the early days, and as far as I can remember, you've never needed to use stupid hacks like that to convert a pointer to a long integer. an ordinary (long) cast should be sufficient.

Could this be changed to return threadid; safely?

safely, yes. but since it isn't a long on all platforms, you might get warnings from the compiler (see Mark's mail).

::: from what I can tell, it's compatible with a long on all sane plat- forms (Win64 doesn't support pthreads anyway ;-), so I guess the right thing here is to remove volatile and simply use:

return (long) threadid;

(Mark: can you try this out on your box? setting up a Python 2.0 environment on our alphas would take more time than I can spare right now...)