Add missing tests for PyArg_Parse* with format 'h'
[python.git] / Python / thread_foobar.h
blob67491a167d61a84263fe97cf1240a93d5f841868
2 /*
3 * Initialization.
4 */
5 static void
6 PyThread__init_thread(void)
11 * Thread support.
13 long
14 PyThread_start_new_thread(void (*func)(void *), void *arg)
16 int success = 0; /* init not needed when SOLARIS_THREADS and */
17 /* C_THREADS implemented properly */
19 dprintf(("PyThread_start_new_thread called\n"));
20 if (!initialized)
21 PyThread_init_thread();
22 return success < 0 ? -1 : 0;
25 long
26 PyThread_get_thread_ident(void)
28 if (!initialized)
29 PyThread_init_thread();
32 static
33 void do_PyThread_exit_thread(int no_cleanup)
35 dprintf(("PyThread_exit_thread called\n"));
36 if (!initialized)
37 if (no_cleanup)
38 _exit(0);
39 else
40 exit(0);
43 void
44 PyThread_exit_thread(void)
46 do_PyThread_exit_thread(0);
49 void
50 PyThread__exit_thread(void)
52 do_PyThread_exit_thread(1);
55 #ifndef NO_EXIT_PROG
56 static
57 void do_PyThread_exit_prog(int status, int no_cleanup)
59 dprintf(("PyThread_exit_prog(%d) called\n", status));
60 if (!initialized)
61 if (no_cleanup)
62 _exit(status);
63 else
64 exit(status);
67 void
68 PyThread_exit_prog(int status)
70 do_PyThread_exit_prog(status, 0);
73 void
74 PyThread__exit_prog(int status)
76 do_PyThread_exit_prog(status, 1);
78 #endif /* NO_EXIT_PROG */
81 * Lock support.
83 PyThread_type_lock
84 PyThread_allocate_lock(void)
87 dprintf(("PyThread_allocate_lock called\n"));
88 if (!initialized)
89 PyThread_init_thread();
91 dprintf(("PyThread_allocate_lock() -> %p\n", lock));
92 return (PyThread_type_lock) lock;
95 void
96 PyThread_free_lock(PyThread_type_lock lock)
98 dprintf(("PyThread_free_lock(%p) called\n", lock));
102 PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
104 int success;
106 dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
107 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
108 return success;
111 void
112 PyThread_release_lock(PyThread_type_lock lock)
114 dprintf(("PyThread_release_lock(%p) called\n", lock));