Skip to content

Commit 285a163

Browse files
committed
Issue python#21312: Update the thread_foobar.h template file to include newer threading APIs. Patch by Jack McCracken.
1 parent c695c95 commit 285a163

3 files changed

Lines changed: 64 additions & 3 deletions

File tree

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ Madison May
847847
Lucas Maystre
848848
Arnaud Mazin
849849
Matt McClure
850+
Jack McCracken
850851
Rebecca McCreary
851852
Kirk McDonald
852853
Chris McDonough

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ C API
320320
Documentation
321321
-------------
322322

323+
- Issue #21312: Update the thread_foobar.h template file to include newer
324+
threading APIs. Patch by Jack McCracken.
325+
323326
- Issue #21043: Remove the recommendation for specific CA organizations and to
324327
mention the ability to load the OS certificates.
325328

Python/thread_foobar.h

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Initialization.
43
*/
@@ -60,11 +59,19 @@ PyThread_free_lock(PyThread_type_lock lock)
6059

6160
int
6261
PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
62+
{
63+
return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0, 0);
64+
}
65+
66+
PyLockStatus
67+
PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
68+
int intr_flag)
6369
{
6470
int success;
6571

66-
dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
67-
dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
72+
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n", lock, microseconds, intr_flag));
73+
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
74+
lock, microseconds, intr_flag, success));
6875
return success;
6976
}
7077

@@ -73,3 +80,53 @@ PyThread_release_lock(PyThread_type_lock lock)
7380
{
7481
dprintf(("PyThread_release_lock(%p) called\n", lock));
7582
}
83+
84+
/* The following are only needed if native TLS support exists */
85+
#define Py_HAVE_NATIVE_TLS
86+
87+
#ifdef Py_HAVE_NATIVE_TLS
88+
int
89+
PyThread_create_key(void)
90+
{
91+
int result;
92+
return result;
93+
}
94+
95+
void
96+
PyThread_delete_key(int key)
97+
{
98+
99+
}
100+
101+
int
102+
PyThread_set_key_value(int key, void *value)
103+
{
104+
int ok;
105+
106+
/* A failure in this case returns -1 */
107+
if (!ok)
108+
return -1;
109+
return 0;
110+
}
111+
112+
void *
113+
PyThread_get_key_value(int key)
114+
{
115+
void *result;
116+
117+
return result;
118+
}
119+
120+
void
121+
PyThread_delete_key_value(int key)
122+
{
123+
124+
}
125+
126+
void
127+
PyThread_ReInitTLS(void)
128+
{
129+
130+
}
131+
132+
#endif

0 commit comments

Comments
 (0)