annotate Python/thread_os2.h @ 17494:a34293ced63b legacy-trunk

Change error message raised when free variable is not yet bound. It now raises NameError instead of UnboundLocalError, because the var in question is definitely not local. (This affects test_scope.py) Also update the recent fix by Ping using get_func_name(). Replace tests of get_func_name() return value with call to get_func_desc() to match all the other uses.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Fri, 13 Apr 2001 16:51:46 +0000
parents 6f6f965c5e2d
children ebfd87e87884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* This code implemented by cvale@netcom.com */
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 #define INCL_DOSPROCESS
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 #define INCL_DOSSEMAPHORES
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #include "os2.h"
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 #include "limits.h"
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 #include "process.h"
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 * Initialization of the C package, should not be needed.
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 * Thread support.
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
24 int
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 int aThread;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 int success = 1;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 if( aThread == -1 ) {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 success = 0;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 fprintf(stderr,"aThread failed == %d",aThread);
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 dprintf(("_beginthread failed. return %ld\n", errno));
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 return success;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 PPIB pib;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 PTIB tib;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 DosGetInfoBlocks(&tib,&pib);
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 return tib->tib_ptib2->tib2_ultid;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 if (!initialized)
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 if (no_cleanup)
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 _exit(0);
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 else
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 exit(0);
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 _endthread();
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
77
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 if (!initialized)
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 if (no_cleanup)
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 _exit(status);
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 else
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 exit(status);
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
89
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
90 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
91 PyThread_exit_prog(int status)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
95
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 #endif /* NO_EXIT_PROG */
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
102
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 * Lock support. It has too be implemented as semaphores.
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 * I [Dag] tried to implement it with mutex but I could find a way to
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 * tell whether a thread already own the lock or not.
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
108 PyThread_type_lock
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
109 PyThread_allocate_lock(void)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 HMTX aLock;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 APIRET rc;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
113
9679
877d23bd5bdc Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
114 dprintf(("PyThread_allocate_lock called\n"));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 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
116 PyThread_init_thread();
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 DosCreateMutexSem(NULL, /* Sem name */
13620
5b727ab37092 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents: 13255
diff changeset
119 &aLock, /* the semaphore */
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 0, /* shared ? */
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
121 0); /* initial state */
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
122
13210
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
123 dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
124
9679
877d23bd5bdc Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
125 return (PyThread_type_lock) aLock;
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
127
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
128 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
129 PyThread_free_lock(PyThread_type_lock aLock)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
130 {
13210
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
131 dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
132
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 DosCloseMutexSem((HMTX)aLock);
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
135
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
137 * Return 1 on success if the lock was acquired
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 *
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
139 * and 0 if the lock was not acquired. This means a 0 is returned
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
140 * if the lock has already been acquired by this thread!
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
142 int
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
143 PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
144 {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
145 int success = 1;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 ULONG rc, count;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
147 PID pid = 0;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
148 TID tid = 0;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
149
13210
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
150 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
151 aLock, waitflag));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
152
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
153 DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count);
9679
877d23bd5bdc Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
154 if( tid == PyThread_get_thread_ident() ) { /* if we own this lock */
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 success = 0;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 } else {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
157 rc = DosRequestMutexSem((HMTX) aLock,
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 (waitflag == 1 ? SEM_INDEFINITE_WAIT : 0));
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 if( rc != 0) {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 success = 0; /* We failed */
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
164
13210
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
165 dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n",
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
166 PyThread_get_thread_ident(),aLock, waitflag, success));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
167
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 return success;
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
169 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
170
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
171 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
172 PyThread_release_lock(PyThread_type_lock aLock)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
173 {
13210
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
174 dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
175
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) {
13210
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
177 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
178 PyThread_get_thread_ident(), aLock, GetLastError()));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
181
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
182 /*
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 * Semaphore support.
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
184 */
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
185 PyThread_type_sema
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
186 PyThread_allocate_sema(int value)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
187 {
9679
877d23bd5bdc Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents: 6626
diff changeset
188 return (PyThread_type_sema) 0;
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
189 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
190
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
191 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
192 PyThread_free_sema(PyThread_type_sema aSemaphore)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
193 {
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
194
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
195 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
196
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
197 int
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
198 PyThread_down_sema(PyThread_type_sema aSemaphore, int waitflag)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
199 {
4371
c277ee8c669c Sjoerd's thread changes (including down_sema typo fix).
Guido van Rossum <guido@python.org>
parents: 2649
diff changeset
200 return -1;
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 }
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
202
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
203 void
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
204 PyThread_up_sema(PyThread_type_sema aSemaphore)
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
205 {
13210
ff243b0f16ee Trent Mick <trentm@activestate.com>:
Fred Drake <fdrake@acm.org>
parents: 9679
diff changeset
206 dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore));
2649
063a96b49b3e OS/2 thread support
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 }