Mercurial > cpython-lru_cache-weakref
annotate Python/thread_os2.h @ 68235:61b0263d6881 2.2
Close 2.2 branch.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sat, 05 Mar 2011 14:55:23 +0100 |
| parents | b1d9029e09d1 |
| children | 8b116a8449bd |
| 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 | |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
10 long PyThread_get_thread_ident(void); |
| 2649 | 11 |
| 12 | |
| 13 /* | |
| 14 * Initialization of the C package, should not be needed. | |
| 15 */ | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
16 static void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
17 PyThread__init_thread(void) |
| 2649 | 18 { |
| 19 } | |
| 20 | |
| 21 /* | |
| 22 * Thread support. | |
| 23 */ | |
|
20468
ebfd87e87884
Partial patch from SF #452266, by Jason Petrone.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
24 long |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
25 PyThread_start_new_thread(void (*func)(void *), void *arg) |
| 2649 | 26 { |
| 27 int aThread; | |
|
20468
ebfd87e87884
Partial patch from SF #452266, by Jason Petrone.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
28 int success = 0; |
| 2649 | 29 |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
30 aThread = _beginthread(func,NULL,65536,arg); |
| 2649 | 31 |
| 32 if( aThread == -1 ) { | |
|
20468
ebfd87e87884
Partial patch from SF #452266, by Jason Petrone.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
33 success = -1; |
| 2649 | 34 fprintf(stderr,"aThread failed == %d",aThread); |
| 35 dprintf(("_beginthread failed. return %ld\n", errno)); | |
| 36 } | |
| 37 | |
| 38 return success; | |
| 39 } | |
| 40 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
41 long |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
42 PyThread_get_thread_ident(void) |
| 2649 | 43 { |
| 44 PPIB pib; | |
| 45 PTIB tib; | |
| 46 | |
| 47 if (!initialized) | |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
48 PyThread_init_thread(); |
| 2649 | 49 |
| 50 DosGetInfoBlocks(&tib,&pib); | |
| 51 return tib->tib_ptib2->tib2_ultid; | |
| 52 } | |
| 53 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
54 static void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
55 do_PyThread_exit_thread(int no_cleanup) |
| 2649 | 56 { |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
57 dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident())); |
| 2649 | 58 if (!initialized) |
| 59 if (no_cleanup) | |
| 60 _exit(0); | |
| 61 else | |
| 62 exit(0); | |
| 63 _endthread(); | |
| 64 } | |
| 65 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
66 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
67 PyThread_exit_thread(void) |
| 2649 | 68 { |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
69 do_PyThread_exit_thread(0); |
| 2649 | 70 } |
| 71 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
72 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
73 PyThread__exit_thread(void) |
| 2649 | 74 { |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
75 do_PyThread_exit_thread(1); |
| 2649 | 76 } |
| 77 | |
| 78 #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
|
79 static void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
80 do_PyThread_exit_prog(int status, int no_cleanup) |
| 2649 | 81 { |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
82 dprintf(("PyThread_exit_prog(%d) called\n", status)); |
| 2649 | 83 if (!initialized) |
| 84 if (no_cleanup) | |
| 85 _exit(status); | |
| 86 else | |
| 87 exit(status); | |
| 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_prog(int status) |
| 2649 | 92 { |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
93 do_PyThread_exit_prog(status, 0); |
| 2649 | 94 } |
| 95 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
96 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
97 PyThread__exit_prog(int status) |
| 2649 | 98 { |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
99 do_PyThread_exit_prog(status, 1); |
| 2649 | 100 } |
| 101 #endif /* NO_EXIT_PROG */ | |
| 102 | |
| 103 /* | |
|
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
|
104 * 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
|
105 * sections to make it behave more like a posix mutex than its OS/2 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
106 # counterparts. |
| 2649 | 107 */ |
|
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
|
108 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
109 typedef struct os2_lock_t { |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
110 int is_set; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
111 HEV changed; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
112 } *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
|
113 |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
114 PyThread_type_lock |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
115 PyThread_allocate_lock(void) |
| 2649 | 116 { |
| 117 APIRET rc; | |
|
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
|
118 type_os2_lock lock = (type_os2_lock)malloc(sizeof(struct os2_lock_t)); |
| 2649 | 119 |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
120 dprintf(("PyThread_allocate_lock called\n")); |
| 2649 | 121 if (!initialized) |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
122 PyThread_init_thread(); |
| 2649 | 123 |
|
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
|
124 lock->is_set = 0; |
|
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 |
|
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 DosCreateEventSem(NULL, &lock->changed, 0, 0); |
| 2649 | 127 |
|
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
|
128 dprintf(("%ld: PyThread_allocate_lock() -> %p\n", |
|
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 PyThread_get_thread_ident(), |
|
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 lock->changed)); |
| 2649 | 131 |
|
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
|
132 return (PyThread_type_lock) lock; |
| 2649 | 133 } |
| 134 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
135 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
136 PyThread_free_lock(PyThread_type_lock aLock) |
| 2649 | 137 { |
|
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
|
138 type_os2_lock lock = (type_os2_lock)aLock; |
|
13210
ff243b0f16ee
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
9679
diff
changeset
|
139 dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); |
| 2649 | 140 |
|
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
|
141 DosCloseEventSem(lock->changed); |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
142 free(aLock); |
| 2649 | 143 } |
| 144 | |
| 145 /* | |
| 146 * Return 1 on success if the lock was acquired | |
| 147 * | |
|
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
|
148 * and 0 if the lock was not acquired. |
| 2649 | 149 */ |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
150 int |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
151 PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) |
| 2649 | 152 { |
|
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
|
153 int done = 0; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
154 ULONG count; |
| 2649 | 155 PID pid = 0; |
| 156 TID tid = 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
|
157 type_os2_lock lock = (type_os2_lock)aLock; |
| 2649 | 158 |
|
13210
ff243b0f16ee
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
9679
diff
changeset
|
159 dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(), |
|
ff243b0f16ee
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
9679
diff
changeset
|
160 aLock, waitflag)); |
| 2649 | 161 |
|
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
|
162 while (!done) { |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
163 /* if the lock is currently set, we have to wait for the state to change */ |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
164 if (lock->is_set) { |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
165 if (!waitflag) |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
166 return 0; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
167 DosWaitEventSem(lock->changed, SEM_INDEFINITE_WAIT); |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
168 } |
| 2649 | 169 |
|
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
|
170 /* |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
171 * enter a critical section and try to get the semaphore. If |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
172 * it is still locked, we will try again. |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
173 */ |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
174 if (DosEnterCritSec()) |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
175 return 0; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
176 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
177 if (!lock->is_set) { |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
178 lock->is_set = 1; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
179 DosResetEventSem(lock->changed, &count); |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
180 done = 1; |
| 2649 | 181 } |
|
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
|
182 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
183 DosExitCritSec(); |
| 2649 | 184 } |
| 185 | |
|
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
|
186 return 1; |
| 2649 | 187 } |
| 188 | |
|
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
|
189 void PyThread_release_lock(PyThread_type_lock aLock) |
| 2649 | 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 type_os2_lock lock = (type_os2_lock)aLock; |
|
13210
ff243b0f16ee
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
9679
diff
changeset
|
192 dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); |
| 2649 | 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 if (!lock->is_set) { |
|
13210
ff243b0f16ee
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
9679
diff
changeset
|
195 dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", |
|
ff243b0f16ee
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
9679
diff
changeset
|
196 PyThread_get_thread_ident(), aLock, GetLastError())); |
|
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
|
197 return; |
| 2649 | 198 } |
|
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
|
199 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
200 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
201 if (DosEnterCritSec()) { |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
202 dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
203 PyThread_get_thread_ident(), aLock, GetLastError())); |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
204 return; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
205 } |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
206 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
207 lock->is_set = 0; |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
208 DosPostEventSem(lock->changed); |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
209 |
|
b1d9029e09d1
SF patch #474500: Make OS/2 locks work like posix locks, from Michael
Tim Peters <tim.peters@gmail.com>
parents:
20468
diff
changeset
|
210 DosExitCritSec(); |
| 2649 | 211 } |
| 212 | |
| 213 /* | |
| 214 * Semaphore support. | |
| 215 */ | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
216 PyThread_type_sema |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
217 PyThread_allocate_sema(int value) |
| 2649 | 218 { |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
219 return (PyThread_type_sema) 0; |
| 2649 | 220 } |
| 221 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
222 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
223 PyThread_free_sema(PyThread_type_sema aSemaphore) |
| 2649 | 224 { |
| 225 | |
| 226 } | |
| 227 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
228 int |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
229 PyThread_down_sema(PyThread_type_sema aSemaphore, int waitflag) |
| 2649 | 230 { |
|
4371
c277ee8c669c
Sjoerd's thread changes (including down_sema typo fix).
Guido van Rossum <guido@python.org>
parents:
2649
diff
changeset
|
231 return -1; |
| 2649 | 232 } |
| 233 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
234 void |
|
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
235 PyThread_up_sema(PyThread_type_sema aSemaphore) |
| 2649 | 236 { |
|
13210
ff243b0f16ee
Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents:
9679
diff
changeset
|
237 dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore)); |
| 2649 | 238 } |
