mem.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*-------------------------------------------------------------------------
  2. *
  3. * mem.h
  4. * portability definitions for various memory operations
  5. *
  6. * Copyright (c) 2001-2022, PostgreSQL Global Development Group
  7. *
  8. * src/include/portability/mem.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef MEM_H
  13. #define MEM_H
  14. #define IPCProtection (0600) /* access/modify by user only */
  15. #ifdef SHM_SHARE_MMU /* use intimate shared memory on Solaris */
  16. #define PG_SHMAT_FLAGS SHM_SHARE_MMU
  17. #else
  18. #define PG_SHMAT_FLAGS 0
  19. #endif
  20. /* Linux prefers MAP_ANONYMOUS, but the flag is called MAP_ANON on other systems. */
  21. #ifndef MAP_ANONYMOUS
  22. #define MAP_ANONYMOUS MAP_ANON
  23. #endif
  24. /* BSD-derived systems have MAP_HASSEMAPHORE, but it's not present (or needed) on Linux. */
  25. #ifndef MAP_HASSEMAPHORE
  26. #define MAP_HASSEMAPHORE 0
  27. #endif
  28. /*
  29. * BSD-derived systems use the MAP_NOSYNC flag to prevent dirty mmap(2)
  30. * pages from being gratuitously flushed to disk.
  31. */
  32. #ifndef MAP_NOSYNC
  33. #define MAP_NOSYNC 0
  34. #endif
  35. #define PG_MMAP_FLAGS (MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE)
  36. /* Some really old systems don't define MAP_FAILED. */
  37. #ifndef MAP_FAILED
  38. #define MAP_FAILED ((void *) -1)
  39. #endif
  40. #endif /* MEM_H */