This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PORTS] [PATCH]: Building PostgreSQL 7.0.2 on Cygwin 1.1.4 (Take 3)


On Tue, Oct 31, 2000 at 03:27:45PM +0000, Pete Forman wrote:
> Provided that my patch against 7.0.2 solves the problems of Christos
> Poulkas, would you mind updating your patch to include it.  You might
> also post a "Take 3" to the list.

Attached is an updated patch that incorporates Pete's 10/26/2000 patch.
Please use it instead of the older ones.

Thanks,
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation         Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com
Tue Sep 26 11:15:38 2000 Jason Tishler <jt@dothill.com>

    * src/backend/utils/Gen_fmgrtab.sh.in: Add conditional compilation to
    appropriately import/export fmgr_pl_finfo with __declspec(dllimport)/
    __declspec(dllexport), respectively.  Note that these declarations
    manifest themselves in fmgr.h since it is generated by Gen_fmgrtab.sh.
    * src/bin/psql/help.c (usage): Change #ifdef to include check for Cygwin
    to prevent free-ing of memory obtained from getpwuid().
    * src/makefiles/Makefile.win: Add filtering out of -lm and -lc from LIBS
    to prevent the linking with multiple instances of libcygwin.a crash
    problems.
    * src/utils/dllinit.c: Update to be consistent with Cygwin Net Release.
    * src/win32/README: Change wording to indicate that un.h is no longer
    needed when building against the Cygwin Net Release.

Thu Oct 26 10:25:21 2000 Pete Forman <gsez020@kryten.bedford.waii.com>

    * src/backend/utils/error/elog.c (elog): Add work around for lack of
    sys_nerr on Cygwin and BeOS.
    * src/backend/utils/error/exc.c (ExcPrint): Ditto.
1. Replace /usr/include/cygwin/cygwin_dll.h with a post 1.1.4 version from
Cygwin's CVS repository or a development snapshot.  The following is a known
good version:

    http://sources.redhat.com/cygwin/snapshots/cygwin-src-20001027.tar.bz2/winsup/cygwin/include/cygwin/cygwin_dll.h

2. Apply patch:

    $ cd postgresql-7.0.2
    $ patch -p1 <patch.diff
    $ rm src/win32/un.h  # Note that this step is optional

3. Install as documented in src/win32/README and INSTALL.
diff -upr postgresql-7.0.2.orig/src/backend/utils/Gen_fmgrtab.sh.in postgresql-7.0.2/src/backend/utils/Gen_fmgrtab.sh.in
--- postgresql-7.0.2.orig/src/backend/utils/Gen_fmgrtab.sh.in	Sun May 21 22:34:21 2000
+++ postgresql-7.0.2/src/backend/utils/Gen_fmgrtab.sh.in	Thu Nov  2 12:57:25 2000
@@ -136,7 +136,12 @@ extern void load_file(char *filename);
  */
 
 /* We don't make this static so fmgr_faddr() macros can access it */
-extern FmgrInfo        *fmgr_pl_finfo;
+#ifdef BUILDING_DLL
+#define DLL_INTERFACE __declspec(dllexport)
+#else
+#define DLL_INTERFACE __declspec(dllimport)
+#endif
+extern DLL_INTERFACE FmgrInfo *fmgr_pl_finfo;
 
 #define fmgr_faddr(finfo) \
 ( \
diff -upr postgresql-7.0.2.orig/src/backend/utils/error/elog.c postgresql-7.0.2/src/backend/utils/error/elog.c
--- postgresql-7.0.2.orig/src/backend/utils/error/elog.c	Sat Apr 15 15:13:08 2000
+++ postgresql-7.0.2/src/backend/utils/error/elog.c	Thu Nov  2 12:58:04 2000
@@ -37,9 +37,6 @@
 #include "utils/trace.h"
 #include "commands/copy.h"
 
-extern int	errno;
-extern int	sys_nerr;
-
 extern CommandDest whereToSendOutput;
 
 #ifdef USE_SYSLOG
@@ -105,6 +102,7 @@ elog(int lev, const char *fmt,...)
 	char	   *bp;
 	int			indent = 0;
 	int			space_needed;
+        int			errno_copy = errno;
 
 #ifdef USE_SYSLOG
 	int			log_level;
@@ -154,12 +152,22 @@ elog(int lev, const char *fmt,...)
 			break;
 	}
 
-	/* get errno string for %m */
-	if (errno < sys_nerr && errno >= 0)
-		errorstr = strerror(errno);
-	else
+	/*
+	 * get errno string for %m
+	 * Standard UNIX (XPG4v2/UNIX95 and later) says that errno will be set
+	 * (to EINVAL) if the argument to strerror() is out of range.
+	 * IRIX and Solaris actually return NULL without setting errno.
+	 * Others such as AIX, Cygwin and Linux return a string for all values.
+	 *   This string contains a number for out of range values.
+	 * HPUX and QNX return the same string for all out of range values.
+	 *   Those will not be well served by this code.  However it is highly
+	 *   unlikely that this code will be called with an out of range errno.
+	 */
+	errno = 0;
+	errorstr = strerror(errno_copy);
+	if (errno != 0 || errorstr == NULL)
 	{
-		sprintf(errorstr_buf, "error %d", errno);
+		sprintf(errorstr_buf, "error %d", errno_copy);
 		errorstr = errorstr_buf;
 	}
 
diff -upr postgresql-7.0.2.orig/src/backend/utils/error/exc.c postgresql-7.0.2/src/backend/utils/error/exc.c
--- postgresql-7.0.2.orig/src/backend/utils/error/exc.c	Wed Jan 26 00:57:20 2000
+++ postgresql-7.0.2/src/backend/utils/error/exc.c	Thu Nov  2 12:58:04 2000
@@ -100,9 +100,9 @@ ExcPrint(Exception *excP,
 		 ExcData data,
 		 ExcMessage message)
 {
-	extern int	errno;
-	extern int	sys_nerr;
-
+	int errno_copy = errno;
+	const char *errorstr;
+        
 #ifdef	lint
 	data = data;
 #endif
@@ -127,10 +127,14 @@ ExcPrint(Exception *excP,
 
 	fprintf(stderr, " (%ld)", detail);
 
-	if (errno > 0 && errno < sys_nerr)
-		fprintf(stderr, " [%s]", strerror(errno));
-	else if (errno != 0)
-		fprintf(stderr, " [Error %d]", errno);
+	if (errno_copy != 0) {
+		errno = 0;
+		errorstr = strerror(errno_copy);
+		if (errno == 0 && errorstr != NULL)
+			fprintf(stderr, " [Error %d: %s]", errno_copy, errorstr);
+		else if (errno_copy != 0)
+			fprintf(stderr, " [Error %d]", errno_copy);
+	}
 
 	fprintf(stderr, "\n");
 
diff -upr postgresql-7.0.2.orig/src/bin/psql/help.c postgresql-7.0.2/src/bin/psql/help.c
--- postgresql-7.0.2.orig/src/bin/psql/help.c	Fri May 26 11:47:18 2000
+++ postgresql-7.0.2/src/bin/psql/help.c	Thu Nov  2 12:57:25 2000
@@ -138,7 +138,7 @@ usage(void)
 	puts("available at <http://www.postgresql.org>.");
 	puts("Report bugs to <pgsql-bugs@postgresql.org>.");
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__CYGWIN__)
 	if (pw)
 		free(pw);
 #endif
diff -upr postgresql-7.0.2.orig/src/makefiles/Makefile.win postgresql-7.0.2/src/makefiles/Makefile.win
--- postgresql-7.0.2.orig/src/makefiles/Makefile.win	Tue Mar  9 08:39:15 1999
+++ postgresql-7.0.2/src/makefiles/Makefile.win	Thu Nov  2 12:57:25 2000
@@ -9,6 +9,9 @@ MAKE_DLL=true
 #MAKE_DLL=false
 SHLIB_LINK=$(DLLLIBS)
 
+CYGWIN_LIBS = -lm -lc
+LIBS:=$(filter-out $(CYGWIN_LIBS), $(LIBS))
+
 %.dll: %.o
 	$(DLLTOOL) --export-all --output-def $*.def $<
 	$(DLLWRAP) -o $@ --def $*.def $< $(SRCDIR)/utils/dllinit.o $(DLLLIBS)
diff -upr postgresql-7.0.2.orig/src/utils/dllinit.c postgresql-7.0.2/src/utils/dllinit.c
--- postgresql-7.0.2.orig/src/utils/dllinit.c	Tue May 25 12:15:32 1999
+++ postgresql-7.0.2/src/utils/dllinit.c	Thu Nov  2 12:57:25 2000
@@ -40,21 +40,19 @@
 #undef WIN32_LEAN_AND_MEAN
 #include <stdio.h>
 
-BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
-		LPVOID reserved /* Not used. */ );
 
 #ifdef __CYGWIN32__
 
 #include <cygwin/cygwin_dll.h>
 DECLARE_CYGWIN_DLL(DllMain);
 /* save hInstance from DllMain */
-HINSTANCE	__hDllInstance_base;
+HANDLE	__hDllInstance_base;
 
 #endif	 /* __CYGWIN32__ */
 
 struct _reent *_impure_ptr;
 
-extern struct _reent *__imp_reent_data;
+extern __declspec(dllimport) struct _reent reent_data;
 
 /*
  *----------------------------------------------------------------------
@@ -84,7 +82,7 @@ DllMain(
 	__hDllInstance_base = hInst;
 #endif	 /* __CYGWIN32__ */
 
-	_impure_ptr = __imp_reent_data;
+	_impure_ptr = &reent_data;
 
 	switch (reason)
 	{
diff -upr postgresql-7.0.2.orig/src/win32/README postgresql-7.0.2/src/win32/README
--- postgresql-7.0.2.orig/src/win32/README	Sun Jan 17 01:27:05 1999
+++ postgresql-7.0.2/src/win32/README	Thu Nov  2 12:57:25 2000
@@ -1,3 +1,7 @@
-Add the included headers endian.h into Cygwin's include/, tcp.h into
-include/netinet, and un.h into include/sys.
+Copy the following headers to Cygwin's include directories:
 
+    $ cp endian.h /usr/include
+    $ cp tcp.h /usr/include/netinet
+
+Note that un.h is already included in Cygwin's Net Release so it no longer
+needs to be manually copied and can be removed from this directory.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]