blob: d2b78c5caed05a2a0a335540fcf13dfeaa17c8f8 [file] [log] [blame]
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +00001
2/*
3 * Initialization.
4 */
Thomas Woutersf70ef4f2000-07-22 18:47:25 +00005static void
6PyThread__init_thread(void)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +00007{
8}
9
10/*
11 * Thread support.
12 */
Guido van Rossum3c288632001-10-16 21:13:49 +000013long
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000014PyThread_start_new_thread(void (*func)(void *), void *arg)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000015{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000016 int success = 0; /* init not needed when SOLARIS_THREADS and */
17 /* C_THREADS implemented properly */
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000018
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000019 dprintf(("PyThread_start_new_thread called\n"));
20 if (!initialized)
21 PyThread_init_thread();
22 return success < 0 ? -1 : 0;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000023}
24
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000025long
26PyThread_get_thread_ident(void)
Guido van Rossume944da81994-05-23 12:43:41 +000027{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000028 if (!initialized)
29 PyThread_init_thread();
Guido van Rossume944da81994-05-23 12:43:41 +000030}
31
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000032void
33PyThread_exit_thread(void)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000034{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000035 dprintf(("PyThread_exit_thread called\n"));
36 if (!initialized)
37 exit(0);
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000038}
39
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000040/*
41 * Lock support.
42 */
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000043PyThread_type_lock
44PyThread_allocate_lock(void)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000045{
46
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000047 dprintf(("PyThread_allocate_lock called\n"));
48 if (!initialized)
49 PyThread_init_thread();
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000050
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000051 dprintf(("PyThread_allocate_lock() -> %p\n", lock));
52 return (PyThread_type_lock) lock;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000053}
54
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000055void
56PyThread_free_lock(PyThread_type_lock lock)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000057{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000058 dprintf(("PyThread_free_lock(%p) called\n", lock));
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000059}
60
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000061int
62PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000063{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000064 int success;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000065
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000066 dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
67 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
68 return success;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000069}
70
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000071void
72PyThread_release_lock(PyThread_type_lock lock)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000073{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000074 dprintf(("PyThread_release_lock(%p) called\n", lock));
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000075}