From cf1474b73ad3e4085af220f3845b75b201974d38 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 8 Oct 1996 14:17:53 +0000 Subject: Sjoerd's thread changes (including down_sema typo fix). Note: waitflag not supported on NT. --- Python/thread_solaris.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'Python/thread_solaris.h') diff --git a/Python/thread_solaris.h b/Python/thread_solaris.h index f7fd056922..871affa096 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 #include #include +#include #include #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) -- cgit v1.2.1