summaryrefslogtreecommitdiff
path: root/innobase/os/os0shm.c
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2001-02-17 14:19:19 +0200
committerunknown <monty@donna.mysql.com>2001-02-17 14:19:19 +0200
commit2662b59306ef0cd495fa6e2edf7129e58a11393a (patch)
treebfe39951a73e906579ab819bf5198ad8f3a64a36 /innobase/os/os0shm.c
parent66de55a56bdcf2f7a9c0c4f8e19b3e761475e202 (diff)
downloadmariadb-git-2662b59306ef0cd495fa6e2edf7129e58a11393a.tar.gz
Added Innobase to source distribution
Docs/manual.texi: Added Innobase documentation configure.in: Incremented version include/my_base.h: Added option for Innobase myisam/mi_check.c: cleanup mysql-test/t/bdb.test: cleanup mysql-test/t/innobase.test: Extended with new tests from bdb.test mysql-test/t/merge.test: Added test of SHOW create mysys/my_init.c: Fix for UNIXWARE 7 scripts/mysql_install_db.sh: Always write how to start mysqld scripts/safe_mysqld.sh: Fixed type sql/ha_innobase.cc: Update to new version sql/ha_innobase.h: Update to new version sql/handler.h: Added 'update_table_comment()' and 'append_create_info()' sql/sql_delete.cc: Fixes for Innobase sql/sql_select.cc: Fixes for Innobase sql/sql_show.cc: Append create information (for MERGE tables) sql/sql_update.cc: Fixes for Innobase
Diffstat (limited to 'innobase/os/os0shm.c')
-rw-r--r--innobase/os/os0shm.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/innobase/os/os0shm.c b/innobase/os/os0shm.c
new file mode 100644
index 00000000000..e03440cd4f4
--- /dev/null
+++ b/innobase/os/os0shm.c
@@ -0,0 +1,146 @@
+/******************************************************
+The interface to the operating system
+shared memory primitives
+
+(c) 1995 Innobase Oy
+
+Created 9/23/1995 Heikki Tuuri
+*******************************************************/
+
+#include "os0shm.h"
+#ifdef UNIV_NONINL
+#include "os0shm.ic"
+#endif
+
+#ifdef __WIN__
+#include "windows.h"
+
+typedef HANDLE os_shm_t;
+#endif
+
+/********************************************************************
+Creates an area of shared memory. It can be named so that
+different processes may access it in the same computer.
+If an area with the same name already exists, returns
+a handle to that area (where the size of the area is
+not changed even if this call requests a different size).
+To use the area, it first has to be mapped to the process
+address space by os_shm_map. */
+
+os_shm_t
+os_shm_create(
+/*==========*/
+ /* out, own: handle to the shared
+ memory area, NULL if error */
+ ulint size, /* in: area size < 4 GB */
+ char* name) /* in: name of the area as a null-terminated
+ string */
+{
+#ifdef __WIN__
+ os_shm_t shm;
+
+ ut_a(name);
+ ut_a(size > 0);
+ ut_a(size < 0xFFFFFFFF);
+
+ /* In Windows NT shared memory is created as a memory mapped
+ file */
+ shm = CreateFileMapping((HANDLE)0xFFFFFFFF, /* use operating system
+ swap file as the backing
+ file */
+ NULL, /* default security
+ descriptor */
+ PAGE_READWRITE, /* allow reading and
+ writing */
+ 0, /* size must be less
+ than 4 GB */
+ (DWORD)size,
+ name);
+ return(shm);
+#else
+ UT_NOT_USED(size);
+ UT_NOT_USED(name);
+
+ return(NULL);
+#endif
+}
+
+/***************************************************************************
+Frees a shared memory area. The area can be freed only after it
+has been unmapped in all the processes where it was mapped. */
+
+ibool
+os_shm_free(
+/*========*/
+ /* out: TRUE if success */
+ os_shm_t shm) /* in, own: handle to a shared memory area */
+{
+#ifdef __WIN__
+
+ BOOL ret;
+
+ ut_a(shm);
+
+ ret = CloseHandle(shm);
+
+ if (ret) {
+ return(TRUE);
+ } else {
+ return(FALSE);
+ }
+#else
+ UT_NOT_USED(shm);
+#endif
+}
+
+/***************************************************************************
+Maps a shared memory area in the address space of a process. */
+
+void*
+os_shm_map(
+/*=======*/
+ /* out: address of the area, NULL if error */
+ os_shm_t shm) /* in: handle to a shared memory area */
+{
+#ifdef __WIN__
+ void* mem;
+
+ ut_a(shm);
+
+ mem = MapViewOfFile(shm,
+ FILE_MAP_ALL_ACCESS, /* read and write access
+ allowed */
+ 0, /* map from start of */
+ 0, /* area */
+ 0); /* map the whole area */
+ return(mem);
+#else
+ UT_NOT_USED(shm);
+#endif
+}
+
+/***************************************************************************
+Unmaps a shared memory area from the address space of a process. */
+
+ibool
+os_shm_unmap(
+/*=========*/
+ /* out: TRUE if succeed */
+ void* addr) /* in: address of the area */
+{
+#ifdef __WIN__
+ BOOL ret;
+
+ ut_a(addr);
+
+ ret = UnmapViewOfFile(addr);
+
+ if (ret) {
+ return(TRUE);
+ } else {
+ return(FALSE);
+ }
+#else
+ UT_NOT_USED(addr);
+#endif
+}