diff options
-rw-r--r-- | Python/thread_cthread.h | 5 | ||||
-rw-r--r-- | Python/thread_foobar.h | 5 | ||||
-rw-r--r-- | Python/thread_lwp.h | 5 | ||||
-rw-r--r-- | Python/thread_nt.h | 6 | ||||
-rw-r--r-- | Python/thread_os2.h | 4 | ||||
-rw-r--r-- | Python/thread_pthread.h | 5 | ||||
-rw-r--r-- | Python/thread_sgi.h | 13 | ||||
-rw-r--r-- | Python/thread_solaris.h | 22 |
8 files changed, 47 insertions, 18 deletions
diff --git a/Python/thread_cthread.h b/Python/thread_cthread.h index 79bcc0f..1e731ac 100644 --- a/Python/thread_cthread.h +++ b/Python/thread_cthread.h @@ -183,10 +183,11 @@ void free_sema _P1(sema, type_sema sema) dprintf(("free_sema(%lx) called\n", (long) sema)); } -void down_sema _P1(sema, type_sema sema) +int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) { - dprintf(("down_sema(%lx) called\n", (long) sema)); + dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag)); dprintf(("down_sema(%lx) return\n", (long) sema)); + return -1; } void up_sema _P1(sema, type_sema sema) diff --git a/Python/thread_foobar.h b/Python/thread_foobar.h index 772f26b..0bf58f4 100644 --- a/Python/thread_foobar.h +++ b/Python/thread_foobar.h @@ -142,10 +142,11 @@ void free_sema _P1(sema, type_sema sema) dprintf(("free_sema(%lx) called\n", (long) sema)); } -void down_sema _P1(sema, type_sema sema) +int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) { - dprintf(("down_sema(%lx) called\n", (long) sema)); + dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag)); dprintf(("down_sema(%lx) return\n", (long) sema)); + return -1; } void up_sema _P1(sema, type_sema sema) diff --git a/Python/thread_lwp.h b/Python/thread_lwp.h index a4e943f..1541334 100644 --- a/Python/thread_lwp.h +++ b/Python/thread_lwp.h @@ -190,10 +190,11 @@ void free_sema _P1(sema, type_sema sema) dprintf(("free_sema(%lx) called\n", (long) sema)); } -void down_sema _P1(sema, type_sema sema) +int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) { - dprintf(("down_sema(%lx) called\n", (long) sema)); + dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag)); dprintf(("down_sema(%lx) return\n", (long) sema)); + return -1; } void up_sema _P1(sema, type_sema sema) diff --git a/Python/thread_nt.h b/Python/thread_nt.h index 453e942..18b01be 100644 --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -223,7 +223,10 @@ void free_sema(type_sema aSemaphore) CloseHandle((HANDLE) aSemaphore); } -void down_sema(type_sema aSemaphore) +/* + XXX must do something about waitflag + */ +int down_sema(type_sema aSemaphore, int waitflag) { DWORD waitResult; @@ -232,6 +235,7 @@ void down_sema(type_sema aSemaphore) waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE); dprintf(("%ld: down_sema(%lx) return: %l\n", get_thread_ident(),(long) aSemaphore, waitResult)); + return 0; } void up_sema(type_sema aSemaphore) diff --git a/Python/thread_os2.h b/Python/thread_os2.h index f9eda92..00a5244 100644 --- a/Python/thread_os2.h +++ b/Python/thread_os2.h @@ -203,9 +203,9 @@ void free_sema(type_sema aSemaphore) } -void down_sema(type_sema aSemaphore) +void down_sema(type_sema aSemaphore, int waitflag) { - + return -1; } void up_sema(type_sema aSemaphore) diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 0485e66..a43a2f8 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -274,10 +274,11 @@ void free_sema _P1(sema, type_sema sema) dprintf(("free_sema(%lx) called\n", (long) sema)); } -void down_sema _P1(sema, type_sema sema) +int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) { - dprintf(("down_sema(%lx) called\n", (long) sema)); + dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag)); dprintf(("down_sema(%lx) return\n", (long) sema)); + return -1; } void up_sema _P1(sema, type_sema sema) diff --git a/Python/thread_sgi.h b/Python/thread_sgi.h index 654d4ae..79357a5 100644 --- a/Python/thread_sgi.h +++ b/Python/thread_sgi.h @@ -423,12 +423,19 @@ void free_sema _P1(sema, type_sema sema) usfreesema((usema_t *) sema, shared_arena); } -void down_sema _P1(sema, type_sema sema) +int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) { + int success; + dprintf(("down_sema(%lx) called\n", (long) sema)); - if (uspsema((usema_t *) sema) < 0) - perror("uspsema"); + if (waitflag) + success = uspsema((usema_t *) sema); + else + success = uscpsema((usema_t *) sema); + if (success < 0) + perror(waitflag ? "uspsema" : "uscpsema"); dprintf(("down_sema(%lx) return\n", (long) sema)); + return success; } void up_sema _P1(sema, type_sema sema) diff --git a/Python/thread_solaris.h b/Python/thread_solaris.h index f7fd056..871affa 100644 --- a/Python/thread_solaris.h +++ b/Python/thread_solaris.h @@ -25,6 +25,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <stdlib.h> #include <stdio.h> #include <unistd.h> +#include <errno.h> #include </usr/include/thread.h> #undef _POSIX_THREADS @@ -211,12 +212,25 @@ void free_sema _P1(sema, type_sema sema) free((void *) sema); } -void down_sema _P1(sema, type_sema sema) +int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) { + int success; + dprintf(("down_sema(%lx) called\n", (long) sema)); - if (sema_wait((sema_t *) sema)) - perror("sema_wait"); - dprintf(("down_sema(%lx) return\n", (long) sema)); + if (waitflag) + success = sema_wait((sema_t *) sema); + else + success = sema_trywait((sema_t *) sema); + if (success < 0) { + if (errno == EBUSY) + success = 0; + else + perror("sema_wait"); + } + else + success = !success; + dprintf(("down_sema(%lx) return %d\n", (long) sema, success)); + return success; } void up_sema _P1(sema, type_sema sema) |