13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include <windows.h>
27 #include <errno.h>
28
29 #include "shmem_md.h"
30 #include "sysShmem.h"
31 #include "shmemBase.h" /* for exitTransportWithError */
32
33 /*
34 * These functions are not completely universal. For now, they are used
35 * exclusively for Jbug's shared memory transport mechanism. They have
36 * been implemented on Win32 only so far, so the abstractions may not be correct
37 * yet.
38 */
39
40 static HANDLE memHandle = NULL;
41
42 #ifdef DEBUG
43 #define sysAssert(expression) { \
44 if (!(expression)) { \
45 exitTransportWithError \
46 ("\"%s\", line %d: assertion failure\n", \
47 __FILE__, __DATE__, __LINE__); \
48 } \
49 }
50 #else
51 #define sysAssert(expression) ((void) 0)
52 #endif
53
54 int
55 sysSharedMemCreate(const char *name, int length,
56 sys_shmem_t *mem, void **buffer)
57 {
58 void *mappedMemory;
59 HANDLE memHandle;
60
61 sysAssert(buffer);
62 sysAssert(name);
63 sysAssert(length > 0);
64
65 memHandle =
66 CreateFileMapping(INVALID_HANDLE_VALUE, /* backed by page file */
67 NULL, /* no inheritance */
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include <windows.h>
27 #include <errno.h>
28
29 #include "shmem_md.h"
30 #include "sysShmem.h"
31 #include "shmemBase.h" /* for exitTransportWithError */
32
33 /* Use THIS_FILE when it is available. */
34 #ifndef THIS_FILE
35 #define THIS_FILE __FILE__
36 #endif
37
38 /*
39 * These functions are not completely universal. For now, they are used
40 * exclusively for Jbug's shared memory transport mechanism. They have
41 * been implemented on Win32 only so far, so the abstractions may not be correct
42 * yet.
43 */
44
45 static HANDLE memHandle = NULL;
46
47 #ifdef DEBUG
48 #define sysAssert(expression) { \
49 if (!(expression)) { \
50 exitTransportWithError \
51 ("\"%s\", line %d: assertion failure\n", \
52 THIS_FILE, __DATE__, __LINE__); \
53 } \
54 }
55 #else
56 #define sysAssert(expression) ((void) 0)
57 #endif
58
59 int
60 sysSharedMemCreate(const char *name, int length,
61 sys_shmem_t *mem, void **buffer)
62 {
63 void *mappedMemory;
64 HANDLE memHandle;
65
66 sysAssert(buffer);
67 sysAssert(name);
68 sysAssert(length > 0);
69
70 memHandle =
71 CreateFileMapping(INVALID_HANDLE_VALUE, /* backed by page file */
72 NULL, /* no inheritance */
|