annotate Python/thread_cthread.h @ 63509:5fd09e410d36 2.6

Merged revisions 83429,83436 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/release27-maint ................ r83429 | georg.brandl | 2010-08-01 21:14:56 +0200 (So, 01 Aug 2010) | 37 lines Merged revisions 83352,83356-83358,83362,83366,83368-83369 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83352 | georg.brandl | 2010-07-31 20:11:07 +0200 (Sa, 31 Jul 2010) | 1 line #9440: Remove borderline test case that fails based on unpredictable conditions such as compiler flags. ........ r83356 | georg.brandl | 2010-07-31 21:29:15 +0200 (Sa, 31 Jul 2010) | 1 line Remove trailing whitespace. ........ r83357 | georg.brandl | 2010-07-31 21:59:55 +0200 (Sa, 31 Jul 2010) | 1 line #5778: document that sys.version can contain a newline. ........ r83358 | georg.brandl | 2010-07-31 22:05:31 +0200 (Sa, 31 Jul 2010) | 1 line #9442: do not document a specific format for sys.version; rather refer to version_info and the platform module. ........ r83362 | georg.brandl | 2010-07-31 23:12:15 +0200 (Sa, 31 Jul 2010) | 1 line #8910: add a file explaining why Lib/test/data is there. ........ r83366 | georg.brandl | 2010-07-31 23:26:40 +0200 (Sa, 31 Jul 2010) | 1 line There always is a False and True now. ........ r83368 | georg.brandl | 2010-07-31 23:40:15 +0200 (Sa, 31 Jul 2010) | 1 line #7909: the prefixes \\.\ and \\?\ indicate special Windows paths, do not try to manipulate them. See http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx for details. ........ r83369 | georg.brandl | 2010-07-31 23:41:42 +0200 (Sa, 31 Jul 2010) | 1 line Fix "Berkeley" name. ........ ................ r83436 | georg.brandl | 2010-08-01 21:33:15 +0200 (So, 01 Aug 2010) | 42 lines Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83259 | georg.brandl | 2010-07-30 09:03:39 +0200 (Fr, 30 Jul 2010) | 1 line Clarification. ........ r83261 | georg.brandl | 2010-07-30 09:21:26 +0200 (Fr, 30 Jul 2010) | 1 line #9230: allow Pdb.checkline() to be called without a current frame, for setting breakpoints before starting debugging. ........ r83264 | georg.brandl | 2010-07-30 10:45:26 +0200 (Fr, 30 Jul 2010) | 1 line Document the "jump" command in pdb.__doc__, and add a version tag for "until X". ........ r83265 | georg.brandl | 2010-07-30 10:54:49 +0200 (Fr, 30 Jul 2010) | 1 line #8015: fix crash when entering an empty line for breakpoint commands. Also restore environment properly when an exception occurs during the definition of commands. ........ r83268 | georg.brandl | 2010-07-30 11:23:23 +0200 (Fr, 30 Jul 2010) | 2 lines Issue #8048: Prevent doctests from failing when sys.displayhook has been reassigned. ........ r83269 | georg.brandl | 2010-07-30 11:43:00 +0200 (Fr, 30 Jul 2010) | 1 line #6719: In pdb, do not stop somewhere in the encodings machinery if the source file to be debugged is in a non-builtin encoding. ........ r83271 | georg.brandl | 2010-07-30 11:59:28 +0200 (Fr, 30 Jul 2010) | 1 line #5727: Restore the ability to use readline when calling into pdb in doctests. ........ r83272 | georg.brandl | 2010-07-30 12:29:19 +0200 (Fr, 30 Jul 2010) | 1 line #5294: Fix the behavior of pdb "continue" command when called in the top-level debugged frame. ........ r83281 | georg.brandl | 2010-07-30 15:36:43 +0200 (Fr, 30 Jul 2010) | 1 line Add myself for pdb. ........ ................
author Georg Brandl <georg@python.org>
date Sun, 01 Aug 2010 22:10:15 +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
21606
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
2 #ifdef MACH_C_THREADS
3838
5aab3f668e84 Changes needed by NeXT (the only platform that seems to use this).
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
3 #include <mach/cthreads.h>
21606
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
4 #endif
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
21606
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
6 #ifdef HURD_C_THREADS
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
7 #include <cthreads.h>
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
8 #endif
1628
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 * Initialization.
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
13 static void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
14 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
15 {
21606
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
16 #ifndef HURD_C_THREADS
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
17 /* Roland McGrath said this should not be used since this is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
18 done while linking to threads */
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
19 cthread_init();
21606
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
20 #else
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
21 /* do nothing */
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
22 ;
21606
67da11293406 Patch #497098: build support for GNU/Hurd.
Martin v. Löwis <martin@v.loewis.de>
parents: 20468
diff changeset
23 #endif
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 /*
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 * Thread support.
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 */
20468
ebfd87e87884 Partial patch from SF #452266, by Jason Petrone.
Guido van Rossum <guido@python.org>
parents: 15403
diff changeset
29 long
15403
5b4abceff53d Fix syntax error. Submitted by Bill Bumgarner. Apparently this is
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
30 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
31 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
32 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
33 /* 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
34
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
35 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
36 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
37 PyThread_init_thread();
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
38 /* looks like solaris detaches the thread to never rejoin
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
39 * so well do it here
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
40 */
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
41 cthread_detach(cthread_fork((cthread_fn_t) func, arg));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
42 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
43 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
45 long
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
46 PyThread_get_thread_ident(void)
1651
7e5f97bab1e6 ceval.c: dict of local mapping is now a tuple
Guido van Rossum <guido@python.org>
parents: 1629
diff changeset
47 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
48 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
49 PyThread_init_thread();
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
50 return (long) cthread_self();
1651
7e5f97bab1e6 ceval.c: dict of local mapping is now a tuple
Guido van Rossum <guido@python.org>
parents: 1629
diff changeset
51 }
7e5f97bab1e6 ceval.c: dict of local mapping is now a tuple
Guido van Rossum <guido@python.org>
parents: 1629
diff changeset
52
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
53 static void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
54 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
55 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
56 dprintf(("PyThread_exit_thread called\n"));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
57 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
58 if (no_cleanup)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
59 _exit(0);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
60 else
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
61 exit(0);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
62 cthread_exit(0);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
65 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
66 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
67 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
68 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
69 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
71 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
72 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
73 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
74 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
75 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
76
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 #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
78 static
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
79 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
80 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
81 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
82 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
83 if (no_cleanup)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
84 _exit(status);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
85 else
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
86 exit(status);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
87 if (no_cleanup)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
88 _exit(status);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
89 else
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
90 exit(status);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
93 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
94 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
95 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
96 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
97 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
98
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
99 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
100 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
101 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
102 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
103 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 #endif /* NO_EXIT_PROG */
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 /*
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 * Lock support.
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
109 PyThread_type_lock
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
110 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
111 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
112 mutex_t 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_allocate_lock called\n"));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
115 if (!initialized)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
116 PyThread_init_thread();
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
118 lock = mutex_alloc();
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
119 if (mutex_init(lock)) {
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
120 perror("mutex_init");
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
121 free((void *) lock);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
122 lock = 0;
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
123 }
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
124 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
125 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
126 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
127
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
128 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
129 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
130 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
131 dprintf(("PyThread_free_lock(%p) called\n", lock));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
132 mutex_free(lock);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
134
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
135 int
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
136 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
137 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
138 int success = FALSE;
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
139
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
140 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
141 if (waitflag) { /* blocking */
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
142 mutex_lock((mutex_t)lock);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
143 success = TRUE;
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
144 } else { /* non blocking */
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
145 success = mutex_try_lock((mutex_t)lock);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
146 }
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
147 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
148 return success;
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
149 }
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
150
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
151 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13256
diff changeset
152 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
153 {
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
154 dprintf(("PyThread_release_lock(%p) called\n", lock));
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 21766
diff changeset
155 mutex_unlock((mutex_t )lock);
1628
a9dd2e1ea5c9 Split thread.c into a number of system-specific files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 }