From 2c99d99a7d99c9b20eb341622c2259e4a9efe8e3 Mon Sep 17 00:00:00 2001 From: Takashi Menjo Date: Fri, 5 Nov 2021 14:16:25 +0900 Subject: [PATCH v6 06/11] Compatible to Windows --- 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 5b50ba80a7..8bd990f1cd 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