Disble some Win32-specific code in win32-client-only builds:
authorBruce Momjian <[email protected]>
Thu, 8 Dec 2005 17:52:20 +0000 (17:52 +0000)
committerBruce Momjian <[email protected]>
Thu, 8 Dec 2005 17:52:20 +0000 (17:52 +0000)
I have the problem, when building by MS-VC6.
An error occurs in the 8.1.0 present source codes.

nmake -f win32.mak
..\..\port\getaddrinfo.c(244) : error C2065: 'WSA_NOT_ENOUGH_MEMORY'
..\..\port\getaddrinfo.c(342) : error C2065: 'WSATYPE_NOT_FOUND'

This is used by winsock2.h. However, Construction of a windows base is
winsock.h.
Then, Since MinGW has special environment, this is right. but, it is not
found in VC6.
Furthermore, in getaddrinfo.c, IPV6-API is used by
LoadLibraryA("ws2_32");
Referring to of dll the external memory generates this violation by VC6
specification.

I considered whether the whole should have been converted into winsock2.
However, Now, DLL of MinGW creation operates wonderfully as it is.
That's right, it has pliability by replacement of simple DLL.
Then, I propose the system using winsock(non IPV6) in construction of
VC6.

Hiroshi Saito

src/bin/pg_config/win32.mak [new file with mode: 0644]
src/include/getaddrinfo.h
src/port/getaddrinfo.c

diff --git a/src/bin/pg_config/win32.mak b/src/bin/pg_config/win32.mak
new file mode 100644 (file)
index 0000000..77726a2
--- /dev/null
@@ -0,0 +1,101 @@
+# Makefile for Microsoft Visual C++ 5.0 (or compat)
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+
+!IFDEF DEBUG
+OPT=/Od /Zi /MDd
+LOPT=/DEBUG
+DEBUGDEF=/D _DEBUG
+OUTDIR=.\Debug
+INTDIR=.\Debug
+!ELSE
+OPT=/O2 /MD
+LOPT=
+DEBUGDEF=/D NDEBUG
+OUTDIR=.\Release
+INTDIR=.\Release
+!ENDIF
+
+ALL : "..\..\port\pg_config_paths.h" "$(OUTDIR)\pg_config.exe"
+
+CLEAN :
+       -@erase "$(INTDIR)\pg_config.obj"
+       -@erase "$(OUTDIR)\pg_config.exe"
+       -@erase "$(INTDIR)\..\..\port\pg_config_paths.h"
+
+"..\..\port\pg_config_paths.h": win32.mak
+       echo #define PGBINDIR "" >$@
+       echo #define PGSHAREDIR "" >>$@
+       echo #define SYSCONFDIR "" >>$@
+       echo #define INCLUDEDIR "" >>$@
+       echo #define PKGINCLUDEDIR "" >>$@
+       echo #define INCLUDEDIRSERVER "" >>$@
+       echo #define LIBDIR "" >>$@
+       echo #define PKGLIBDIR "" >>$@
+       echo #define LOCALEDIR "" >>$@
+       echo #define DOCDIR "" >>$@
+       echo #define MANDIR "" >>$@
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo $(OPT) /W3 /GX /D "WIN32" $(DEBUGDEF) /D "_CONSOLE" /D\
+ "_MBCS" /Fp"$(INTDIR)\pg_config.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c \
+ /I ..\..\include /I ..\..\interfaces\libpq /I ..\..\include\port\win32 \
+ /D "HAVE_STRDUP" /D "FRONTEND"
+
+CPP_OBJS=$(INTDIR)/
+CPP_SBRS=.
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib shfolder.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)\pg_config.pdb" /machine:I386 $(LOPT) /out:"$(OUTDIR)\pg_config.exe" 
+LINK32_OBJS= \
+       "$(INTDIR)\pg_config.obj" \
+       "$(INTDIR)\pgstrcasecmp.obj" \
+       "$(OUTDIR)\path.obj" \
+       "$(INTDIR)\exec.obj" \
+!IFDEF DEBUG
+       "..\..\interfaces\libpq\Debug\libpqddll.lib"
+!ELSE
+       "..\..\interfaces\libpq\Release\libpqdll.lib"
+!ENDIF
+
+"$(OUTDIR)\pg_config.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+"$(OUTDIR)\path.obj" : "$(OUTDIR)" ..\..\port\path.c
+    $(CPP) @<<
+    $(CPP_PROJ) ..\..\port\path.c
+<<
+
+"$(INTDIR)\pgstrcasecmp.obj" : ..\..\port\pgstrcasecmp.c
+    $(CPP) @<<
+    $(CPP_PROJ) ..\..\port\pgstrcasecmp.c
+<<
+
+"$(INTDIR)\exec.obj" : ..\..\port\exec.c
+    $(CPP) @<<
+    $(CPP_PROJ) ..\..\port\exec.c
+<<
+
+.c{$(CPP_OBJS)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(CPP_OBJS)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
index 8af36b446f51974d8490015d16051936be19b0c8..a5d6e073aac548bb13608d80c099855dd7e6169a 100644 (file)
 #define EAI_MEMORY             (-10)
 #define EAI_SYSTEM             (-11)
 #else                                                  /* WIN32 */
+#if defined(WIN32_CLIENT_ONLY)
+#define WSA_NOT_ENOUGH_MEMORY   (WSAENOBUFS)
+#define WSATYPE_NOT_FOUND       (WSABASEERR+109)
+#endif
 #define EAI_AGAIN              WSATRY_AGAIN
 #define EAI_BADFLAGS   WSAEINVAL
 #define EAI_FAIL               WSANO_RECOVERY
index 0d3932dfafe48388d3c59967d6a529c50987a2d5..535a2b1b38c12ddd7fc419c43efed63e54ffab4c 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <windows.h>
 
+#if !defined(WIN32_CLIENT_ONLY)
 /*
  * The native routines may or may not exist on the Windows platform we are on,
  * so we dynamically look up the routines, and call them via function pointers.
@@ -129,6 +130,7 @@ haveNativeWindowsIPv6routines(void)
        return (getaddrinfo_ptr != NULL);
 }
 #endif
+#endif
 
 
 /*
@@ -149,7 +151,7 @@ getaddrinfo(const char *node, const char *service,
                           *psin;
        struct addrinfo hints;
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(WIN32_CLIENT_ONLY)
 
        /*
         * If Windows has native IPv6 support, use the native Windows routine.
@@ -272,7 +274,7 @@ freeaddrinfo(struct addrinfo * res)
 {
        if (res)
        {
-#ifdef WIN32
+#if defined(WIN32) && !defined(WIN32_CLIENT_ONLY)
 
                /*
                 * If Windows has native IPv6 support, use the native Windows routine.
@@ -364,7 +366,7 @@ getnameinfo(const struct sockaddr * sa, int salen,
                        char *node, int nodelen,
                        char *service, int servicelen, int flags)
 {
-#ifdef WIN32
+#if defined(WIN32) && !defined(WIN32_CLIENT_ONLY)
 
        /*
         * If Windows has native IPv6 support, use the native Windows routine.