From f34240de0639dcaee3778c10bd860883aa88c5dc Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Tue, 9 Mar 1999 13:39:15 +0000 Subject: [PATCH] Changes to fix/improve the dynamic loading on NT From: Horak Daniel --- src/backend/commands/trigger.c | 2 +- src/backend/executor/spi.c | 8 ++++---- src/include/c.h | 20 +++++++++++++++++++- src/include/commands/trigger.h | 2 +- src/include/executor/spi.h | 6 +++--- src/makefiles/Makefile.win | 5 +++++ 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index f23180bfd3..1a06065da0 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -35,7 +35,7 @@ #include "utils/acl.h" #endif -TriggerData *CurrentTriggerData = NULL; +DLLIMPORT TriggerData *CurrentTriggerData = NULL; void RelationBuildTriggers(Relation relation); void FreeTriggerDesc(Relation relation); diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 03b9edf332..519d119bdc 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -3,7 +3,7 @@ * spi.c * Server Programming Interface * - * $Id: spi.c,v 1.34 1999/02/13 23:15:30 momjian Exp $ + * $Id: spi.c,v 1.35 1999/03/09 13:39:00 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -19,9 +19,9 @@ static _SPI_connection *_SPI_current = NULL; static int _SPI_connected = -1; static int _SPI_curid = -1; -uint32 SPI_processed = 0; -SPITupleTable *SPI_tuptable; -int SPI_result; +DLLIMPORT uint32 SPI_processed = 0; +DLLIMPORT SPITupleTable *SPI_tuptable; +DLLIMPORT int SPI_result; static int _SPI_execute(char *src, int tcount, _SPI_plan *plan); static int _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount); diff --git a/src/include/c.h b/src/include/c.h index 9c7d823ea8..b73396f92f 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.51 1999/02/13 23:20:44 momjian Exp $ + * $Id: c.h,v 1.52 1999/03/09 13:39:01 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -57,6 +57,10 @@ #include #endif +#ifdef __CYGWIN32__ +#include +#endif + /* ---------------------------------------------------------------- * Section 1: bool, true, false, TRUE, FALSE * ---------------------------------------------------------------- @@ -829,6 +833,20 @@ extern char *form(const char *fmt,...); #define COPY_CMD "cp" #define SEP_CHAR '/' +/* defines for dynamic linking on Win32 platform */ +#ifdef __CYGWIN32__ +#if __GNUC__ && ! defined (__declspec) +#error You need egcs 1.1 or newer for compiling! +#endif +#ifdef BUILDING_DLL +#define DLLIMPORT __declspec (dllexport) +#else /* not BUILDING_DLL */ +#define DLLIMPORT __declspec (dllimport) +#endif +#else /* not CYGWIN */ +#define DLLIMPORT +#endif + /* Provide prototypes for routines not present in a particular machine's * standard C library. It'd be better to put these in config.h, but * in config.h we haven't yet included anything that defines size_t... diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h index f96221f6e6..89e13188ea 100644 --- a/src/include/commands/trigger.h +++ b/src/include/commands/trigger.h @@ -26,7 +26,7 @@ typedef struct TriggerData Trigger *tg_trigger; } TriggerData; -extern TriggerData *CurrentTriggerData; +extern DLLIMPORT TriggerData *CurrentTriggerData; #define TRIGGER_EVENT_INSERT 0x00000000 #define TRIGGER_EVENT_DELETE 0x00000001 diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index cc72cddc90..104bf24aac 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -66,9 +66,9 @@ typedef struct #define SPI_OK_UPDATE 9 #define SPI_OK_CURSOR 10 -extern uint32 SPI_processed; -extern SPITupleTable *SPI_tuptable; -extern int SPI_result; +extern DLLIMPORT uint32 SPI_processed; +extern DLLIMPORT SPITupleTable *SPI_tuptable; +extern DLLIMPORT int SPI_result; extern int SPI_connect(void); extern int SPI_finish(void); diff --git a/src/makefiles/Makefile.win b/src/makefiles/Makefile.win index 44b1369aa8..b73f1f2d09 100644 --- a/src/makefiles/Makefile.win +++ b/src/makefiles/Makefile.win @@ -13,3 +13,8 @@ SHLIB_LINK=$(DLLLIBS) $(DLLTOOL) --export-all --output-def $*.def $< $(DLLWRAP) -o $@ --def $*.def $< $(SRCDIR)/utils/dllinit.o $(DLLLIBS) rm -f $*.def + +curdir:=$(shell pwd) +ifeq ($(findstring backend,$(curdir)), backend) +CFLAGS+= -DBUILDING_DLL=1 +endif