Mercurial > cpython-lru_cache-weakref
comparison Python/thread_pthread.h @ 13658:f79434ee41fa legacy-trunk
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Sat, 22 Jul 2000 18:47:25 +0000 |
| parents | 87ee82e5c56d |
| children | 31cda87e9ff4 |
comparison
equal
deleted
inserted
replaced
| 13657:6a5314a6c2c2 | 13658:f79434ee41fa |
|---|---|
| 98 /* | 98 /* |
| 99 * Initialization. | 99 * Initialization. |
| 100 */ | 100 */ |
| 101 | 101 |
| 102 #ifdef _HAVE_BSDI | 102 #ifdef _HAVE_BSDI |
| 103 static void _noop() | 103 static |
| 104 { | 104 void _noop(void) |
| 105 } | 105 { |
| 106 | 106 } |
| 107 static void PyThread__init_thread _P0() | 107 |
| 108 static void | |
| 109 PyThread__init_thread(void) | |
| 108 { | 110 { |
| 109 /* DO AN INIT BY STARTING THE THREAD */ | 111 /* DO AN INIT BY STARTING THE THREAD */ |
| 110 static int dummy = 0; | 112 static int dummy = 0; |
| 111 pthread_t thread1; | 113 pthread_t thread1; |
| 112 pthread_create(&thread1, NULL, (void *) _noop, &dummy); | 114 pthread_create(&thread1, NULL, (void *) _noop, &dummy); |
| 113 pthread_join(thread1, NULL); | 115 pthread_join(thread1, NULL); |
| 114 } | 116 } |
| 115 | 117 |
| 116 #else /* !_HAVE_BSDI */ | 118 #else /* !_HAVE_BSDI */ |
| 117 | 119 |
| 118 static void PyThread__init_thread _P0() | 120 static void |
| 121 PyThread__init_thread(void) | |
| 119 { | 122 { |
| 120 #if defined(_AIX) && defined(__GNUC__) | 123 #if defined(_AIX) && defined(__GNUC__) |
| 121 pthread_init(); | 124 pthread_init(); |
| 122 #endif | 125 #endif |
| 123 } | 126 } |
| 127 /* | 130 /* |
| 128 * Thread support. | 131 * Thread support. |
| 129 */ | 132 */ |
| 130 | 133 |
| 131 | 134 |
| 132 int PyThread_start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg) | 135 int |
| 136 PyThread_start_new_thread(void (*func)(void *), void *arg) | |
| 133 { | 137 { |
| 134 pthread_t th; | 138 pthread_t th; |
| 135 int success; | 139 int success; |
| 136 dprintf(("PyThread_start_new_thread called\n")); | 140 dprintf(("PyThread_start_new_thread called\n")); |
| 137 if (!initialized) | 141 if (!initialized) |
| 142 pthread_attr_default, | 146 pthread_attr_default, |
| 143 (pthread_startroutine_t)func, | 147 (pthread_startroutine_t)func, |
| 144 (pthread_addr_t)arg | 148 (pthread_addr_t)arg |
| 145 #elif defined(PY_PTHREAD_D6) | 149 #elif defined(PY_PTHREAD_D6) |
| 146 pthread_attr_default, | 150 pthread_attr_default, |
| 147 (void* (*)_P((void *)))func, | 151 (void* (*)(void *))func, |
| 148 arg | 152 arg |
| 149 #elif defined(PY_PTHREAD_D7) | 153 #elif defined(PY_PTHREAD_D7) |
| 150 pthread_attr_default, | 154 pthread_attr_default, |
| 151 func, | 155 func, |
| 152 arg | 156 arg |
| 153 #elif defined(PY_PTHREAD_STD) | 157 #elif defined(PY_PTHREAD_STD) |
| 154 (pthread_attr_t*)NULL, | 158 (pthread_attr_t*)NULL, |
| 155 (void* (*)_P((void *)))func, | 159 (void* (*)(void *))func, |
| 156 (void *)arg | 160 (void *)arg |
| 157 #endif | 161 #endif |
| 158 ); | 162 ); |
| 159 | 163 |
| 160 if (success == 0) { | 164 if (success == 0) { |
| 165 #endif | 169 #endif |
| 166 } | 170 } |
| 167 return success != 0 ? 0 : 1; | 171 return success != 0 ? 0 : 1; |
| 168 } | 172 } |
| 169 | 173 |
| 170 long PyThread_get_thread_ident _P0() | 174 long |
| 175 PyThread_get_thread_ident(void) | |
| 171 { | 176 { |
| 172 volatile pthread_t threadid; | 177 volatile pthread_t threadid; |
| 173 if (!initialized) | 178 if (!initialized) |
| 174 PyThread_init_thread(); | 179 PyThread_init_thread(); |
| 175 /* Jump through some hoops for Alpha OSF/1 */ | 180 /* Jump through some hoops for Alpha OSF/1 */ |
| 176 threadid = pthread_self(); | 181 threadid = pthread_self(); |
| 177 return (long) *(long *) &threadid; | 182 return (long) *(long *) &threadid; |
| 178 } | 183 } |
| 179 | 184 |
| 180 static void do_PyThread_exit_thread _P1(no_cleanup, int no_cleanup) | 185 static void |
| 186 do_PyThread_exit_thread(int no_cleanup) | |
| 181 { | 187 { |
| 182 dprintf(("PyThread_exit_thread called\n")); | 188 dprintf(("PyThread_exit_thread called\n")); |
| 183 if (!initialized) { | 189 if (!initialized) { |
| 184 if (no_cleanup) | 190 if (no_cleanup) |
| 185 _exit(0); | 191 _exit(0); |
| 186 else | 192 else |
| 187 exit(0); | 193 exit(0); |
| 188 } | 194 } |
| 189 } | 195 } |
| 190 | 196 |
| 191 void PyThread_exit_thread _P0() | 197 void |
| 198 PyThread_exit_thread(void) | |
| 192 { | 199 { |
| 193 do_PyThread_exit_thread(0); | 200 do_PyThread_exit_thread(0); |
| 194 } | 201 } |
| 195 | 202 |
| 196 void PyThread__exit_thread _P0() | 203 void |
| 204 PyThread__exit_thread(void) | |
| 197 { | 205 { |
| 198 do_PyThread_exit_thread(1); | 206 do_PyThread_exit_thread(1); |
| 199 } | 207 } |
| 200 | 208 |
| 201 #ifndef NO_EXIT_PROG | 209 #ifndef NO_EXIT_PROG |
| 202 static void do_PyThread_exit_prog _P2(status, int status, no_cleanup, int no_cleanup) | 210 static void |
| 211 do_PyThread_exit_prog(int status, int no_cleanup) | |
| 203 { | 212 { |
| 204 dprintf(("PyThread_exit_prog(%d) called\n", status)); | 213 dprintf(("PyThread_exit_prog(%d) called\n", status)); |
| 205 if (!initialized) | 214 if (!initialized) |
| 206 if (no_cleanup) | 215 if (no_cleanup) |
| 207 _exit(status); | 216 _exit(status); |
| 208 else | 217 else |
| 209 exit(status); | 218 exit(status); |
| 210 } | 219 } |
| 211 | 220 |
| 212 void PyThread_exit_prog _P1(status, int status) | 221 void |
| 222 PyThread_exit_prog(int status) | |
| 213 { | 223 { |
| 214 do_PyThread_exit_prog(status, 0); | 224 do_PyThread_exit_prog(status, 0); |
| 215 } | 225 } |
| 216 | 226 |
| 217 void PyThread__exit_prog _P1(status, int status) | 227 void |
| 228 PyThread__exit_prog(int status) | |
| 218 { | 229 { |
| 219 do_PyThread_exit_prog(status, 1); | 230 do_PyThread_exit_prog(status, 1); |
| 220 } | 231 } |
| 221 #endif /* NO_EXIT_PROG */ | 232 #endif /* NO_EXIT_PROG */ |
| 222 | 233 |
| 223 /* | 234 /* |
| 224 * Lock support. | 235 * Lock support. |
| 225 */ | 236 */ |
| 226 PyThread_type_lock PyThread_allocate_lock _P0() | 237 PyThread_type_lock |
| 238 PyThread_allocate_lock(void) | |
| 227 { | 239 { |
| 228 pthread_lock *lock; | 240 pthread_lock *lock; |
| 229 int status, error = 0; | 241 int status, error = 0; |
| 230 | 242 |
| 231 dprintf(("PyThread_allocate_lock called\n")); | 243 dprintf(("PyThread_allocate_lock called\n")); |
| 253 | 265 |
| 254 dprintf(("PyThread_allocate_lock() -> %p\n", lock)); | 266 dprintf(("PyThread_allocate_lock() -> %p\n", lock)); |
| 255 return (PyThread_type_lock) lock; | 267 return (PyThread_type_lock) lock; |
| 256 } | 268 } |
| 257 | 269 |
| 258 void PyThread_free_lock _P1(lock, PyThread_type_lock lock) | 270 void |
| 271 PyThread_free_lock(PyThread_type_lock lock) | |
| 259 { | 272 { |
| 260 pthread_lock *thelock = (pthread_lock *)lock; | 273 pthread_lock *thelock = (pthread_lock *)lock; |
| 261 int status, error = 0; | 274 int status, error = 0; |
| 262 | 275 |
| 263 dprintf(("PyThread_free_lock(%p) called\n", lock)); | 276 dprintf(("PyThread_free_lock(%p) called\n", lock)); |
| 269 CHECK_STATUS("pthread_cond_destroy"); | 282 CHECK_STATUS("pthread_cond_destroy"); |
| 270 | 283 |
| 271 free((void *)thelock); | 284 free((void *)thelock); |
| 272 } | 285 } |
| 273 | 286 |
| 274 int PyThread_acquire_lock _P2(lock, PyThread_type_lock lock, waitflag, int waitflag) | 287 int |
| 288 PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) | |
| 275 { | 289 { |
| 276 int success; | 290 int success; |
| 277 pthread_lock *thelock = (pthread_lock *)lock; | 291 pthread_lock *thelock = (pthread_lock *)lock; |
| 278 int status, error = 0; | 292 int status, error = 0; |
| 279 | 293 |
| 306 if (error) success = 0; | 320 if (error) success = 0; |
| 307 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); | 321 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); |
| 308 return success; | 322 return success; |
| 309 } | 323 } |
| 310 | 324 |
| 311 void PyThread_release_lock _P1(lock, PyThread_type_lock lock) | 325 void |
| 326 PyThread_release_lock(PyThread_type_lock lock) | |
| 312 { | 327 { |
| 313 pthread_lock *thelock = (pthread_lock *)lock; | 328 pthread_lock *thelock = (pthread_lock *)lock; |
| 314 int status, error = 0; | 329 int status, error = 0; |
| 315 | 330 |
| 316 dprintf(("PyThread_release_lock(%p) called\n", lock)); | 331 dprintf(("PyThread_release_lock(%p) called\n", lock)); |
| 336 pthread_mutex_t mutex; | 351 pthread_mutex_t mutex; |
| 337 pthread_cond_t cond; | 352 pthread_cond_t cond; |
| 338 int value; | 353 int value; |
| 339 }; | 354 }; |
| 340 | 355 |
| 341 PyThread_type_sema PyThread_allocate_sema _P1(value, int value) | 356 PyThread_type_sema |
| 357 PyThread_allocate_sema(int value) | |
| 342 { | 358 { |
| 343 struct semaphore *sema; | 359 struct semaphore *sema; |
| 344 int status, error = 0; | 360 int status, error = 0; |
| 345 | 361 |
| 346 dprintf(("PyThread_allocate_sema called\n")); | 362 dprintf(("PyThread_allocate_sema called\n")); |
| 363 } | 379 } |
| 364 dprintf(("PyThread_allocate_sema() -> %p\n", sema)); | 380 dprintf(("PyThread_allocate_sema() -> %p\n", sema)); |
| 365 return (PyThread_type_sema) sema; | 381 return (PyThread_type_sema) sema; |
| 366 } | 382 } |
| 367 | 383 |
| 368 void PyThread_free_sema _P1(sema, PyThread_type_sema sema) | 384 void |
| 385 PyThread_free_sema(PyThread_type_sema sema) | |
| 369 { | 386 { |
| 370 int status, error = 0; | 387 int status, error = 0; |
| 371 struct semaphore *thesema = (struct semaphore *) sema; | 388 struct semaphore *thesema = (struct semaphore *) sema; |
| 372 | 389 |
| 373 dprintf(("PyThread_free_sema(%p) called\n", sema)); | 390 dprintf(("PyThread_free_sema(%p) called\n", sema)); |
| 376 status = pthread_mutex_destroy(&thesema->mutex); | 393 status = pthread_mutex_destroy(&thesema->mutex); |
| 377 CHECK_STATUS("pthread_mutex_destroy"); | 394 CHECK_STATUS("pthread_mutex_destroy"); |
| 378 free((void *) thesema); | 395 free((void *) thesema); |
| 379 } | 396 } |
| 380 | 397 |
| 381 int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) | 398 int |
| 399 PyThread_down_sema(PyThread_type_sema sema, int waitflag) | |
| 382 { | 400 { |
| 383 int status, error = 0, success; | 401 int status, error = 0, success; |
| 384 struct semaphore *thesema = (struct semaphore *) sema; | 402 struct semaphore *thesema = (struct semaphore *) sema; |
| 385 | 403 |
| 386 dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); | 404 dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); |
| 405 CHECK_STATUS("pthread_mutex_unlock"); | 423 CHECK_STATUS("pthread_mutex_unlock"); |
| 406 dprintf(("PyThread_down_sema(%p) return\n", sema)); | 424 dprintf(("PyThread_down_sema(%p) return\n", sema)); |
| 407 return success; | 425 return success; |
| 408 } | 426 } |
| 409 | 427 |
| 410 void PyThread_up_sema _P1(sema, PyThread_type_sema sema) | 428 void |
| 429 PyThread_up_sema(PyThread_type_sema sema) | |
| 411 { | 430 { |
| 412 int status, error = 0; | 431 int status, error = 0; |
| 413 struct semaphore *thesema = (struct semaphore *) sema; | 432 struct semaphore *thesema = (struct semaphore *) sema; |
| 414 | 433 |
| 415 dprintf(("PyThread_up_sema(%p)\n", sema)); | 434 dprintf(("PyThread_up_sema(%p)\n", sema)); |
