Files
MSYS2-packages/python3/011-3.6-thread-cygwin64.patch
2017-07-14 10:38:34 +03:00

108 lines
3.2 KiB
Diff

--- Python-3.4.3/Include/pythread.h.orig 2015-02-25 05:27:44.000000000 -0600
+++ Python-3.4.3/Include/pythread.h 2015-05-05 11:27:20.117994100 -0500
@@ -74,11 +74,11 @@ PyAPI_FUNC(int) PyThread_set_stacksize(s
#endif
/* Thread Local Storage (TLS) API */
-PyAPI_FUNC(int) PyThread_create_key(void);
-PyAPI_FUNC(void) PyThread_delete_key(int);
-PyAPI_FUNC(int) PyThread_set_key_value(int, void *);
-PyAPI_FUNC(void *) PyThread_get_key_value(int);
-PyAPI_FUNC(void) PyThread_delete_key_value(int key);
+PyAPI_FUNC(long) PyThread_create_key(void);
+PyAPI_FUNC(void) PyThread_delete_key(long);
+PyAPI_FUNC(int) PyThread_set_key_value(long, void *);
+PyAPI_FUNC(void *) PyThread_get_key_value(long);
+PyAPI_FUNC(void) PyThread_delete_key_value(long key);
/* Cleanup after a fork */
PyAPI_FUNC(void) PyThread_ReInitTLS(void);
--- Python-3.6.0/Python/pystate.c.orig 2017-02-08 04:54:10.265051500 -0500
+++ Python-3.6.0/Python/pystate.c 2017-02-08 05:00:43.539089400 -0500
@@ -47,7 +47,7 @@
GILState implementation
*/
static PyInterpreterState *autoInterpreterState = NULL;
-static int autoTLSkey = -1;
+static long autoTLSkey = -1L;
#else
#define HEAD_INIT() /* Nothing */
#define HEAD_LOCK() /* Nothing */
@@ -713,7 +713,7 @@ _PyGILState_Init(PyInterpreterState *i,
{
assert(i && t); /* must init with valid states */
autoTLSkey = PyThread_create_key();
- if (autoTLSkey == -1)
+ if (autoTLSkey == -1L)
Py_FatalError("Could not allocate TLS entry");
autoInterpreterState = i;
assert(PyThread_get_key_value(autoTLSkey) == NULL);
@@ -745,7 +745,7 @@ _PyGILState_Reinit(void)
{
PyThreadState *tstate = PyGILState_GetThisThreadState();
PyThread_delete_key(autoTLSkey);
- if ((autoTLSkey = PyThread_create_key()) == -1)
+ if ((autoTLSkey = PyThread_create_key()) == -1L)
Py_FatalError("Could not allocate TLS entry");
/* If the thread had an associated auto thread state, reassociate it with
--- Python-3.6.0/Python/thread_pthread.h.orig 2016-12-22 21:21:22.000000000 -0500
+++ Python-3.6.0/Python/thread_pthread.h 2017-02-08 05:18:45.791168100 -0500
@@ -603,36 +603,39 @@
#define Py_HAVE_NATIVE_TLS
-int
+long
PyThread_create_key(void)
{
pthread_key_t key;
int fail = pthread_key_create(&key, NULL);
if (fail)
- return -1;
- if (key > INT_MAX) {
+ return -1L;
+#ifndef __CYGWIN__
+ /* Cygwin pthread types are pointers, which may "overflow" signed long */
+ if (key > LONG_MAX) {
/* Issue #22206: handle integer overflow */
pthread_key_delete(key);
errno = ENOMEM;
- return -1;
+ return -1L;
}
- return (int)key;
+#endif
+ return (long)key;
}
void
-PyThread_delete_key(int key)
+PyThread_delete_key(long key)
{
pthread_key_delete(key);
}
void
-PyThread_delete_key_value(int key)
+PyThread_delete_key_value(long key)
{
pthread_setspecific(key, NULL);
}
int
-PyThread_set_key_value(int key, void *value)
+PyThread_set_key_value(long key, void *value)
{
int fail;
fail = pthread_setspecific(key, value);
@@ -640,7 +640,7 @@ PyThread_set_key_value(int key, void *va
}
void *
-PyThread_get_key_value(int key)
+PyThread_get_key_value(long key)
{
return pthread_getspecific(key);
}