diff options
| author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2010-09-20 02:11:49 +0000 |
|---|---|---|
| committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2010-09-20 02:11:49 +0000 |
| commit | 4a6fcda50b929b61836ed82e57937dec5d47961a (patch) | |
| tree | 6b7363d25b407aeb638b91055592894d84122ed2 /Python/thread_pthread.h | |
| parent | 3a6e237d50e392fe1d864c8140442e75c3aeaa64 (diff) | |
| download | cpython-4a6fcda50b929b61836ed82e57937dec5d47961a.tar.gz | |
issue 9786 Native TLS support for pthreads
PyThread_create_key now has a failure mode that the applicatino can detect.
Diffstat (limited to 'Python/thread_pthread.h')
| -rw-r--r-- | Python/thread_pthread.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 5e52b3977e..a529b7a7eb 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -558,3 +558,46 @@ _pythread_pthread_set_stacksize(size_t size) } #define THREAD_SET_STACKSIZE(x) _pythread_pthread_set_stacksize(x) + +#define Py_HAVE_NATIVE_TLS + +int +PyThread_create_key(void) +{ + pthread_key_t key; + int fail = pthread_key_create(&key, NULL); + return fail ? -1 : key; +} + +void +PyThread_delete_key(int key) +{ + pthread_key_delete(key); +} + +void +PyThread_delete_key_value(int key) +{ + pthread_setspecific(key, NULL); +} + +int +PyThread_set_key_value(int key, void *value) +{ + int fail; + void *oldValue = pthread_getspecific(key); + if (oldValue != NULL) + return 0; + fail = pthread_setspecific(key, value); + return fail ? -1 : 0; +} + +void * +PyThread_get_key_value(int key) +{ + return pthread_getspecific(key); +} + +void +PyThread_ReInitTLS(void) +{} |
