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