mirror of
https://github.com/postgres/postgres.git
synced 2026-01-26 09:41:40 +03:00
Remove PG_MMAP_FLAGS from mem.h
Based on name of the macro, it was implied that it could be used for all mmap() calls on portability grounds. However, its use is limited to sysv_shmem.c, for CreateAnonymousSegment(). This commit removes the declaration, reducing the confusion around it as a portability tweak, being limited to SysV-style shared memory. This macro has been introduced inb0fc0df936for sysv_shmem.c, originally. It has been moved to mem.h in0ac5e5a7e1a bit later. Suggested by: Peter Eisentraut <peter@eisentraut.org> Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://postgr.es/m/CAExHW5vTWABxuM5fbQcFkGuTLwaxuZDEE2vtx2WuMUWk6JnF4g@mail.gmail.com Discussion: https://postgr.es/m/12add41a-7625-4639-a394-a5563e349322@eisentraut.org
This commit is contained in:
@@ -602,6 +602,7 @@ CreateAnonymousSegment(Size *size)
|
||||
Size allocsize = *size;
|
||||
void *ptr = MAP_FAILED;
|
||||
int mmap_errno = 0;
|
||||
int mmap_flags = MAP_SHARED | MAP_ANONYMOUS | MAP_HASSEMAPHORE;
|
||||
|
||||
#ifndef MAP_HUGETLB
|
||||
/* PGSharedMemoryCreate should have dealt with this case */
|
||||
@@ -613,15 +614,15 @@ CreateAnonymousSegment(Size *size)
|
||||
* Round up the request size to a suitable large value.
|
||||
*/
|
||||
Size hugepagesize;
|
||||
int mmap_flags;
|
||||
int huge_mmap_flags;
|
||||
|
||||
GetHugePageSize(&hugepagesize, &mmap_flags);
|
||||
GetHugePageSize(&hugepagesize, &huge_mmap_flags);
|
||||
|
||||
if (allocsize % hugepagesize != 0)
|
||||
allocsize = add_size(allocsize, hugepagesize - (allocsize % hugepagesize));
|
||||
|
||||
ptr = mmap(NULL, allocsize, PROT_READ | PROT_WRITE,
|
||||
PG_MMAP_FLAGS | mmap_flags, -1, 0);
|
||||
mmap_flags | huge_mmap_flags, -1, 0);
|
||||
mmap_errno = errno;
|
||||
if (huge_pages == HUGE_PAGES_TRY && ptr == MAP_FAILED)
|
||||
elog(DEBUG1, "mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m",
|
||||
@@ -645,7 +646,7 @@ CreateAnonymousSegment(Size *size)
|
||||
*/
|
||||
allocsize = *size;
|
||||
ptr = mmap(NULL, allocsize, PROT_READ | PROT_WRITE,
|
||||
PG_MMAP_FLAGS, -1, 0);
|
||||
mmap_flags, -1, 0);
|
||||
mmap_errno = errno;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#define MAP_NOSYNC 0
|
||||
#endif
|
||||
|
||||
#define PG_MMAP_FLAGS (MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE)
|
||||
|
||||
/* Some really old systems don't define MAP_FAILED. */
|
||||
#ifndef MAP_FAILED
|
||||
#define MAP_FAILED ((void *) -1)
|
||||
|
||||
Reference in New Issue
Block a user