This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
3.6-thread-cygwin64.patch
107 lines (98 loc) · 3.33 KB
/
3.6-thread-cygwin64.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--- origsrc/Python-3.6.1rc1/Include/pythread.h 2017-03-04 11:25:04.000000000 -0600
+++ src/Python-3.6.1rc1/Include/pythread.h 2017-03-12 14:26:43.582078500 -0500
@@ -74,11 +74,11 @@ PyAPI_FUNC(PyObject*) PyThread_GetInfo(v
#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);
--- origsrc/Python-3.6.1rc1/Python/pystate.c 2017-03-04 11:25:04.000000000 -0600
+++ src/Python-3.6.1rc1/Python/pystate.c 2017-03-12 14:26:43.582078500 -0500
@@ -47,7 +47,7 @@ static PyThread_type_lock head_mutex = N
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
--- origsrc/Python-3.6.1rc1/Python/thread_pthread.h 2017-03-04 11:25:04.000000000 -0600
+++ src/Python-3.6.1rc1/Python/thread_pthread.h 2017-03-12 14:26:43.597702400 -0500
@@ -603,36 +603,39 @@ _pythread_pthread_set_stacksize(size_t s
#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 +643,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);
}