VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/pripcsem.h@ 22683

最後變更 在這個檔案從22683是 11551,由 vboxsync 提交於 16 年 前

API/xpcom: prefix any C symbols in VBoxXPCOM.so, to avoid namespace pollution. Enabled only on Linux at the moment.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.4 KB
 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/*
39 * File: pripcsem.h
40 *
41 * Description: named semaphores for interprocess
42 * synchronization
43 *
44 * Unrelated processes obtain access to a shared semaphore
45 * by specifying its name.
46 *
47 * Our goal is to support named semaphores on at least
48 * Unix and Win32 platforms. The implementation will use
49 * one of the three native semaphore APIs: POSIX, System V,
50 * and Win32.
51 *
52 * Because POSIX named semaphores have kernel persistence,
53 * we are forced to have a delete function in this API.
54 */
55
56#ifndef pripcsem_h___
57#define pripcsem_h___
58
59#include "prtypes.h"
60#include "prio.h"
61
62#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
63#define PR_OpenSemaphore VBoxNsprPR_OpenSemaphore
64#define PR_WaitSemaphore VBoxNsprPR_WaitSemaphore
65#define PR_PostSemaphore VBoxNsprPR_PostSemaphore
66#define PR_CloseSemaphore VBoxNsprPR_CloseSemaphore
67#define PR_DeleteSemaphore VBoxNsprPR_DeleteSemaphore
68#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
69
70PR_BEGIN_EXTERN_C
71
72/*
73 * PRSem is an opaque structure that represents a named
74 * semaphore.
75 */
76typedef struct PRSem PRSem;
77
78/*
79 * PR_OpenSemaphore --
80 *
81 * Create or open a named semaphore with the specified name.
82 * A handle to the semaphore is returned.
83 *
84 * If the named semaphore doesn't exist and the PR_SEM_CREATE
85 * flag is specified, the named semaphore is created. The
86 * created semaphore needs to be removed from the system with
87 * a PR_DeleteSemaphore call.
88 *
89 * If PR_SEM_CREATE is specified, the third argument is the
90 * access permission bits of the new semaphore (same
91 * interpretation as the mode argument to PR_Open) and the
92 * fourth argument is the initial value of the new semaphore.
93 * If PR_SEM_CREATE is not specified, the third and fourth
94 * arguments are ignored.
95 */
96
97#define PR_SEM_CREATE 0x1 /* create if not exist */
98#define PR_SEM_EXCL 0x2 /* fail if already exists */
99
100NSPR_API(PRSem *) PR_OpenSemaphore(
101 const char *name, PRIntn flags, PRIntn mode, PRUintn value);
102
103/*
104 * PR_WaitSemaphore --
105 *
106 * If the value of the semaphore is > 0, decrement the value and return.
107 * If the value is 0, sleep until the value becomes > 0, then decrement
108 * the value and return.
109 *
110 * The "test and decrement" operation is performed atomically.
111 */
112
113NSPR_API(PRStatus) PR_WaitSemaphore(PRSem *sem);
114
115/*
116 * PR_PostSemaphore --
117 *
118 * Increment the value of the named semaphore by 1.
119 */
120
121NSPR_API(PRStatus) PR_PostSemaphore(PRSem *sem);
122
123/*
124 * PR_CloseSemaphore --
125 *
126 * Close a named semaphore handle.
127 */
128
129NSPR_API(PRStatus) PR_CloseSemaphore(PRSem *sem);
130
131/*
132 * PR_DeleteSemaphore --
133 *
134 * Remove a named semaphore from the system.
135 */
136
137NSPR_API(PRStatus) PR_DeleteSemaphore(const char *name);
138
139PR_END_EXTERN_C
140
141#endif /* pripcsem_h___ */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette