diff options
author | Robert Haas <rhaas@postgresql.org> | 2013-10-09 21:05:02 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2013-10-09 21:05:02 -0400 |
commit | 0ac5e5a7e152504c71ce2168acc9cef7fde7893c (patch) | |
tree | 9060ae6a71ae9b7ce5fda85846d3060cdc215432 /src/include/storage/dsm_impl.h | |
parent | f566515192461acd8d9c232f48ddac3fc965cfd8 (diff) |
Allow dynamic allocation of shared memory segments.
Patch by myself and Amit Kapila. Design help from Noah Misch. Review
by Andres Freund.
Diffstat (limited to 'src/include/storage/dsm_impl.h')
-rw-r--r-- | src/include/storage/dsm_impl.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/include/storage/dsm_impl.h b/src/include/storage/dsm_impl.h new file mode 100644 index 00000000000..13f1f48b237 --- /dev/null +++ b/src/include/storage/dsm_impl.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------------------- + * + * dsm_impl.h + * low-level dynamic shared memory primitives + * + * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/storage/dsm_impl.h + * + *------------------------------------------------------------------------- + */ +#ifndef DSM_IMPL_H +#define DSM_IMPL_H + +/* Dynamic shared memory implementations. */ +#define DSM_IMPL_NONE 0 +#define DSM_IMPL_POSIX 1 +#define DSM_IMPL_SYSV 2 +#define DSM_IMPL_WINDOWS 3 +#define DSM_IMPL_MMAP 4 + +/* + * Determine which dynamic shared memory implementations will be supported + * on this platform, and which one will be the default. + */ +#ifdef WIN32 +#define USE_DSM_WINDOWS +#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_WINDOWS +#else +#ifdef HAVE_SHM_OPEN +#define USE_DSM_POSIX +#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_POSIX +#endif +#define USE_DSM_SYSV +#ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE +#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV +#endif +#define USE_DSM_MMAP +#endif + +/* GUC. */ +extern int dynamic_shared_memory_type; + +/* + * Directory for on-disk state. + * + * This is used by all implementations for crash recovery and by the mmap + * implementation for storage. + */ +#define PG_DYNSHMEM_DIR "pg_dynshmem" +#define PG_DYNSHMEM_MMAP_FILE_PREFIX "mmap." + +/* A "name" for a dynamic shared memory segment. */ +typedef uint32 dsm_handle; + +/* All the shared-memory operations we know about. */ +typedef enum +{ + DSM_OP_CREATE, + DSM_OP_ATTACH, + DSM_OP_DETACH, + DSM_OP_RESIZE, + DSM_OP_DESTROY +} dsm_op; + +/* Create, attach to, detach from, resize, or destroy a segment. */ +extern bool dsm_impl_op(dsm_op op, dsm_handle handle, uint64 request_size, + void **impl_private, void **mapped_address, uint64 *mapped_size, + int elevel); + +/* Some implementations cannot resize segments. Can this one? */ +extern bool dsm_impl_can_resize(void); + +#endif /* DSM_IMPL_H */ |