dsm_impl.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*-------------------------------------------------------------------------
  2. *
  3. * dsm_impl.h
  4. * low-level dynamic shared memory primitives
  5. *
  6. * Portions Copyright (c) 1996-2016, 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. /* Dynamic shared memory implementations. */
  16. #define DSM_IMPL_NONE 0
  17. #define DSM_IMPL_POSIX 1
  18. #define DSM_IMPL_SYSV 2
  19. #define DSM_IMPL_WINDOWS 3
  20. #define DSM_IMPL_MMAP 4
  21. /*
  22. * Determine which dynamic shared memory implementations will be supported
  23. * on this platform, and which one will be the default.
  24. */
  25. #ifdef WIN32
  26. #define USE_DSM_WINDOWS
  27. #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_WINDOWS
  28. #else
  29. #ifdef HAVE_SHM_OPEN
  30. #define USE_DSM_POSIX
  31. #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_POSIX
  32. #endif
  33. #define USE_DSM_SYSV
  34. #ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE
  35. #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV
  36. #endif
  37. #define USE_DSM_MMAP
  38. #endif
  39. /* GUC. */
  40. extern int dynamic_shared_memory_type;
  41. /*
  42. * Directory for on-disk state.
  43. *
  44. * This is used by all implementations for crash recovery and by the mmap
  45. * implementation for storage.
  46. */
  47. #define PG_DYNSHMEM_DIR "pg_dynshmem"
  48. #define PG_DYNSHMEM_MMAP_FILE_PREFIX "mmap."
  49. /* A "name" for a dynamic shared memory segment. */
  50. typedef uint32 dsm_handle;
  51. /* All the shared-memory operations we know about. */
  52. typedef enum
  53. {
  54. DSM_OP_CREATE,
  55. DSM_OP_ATTACH,
  56. DSM_OP_DETACH,
  57. DSM_OP_RESIZE,
  58. DSM_OP_DESTROY
  59. } dsm_op;
  60. /* Create, attach to, detach from, resize, or destroy a segment. */
  61. extern bool dsm_impl_op(dsm_op op, dsm_handle handle, Size request_size,
  62. void **impl_private, void **mapped_address, Size *mapped_size,
  63. int elevel);
  64. /* Some implementations cannot resize segments. Can this one? */
  65. extern bool dsm_impl_can_resize(void);
  66. /* Implementation-dependent actions required to keep segment until shutdown. */
  67. extern void dsm_impl_pin_segment(dsm_handle handle, void *impl_private);
  68. #endif /* DSM_IMPL_H */