thread_foobar.h 1.88 KB
Newer Older
1 2 3 4

/*
 * Initialization.
 */
5 6
static void
PyThread__init_thread(void)
7 8 9 10 11 12
{
}

/*
 * Thread support.
 */
13
long
14
PyThread_start_new_thread(void (*func)(void *), void *arg)
15 16 17 18
{
	int success = 0;	/* init not needed when SOLARIS_THREADS and */
				/* 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;
23 24
}

25 26
long
PyThread_get_thread_ident(void)
27 28
{
	if (!initialized)
29
		PyThread_init_thread();
30 31
}

32 33
static
void do_PyThread_exit_thread(int no_cleanup)
34
{
35
	dprintf(("PyThread_exit_thread called\n"));
36 37 38 39 40 41 42
	if (!initialized)
		if (no_cleanup)
			_exit(0);
		else
			exit(0);
}

43 44
void
PyThread_exit_thread(void)
45
{
46
	do_PyThread_exit_thread(0);
47 48
}

49 50
void
PyThread__exit_thread(void)
51
{
52
	do_PyThread_exit_thread(1);
53 54 55
}

#ifndef NO_EXIT_PROG
56 57
static
void do_PyThread_exit_prog(int status, int no_cleanup)
58
{
59
	dprintf(("PyThread_exit_prog(%d) called\n", status));
60 61 62 63 64 65 66
	if (!initialized)
		if (no_cleanup)
			_exit(status);
		else
			exit(status);
}

67 68
void
PyThread_exit_prog(int status)
69
{
70
	do_PyThread_exit_prog(status, 0);
71 72
}

73 74
void
PyThread__exit_prog(int status)
75
{
76
	do_PyThread_exit_prog(status, 1);
77 78 79 80 81 82
}
#endif /* NO_EXIT_PROG */

/*
 * Lock support.
 */
83 84
PyThread_type_lock
PyThread_allocate_lock(void)
85 86
{

87
	dprintf(("PyThread_allocate_lock called\n"));
88
	if (!initialized)
89
		PyThread_init_thread();
90

91
	dprintf(("PyThread_allocate_lock() -> %p\n", lock));
92
	return (PyThread_type_lock) lock;
93 94
}

95 96
void
PyThread_free_lock(PyThread_type_lock lock)
97
{
98
	dprintf(("PyThread_free_lock(%p) called\n", lock));
99 100
}

101 102
int
PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
103 104 105
{
	int success;

106 107
	dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
	dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
108 109 110
	return success;
}

111 112
void
PyThread_release_lock(PyThread_type_lock lock)
113
{
114
	dprintf(("PyThread_release_lock(%p) called\n", lock));
115
}