Mercurial > cpython-lru_cache-weakref
annotate Python/thread_os2.h @ 38579:19430cdff2bd legacy-trunk
clean up function declarations to conform to PEP-7 style.
| author | Andrew MacIntyre <andymac@bullseye.apana.org.au> |
|---|---|
| date | Sun, 04 Jun 2006 12:59:59 +0000 |
| parents | 0b2b076e5908 |
| children | c4587a5f5e94 |
| 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 |
|
38578
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
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 |
|
38578
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
22 #define OS2_STACKSIZE(x) (x ? x : THREAD_STACK_SIZE) |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
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 { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
38 int aThread; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
39 int success = 0; |
| 2649 | 40 |
|
38578
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
41 aThread = _beginthread(func, |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
42 NULL, |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
43 OS2_STACKSIZE(_pythread_stacksize), |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
44 arg); |
| 2649 | 45 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
46 if (aThread == -1) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
47 success = -1; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
48 fprintf(stderr, "aThread failed == %d", aThread); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
49 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
|
50 } |
| 2649 | 51 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
52 return success; |
| 2649 | 53 } |
| 54 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
55 long |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
56 PyThread_get_thread_ident(void) |
| 2649 | 57 { |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
58 #if !defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
59 PPIB pib; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
60 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
|
61 #endif |
| 2649 | 62 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
63 if (!initialized) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
64 PyThread_init_thread(); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
65 |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
66 #if defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
67 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
|
68 #else |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
69 DosGetInfoBlocks(&tib, &pib); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
70 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
|
71 #endif |
| 2649 | 72 } |
| 73 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
74 static void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
75 do_PyThread_exit_thread(int no_cleanup) |
| 2649 | 76 { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
77 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
|
78 PyThread_get_thread_ident())); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
79 if (!initialized) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
80 if (no_cleanup) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
81 _exit(0); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
82 else |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
83 exit(0); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
84 _endthread(); |
| 2649 | 85 } |
| 86 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
87 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
88 PyThread_exit_thread(void) |
| 2649 | 89 { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
90 do_PyThread_exit_thread(0); |
| 2649 | 91 } |
| 92 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
93 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
94 PyThread__exit_thread(void) |
| 2649 | 95 { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
96 do_PyThread_exit_thread(1); |
| 2649 | 97 } |
| 98 | |
| 99 #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
|
100 static void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
101 do_PyThread_exit_prog(int status, int no_cleanup) |
| 2649 | 102 { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
103 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
|
104 if (!initialized) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
105 if (no_cleanup) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
106 _exit(status); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
107 else |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
108 exit(status); |
| 2649 | 109 } |
| 110 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
111 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
112 PyThread_exit_prog(int status) |
| 2649 | 113 { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
114 do_PyThread_exit_prog(status, 0); |
| 2649 | 115 } |
| 116 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
117 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
118 PyThread__exit_prog(int status) |
| 2649 | 119 { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
120 do_PyThread_exit_prog(status, 1); |
| 2649 | 121 } |
| 122 #endif /* NO_EXIT_PROG */ | |
| 123 | |
| 124 /* | |
|
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
|
125 * 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
|
126 * 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
|
127 * counterparts. |
| 2649 | 128 */ |
|
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
|
129 |
|
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 typedef struct os2_lock_t { |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
131 int is_set; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
132 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
|
133 } *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
|
134 |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
135 PyThread_type_lock |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
136 PyThread_allocate_lock(void) |
| 2649 | 137 { |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
138 #if defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
139 _fmutex *sem = malloc(sizeof(_fmutex)); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
140 if (!initialized) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
141 PyThread_init_thread(); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
142 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
|
143 PyThread_get_thread_ident(), |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
144 (long)sem)); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
145 if (_fmutex_create(sem, 0)) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
146 free(sem); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
147 sem = NULL; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
148 } |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
149 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
|
150 #else |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
151 APIRET rc; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
152 type_os2_lock lock = (type_os2_lock)malloc(sizeof(struct os2_lock_t)); |
| 2649 | 153 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
154 dprintf(("PyThread_allocate_lock called\n")); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
155 if (!initialized) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
156 PyThread_init_thread(); |
| 2649 | 157 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
158 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
|
159 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
160 DosCreateEventSem(NULL, &lock->changed, 0, 0); |
| 2649 | 161 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
162 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
|
163 PyThread_get_thread_ident(), |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
164 lock->changed)); |
| 2649 | 165 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
166 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
|
167 #endif |
| 2649 | 168 } |
| 169 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
170 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
171 PyThread_free_lock(PyThread_type_lock aLock) |
| 2649 | 172 { |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
173 #if !defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
174 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
|
175 #endif |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
176 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
177 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
|
178 PyThread_get_thread_ident(),aLock)); |
| 2649 | 179 |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
180 #if defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
181 if (aLock) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
182 _fmutex_close((_fmutex *)aLock); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
183 free((_fmutex *)aLock); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
184 } |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
185 #else |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
186 DosCloseEventSem(lock->changed); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
187 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
|
188 #endif |
| 2649 | 189 } |
| 190 | |
| 191 /* | |
| 192 * Return 1 on success if the lock was acquired | |
| 193 * | |
|
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
|
194 * and 0 if the lock was not acquired. |
| 2649 | 195 */ |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
196 int |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
197 PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) |
| 2649 | 198 { |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
199 #if !defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
200 int done = 0; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
201 ULONG count; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
202 PID pid = 0; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
203 TID tid = 0; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
204 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
|
205 #endif |
| 2649 | 206 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
207 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
|
208 PyThread_get_thread_ident(), |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
209 aLock, |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
210 waitflag)); |
| 2649 | 211 |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
212 #if defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
213 /* 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
|
214 if (aLock && |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
215 _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
|
216 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
|
217 #else |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
218 while (!done) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
219 /* 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
|
220 * the state to change |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
221 */ |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
222 if (lock->is_set) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
223 if (!waitflag) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
224 return 0; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
225 DosWaitEventSem(lock->changed, SEM_INDEFINITE_WAIT); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
226 } |
|
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
|
227 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
228 /* 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
|
229 * 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
|
230 */ |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
231 if (DosEnterCritSec()) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
232 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
|
233 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
234 if (!lock->is_set) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
235 lock->is_set = 1; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
236 DosResetEventSem(lock->changed, &count); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
237 done = 1; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
238 } |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
239 |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
240 DosExitCritSec(); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
241 } |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
242 #endif |
| 2649 | 243 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
244 return 1; |
| 2649 | 245 } |
| 246 | |
|
38579
19430cdff2bd
clean up function declarations to conform to PEP-7 style.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
38578
diff
changeset
|
247 void |
|
19430cdff2bd
clean up function declarations to conform to PEP-7 style.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
38578
diff
changeset
|
248 PyThread_release_lock(PyThread_type_lock aLock) |
| 2649 | 249 { |
|
26530
b5837b8f3b2c
typo fix: declaration required for VACPP not EMX+gcc
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
22054
diff
changeset
|
250 #if !defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
251 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
|
252 #endif |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
253 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
254 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
|
255 PyThread_get_thread_ident(), |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
256 aLock)); |
| 2649 | 257 |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
258 #if defined(PYCC_GCC) |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
259 if (aLock) |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
260 _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
|
261 #else |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
262 if (!lock->is_set) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
263 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
|
264 PyThread_get_thread_ident(), |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
265 aLock, |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
266 GetLastError())); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
267 return; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
268 } |
|
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
|
269 |
|
26531
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
270 if (DosEnterCritSec()) { |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
271 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
|
272 PyThread_get_thread_ident(), |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
273 aLock, |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
274 GetLastError())); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
275 return; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
276 } |
|
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 lock->is_set = 0; |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
279 DosPostEventSem(lock->changed); |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
280 |
|
8e1567dbcba8
reformat for PEP-7 style conformance
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
26530
diff
changeset
|
281 DosExitCritSec(); |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21766
diff
changeset
|
282 #endif |
| 2649 | 283 } |
|
38578
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
284 |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
285 /* minimum/maximum thread stack sizes supported */ |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
286 #define THREAD_MIN_STACKSIZE 0x8000 /* 32kB */ |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
287 #define THREAD_MAX_STACKSIZE 0x2000000 /* 32MB */ |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
288 |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
289 /* set the thread stack size. |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
290 * Return 1 if an exception is pending, 0 otherwise. |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
291 */ |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
292 static int |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
293 _pythread_os2_set_stacksize(size_t size) |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
294 { |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
295 /* set to default */ |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
296 if (size == 0) { |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
297 _pythread_stacksize = 0; |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
298 return 0; |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
299 } |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
300 |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
301 /* valid range? */ |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
302 if (size >= THREAD_MIN_STACKSIZE && size < THREAD_MAX_STACKSIZE) { |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
303 _pythread_stacksize = size; |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
304 return 0; |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
305 } |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
306 else { |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
307 char warning[128]; |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
308 snprintf(warning, |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
309 128, |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
310 "thread stack size of %#x bytes not supported on OS/2", |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
311 size); |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
312 return PyErr_Warn(PyExc_RuntimeWarning, warning); |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
313 } |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
314 } |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
315 |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
316 #undef THREAD_SET_STACKSIZE |
|
0b2b076e5908
Patch #1454481: Make thread stack size runtime tunable.
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
34433
diff
changeset
|
317 #define THREAD_SET_STACKSIZE(x) _pythread_os2_set_stacksize(x) |
