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 ** prshm.c -- NSPR Named Shared Memory
8 **
9 ** lth. Jul-1999.
10 */
11 #include <string.h>
12 #include "primpl.h"
13
14 extern PRLogModuleInfo *_pr_shm_lm;
15
16
17 #if defined PR_HAVE_SYSV_NAMED_SHARED_MEMORY
18 /* SysV implementation is in pr/src/md/unix/uxshm.c */
19 #elif defined PR_HAVE_POSIX_NAMED_SHARED_MEMORY
20 /* Posix implementation is in pr/src/md/unix/uxshm.c */
21 #elif defined PR_HAVE_WIN32_NAMED_SHARED_MEMORY
22 /* Win32 implementation is in pr/src/md/windows/w32shm.c */
23 #else
24 /*
25 ** there is no named_shared_memory
26 */
_MD_OpenSharedMemory(const char * name,PRSize size,PRIntn flags,PRIntn mode)27 extern PRSharedMemory* _MD_OpenSharedMemory( const char *name, PRSize size, PRIntn flags, PRIntn mode )
28 {
29 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
30 return NULL;
31 }
32
_MD_AttachSharedMemory(PRSharedMemory * shm,PRIntn flags)33 extern void * _MD_AttachSharedMemory( PRSharedMemory *shm, PRIntn flags )
34 {
35 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
36 return NULL;
37 }
38
_MD_DetachSharedMemory(PRSharedMemory * shm,void * addr)39 extern PRStatus _MD_DetachSharedMemory( PRSharedMemory *shm, void *addr )
40 {
41 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
42 return PR_FAILURE;
43 }
44
_MD_CloseSharedMemory(PRSharedMemory * shm)45 extern PRStatus _MD_CloseSharedMemory( PRSharedMemory *shm )
46 {
47 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
48 return PR_FAILURE;
49 }
50
_MD_DeleteSharedMemory(const char * name)51 extern PRStatus _MD_DeleteSharedMemory( const char *name )
52 {
53 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
54 return PR_FAILURE;
55 }
56 #endif /* HAVE_SYSV_NAMED_SHARED_MEMORY */
57
58 /*
59 ** FUNCTION: PR_OpenSharedMemory()
60 **
61 */
62 PR_IMPLEMENT( PRSharedMemory * )
PR_OpenSharedMemory(const char * name,PRSize size,PRIntn flags,PRIntn mode)63 PR_OpenSharedMemory(
64 const char *name,
65 PRSize size,
66 PRIntn flags,
67 PRIntn mode
68 )
69 {
70 if (!_pr_initialized) {
71 _PR_ImplicitInitialization();
72 }
73 return( _PR_MD_OPEN_SHARED_MEMORY( name, size, flags, mode ));
74 } /* end PR_OpenSharedMemory() */
75
76 /*
77 ** FUNCTION: PR_AttachSharedMemory()
78 **
79 */
80 PR_IMPLEMENT( void * )
PR_AttachSharedMemory(PRSharedMemory * shm,PRIntn flags)81 PR_AttachSharedMemory(
82 PRSharedMemory *shm,
83 PRIntn flags
84 )
85 {
86 return( _PR_MD_ATTACH_SHARED_MEMORY( shm, flags ));
87 } /* end PR_AttachSharedMemory() */
88
89 /*
90 ** FUNCTION: PR_DetachSharedMemory()
91 **
92 */
93 PR_IMPLEMENT( PRStatus )
PR_DetachSharedMemory(PRSharedMemory * shm,void * addr)94 PR_DetachSharedMemory(
95 PRSharedMemory *shm,
96 void *addr
97 )
98 {
99 return( _PR_MD_DETACH_SHARED_MEMORY( shm, addr ));
100 } /* end PR_DetachSharedMemory() */
101
102 /*
103 ** FUNCTION: PR_CloseSharedMemory()
104 **
105 */
106 PR_IMPLEMENT( PRStatus )
PR_CloseSharedMemory(PRSharedMemory * shm)107 PR_CloseSharedMemory(
108 PRSharedMemory *shm
109 )
110 {
111 return( _PR_MD_CLOSE_SHARED_MEMORY( shm ));
112 } /* end PR_CloseSharedMemory() */
113
114 /*
115 ** FUNCTION: PR_DeleteSharedMemory()
116 **
117 */
118 PR_EXTERN( PRStatus )
PR_DeleteSharedMemory(const char * name)119 PR_DeleteSharedMemory(
120 const char *name
121 )
122 {
123 if (!_pr_initialized) {
124 _PR_ImplicitInitialization();
125 }
126 return(_PR_MD_DELETE_SHARED_MEMORY( name ));
127 } /* end PR_DestroySharedMemory() */
128 /* end prshm.c */
129