From d8f75d4131589f45e77189e93190a5d5f04814a7 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sun, 25 Jun 2006 00:18:24 +0000 Subject: [PATCH] Fix Win32/Cygwin problems: After updating to the latest cvs, and also building most of the addons (like PLs), the following patch is neededf for win32 + Visual C++. * Switch to use the new win32 semaphore code * Rename win32_open to pgwin32_open. win32_open collides with symbols defined in Perl. MingW didn't detect ig, MSVC did. And it's a bit too generic a name to export globally, imho... * Python defines some partially broken #pragmas in the headers when doing a debug build. Workaround. Magnus Hagander --- src/include/pg_config.h.win32 | 5 ++++- src/include/port.h | 6 +++--- src/pl/plpython/plpython.c | 10 +++++++++- src/port/open.c | 6 +++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index 430ab02a2f..b2cf29246e 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -628,7 +628,7 @@ /* #undef USE_SSL */ /* Define to select SysV-style semaphores. */ -#define USE_SYSV_SEMAPHORES 1 +/* #undef USE_SYSV_SEMAPHORES */ /* Define to select SysV-style shared memory. */ #define USE_SYSV_SHARED_MEMORY 1 @@ -636,6 +636,9 @@ /* Define to select unnamed POSIX semaphores. */ /* #undef USE_UNNAMED_POSIX_SEMAPHORES */ +/* Define to select Win32-style semaphores. */ +#define USE_WIN32_SEMAPHORES + /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ diff --git a/src/include/port.h b/src/include/port.h index b195e95c7c..7cb5608394 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/port.h,v 1.92 2006/06/07 22:24:45 momjian Exp $ + * $PostgreSQL: pgsql/src/include/port.h,v 1.93 2006/06/25 00:18:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -246,10 +246,10 @@ extern bool rmtree(char *path, bool rmtopdir); /* open() replacement to allow delete of held files and passing * of special options. */ -extern int win32_open(const char *, int,...); +extern int pgwin32_open(const char *, int,...); #ifndef FRONTEND -#define open(a,b,c) win32_open(a,b,c) +#define open(a,b,c) pgwin32_open(a,b,c) #endif #define popen(a,b) _popen(a,b) diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index bc8310a045..20974bb4d9 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -1,12 +1,20 @@ /********************************************************************** * plpython.c - python as a procedural language for PostgreSQL * - * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.82 2006/06/16 18:42:23 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.83 2006/06/25 00:18:24 momjian Exp $ * ********************************************************************* */ +#if defined(_MSC_VER) && defined(_DEBUG) +/* Python uses #pragma to bring in a non-default libpython on VC++ if + * _DEBUG is defined */ +#undef _DEBUG #include +#define _DEBUG +#else +#include +#endif #include "postgres.h" /* system stuff */ diff --git a/src/port/open.c b/src/port/open.c index f0de771e8b..4df74d8b51 100644 --- a/src/port/open.c +++ b/src/port/open.c @@ -6,7 +6,7 @@ * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/open.c,v 1.12 2006/03/05 15:59:10 momjian Exp $ + * $PostgreSQL: pgsql/src/port/open.c,v 1.13 2006/06/25 00:18:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ #include #include -int win32_open(const char *fileName, int fileFlags,...); +int pgwin32_open(const char *fileName, int fileFlags,...); static int openFlagsToCreateFileFlags(int openFlags) @@ -54,7 +54,7 @@ openFlagsToCreateFileFlags(int openFlags) * - handle other flags? (eg FILE_FLAG_NO_BUFFERING/FILE_FLAG_WRITE_THROUGH) */ int -win32_open(const char *fileName, int fileFlags,...) +pgwin32_open(const char *fileName, int fileFlags,...) { int fd; HANDLE h;