mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
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.
This commit is contained in:
@@ -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.
|
||||
|
||||
108
src/backend/port/dllinit.c
Normal file
108
src/backend/port/dllinit.c
Normal file
@@ -0,0 +1,108 @@
|
||||
#include <cygwin/version.h>
|
||||
#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__ */
|
||||
|
||||
_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 */
|
||||
26
src/backend/port/strdup.c
Normal file
26
src/backend/port/strdup.c
Normal file
@@ -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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "strdup.h"
|
||||
|
||||
char *
|
||||
strdup(char const * string)
|
||||
{
|
||||
char *nstr;
|
||||
|
||||
nstr = strcpy((char *) malloc(strlen(string) + 1), string);
|
||||
return nstr;
|
||||
}
|
||||
Reference in New Issue
Block a user