andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: /* andre@0: * File: pripcsem.c andre@0: * andre@0: * Description: implements the named semaphores API in prsemipc.h andre@0: * for classic NSPR. If _PR_HAVE_NAMED_SEMAPHORES is not defined, andre@0: * the named semaphore functions all fail with the error code andre@0: * PR_NOT_IMPLEMENTED_ERROR. andre@0: */ andre@0: andre@0: #include "primpl.h" andre@0: andre@0: #ifdef _PR_PTHREADS andre@0: andre@0: #error "This file should not be compiled for the pthreads version" andre@0: andre@0: #else andre@0: andre@0: #ifndef _PR_HAVE_NAMED_SEMAPHORES andre@0: andre@0: PRSem * _PR_MD_OPEN_SEMAPHORE( andre@0: const char *osname, PRIntn flags, PRIntn mode, PRUintn value) andre@0: { andre@0: PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); andre@0: return NULL; andre@0: } andre@0: andre@0: PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem *sem) andre@0: { andre@0: PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); andre@0: return PR_FAILURE; andre@0: } andre@0: andre@0: PRStatus _PR_MD_POST_SEMAPHORE(PRSem *sem) andre@0: { andre@0: PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); andre@0: return PR_FAILURE; andre@0: } andre@0: andre@0: PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem *sem) andre@0: { andre@0: PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); andre@0: return PR_FAILURE; andre@0: } andre@0: andre@0: PRStatus _PR_MD_DELETE_SEMAPHORE(const char *osname) andre@0: { andre@0: PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); andre@0: return PR_FAILURE; andre@0: } andre@0: andre@0: #endif /* !_PR_HAVE_NAMED_SEMAPHORES */ andre@0: andre@0: PR_IMPLEMENT(PRSem *) PR_OpenSemaphore( andre@0: const char *name, PRIntn flags, PRIntn mode, PRUintn value) andre@0: { andre@0: char osname[PR_IPC_NAME_SIZE]; andre@0: andre@0: if (!_pr_initialized) _PR_ImplicitInitialization(); andre@0: if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) andre@0: == PR_FAILURE) { andre@0: return NULL; andre@0: } andre@0: return _PR_MD_OPEN_SEMAPHORE(osname, flags, mode, value); andre@0: } andre@0: andre@0: PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem *sem) andre@0: { andre@0: return _PR_MD_WAIT_SEMAPHORE(sem); andre@0: } andre@0: andre@0: PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem *sem) andre@0: { andre@0: return _PR_MD_POST_SEMAPHORE(sem); andre@0: } andre@0: andre@0: PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem) andre@0: { andre@0: return _PR_MD_CLOSE_SEMAPHORE(sem); andre@0: } andre@0: andre@0: PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) andre@0: { andre@0: char osname[PR_IPC_NAME_SIZE]; andre@0: andre@0: if (!_pr_initialized) _PR_ImplicitInitialization(); andre@0: if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem) andre@0: == PR_FAILURE) { andre@0: return PR_FAILURE; andre@0: } andre@0: return _PR_MD_DELETE_SEMAPHORE(osname); andre@0: } andre@0: andre@0: #endif /* _PR_PTHREADS */