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