annotate Python/thread_foobar.h @ 61774:55e2368f72f2 2.6

Merged revisions 81380 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81380 | brett.cannon | 2010-05-20 11:37:55 -0700 (Thu, 20 May 2010) | 8 lines Turned out that if you used explicit relative import syntax (e.g. from .os import sep) and it failed, import would still try the implicit relative import semantics of an absolute import (from os import sep). That's not right, so when level is negative, only do explicit relative import semantics. Fixes issue #7902. Thanks to Meador Inge for the patch. ........
author Brett Cannon <bcannon@gmail.com>
date Thu, 20 May 2010 18:41:08 +0000
parents e38335d4df91
children b36cb4602e21
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /*
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 * Initialization.
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
5 static void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
6 PyThread__init_thread(void)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 {
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 /*
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 * Thread support.
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 */
20468
ebfd87e87884 Partial patch from SF #452266, by Jason Petrone.
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
13 long
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
14 PyThread_start_new_thread(void (*func)(void *), void *arg)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
16 int success = 0; /* init not needed when SOLARIS_THREADS and */
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
17 /* C_THREADS implemented properly */
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
19 dprintf(("PyThread_start_new_thread called\n"));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
20 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
21 PyThread_init_thread();
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
22 return success < 0 ? -1 : 0;
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
25 long
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
26 PyThread_get_thread_ident(void)
1651
7e5f97bab1e6 ceval.c: dict of local mapping is now a tuple
Guido van Rossum <guido@python.org>
parents: 1628
diff changeset
27 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
28 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
29 PyThread_init_thread();
1651
7e5f97bab1e6 ceval.c: dict of local mapping is now a tuple
Guido van Rossum <guido@python.org>
parents: 1628
diff changeset
30 }
7e5f97bab1e6 ceval.c: dict of local mapping is now a tuple
Guido van Rossum <guido@python.org>
parents: 1628
diff changeset
31
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
32 static
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
33 void do_PyThread_exit_thread(int no_cleanup)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
35 dprintf(("PyThread_exit_thread called\n"));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
36 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
37 if (no_cleanup)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
38 _exit(0);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
39 else
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
40 exit(0);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
43 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
44 PyThread_exit_thread(void)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
46 do_PyThread_exit_thread(0);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
49 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
50 PyThread__exit_thread(void)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
52 do_PyThread_exit_thread(1);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 #ifndef NO_EXIT_PROG
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
56 static
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
57 void do_PyThread_exit_prog(int status, int no_cleanup)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
59 dprintf(("PyThread_exit_prog(%d) called\n", status));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
60 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
61 if (no_cleanup)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
62 _exit(status);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
63 else
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
64 exit(status);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
67 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
68 PyThread_exit_prog(int status)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
70 do_PyThread_exit_prog(status, 0);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
73 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
74 PyThread__exit_prog(int status)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
76 do_PyThread_exit_prog(status, 1);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 #endif /* NO_EXIT_PROG */
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 /*
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 * Lock support.
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
83 PyThread_type_lock
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
84 PyThread_allocate_lock(void)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 {
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
86
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
87 dprintf(("PyThread_allocate_lock called\n"));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
88 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
89 PyThread_init_thread();
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
91 dprintf(("PyThread_allocate_lock() -> %p\n", lock));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
92 return (PyThread_type_lock) lock;
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
95 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
96 PyThread_free_lock(PyThread_type_lock lock)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
98 dprintf(("PyThread_free_lock(%p) called\n", lock));
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
101 int
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
102 PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
104 int success;
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
106 dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
107 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
108 return success;
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
110
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
111 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
112 PyThread_release_lock(PyThread_type_lock lock)
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
114 dprintf(("PyThread_release_lock(%p) called\n", lock));
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 }