From 3cbb9eb2650bd39997e1bd1236622e1d7260c978 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 16 Jul 2002 05:46:36 +0000 Subject: Move few remaining src/utils files to backend/port so everything is in one place. Everything may be moved to src/utils eventually. Add DLLINIT variable to simplify makfiles. --- src/Makefile.global.in | 3 +- src/Makefile.shlib | 10 ++--- src/backend/Makefile | 10 ++--- src/backend/port/dllinit.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ src/backend/port/strdup.c | 26 +++++++++++ src/makefiles/Makefile.win | 4 +- src/utils/Makefile | 34 -------------- src/utils/README | 6 --- src/utils/dllinit.c | 108 --------------------------------------------- src/utils/strdup.c | 26 ----------- 10 files changed, 148 insertions(+), 187 deletions(-) create mode 100644 src/backend/port/dllinit.c create mode 100644 src/backend/port/strdup.c delete mode 100644 src/utils/Makefile delete mode 100644 src/utils/README delete mode 100644 src/utils/dllinit.c delete mode 100644 src/utils/strdup.c (limited to 'src') diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 991a42f62be..8e59196dedd 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-makefile-*- -# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.148 2002/05/28 16:57:53 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.149 2002/07/16 05:46:35 momjian Exp $ #------------------------------------------------------------------------------ # All PostgreSQL makefiles include this file and use the variables it sets, @@ -359,6 +359,7 @@ STRDUP = @STRDUP@ STRERROR = @STRERROR@ STRTOL = @STRTOL@ STRTOUL = @STRTOUL@ +DLLINIT = @DLLINIT@ TAS = @TAS@ diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 06e0060df08..8b4145b12a5 100644 --- a/src/Makefile.shlib +++ b/src/Makefile.shlib @@ -6,7 +6,7 @@ # Copyright (c) 1998, Regents of the University of California # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.58 2002/05/24 18:10:17 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.59 2002/07/16 05:46:35 momjian Exp $ # #------------------------------------------------------------------------- @@ -327,13 +327,13 @@ endif # PORTNAME == aix else # PORTNAME == win # WIN case -$(shlib) lib$(NAME).a: $(OBJS) $(top_builddir)/src/utils/dllinit.o +$(shlib) lib$(NAME).a: $(OBJS) $(DLLINIT) $(DLLTOOL) --export-all --output-def $(NAME).def $(OBJS) - $(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(top_builddir)/src/utils/dllinit.o $(DLLINIT) $(DLLLIBS) $(SHLIB_LINK) + $(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(DLLINIT) $(DLLLIBS) $(SHLIB_LINK) $(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a -$(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c - $(MAKE) -C $(top_builddir)/src/utils dllinit.o +$(DLLINIT): + $(MAKE) -C $(@D) $(@F) endif # PORTNAME == win diff --git a/src/backend/Makefile b/src/backend/Makefile index f10efb8919e..cfd065d6c2f 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.79 2002/05/22 21:46:40 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.80 2002/07/16 05:46:35 momjian Exp $ # #------------------------------------------------------------------------- @@ -43,7 +43,7 @@ else # win # No points for style here. How about encapsulating some of these # commands into variables? -postgres: $(OBJS) $(top_builddir)/src/utils/dllinit.o postgres.def libpostgres.a +postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def gcc $(LDFLAGS) -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(DLLLIBS) dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def @@ -67,14 +67,14 @@ ifeq ($(MAKE_DLL), true) postgres.def: $(OBJS) $(DLLTOOL) --export-all --output-def $@ $(OBJS) -libpostgres.a: $(OBJS) $(top_builddir)/src/utils/dllinit.o postgres.def +libpostgres.a: $(OBJS) $(DLLINIT) postgres.def $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@ endif # MAKE_DLL -$(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c - $(MAKE) -C $(top_builddir)/src/utils dllinit.o +$(DLLINIT): + $(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. diff --git a/src/backend/port/dllinit.c b/src/backend/port/dllinit.c new file mode 100644 index 00000000000..e30a76a5f25 --- /dev/null +++ b/src/backend/port/dllinit.c @@ -0,0 +1,108 @@ +#include +#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 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 +#undef WIN32_LEAN_AND_MEAN +#include + +BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, + LPVOID reserved /* Not used. */ ); + +#ifdef __CYGWIN__ + +#include +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__ */ + + _impure_ptr = __imp_reent_data; + + 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 */ diff --git a/src/backend/port/strdup.c b/src/backend/port/strdup.c new file mode 100644 index 00000000000..5190990b60b --- /dev/null +++ b/src/backend/port/strdup.c @@ -0,0 +1,26 @@ +/*------------------------------------------------------------------------- + * + * strdup.c + * copies a null-terminated string. + * + * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/Attic/strdup.c,v 1.3 2002/07/16 05:46:35 momjian Exp $ + * + *------------------------------------------------------------------------- + */ +#include +#include +#include "strdup.h" + +char * +strdup(char const * string) +{ + char *nstr; + + nstr = strcpy((char *) malloc(strlen(string) + 1), string); + return nstr; +} diff --git a/src/makefiles/Makefile.win b/src/makefiles/Makefile.win index e91e5a57464..b9b0a7381d6 100644 --- a/src/makefiles/Makefile.win +++ b/src/makefiles/Makefile.win @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.15 2001/09/06 02:58:33 momjian Exp $ +# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.16 2002/07/16 05:46:35 momjian Exp $ LDFLAGS+= -g DLLTOOL= dlltool DLLWRAP= dllwrap @@ -17,7 +17,7 @@ CFLAGS_SL = %.dll: %.o $(DLLTOOL) --export-all --output-def $*.def $< - $(DLLWRAP) -o $@ --def $*.def $< $(top_builddir)/src/utils/dllinit.o $(DLLLIBS) + $(DLLWRAP) -o $@ --def $*.def $< $(DLLINIT) $(DLLLIBS) rm -f $*.def ifeq ($(findstring backend,$(subdir)), backend) diff --git a/src/utils/Makefile b/src/utils/Makefile deleted file mode 100644 index 5369c33b360..00000000000 --- a/src/utils/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#------------------------------------------------------------------------- -# -# Makefile for utils -# -# $Header: /cvsroot/pgsql/src/utils/Attic/Makefile,v 1.12 2002/07/15 23:32:28 momjian Exp $ -# -# About strdup: Some systems have strdup in their standard library, others -# don't. Ones that don't will use this make file to compile the strdup.c -# in this directory. (You don't see strdup mentioned because the implicit -# rule does the job). We don't make strdup.o unless asked to explicitly -# because the strdup.c in this directory may conflict with the strdup() -# prototype from the system library and cause a compile error. -# -# dllinit.o is only built on Win32 platform. -# -#------------------------------------------------------------------------- - -subdir = src/utils -top_builddir = ../.. -include $(top_builddir)/src/Makefile.global - -all: -# Nothing required here. These C files are compiled in -# directories as needed. - -clean distclean maintainer-clean: - rm -f dllinit.o strdup.o - -depend dep: - $(CC) $(CFLAGS) -MM *.c >depend - -ifeq (depend,$(wildcard depend)) -include depend -endif diff --git a/src/utils/README b/src/utils/README deleted file mode 100644 index c7fb0149b39..00000000000 --- a/src/utils/README +++ /dev/null @@ -1,6 +0,0 @@ -The utils directory contains components that are used by multiple subsystems -in the Postgres source tree. We don't want subsystems reaching into other -subsystems' directories and messing with the modularity of the system, so -we gather any cross-subsystem utilities here. - -In particular, programs that form an interface between subsystems go here. diff --git a/src/utils/dllinit.c b/src/utils/dllinit.c deleted file mode 100644 index e30a76a5f25..00000000000 --- a/src/utils/dllinit.c +++ /dev/null @@ -1,108 +0,0 @@ -#include -#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 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 -#undef WIN32_LEAN_AND_MEAN -#include - -BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, - LPVOID reserved /* Not used. */ ); - -#ifdef __CYGWIN__ - -#include -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__ */ - - _impure_ptr = __imp_reent_data; - - 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 */ diff --git a/src/utils/strdup.c b/src/utils/strdup.c deleted file mode 100644 index 35400459127..00000000000 --- a/src/utils/strdup.c +++ /dev/null @@ -1,26 +0,0 @@ -/*------------------------------------------------------------------------- - * - * strdup.c - * copies a null-terminated string. - * - * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/utils/Attic/strdup.c,v 1.9 2002/06/20 20:29:54 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#include -#include -#include "strdup.h" - -char * -strdup(char const * string) -{ - char *nstr; - - nstr = strcpy((char *) malloc(strlen(string) + 1), string); - return nstr; -} -- cgit v1.2.3