Author: Armin Rigo <ar...@tunes.org> Branch: portable-threadlocal Changeset: r74641:d622788cadbe Date: 2014-11-22 21:54 +0100 http://bitbucket.org/pypy/pypy/changeset/d622788cadbe/
Log: Kill RPyThreadGetIdent(), and just copy the (easy) logic in module/_ssl. diff --git a/pypy/module/_ssl/thread_lock.py b/pypy/module/_ssl/thread_lock.py --- a/pypy/module/_ssl/thread_lock.py +++ b/pypy/module/_ssl/thread_lock.py @@ -24,12 +24,19 @@ separate_module_source = """ #include <openssl/crypto.h> +#ifndef _WIN32 +# include <pthread.h> +#endif static unsigned int _ssl_locks_count = 0; static struct RPyOpaque_ThreadLock *_ssl_locks; static unsigned long _ssl_thread_id_function(void) { - return RPyThreadGetIdent(); +#ifdef _WIN32 + return (unsigned long)GetCurrentThreadId(); +#else + return (unsigned long)pthread_self(); +#endif } static void _ssl_thread_locking_function(int mode, int n, const char *file, diff --git a/rpython/translator/c/src/threadlocal.c b/rpython/translator/c/src/threadlocal.c --- a/rpython/translator/c/src/threadlocal.c +++ b/rpython/translator/c/src/threadlocal.c @@ -4,20 +4,12 @@ #include <stdlib.h> #include <errno.h> #include <string.h> +#ifndef _WIN32 +# include <pthread.h> +#endif #include "src/threadlocal.h" -#ifdef _WIN32 -# define RPyThreadGetIdent() GetCurrentThreadId() -#else -# include <pthread.h> -# define RPyThreadGetIdent() ((long)pthread_self()) -/* xxx This abuses pthread_self() by assuming it just returns a long. - According to comments in CPython's source code, the platforms where - it is wrong are rather old nowadays. */ -#endif - - static void _RPy_ThreadLocals_Init(void *p) { memset(p, 0, sizeof(struct pypy_threadlocal_s)); @@ -25,7 +17,15 @@ ((struct pypy_threadlocal_s *)p)->p_errno = &errno; #endif #ifdef RPY_TLOFS_thread_ident - ((struct pypy_threadlocal_s *)p)->thread_ident = RPyThreadGetIdent(); + ((struct pypy_threadlocal_s *)p)->thread_ident = +# ifdef _WIN32 + GetCurrentThreadId(); +# else + (long)pthread_self(); /* xxx This abuses pthread_self() by + assuming it just returns a integer. According to + comments in CPython's source code, the platforms + where it is not the case are rather old nowadays. */ +# endif #endif ((struct pypy_threadlocal_s *)p)->ready = 1; } _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit