From b8bf06b8985ea8b93c8300f6035e1f43c1cf3052 Mon Sep 17 00:00:00 2001 From: Takashi Menjo Date: Fri, 5 Nov 2021 14:16:25 +0900 Subject: [PATCH v7 12/15] Compatible to Windows This may melt into "Map WAL segment files on PMEM as WAL buffers". --- src/backend/access/transam/xlogpmem.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/backend/access/transam/xlogpmem.c b/src/backend/access/transam/xlogpmem.c index 73adde190c..95a5920a8f 100644 --- a/src/backend/access/transam/xlogpmem.c +++ b/src/backend/access/transam/xlogpmem.c @@ -8,7 +8,24 @@ #include /* uintptr_t */ #include /* getpid, unlink */ +/* + * On Windows, we will have two ported but conflicting mode_t: + * + * mode_t in libpmem: + * libpmem.h -> pmemcompat.h -> typedef int mode_t + * mode_t in PostgreSQL: + * c.h -> port.h -> win32_port.h -> typedef unsigned short mode_t + * + * We want to use PostgreSQL's one, so conseal libpmem's one. + */ +#if defined(WIN32) && !defined(__CYGWIN__) +#define mode_t unused_libpmem_mode_t #include +#undef mode_t +/* On other platforms, simply include libpmem.h */ +#else +#include +#endif #include "c.h" /* bool, Size */ #include "access/xlog.h" @@ -242,7 +259,11 @@ PmemMapFile(const char *path, size_t expected_len, int flags, bool try_open) mapped_len = 0; is_pmem = 0; +#if defined(WIN32) && !defined(__CYGWIN__) + addr = pmem_map_fileU(path, param_len, flags, mode, &mapped_len, &is_pmem); +#else addr = pmem_map_file(path, param_len, flags, mode, &mapped_len, &is_pmem); +#endif if (addr == NULL) { -- 2.25.1