From 69bf0a0ddd52bcc35e75c63547603f96bcdff74b Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 22 Jun 2006 23:50:35 +0000
Subject: [PATCH] Remove dllinit.c; it was only needed for long-obsolete Cygwin
 versions, and there was some question about its copyright status.

---
 src/Makefile                  |   5 +-
 src/backend/Makefile          |   9 +--
 src/makefiles/Makefile.cygwin |   5 +-
 src/makefiles/Makefile.win32  |   5 +-
 src/utils/Makefile            |  32 ----------
 src/utils/dllinit.c           | 114 ----------------------------------
 6 files changed, 8 insertions(+), 162 deletions(-)
 delete mode 100644 src/utils/Makefile
 delete mode 100644 src/utils/dllinit.c

diff --git a/src/Makefile b/src/Makefile
index 9c94d3bbc23..6d9043ac66c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/Makefile,v 1.39 2006/02/04 01:04:20 momjian Exp $
+# $PostgreSQL: pgsql/src/Makefile,v 1.40 2006/06/22 23:50:35 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -23,7 +23,6 @@ all install installdirs uninstall dep depend distprep:
 	$(MAKE) -C bin $@
 	$(MAKE) -C pl $@
 	$(MAKE) -C makefiles $@
-	$(MAKE) -C utils $@
 	$(MAKE) -C test/regress $@
 
 install: install-local
@@ -55,7 +54,6 @@ clean:
 	$(MAKE) -C makefiles $@
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
-	$(MAKE) -C utils $@
 	$(MAKE) -C test/thread $@
 
 distclean maintainer-clean:
@@ -69,7 +67,6 @@ distclean maintainer-clean:
 	-$(MAKE) -C makefiles $@
 	-$(MAKE) -C test $@
 	-$(MAKE) -C tutorial NO_PGXS=1 $@
-	-$(MAKE) -C utils $@
 	-$(MAKE) -C test/thread $@
 	rm -f Makefile.port Makefile.global
 
diff --git a/src/backend/Makefile b/src/backend/Makefile
index eeead6c0260..8908a5a7dbb 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/backend/Makefile,v 1.115 2006/06/18 15:38:36 petere Exp $
+# $PostgreSQL: pgsql/src/backend/Makefile,v 1.116 2006/06/22 23:50:35 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -44,7 +44,7 @@ endif
 
 ifeq ($(PORTNAME), cygwin)
 
-postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
+postgres: $(OBJS) postgres.def libpostgres.a
 	$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
 	$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
@@ -61,7 +61,7 @@ endif # cygwin
 
 ifeq ($(PORTNAME), win32)
 
-postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(WIN32RES)
+postgres: $(OBJS) postgres.def libpostgres.a $(WIN32RES)
 	$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(WIN32RES) $(LIBS)
 	$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
@@ -105,9 +105,6 @@ $(DIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir
 	$(MAKE) -C $(subst -recursive,,$@) all
 
 
-$(DLLINIT): $(DLLINIT:%.o=%.c)
-	$(MAKE) -C $(@D) $(@F)
-
 # The postgres.o target is needed by the rule in Makefile.global that
 # creates the exports file when MAKE_EXPORTS = true.
 postgres.o: $(OBJS)
diff --git a/src/makefiles/Makefile.cygwin b/src/makefiles/Makefile.cygwin
index 80ece2b8048..4ce0f6b1ff3 100644
--- a/src/makefiles/Makefile.cygwin
+++ b/src/makefiles/Makefile.cygwin
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/makefiles/Makefile.cygwin,v 1.8 2006/01/19 20:45:29 momjian Exp $
+# $PostgreSQL: pgsql/src/makefiles/Makefile.cygwin,v 1.9 2006/06/22 23:50:35 tgl Exp $
 DLLTOOL= dlltool
 DLLWRAP= dllwrap
 ifdef PGXS
@@ -6,7 +6,6 @@ BE_DLLLIBS= -L$(libdir) -lpostgres
 else
 BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
 endif
-DLLINIT = $(top_builddir)/src/utils/dllinit.o
 
 # linking with -lm or -lc causes program to crash
 # (see http://sources.redhat.com/cygwin/faq/faq.html#SEC110)
@@ -18,7 +17,7 @@ CFLAGS_SL =
 
 %.dll: %.o
 	$(DLLTOOL) --export-all --output-def $*.def $<
-	$(DLLWRAP) -o $@ --def $*.def $< $(DLLINIT) $(SHLIB_LINK)
+	$(DLLWRAP) -o $@ --def $*.def $< $(SHLIB_LINK)
 	rm -f $*.def
 
 ifneq (,$(findstring backend,$(subdir)))
diff --git a/src/makefiles/Makefile.win32 b/src/makefiles/Makefile.win32
index 36b4e802bb7..a3ce9f29eaf 100644
--- a/src/makefiles/Makefile.win32
+++ b/src/makefiles/Makefile.win32
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/makefiles/Makefile.win32,v 1.9 2006/01/19 20:45:29 momjian Exp $
+# $PostgreSQL: pgsql/src/makefiles/Makefile.win32,v 1.10 2006/06/22 23:50:35 tgl Exp $
 
 # Use replacement include files for those missing on Win32
 override CPPFLAGS+="-I$(top_srcdir)/src/include/port/win32"
@@ -10,7 +10,6 @@ BE_DLLLIBS= -L$(libdir) -lpostgres
 else
 BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
 endif
-DLLINIT = $(top_builddir)/src/utils/dllinit.o
 
 AROPT = crs
 DLSUFFIX = .dll
@@ -18,7 +17,7 @@ CFLAGS_SL =
 
 %.dll: %.o
 	$(DLLTOOL) --export-all --output-def $*.def $<
-	$(DLLWRAP) -o $@ --def $*.def $< $(DLLINIT) $(SHLIB_LINK)
+	$(DLLWRAP) -o $@ --def $*.def $< $(SHLIB_LINK)
 	rm -f $*.def
 
 ifneq (,$(findstring backend,$(subdir)))
diff --git a/src/utils/Makefile b/src/utils/Makefile
deleted file mode 100644
index 3f5b1fdc4b3..00000000000
--- a/src/utils/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#-------------------------------------------------------------------------
-#
-# Makefile for utils
-#
-# $PostgreSQL: pgsql/src/utils/Makefile,v 1.22 2005/12/09 21:19:36 petere Exp $
-#
-# dllinit.o is only built on Win32 platform.
-#
-#-------------------------------------------------------------------------
-
-subdir = src/utils
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-
-
-ifdef DLLINIT
-
-all:
-
-install: all installdirs
-	$(INSTALL_DATA) dllinit.o $(DESTDIR)$(pgxsdir)/$(subdir)/
-
-installdirs:
-	$(mkinstalldirs) '$(DESTDIR)$(pgxsdir)/$(subdir)'
-
-uninstall:
-	rm -f $(DESTDIR)$(pgxsdir)/$(subdir)/dllinit.o
-
-clean distclean maintainer-clean:
-	rm -f dllinit.o
-
-endif # not DLLINIT
diff --git a/src/utils/dllinit.c b/src/utils/dllinit.c
deleted file mode 100644
index 66859149d51..00000000000
--- a/src/utils/dllinit.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/* $PostgreSQL: pgsql/src/utils/dllinit.c,v 1.17 2006/03/11 04:38:42 momjian Exp $ */
-
-#ifdef __CYGWIN__
-#include <cygwin/version.h>
-#endif
-#if CYGWIN_VERSION_DLL_MAJOR < 1001
-
-/* dllinit.c -- Portable DLL initialization.
-   Copyright (C) 1998 Free Software Foundation, Inc.
-   Contributed by Mumit Khan (khan@xraylith.wisc.edu).
-
-   I've used DllMain as the DLL "main" since that's the most common
-   usage. MSVC and Mingw32 both default to DllMain as the standard
-   callback from the linker entry point. Cygwin32 b19+ uses essentially
-   the same, albeit slightly differently implemented, scheme. Please
-   see DECLARE_CYGWIN_DLL macro in <cygwin32/cygwin_dll.h> for more
-   info on how Cygwin32 uses the callback function.
-
-   The real entry point is typically always defined by the runtime
-   library, and usually never overridden by (casual) user. What you can
-   override however is the callback routine that the entry point calls,
-   and this file provides such a callback function, DllMain.
-
-   Mingw32: The default entry point for mingw32 is DllMainCRTStartup
-   which is defined in libmingw32.a This in turn calls DllMain which is
-   defined here. If not defined, there is a stub in libmingw32.a which
-   does nothing.
-
-   Cygwin32: The default entry point for cygwin32 b19 or newer is
-   __cygwin32_dll_entry which is defined in libcygwin.a. This in turn
-   calls the routine you supply to the DECLARE_CYGWIN_DLL (see below)
-   and, for this example, I've chose DllMain to be consistent with all
-   the other platforms.
-
-   MSVC: MSVC runtime calls DllMain, just like Mingw32.
-
-   Summary: If you need to do anything special in DllMain, just add it
-   here. Otherwise, the default setup should be just fine for 99%+ of
-   the time. I strongly suggest that you *not* change the entry point,
-   but rather change DllMain as appropriate.
-
- */
-
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#undef WIN32_LEAN_AND_MEAN
-#include <stdio.h>
-
-BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
-		LPVOID reserved /* Not used. */ );
-
-#ifdef __CYGWIN__
-
-#include <cygwin/cygwin_dll.h>
-DECLARE_CYGWIN_DLL(DllMain);
-/* save hInstance from DllMain */
-HINSTANCE	__hDllInstance_base;
-#endif   /* __CYGWIN__ */
-
-struct _reent *_impure_ptr;
-
-extern struct _reent *__imp_reent_data;
-
-/*
- *----------------------------------------------------------------------
- *
- * DllMain
- *
- *	This routine is called by the Mingw32, Cygwin32 or VC++ C run
- *	time library init code, or the Borland DllEntryPoint routine. It
- *	is responsible for initializing various dynamically loaded
- *	libraries.
- *
- * Results:
- *		TRUE on sucess, FALSE on failure.
- *
- * Side effects:
- *
- *----------------------------------------------------------------------
- */
-BOOL		APIENTRY
-DllMain(
-		HINSTANCE hInst /* Library instance handle. */ ,
-		DWORD reason /* Reason this function is being called. */ ,
-		LPVOID reserved /* Not used. */ )
-{
-
-#ifdef __CYGWIN__
-	__hDllInstance_base = hInst;
-#endif   /* __CYGWIN__ */
-
-#ifdef __CYGWIN__
-	_impure_ptr = __imp_reent_data;
-#endif
-
-	switch (reason)
-	{
-		case DLL_PROCESS_ATTACH:
-			break;
-
-		case DLL_PROCESS_DETACH:
-			break;
-
-		case DLL_THREAD_ATTACH:
-			break;
-
-		case DLL_THREAD_DETACH:
-			break;
-	}
-	return TRUE;
-}
-
-#endif   /* CYGWIN_VERSION_DLL_MAJOR < 1001 */
-- 
GitLab