PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
dsm_impl.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * dsm_impl.h
4  * low-level dynamic shared memory primitives
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/storage/dsm_impl.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef DSM_IMPL_H
14 #define DSM_IMPL_H
15 
16 /* Dynamic shared memory implementations. */
17 #define DSM_IMPL_NONE 0
18 #define DSM_IMPL_POSIX 1
19 #define DSM_IMPL_SYSV 2
20 #define DSM_IMPL_WINDOWS 3
21 #define DSM_IMPL_MMAP 4
22 
23 /*
24  * Determine which dynamic shared memory implementations will be supported
25  * on this platform, and which one will be the default.
26  */
27 #ifdef WIN32
28 #define USE_DSM_WINDOWS
29 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_WINDOWS
30 #else
31 #ifdef HAVE_SHM_OPEN
32 #define USE_DSM_POSIX
33 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_POSIX
34 #endif
35 #define USE_DSM_SYSV
36 #ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE
37 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV
38 #endif
39 #define USE_DSM_MMAP
40 #endif
41 
42 /* GUC. */
44 
45 /*
46  * Directory for on-disk state.
47  *
48  * This is used by all implementations for crash recovery and by the mmap
49  * implementation for storage.
50  */
51 #define PG_DYNSHMEM_DIR "pg_dynshmem"
52 #define PG_DYNSHMEM_MMAP_FILE_PREFIX "mmap."
53 
54 /* A "name" for a dynamic shared memory segment. */
56 
57 /* All the shared-memory operations we know about. */
58 typedef enum
59 {
65 } dsm_op;
66 
67 /* Create, attach to, detach from, resize, or destroy a segment. */
68 extern bool dsm_impl_op(dsm_op op, dsm_handle handle, Size request_size,
69  void **impl_private, void **mapped_address, Size *mapped_size,
70  int elevel);
71 
72 /* Some implementations cannot resize segments. Can this one? */
73 extern bool dsm_impl_can_resize(void);
74 
75 /* Implementation-dependent actions required to keep segment until shutdown. */
76 extern void dsm_impl_pin_segment(dsm_handle handle, void *impl_private,
77  void **impl_private_pm_handle);
78 extern void dsm_impl_unpin_segment(dsm_handle handle, void **impl_private);
79 
80 #endif /* DSM_IMPL_H */
uint32 dsm_handle
Definition: dsm_impl.h:55
void dsm_impl_unpin_segment(dsm_handle handle, void **impl_private)
Definition: dsm_impl.c:1059
void dsm_impl_pin_segment(dsm_handle handle, void *impl_private, void **impl_private_pm_handle)
Definition: dsm_impl.c:1009
bool dsm_impl_can_resize(void)
Definition: dsm_impl.c:207
bool dsm_impl_op(dsm_op op, dsm_handle handle, Size request_size, void **impl_private, void **mapped_address, Size *mapped_size, int elevel)
Definition: dsm_impl.c:162
unsigned int uint32
Definition: c.h:268
static int elevel
Definition: vacuumlazy.c:137
size_t Size
Definition: c.h:356
int dynamic_shared_memory_type
Definition: dsm_impl.c:112
dsm_op
Definition: dsm_impl.h:58