nsprpub/pr/src/misc/pripcsem.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * File: pripcsem.c
michael@0 8 *
michael@0 9 * Description: implements the named semaphores API in prsemipc.h
michael@0 10 * for classic NSPR. If _PR_HAVE_NAMED_SEMAPHORES is not defined,
michael@0 11 * the named semaphore functions all fail with the error code
michael@0 12 * PR_NOT_IMPLEMENTED_ERROR.
michael@0 13 */
michael@0 14
michael@0 15 #include "primpl.h"
michael@0 16
michael@0 17 #ifdef _PR_PTHREADS
michael@0 18
michael@0 19 #error "This file should not be compiled for the pthreads version"
michael@0 20
michael@0 21 #else
michael@0 22
michael@0 23 #ifndef _PR_HAVE_NAMED_SEMAPHORES
michael@0 24
michael@0 25 PRSem * _PR_MD_OPEN_SEMAPHORE(
michael@0 26 const char *osname, PRIntn flags, PRIntn mode, PRUintn value)
michael@0 27 {
michael@0 28 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
michael@0 29 return NULL;
michael@0 30 }
michael@0 31
michael@0 32 PRStatus _PR_MD_WAIT_SEMAPHORE(PRSem *sem)
michael@0 33 {
michael@0 34 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
michael@0 35 return PR_FAILURE;
michael@0 36 }
michael@0 37
michael@0 38 PRStatus _PR_MD_POST_SEMAPHORE(PRSem *sem)
michael@0 39 {
michael@0 40 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
michael@0 41 return PR_FAILURE;
michael@0 42 }
michael@0 43
michael@0 44 PRStatus _PR_MD_CLOSE_SEMAPHORE(PRSem *sem)
michael@0 45 {
michael@0 46 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
michael@0 47 return PR_FAILURE;
michael@0 48 }
michael@0 49
michael@0 50 PRStatus _PR_MD_DELETE_SEMAPHORE(const char *osname)
michael@0 51 {
michael@0 52 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
michael@0 53 return PR_FAILURE;
michael@0 54 }
michael@0 55
michael@0 56 #endif /* !_PR_HAVE_NAMED_SEMAPHORES */
michael@0 57
michael@0 58 PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
michael@0 59 const char *name, PRIntn flags, PRIntn mode, PRUintn value)
michael@0 60 {
michael@0 61 char osname[PR_IPC_NAME_SIZE];
michael@0 62
michael@0 63 if (!_pr_initialized) _PR_ImplicitInitialization();
michael@0 64 if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem)
michael@0 65 == PR_FAILURE) {
michael@0 66 return NULL;
michael@0 67 }
michael@0 68 return _PR_MD_OPEN_SEMAPHORE(osname, flags, mode, value);
michael@0 69 }
michael@0 70
michael@0 71 PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem *sem)
michael@0 72 {
michael@0 73 return _PR_MD_WAIT_SEMAPHORE(sem);
michael@0 74 }
michael@0 75
michael@0 76 PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem *sem)
michael@0 77 {
michael@0 78 return _PR_MD_POST_SEMAPHORE(sem);
michael@0 79 }
michael@0 80
michael@0 81 PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem)
michael@0 82 {
michael@0 83 return _PR_MD_CLOSE_SEMAPHORE(sem);
michael@0 84 }
michael@0 85
michael@0 86 PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name)
michael@0 87 {
michael@0 88 char osname[PR_IPC_NAME_SIZE];
michael@0 89
michael@0 90 if (!_pr_initialized) _PR_ImplicitInitialization();
michael@0 91 if (_PR_MakeNativeIPCName(name, osname, sizeof(osname), _PRIPCSem)
michael@0 92 == PR_FAILURE) {
michael@0 93 return PR_FAILURE;
michael@0 94 }
michael@0 95 return _PR_MD_DELETE_SEMAPHORE(osname);
michael@0 96 }
michael@0 97
michael@0 98 #endif /* _PR_PTHREADS */

mercurial