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