blob: ea96f9c9d79fb5f60a17798b00bcab00b3621a7e [file] [log] [blame]
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +00001/*
2 * Initialization.
3 */
Thomas Woutersf70ef4f2000-07-22 18:47:25 +00004static void
5PyThread__init_thread(void)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +00006{
7}
8
9/*
10 * Thread support.
11 */
Guido van Rossum3c288632001-10-16 21:13:49 +000012long
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000013PyThread_start_new_thread(void (*func)(void *), void *arg)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000014{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000015 int success = 0; /* init not needed when SOLARIS_THREADS and */
16 /* C_THREADS implemented properly */
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000017
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000018 dprintf(("PyThread_start_new_thread called\n"));
19 if (!initialized)
20 PyThread_init_thread();
21 return success < 0 ? -1 : 0;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000022}
23
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000024long
25PyThread_get_thread_ident(void)
Guido van Rossume944da81994-05-23 12:43:41 +000026{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000027 if (!initialized)
28 PyThread_init_thread();
Guido van Rossume944da81994-05-23 12:43:41 +000029}
30
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000031void
32PyThread_exit_thread(void)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000033{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000034 dprintf(("PyThread_exit_thread called\n"));
35 if (!initialized)
36 exit(0);
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000037}
38
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000039/*
40 * Lock support.
41 */
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000042PyThread_type_lock
43PyThread_allocate_lock(void)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000044{
45
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000046 dprintf(("PyThread_allocate_lock called\n"));
47 if (!initialized)
48 PyThread_init_thread();
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000049
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000050 dprintf(("PyThread_allocate_lock() -> %p\n", lock));
51 return (PyThread_type_lock) lock;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000052}
53
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000054void
55PyThread_free_lock(PyThread_type_lock lock)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000056{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000057 dprintf(("PyThread_free_lock(%p) called\n", lock));
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000058}
59
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000060int
61PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000062{
Antoine Pitrou285a1632014-04-28 21:12:11 +020063 return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0, 0);
64}
65
66PyLockStatus
67PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
68 int intr_flag)
69{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000070 int success;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000071
Antoine Pitrou285a1632014-04-28 21:12:11 +020072 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));
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000075 return success;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000076}
77
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000078void
79PyThread_release_lock(PyThread_type_lock lock)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000080{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000081 dprintf(("PyThread_release_lock(%p) called\n", lock));
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000082}
Antoine Pitrou285a1632014-04-28 21:12:11 +020083
84/* The following are only needed if native TLS support exists */
85#define Py_HAVE_NATIVE_TLS
86
87#ifdef Py_HAVE_NATIVE_TLS
88int
89PyThread_create_key(void)
90{
91 int result;
92 return result;
93}
94
95void
96PyThread_delete_key(int key)
97{
98
99}
100
101int
102PyThread_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
112void *
113PyThread_get_key_value(int key)
114{
115 void *result;
116
117 return result;
118}
119
120void
121PyThread_delete_key_value(int key)
122{
123
124}
125
126void
127PyThread_ReInitTLS(void)
128{
129
130}
131
132#endif