annotate Python/thread_os2.h @ 49677:82ccc7e77ec5 2.6

Merged revisions 66801,66803-66804,66813,66854-66856,66866,66870-66872,66874,66887,66903,66905,66911,66913,66927,66932,66938,66942,66962,66964,66973-66974,66977,66992,66998-66999,67002,67005,67007,67028,67040-67041,67044,67070,67089,67091,67101,67117-67119,67123-67124 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ................ r66801 | andrew.kuchling | 2008-10-04 23:51:59 +0200 (Sat, 04 Oct 2008) | 1 line Punctuation fix; expand dict.update docstring to be clearer ................ r66803 | benjamin.peterson | 2008-10-05 00:15:31 +0200 (Sun, 05 Oct 2008) | 1 line fix typo ................ r66804 | andrew.kuchling | 2008-10-05 02:11:56 +0200 (Sun, 05 Oct 2008) | 1 line #1415508 from Rocky Bernstein: add docstrings for enable_interspersed_args(), disable_interspersed_args() ................ r66813 | andrew.kuchling | 2008-10-06 14:07:04 +0200 (Mon, 06 Oct 2008) | 3 lines Per Greg Ward, optparse is no longer being externally maintained. I'll look at the bugs in the Optik bug tracker and copy them to the Python bug tracker if they're still relevant. ................ r66854 | georg.brandl | 2008-10-08 19:20:20 +0200 (Wed, 08 Oct 2008) | 2 lines #4059: patch up some sqlite docs. ................ r66855 | georg.brandl | 2008-10-08 19:30:55 +0200 (Wed, 08 Oct 2008) | 2 lines #4058: fix some whatsnew markup. ................ r66856 | georg.brandl | 2008-10-08 20:47:17 +0200 (Wed, 08 Oct 2008) | 3 lines #3935: properly support list subclasses in the C impl. of bisect. Patch reviewed by Raymond. ................ r66866 | benjamin.peterson | 2008-10-09 22:54:43 +0200 (Thu, 09 Oct 2008) | 1 line update paragraph about __future__ for 2.6 ................ r66870 | armin.rigo | 2008-10-10 10:40:44 +0200 (Fri, 10 Oct 2008) | 2 lines Typo: "ThreadError" is the name in the C source. ................ r66871 | benjamin.peterson | 2008-10-10 22:38:49 +0200 (Fri, 10 Oct 2008) | 1 line fix a small typo ................ r66872 | benjamin.peterson | 2008-10-10 22:51:37 +0200 (Fri, 10 Oct 2008) | 1 line talk about how you can unzip with zip ................ r66874 | benjamin.peterson | 2008-10-11 00:23:41 +0200 (Sat, 11 Oct 2008) | 1 line PyGILState_Acquire -> PyGILState_Ensure ................ r66887 | benjamin.peterson | 2008-10-13 23:51:40 +0200 (Mon, 13 Oct 2008) | 1 line document how to disable fixers ................ r66903 | benjamin.peterson | 2008-10-15 22:34:09 +0200 (Wed, 15 Oct 2008) | 1 line don't recurse into directories that start with '.' ................ r66905 | benjamin.peterson | 2008-10-15 23:05:55 +0200 (Wed, 15 Oct 2008) | 1 line support the optional line argument for idle ................ r66911 | benjamin.peterson | 2008-10-16 01:10:28 +0200 (Thu, 16 Oct 2008) | 41 lines Merged revisions 66805,66841,66860,66884-66886,66893,66907,66910 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r66805 | benjamin.peterson | 2008-10-04 20:11:02 -0500 (Sat, 04 Oct 2008) | 1 line mention what the fixes directory is for ........ r66841 | benjamin.peterson | 2008-10-07 17:48:12 -0500 (Tue, 07 Oct 2008) | 1 line use assertFalse and assertTrue ........ r66860 | benjamin.peterson | 2008-10-08 16:05:07 -0500 (Wed, 08 Oct 2008) | 1 line instead of abusing the pattern matcher, use start_tree to find a next binding ........ r66884 | benjamin.peterson | 2008-10-13 15:50:30 -0500 (Mon, 13 Oct 2008) | 1 line don't print tokens to stdout when -v is given ........ r66885 | benjamin.peterson | 2008-10-13 16:28:57 -0500 (Mon, 13 Oct 2008) | 1 line add the -x option to disable fixers ........ r66886 | benjamin.peterson | 2008-10-13 16:33:53 -0500 (Mon, 13 Oct 2008) | 1 line cut down on some crud ........ r66893 | benjamin.peterson | 2008-10-14 17:16:54 -0500 (Tue, 14 Oct 2008) | 1 line add an optional set literal fixer ........ r66907 | benjamin.peterson | 2008-10-15 16:59:41 -0500 (Wed, 15 Oct 2008) | 1 line don't write backup files by default ........ r66910 | benjamin.peterson | 2008-10-15 17:43:10 -0500 (Wed, 15 Oct 2008) | 1 line add the -n option; it stops backupfiles from being written ........ ................ r66913 | benjamin.peterson | 2008-10-16 20:52:14 +0200 (Thu, 16 Oct 2008) | 1 line document that deque indexing is O(n) #4123 ................ r66927 | andrew.kuchling | 2008-10-16 22:15:47 +0200 (Thu, 16 Oct 2008) | 1 line Fix wording (2.6.1 backport candidate) ................ r66932 | benjamin.peterson | 2008-10-16 23:09:28 +0200 (Thu, 16 Oct 2008) | 1 line check for error conditions in _json #3623 ................ r66938 | benjamin.peterson | 2008-10-16 23:27:54 +0200 (Thu, 16 Oct 2008) | 1 line fix possible ref leak ................ r66942 | benjamin.peterson | 2008-10-16 23:48:06 +0200 (Thu, 16 Oct 2008) | 1 line fix more possible ref leaks in _json and use Py_CLEAR ................ r66962 | benjamin.peterson | 2008-10-17 22:01:01 +0200 (Fri, 17 Oct 2008) | 1 line clarify CALL_FUNCTION #4141 ................ r66964 | georg.brandl | 2008-10-17 23:41:49 +0200 (Fri, 17 Oct 2008) | 2 lines Fix duplicate word. ................ r66973 | armin.ronacher | 2008-10-19 10:27:43 +0200 (Sun, 19 Oct 2008) | 3 lines Fixed #4067 by implementing _attributes and _fields for the AST root node. ................ r66974 | benjamin.peterson | 2008-10-19 15:59:01 +0200 (Sun, 19 Oct 2008) | 1 line fix compiler warning ................ r66977 | benjamin.peterson | 2008-10-19 21:39:16 +0200 (Sun, 19 Oct 2008) | 1 line mention -n ................ r66992 | benjamin.peterson | 2008-10-21 22:51:13 +0200 (Tue, 21 Oct 2008) | 1 line make sure to call iteritems() ................ r66998 | benjamin.peterson | 2008-10-22 22:57:43 +0200 (Wed, 22 Oct 2008) | 1 line fix a few typos ................ r66999 | benjamin.peterson | 2008-10-22 23:05:30 +0200 (Wed, 22 Oct 2008) | 1 line and another typo... ................ r67002 | hirokazu.yamamoto | 2008-10-23 02:37:33 +0200 (Thu, 23 Oct 2008) | 1 line Issue #4183: Some tests didn't run with pickle.HIGHEST_PROTOCOL. ................ r67005 | walter.doerwald | 2008-10-23 15:11:39 +0200 (Thu, 23 Oct 2008) | 2 lines Use the correct names of the stateless codec functions (Fixes issue 4178). ................ r67007 | benjamin.peterson | 2008-10-23 23:43:48 +0200 (Thu, 23 Oct 2008) | 1 line only nonempty __slots__ don't work ................ r67028 | benjamin.peterson | 2008-10-26 01:27:07 +0200 (Sun, 26 Oct 2008) | 1 line don't use a catch-all ................ r67040 | armin.rigo | 2008-10-28 18:01:21 +0100 (Tue, 28 Oct 2008) | 5 lines Fix one of the tests: it relied on being present in an "output test" in order to actually test what it was supposed to test, i.e. that the code in the __del__ method did not crash. Use instead the new helper test_support.captured_output(). ................ r67041 | benjamin.peterson | 2008-10-29 21:33:00 +0100 (Wed, 29 Oct 2008) | 1 line mention the version gettempdir() was added ................ r67044 | amaury.forgeotdarc | 2008-10-30 00:15:57 +0100 (Thu, 30 Oct 2008) | 3 lines Correct error message in io.open(): closefd=True is the only accepted value with a file name. ................ r67070 | benjamin.peterson | 2008-10-31 21:41:44 +0100 (Fri, 31 Oct 2008) | 1 line rephrase has_key doc ................ r67089 | benjamin.peterson | 2008-11-03 21:43:20 +0100 (Mon, 03 Nov 2008) | 1 line clarify by splitting into multiple paragraphs ................ r67091 | benjamin.peterson | 2008-11-03 23:34:57 +0100 (Mon, 03 Nov 2008) | 1 line move a FileIO test to test_fileio ................ r67101 | georg.brandl | 2008-11-04 21:49:35 +0100 (Tue, 04 Nov 2008) | 2 lines #4167: fix markup glitches. ................ r67117 | georg.brandl | 2008-11-06 11:17:58 +0100 (Thu, 06 Nov 2008) | 2 lines #4268: Use correct module for two toplevel functions. ................ r67118 | georg.brandl | 2008-11-06 11:19:11 +0100 (Thu, 06 Nov 2008) | 2 lines #4267: small fixes in sqlite3 docs. ................ r67119 | georg.brandl | 2008-11-06 11:20:49 +0100 (Thu, 06 Nov 2008) | 2 lines #4245: move Thread section to the top. ................ r67123 | georg.brandl | 2008-11-06 19:49:15 +0100 (Thu, 06 Nov 2008) | 2 lines #4247: add "pass" examples to tutorial. ................ r67124 | andrew.kuchling | 2008-11-06 20:23:02 +0100 (Thu, 06 Nov 2008) | 1 line Fix grammar error; reword two paragraphs ................
author Georg Brandl <georg@python.org>
date Fri, 07 Nov 2008 08:56:27 +0000
parents 0a4ad83fd654
children e38335d4df91 df5719c298db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* This code implemented by cvale@netcom.com */
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 #define INCL_DOSPROCESS
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 #define INCL_DOSSEMAPHORES
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #include "os2.h"
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 #include "limits.h"
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 #include "process.h"
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
10 #if defined(PYCC_GCC)
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
11 #include <sys/builtin.h>
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
12 #include <sys/fmutex.h>
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
13 #else
9679
877d23bd5bdc Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
14 long PyThread_get_thread_ident(void);
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
15 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
38794
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
17 /* default thread stack size of 64kB */
34433
e1a7eb832cb5 backport: make thread stack size compile-time tunable on OS/2
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26531
diff changeset
18 #if !defined(THREAD_STACK_SIZE)
e1a7eb832cb5 backport: make thread stack size compile-time tunable on OS/2
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26531
diff changeset
19 #define THREAD_STACK_SIZE 0x10000
e1a7eb832cb5 backport: make thread stack size compile-time tunable on OS/2
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26531
diff changeset
20 #endif
e1a7eb832cb5 backport: make thread stack size compile-time tunable on OS/2
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26531
diff changeset
21
38794
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
22 #define OS2_STACKSIZE(x) (x ? x : THREAD_STACK_SIZE)
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
23
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 * Initialization of the C package, should not be needed.
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
27 static void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
28 PyThread__init_thread(void)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 * Thread support.
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 */
20468
ebfd87e87884 Partial patch from SF #452266, by Jason Petrone.
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
35 long
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
36 PyThread_start_new_thread(void (*func)(void *), void *arg)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 {
39149
0a4ad83fd654 bugfix: PyThread_start_new_thread() returns the thread ID, not a flag;
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38794
diff changeset
38 int thread_id;
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
39
39149
0a4ad83fd654 bugfix: PyThread_start_new_thread() returns the thread ID, not a flag;
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38794
diff changeset
40 thread_id = _beginthread(func,
38794
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
41 NULL,
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
42 OS2_STACKSIZE(_pythread_stacksize),
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
43 arg);
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
39149
0a4ad83fd654 bugfix: PyThread_start_new_thread() returns the thread ID, not a flag;
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38794
diff changeset
45 if (thread_id == -1) {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
46 dprintf(("_beginthread failed. return %ld\n", errno));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
47 }
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
39149
0a4ad83fd654 bugfix: PyThread_start_new_thread() returns the thread ID, not a flag;
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38794
diff changeset
49 return thread_id;
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
52 long
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
53 PyThread_get_thread_ident(void)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 {
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
55 #if !defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
56 PPIB pib;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
57 PTIB tib;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
58 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
59
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
60 if (!initialized)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
61 PyThread_init_thread();
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
62
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
63 #if defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
64 return _gettid();
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
65 #else
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
66 DosGetInfoBlocks(&tib, &pib);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
67 return tib->tib_ptib2->tib2_ultid;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
68 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 }
063a96b49b3e OS/2 thread support
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: 13620
diff changeset
71 static void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
72 do_PyThread_exit_thread(int no_cleanup)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
74 dprintf(("%ld: PyThread_exit_thread called\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
75 PyThread_get_thread_ident()));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
76 if (!initialized)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
77 if (no_cleanup)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
78 _exit(0);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
79 else
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
80 exit(0);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
81 _endthread();
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
83
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
84 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
85 PyThread_exit_thread(void)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
87 do_PyThread_exit_thread(0);
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
89
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
90 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
91 PyThread__exit_thread(void)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
93 do_PyThread_exit_thread(1);
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
95
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 #ifndef NO_EXIT_PROG
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
97 static void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
98 do_PyThread_exit_prog(int status, int no_cleanup)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
100 dprintf(("PyThread_exit_prog(%d) called\n", status));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
101 if (!initialized)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
102 if (no_cleanup)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
103 _exit(status);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
104 else
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
105 exit(status);
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
107
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
108 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
109 PyThread_exit_prog(int status)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
111 do_PyThread_exit_prog(status, 0);
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
113
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
114 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
115 PyThread__exit_prog(int status)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
117 do_PyThread_exit_prog(status, 1);
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 #endif /* NO_EXIT_PROG */
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
120
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
121 /*
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
122 * Lock support. This is implemented with an event semaphore and critical
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
123 * sections to make it behave more like a posix mutex than its OS/2
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
124 * counterparts.
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 */
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
126
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
127 typedef struct os2_lock_t {
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
128 int is_set;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
129 HEV changed;
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
130 } *type_os2_lock;
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
131
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
132 PyThread_type_lock
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
133 PyThread_allocate_lock(void)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 {
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
135 #if defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
136 _fmutex *sem = malloc(sizeof(_fmutex));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
137 if (!initialized)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
138 PyThread_init_thread();
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
139 dprintf(("%ld: PyThread_allocate_lock() -> %lx\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
140 PyThread_get_thread_ident(),
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
141 (long)sem));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
142 if (_fmutex_create(sem, 0)) {
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
143 free(sem);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
144 sem = NULL;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
145 }
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
146 return (PyThread_type_lock)sem;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
147 #else
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
148 APIRET rc;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
149 type_os2_lock lock = (type_os2_lock)malloc(sizeof(struct os2_lock_t));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
150
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
151 dprintf(("PyThread_allocate_lock called\n"));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
152 if (!initialized)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
153 PyThread_init_thread();
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
154
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
155 lock->is_set = 0;
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
156
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
157 DosCreateEventSem(NULL, &lock->changed, 0, 0);
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
158
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
159 dprintf(("%ld: PyThread_allocate_lock() -> %p\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
160 PyThread_get_thread_ident(),
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
161 lock->changed));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
162
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
163 return (PyThread_type_lock)lock;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
164 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
166
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
167 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
168 PyThread_free_lock(PyThread_type_lock aLock)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
169 {
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
170 #if !defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
171 type_os2_lock lock = (type_os2_lock)aLock;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
172 #endif
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
173
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
174 dprintf(("%ld: PyThread_free_lock(%p) called\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
175 PyThread_get_thread_ident(),aLock));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
176
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
177 #if defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
178 if (aLock) {
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
179 _fmutex_close((_fmutex *)aLock);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
180 free((_fmutex *)aLock);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
181 }
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
182 #else
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
183 DosCloseEventSem(lock->changed);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
184 free(aLock);
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
185 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
186 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
187
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
188 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
189 * Return 1 on success if the lock was acquired
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
190 *
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
191 * and 0 if the lock was not acquired.
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
192 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
193 int
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
194 PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
195 {
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
196 #if !defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
197 int done = 0;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
198 ULONG count;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
199 PID pid = 0;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
200 TID tid = 0;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
201 type_os2_lock lock = (type_os2_lock)aLock;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
202 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
203
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
204 dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
205 PyThread_get_thread_ident(),
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
206 aLock,
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
207 waitflag));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
208
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
209 #if defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
210 /* always successful if the lock doesn't exist */
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
211 if (aLock &&
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
212 _fmutex_request((_fmutex *)aLock, waitflag ? 0 : _FMR_NOWAIT))
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
213 return 0;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
214 #else
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
215 while (!done) {
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
216 /* if the lock is currently set, we have to wait for
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
217 * the state to change
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
218 */
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
219 if (lock->is_set) {
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
220 if (!waitflag)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
221 return 0;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
222 DosWaitEventSem(lock->changed, SEM_INDEFINITE_WAIT);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
223 }
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
224
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
225 /* enter a critical section and try to get the semaphore. If
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
226 * it is still locked, we will try again.
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
227 */
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
228 if (DosEnterCritSec())
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
229 return 0;
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
230
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
231 if (!lock->is_set) {
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
232 lock->is_set = 1;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
233 DosResetEventSem(lock->changed, &count);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
234 done = 1;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
235 }
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
236
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
237 DosExitCritSec();
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
238 }
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
239 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
240
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
241 return 1;
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
242 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
243
38579
19430cdff2bd clean up function declarations to conform to PEP-7 style.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38578
diff changeset
244 void
19430cdff2bd clean up function declarations to conform to PEP-7 style.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38578
diff changeset
245 PyThread_release_lock(PyThread_type_lock aLock)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
246 {
26530
b5837b8f3b2c typo fix: declaration required for VACPP not EMX+gcc
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 22054
diff changeset
247 #if !defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
248 type_os2_lock lock = (type_os2_lock)aLock;
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
249 #endif
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
250
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
251 dprintf(("%ld: PyThread_release_lock(%p) called\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
252 PyThread_get_thread_ident(),
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
253 aLock));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
254
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
255 #if defined(PYCC_GCC)
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
256 if (aLock)
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
257 _fmutex_release((_fmutex *)aLock);
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
258 #else
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
259 if (!lock->is_set) {
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
260 dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
261 PyThread_get_thread_ident(),
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
262 aLock,
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
263 GetLastError()));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
264 return;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
265 }
20782
b1d9029e09d1 SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents: 20468
diff changeset
266
26531
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
267 if (DosEnterCritSec()) {
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
268 dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n",
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
269 PyThread_get_thread_ident(),
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
270 aLock,
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
271 GetLastError()));
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
272 return;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
273 }
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
274
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
275 lock->is_set = 0;
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
276 DosPostEventSem(lock->changed);
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
277
8e1567dbcba8 reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 26530
diff changeset
278 DosExitCritSec();
22054
5cbcfde3ad55 OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21766
diff changeset
279 #endif
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
280 }
38794
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
281
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
282 /* minimum/maximum thread stack sizes supported */
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
283 #define THREAD_MIN_STACKSIZE 0x8000 /* 32kB */
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
284 #define THREAD_MAX_STACKSIZE 0x2000000 /* 32MB */
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
285
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
286 /* set the thread stack size.
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
287 * Return 0 if size is valid, -1 otherwise.
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
288 */
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
289 static int
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
290 _pythread_os2_set_stacksize(size_t size)
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
291 {
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
292 /* set to default */
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
293 if (size == 0) {
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
294 _pythread_stacksize = 0;
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
295 return 0;
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
296 }
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
297
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
298 /* valid range? */
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
299 if (size >= THREAD_MIN_STACKSIZE && size < THREAD_MAX_STACKSIZE) {
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
300 _pythread_stacksize = size;
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
301 return 0;
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
302 }
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
303
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
304 return -1;
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
305 }
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
306
f7d23bca599f Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 38592
diff changeset
307 #define THREAD_SET_STACKSIZE(x) _pythread_os2_set_stacksize(x)