Mercurial > cpython-lru_cache-weakref
annotate Python/thread_os2.h @ 45852:30c4e1ca8421
Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61431 | vinay.sajip | 2008-03-16 22:35:58 +0100 (So, 16 Mär 2008) | 1 line
Clarified documentation on use of shutdown().
........
r61433 | mark.summerfield | 2008-03-17 09:28:15 +0100 (Mo, 17 Mär 2008) | 5 lines
Added a footnote to each pointing out that for XML output if an encoding
string is given it should conform to the appropriate XML standards---for
example, "UTF-8" is okay, but "UTF8" is not.
........
r61434 | eric.smith | 2008-03-17 12:01:01 +0100 (Mo, 17 Mär 2008) | 7 lines
Issue 2264: empty float presentation type needs to have at least one digit past the decimal point.
Added "Z" format_char to PyOS_ascii_formatd to support empty float presentation type.
Renamed buf_size in PyOS_ascii_formatd to more accurately reflect it's meaning.
Modified format.__float__ to use the new "Z" format as the default.
Added test cases.
........
r61435 | eric.smith | 2008-03-17 13:14:29 +0100 (Mo, 17 Mär 2008) | 2 lines
Reformated lines > 79 chars.
Deleted unused macro ISXDIGIT.
........
r61436 | jeffrey.yasskin | 2008-03-17 15:40:53 +0100 (Mo, 17 Mär 2008) | 13 lines
Allow Gnu gcc's to build python on OSX by removing -Wno-long-double,
-no-cpp-precomp, and -mno-fused-madd from configure.
* r22183 added -no-cpp-precomp, which
http://gcc.gnu.org/ml/gcc/2005-12/msg00368.html claims hasn't been
needed since gcc-3.1.
* r25607 added -Wno-long-double to avoid a warning in
Include/objimpl.h (issue 525481). The long double is still there,
but OSX 10.4's gcc no longer warns about it.
* r33666 fixed issue 775892 on OSX 10.3 by adding -mno-fused-madd,
which changed the sign of some float 0s. Tim Peters said it wasn't
a real issue anyway, and it no longer causes test failures.
Fixes issue #1779871.
........
r61439 | martin.v.loewis | 2008-03-17 17:31:57 +0100 (Mo, 17 Mär 2008) | 2 lines
Add Trent Nelson.
........
r61444 | travis.oliphant | 2008-03-17 18:36:12 +0100 (Mo, 17 Mär 2008) | 1 line
Add necessary headers to back-port new buffer protocol to Python 2.6
........
r61449 | gregory.p.smith | 2008-03-17 19:48:05 +0100 (Mo, 17 Mär 2008) | 8 lines
Force zlib.crc32 and zlib.adler32 to return a signed integer on all platforms
regardless of the native sizeof(long) used in the integer object.
This somewhat odd behavior of returning a signed is maintained in 2.x for
compatibility reasons of always returning an integer rather than a long object.
Fixes Issue1202 for Python 2.6
........
r61450 | neal.norwitz | 2008-03-17 20:02:45 +0100 (Mo, 17 Mär 2008) | 3 lines
Use a buffer large enough to ensure we don't overrun, even if the value
is outside the range we expect.
........
r61453 | steven.bethard | 2008-03-17 20:33:11 +0100 (Mo, 17 Mär 2008) | 1 line
Document unicode.isnumeric() and unicode.isdecimal() (issue2326)
........
r61458 | neal.norwitz | 2008-03-17 21:22:43 +0100 (Mo, 17 Mär 2008) | 5 lines
Issue 2321: reduce memory usage (increase the memory that is returned
to the system) by using pymalloc for the data of unicode objects.
Will backport.
........
r61465 | martin.v.loewis | 2008-03-17 22:55:30 +0100 (Mo, 17 Mär 2008) | 2 lines
Add David Wolever.
........
r61468 | gregory.p.smith | 2008-03-18 01:20:01 +0100 (Di, 18 Mär 2008) | 3 lines
Fix the IOError message text when opening a file with an invalid filename.
Error reported by Ilan Schnell.
........
r61471 | brett.cannon | 2008-03-18 02:00:07 +0100 (Di, 18 Mär 2008) | 2 lines
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
........
r61472 | jeffrey.yasskin | 2008-03-18 02:09:59 +0100 (Di, 18 Mär 2008) | 2 lines
Fix build on platforms that don't have intptr_t. Patch by Joseph Armbruster.
........
r61473 | brett.cannon | 2008-03-18 02:50:25 +0100 (Di, 18 Mär 2008) | 2 lines
Convert test_dummy_threading and test_dbm to unittest.
........
r61474 | brett.cannon | 2008-03-18 02:58:56 +0100 (Di, 18 Mär 2008) | 2 lines
Move test_extcall to doctest.
........
r61480 | brett.cannon | 2008-03-18 04:46:22 +0100 (Di, 18 Mär 2008) | 2 lines
test_errno was a no-op test; now it actually tests things and uses unittest.
........
r61483 | brett.cannon | 2008-03-18 05:09:00 +0100 (Di, 18 Mär 2008) | 3 lines
Remove our implementation of memmove() and strerror(); both are in the C89
standard library.
........
r61484 | brett.cannon | 2008-03-18 05:16:06 +0100 (Di, 18 Mär 2008) | 2 lines
The output directory for tests that compare against stdout is now gone!
........
r61488 | jeffrey.yasskin | 2008-03-18 05:29:35 +0100 (Di, 18 Mär 2008) | 2 lines
Block the "socket.ssl() is deprecated" warning from test_socket_ssl.
........
r61495 | jeffrey.yasskin | 2008-03-18 05:56:06 +0100 (Di, 18 Mär 2008) | 4 lines
Speed test_thread up from 51.328s to 0.081s by reducing its sleep times. We
still sleep at all to make it likely that all threads are active at the same
time.
........
r61496 | jeffrey.yasskin | 2008-03-18 06:12:41 +0100 (Di, 18 Mär 2008) | 4 lines
Speed up test_dict by about 10x by only checking selected dict literal sizes,
instead of every integer from 0 to 400. Exhaustive testing wastes time without
providing enough more assurance that the code is correct.
........
r61498 | neal.norwitz | 2008-03-18 06:20:29 +0100 (Di, 18 Mär 2008) | 1 line
Try increasing the timeout to reduce the flakiness of this test.
........
r61503 | brett.cannon | 2008-03-18 06:43:04 +0100 (Di, 18 Mär 2008) | 2 lines
Improve the error message for a test that failed on the S-390 Debian buildbot.
........
r61504 | jeffrey.yasskin | 2008-03-18 06:45:40 +0100 (Di, 18 Mär 2008) | 3 lines
Add a -S/--slow flag to regrtest to have it print the 10 slowest tests with
their times.
........
r61507 | neal.norwitz | 2008-03-18 07:03:46 +0100 (Di, 18 Mär 2008) | 1 line
Add some info to the failure messages
........
r61509 | trent.nelson | 2008-03-18 08:02:12 +0100 (Di, 18 Mär 2008) | 1 line
Issue 2286: bump up the stack size of the 64-bit debug python_d.exe to 2100000. The default value of 200000 causes a stack overflow at 1965 iterations of r_object() in marshal.c, 35 iterations before the 2000 limit enforced by MAX_MARSHAL_STACK_DEPTH.
........
r61510 | trent.nelson | 2008-03-18 08:32:47 +0100 (Di, 18 Mär 2008) | 5 lines
The behaviour of winsound.Beep() seems to differ between different versions of Windows when there's either:
a) no sound card entirely
b) legacy beep driver has been disabled
c) the legacy beep driver has been uninstalled
Sometimes RuntimeErrors are raised, sometimes they're not. If _have_soundcard() returns False, don't expect winsound.Beep() to raise a RuntimeError, as this clearly isn't the case, as demonstrated by the various Win32 XP buildbots.
........
r61515 | martin.v.loewis | 2008-03-18 13:20:15 +0100 (Di, 18 Mär 2008) | 2 lines
norwitz-amd64 (gentoo) has EREMOTEIO.
........
r61516 | martin.v.loewis | 2008-03-18 13:45:37 +0100 (Di, 18 Mär 2008) | 2 lines
Add more Linux error codes.
........
r61517 | martin.v.loewis | 2008-03-18 14:05:03 +0100 (Di, 18 Mär 2008) | 2 lines
Add WSA errors.
........
r61518 | martin.v.loewis | 2008-03-18 14:16:05 +0100 (Di, 18 Mär 2008) | 2 lines
Note that the stderr output of the test is intentional.
........
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Tue, 18 Mar 2008 15:15:01 +0000 |
| parents | 654c380cf8b9 |
| children | f197407bdba2 798e0d0c7246 |
| rev | line source |
|---|---|
| 2649 | 1 /* This code implemented by cvale@netcom.com */ |
| 2 | |
| 3 #define INCL_DOSPROCESS | |
| 4 #define INCL_DOSSEMAPHORES | |
| 5 #include "os2.h" | |
| 6 #include "limits.h" | |
| 7 | |
| 8 #include "process.h" | |
| 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 | 16 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
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 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
22 #define OS2_STACKSIZE(x) (x ? x : THREAD_STACK_SIZE) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
23 |
| 2649 | 24 /* |
| 25 * Initialization of the C package, should not be needed. | |
| 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 | 29 { |
| 30 } | |
| 31 | |
| 32 /* | |
| 33 * Thread support. | |
| 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 | 37 { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
38 int thread_id; |
| 2649 | 39 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
40 thread_id = _beginthread(func, |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
41 NULL, |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
42 OS2_STACKSIZE(_pythread_stacksize), |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
43 arg); |
| 2649 | 44 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
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 | 48 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
49 return thread_id; |
| 2649 | 50 } |
| 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 | 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 | 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 | 69 } |
| 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 | 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 | 82 } |
| 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 | 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 | 88 } |
| 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 | 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 | 94 } |
| 95 | |
| 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 | 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 | 106 } |
| 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 | 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 | 112 } |
| 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 | 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 | 118 } |
| 119 #endif /* NO_EXIT_PROG */ | |
| 120 | |
| 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 | 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 | 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 | 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 | 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 | 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 | 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 | 165 } |
| 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 | 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 | 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 | 186 } |
| 187 | |
| 188 /* | |
| 189 * Return 1 on success if the lock was acquired | |
| 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 | 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 | 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 | 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 | 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 | 240 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
241 return 1; |
| 2649 | 242 } |
| 243 | |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
34433
diff
changeset
|
244 void |
|
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
34433
diff
changeset
|
245 PyThread_release_lock(PyThread_type_lock aLock) |
| 2649 | 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 | 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 | 280 } |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
281 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
282 /* minimum/maximum thread stack sizes supported */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
283 #define THREAD_MIN_STACKSIZE 0x8000 /* 32kB */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
284 #define THREAD_MAX_STACKSIZE 0x2000000 /* 32MB */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
285 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
286 /* set the thread stack size. |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
287 * Return 0 if size is valid, -1 otherwise. |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
288 */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
289 static int |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
290 _pythread_os2_set_stacksize(size_t size) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
291 { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
292 /* set to default */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
293 if (size == 0) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
294 _pythread_stacksize = 0; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
295 return 0; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
296 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
297 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
298 /* valid range? */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
299 if (size >= THREAD_MIN_STACKSIZE && size < THREAD_MAX_STACKSIZE) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
300 _pythread_stacksize = size; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
301 return 0; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
302 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
303 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
304 return -1; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
305 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
306 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
307 #define THREAD_SET_STACKSIZE(x) _pythread_os2_set_stacksize(x) |
