From 91de97c45aedbd0e2d0fb1cd28dc95a2f51a33c7 Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Wed, 22 Mar 2000 18:21:12 +0000 Subject: [PATCH] Provide a default implementation of interprocess named semaphore functions (which just fail with PR_NOT_IMPLEMENTED_ERROR) if neither POSIX nor System V semaphores are supported. Fixed an error in the comments. git-svn-id: svn://10.0.0.236/trunk@63749 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/nsprpub/pr/src/pthreads/ptsynch.c | 52 ++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/mozilla/nsprpub/pr/src/pthreads/ptsynch.c b/mozilla/nsprpub/pr/src/pthreads/ptsynch.c index b3ff68da05e..5cdd0fd3a8e 100644 --- a/mozilla/nsprpub/pr/src/pthreads/ptsynch.c +++ b/mozilla/nsprpub/pr/src/pthreads/ptsynch.c @@ -248,7 +248,7 @@ static PRIntn pt_TimedWait( /* - * Notifies just get posted to the to the protecting mutex. The + * Notifies just get posted to the protecting mutex. The * actual notification is done when the lock is released so that * MP systems don't contend for a lock that they can't have. */ @@ -649,6 +649,14 @@ PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value) return NULL; } +/* + * Define the interprocess named semaphore functions. + * There are three implementations: + * 1. POSIX semaphore based; + * 2. System V semaphore based; + * 3. unsupported (fails with PR_NOT_IMPLEMENTED_ERROR). + */ + #ifdef _PR_HAVE_POSIX_SEMAPHORES #include @@ -750,9 +758,7 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) return PR_SUCCESS; } -#endif /* _PR_HAVE_POSIX_SEMAPHORES */ - -#ifdef _PR_HAVE_SYSV_SEMAPHORES +#elif defined(_PR_HAVE_SYSV_SEMAPHORES) #include #include @@ -961,7 +967,43 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) return PR_SUCCESS; } -#endif /* _PR_HAVE_SYSV_SEMAPHORES */ +#else /* neither POSIX nor System V semaphores are available */ + +PR_IMPLEMENT(PRSem *) PR_OpenSemaphore( + const char *name, + PRIntn flags, + PRIntn mode, + PRUintn value) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return NULL; +} + +PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem *sem) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem *sem) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +#endif /* end of interprocess named semaphore functions */ /**************************************************************/ /**************************************************************/