1 /*-------------------------------------------------------------------------
4 * low-level dynamic shared memory primitives
6 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/storage/dsm_impl.h
11 *-------------------------------------------------------------------------
16 /* Dynamic shared memory implementations. */
17 #define DSM_IMPL_POSIX 1
18 #define DSM_IMPL_SYSV 2
19 #define DSM_IMPL_WINDOWS 3
20 #define DSM_IMPL_MMAP 4
23 * Determine which dynamic shared memory implementations will be supported
24 * on this platform, and which one will be the default.
27 #define USE_DSM_WINDOWS
28 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_WINDOWS
32 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_POSIX
35 #ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE
36 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV
42 extern PGDLLIMPORT
int dynamic_shared_memory_type
;
43 extern PGDLLIMPORT
int min_dynamic_shared_memory
;
46 * Directory for on-disk state.
48 * This is used by all implementations for crash recovery and by the mmap
49 * implementation for storage.
51 #define PG_DYNSHMEM_DIR "pg_dynshmem"
52 #define PG_DYNSHMEM_MMAP_FILE_PREFIX "mmap."
54 /* A "name" for a dynamic shared memory segment. */
55 typedef uint32 dsm_handle
;
57 /* Sentinel value to use for invalid DSM handles. */
58 #define DSM_HANDLE_INVALID ((dsm_handle) 0)
60 /* All the shared-memory operations we know about. */
69 /* Create, attach to, detach from, resize, or destroy a segment. */
70 extern bool dsm_impl_op(dsm_op op
, dsm_handle handle
, Size request_size
,
71 void **impl_private
, void **mapped_address
, Size
*mapped_size
,
74 /* Implementation-dependent actions required to keep segment until shutdown. */
75 extern void dsm_impl_pin_segment(dsm_handle handle
, void *impl_private
,
76 void **impl_private_pm_handle
);
77 extern void dsm_impl_unpin_segment(dsm_handle handle
, void **impl_private
);
79 #endif /* DSM_IMPL_H */