Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7a6b562

Browse files
committed
Apply Win32 patch from Horak Daniel.
1 parent 298682d commit 7a6b562

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+484
-86
lines changed

src/Makefile.shlib

+19-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright (c) 1998, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.5 1998/11/30 00:30:03 tgl Exp $
9+
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.6 1999/01/17 06:18:08 momjian Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -156,24 +156,40 @@ ifeq ($(PORTNAME), unixware)
156156
endif
157157
endif
158158

159+
ifeq ($(PORTNAME), win)
160+
install-shlib-dep := install-shlib
161+
shlib := $(NAME)$(DLSUFFIX)
162+
endif
159163

160164
# Default target definition. Note shlib is empty if not building a shlib.
161165

162166
all: lib$(NAME).a $(shlib)
163167

164168
# Rules to build regular and shared libraries
165169

170+
ifneq ($(PORTNAME), win)
166171
lib$(NAME).a: $(OBJS)
167172
ifdef MK_NO_LORDER
168173
$(AR) $(AROPT) $@ $(OBJS)
169174
else
170175
$(AR) $(AROPT) $@ `lorder $(OBJS) | tsort`
171176
endif
172177
$(RANLIB) $@
178+
endif
173179

174180
ifneq ($(shlib),)
181+
ifneq ($(PORTNAME), win)
175182
$(shlib): $(OBJS)
176183
$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(SHLIB_LINK)
184+
else
185+
$(shlib) lib$(NAME).a: $(OBJS) $(SRCDIR)/utils/dllinit.o
186+
$(DLLTOOL) --export-all --output-def $(NAME).def $(OBJS)
187+
$(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(SRCDIR)/utils/dllinit.o $(DLLINIT) $(SHLIB_LINK)
188+
$(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a
189+
190+
$(SRCDIR)/utils/dllinit.o: $(SRCDIR)/utils/dllinit.c
191+
$(MAKE) -C $(SRCDIR)/utils dllinit.o
192+
endif
177193
endif
178194

179195
# Rules to install regular and shared libraries
@@ -185,6 +201,7 @@ install-lib: lib$(NAME).a
185201

186202
install-shlib: $(shlib)
187203
$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
204+
ifneq ($(PORTNAME), win)
188205
if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
189206
cd $(LIBDIR); \
190207
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
@@ -195,3 +212,4 @@ install-shlib: $(shlib)
195212
rm -f lib$(NAME)$(DLSUFFIX); \
196213
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
197214
fi
215+
endif

src/backend/Makefile

+48-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#
3535
#
3636
# IDENTIFICATION
37-
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.34 1998/11/27 19:51:27 vadim Exp $
37+
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.35 1999/01/17 06:18:11 momjian Exp $
3838
#
3939
#-------------------------------------------------------------------------
4040

@@ -58,20 +58,45 @@ CFLAGS+= $(KRBFLAGS)
5858
LDFLAGS+= $(KRBLIBS)
5959
endif
6060

61+
ifeq ($(MAKE_DLL), true)
62+
DLLOBJS=$(OBJS)
63+
DLLOBJS+= ../utils/version.o
64+
DLLLIBS= -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32
65+
66+
postgres.def: $(DLLOBJS)
67+
$(DLLTOOL) --export-all --output-def $@ $(DLLOBJS)
68+
69+
libpostgres.a: $(DLLOBJS) ../utils/dllinit.o postgres.def
70+
$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
71+
endif
6172

6273
all: postgres $(POSTGRES_IMP) global1.bki.source local1_template1.bki.source \
6374
global1.description local1_template1.description
6475

76+
ifneq ($(PORTNAME), win)
6577
postgres: fmgr.h $(OBJS) ../utils/version.o
6678
$(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
79+
else
80+
postgres: $(DLLOBJS) ../utils/dllinit.o postgres.def libpostgres.a
81+
dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def
82+
gcc -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(DLLOBJS) $(DLLLIBS)
83+
dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
84+
gcc -g -o $@$(X) $@.exp $(DLLOBJS) $(DLLLIBS)
85+
rm $@.exp $@.base
86+
endif
87+
88+
#.PHONY: postgres
6789

6890
$(OBJS): $(DIRS:%=%.dir)
6991

7092
$(DIRS:%=%.dir):
7193
$(MAKE) -C $(subst .dir,,$@) all
7294

7395
../utils/version.o:
74-
$(MAKE) -C ../utils version.o
96+
$(MAKE) -C ../utils version.o
97+
98+
../utils/dllinit.c:
99+
$(MAKE) -C ../utils dllinit.o
75100

76101
global1.bki.source local1_template1.bki.source \
77102
global1.description local1_template1.description: catalog/$@
@@ -89,7 +114,6 @@ postgres.o: $(OBJS)
89114
fast:
90115
$(CC) -r -o postgres.o $(OBJS) $(LDFLAGS)
91116

92-
93117
############################################################################
94118
# The following targets are specified in make commands that appear in the
95119
# make files in our subdirectories.
@@ -104,9 +128,14 @@ fmgr.h:
104128

105129
#############################################################################
106130
clean:
107-
rm -f postgres $(POSTGRES_IMP) fmgr.h parse.h \
131+
rm -f postgres$(X) $(POSTGRES_IMP) fmgr.h parse.h \
108132
global1.bki.source local1_template1.bki.source \
109133
global1.description local1_template1.description
134+
ifeq ($(PORTNAME), win)
135+
ifeq ($(MAKE_DLL), true)
136+
rm -f postgres.dll postgres.def libpostgres.a
137+
endif
138+
endif
110139
for i in $(DIRS); do $(MAKE) -C $$i clean; done
111140

112141
.DEFAULT:
@@ -132,12 +161,18 @@ install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(POSTGRES_IMP) fmgr.h\
132161
global1.bki.source local1_template1.bki.source \
133162
global1.description local1_template1.description \
134163
libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample
135-
$(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
164+
$(INSTALL) $(INSTL_EXE_OPTS) postgres$(X) $(BINDIR)/postgres$(X)
136165
ifeq ($(MAKE_EXPORTS), true)
137166
$(INSTALL) $(INSTLOPTS) $(POSTGRES_IMP) $(LIBDIR)/$(POSTGRES_IMP)
138167
endif
139168
@rm -f $(BINDIR)/postmaster
140-
ln -s postgres $(BINDIR)/postmaster
169+
ln -s postgres$(X) $(BINDIR)/postmaster
170+
ifeq ($(PORTNAME), win)
171+
ifeq ($(MAKE_DLL), true)
172+
# $(INSTALL) $(INSTLOPTS) postgres.dll $(BINDIR)/postgres.dll
173+
$(INSTALL) $(INSTLOPTS) libpostgres.a $(LIBDIR)/libpostgres.a
174+
endif
175+
endif
141176
$(INSTALL) $(INSTLOPTS) fmgr.h $(HEADERDIR)/fmgr.h
142177
$(INSTALL) $(INSTLOPTS) global1.bki.source \
143178
$(LIBDIR)/global1.bki.source
@@ -152,7 +187,13 @@ endif
152187
$(INSTALL) $(INSTLOPTS) optimizer/geqo/pg_geqo.sample \
153188
$(LIBDIR)/pg_geqo.sample
154189

155-
$(BINDIR) $(LIBDIR) $(HEADERDIR):
190+
#$(BINDIR) $(LIBDIR) $(HEADERDIR):
191+
# mkdir $@
192+
$(BINDIR):
193+
mkdir $@
194+
$(LIBDIR):
195+
mkdir $@
196+
$(HEADERDIR):
156197
mkdir $@
157198

158199
#############################################################################

src/backend/access/nbtree/nbtsort.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*
77
* IDENTIFICATION
8-
* $Id: nbtsort.c,v 1.33 1998/09/01 04:27:07 momjian Exp $
8+
* $Id: nbtsort.c,v 1.34 1999/01/17 06:18:12 momjian Exp $
99
*
1010
* NOTES
1111
*
@@ -420,7 +420,11 @@ _bt_tapecreate(char *fname)
420420

421421
tape->bttb_magic = BTTAPEMAGIC;
422422

423+
#ifndef __CYGWIN32__
423424
tape->bttb_fd = FileNameOpenFile(fname, O_RDWR | O_CREAT | O_TRUNC, 0600);
425+
#else
426+
tape->bttb_fd = FileNameOpenFile(fname, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
427+
#endif
424428
Assert(tape->bttb_fd >= 0);
425429

426430
/* initialize the buffer */

src/backend/bootstrap/bootstrap.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.52 1998/11/27 19:51:45 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.53 1999/01/17 06:18:14 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,6 +17,9 @@
1717
#include <signal.h>
1818
#include <setjmp.h>
1919
#include <string.h>
20+
#ifdef __CYGWIN32__
21+
#include <getopt.h>
22+
#endif
2023

2124
#define BOOTSTRAP_INCLUDE /* mask out stuff in tcop/tcopprot.h */
2225

src/backend/catalog/Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for catalog
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.14 1998/10/08 18:29:19 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.15 1999/01/17 06:18:14 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -39,17 +39,26 @@ LOCALBKI_SRCS= $(addprefix ../../include/catalog/, \
3939
)
4040

4141
global1.bki.source: $(GENBKI) $(GLOBALBKI_SRCS)
42+
ifneq ($(PORTNAME), win)
4243
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description
44+
else
45+
$(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description
46+
endif
4347

4448
local1_template1.bki.source: $(GENBKI) $(LOCALBKI_SRCS)
49+
ifneq ($(PORTNAME), win)
4550
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(LOCALBKI_SRCS) > $@ 2>local1_template1.description
51+
else
52+
$(GENBKI) $(BKIOPTS) $(LOCALBKI_SRCS) > $@ 2>local1_template1.description
53+
endif
4654

4755
depend dep:
4856
$(CC) -MM $(CFLAGS) *.c >depend
4957

5058
clean:
5159
rm -f SUBSYS.o $(OBJS) global1.bki.source local1_template1.bki.source \
52-
global1.description local1_template1.description
60+
global1.description local1_template1.description \
61+
$(GENBKI)
5362

5463
ifeq (depend,$(wildcard depend))
5564
include depend

src/backend/commands/copy.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.66 1999/01/11 03:56:05 scrappy Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.67 1999/01/17 06:18:15 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -250,7 +250,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
250250
}
251251
else
252252
{
253+
#ifndef __CYGWIN32__
253254
fp = AllocateFile(filename, "r");
255+
#else
256+
fp = AllocateFile(filename, "rb");
257+
#endif
254258
if (fp == NULL)
255259
elog(ERROR, "COPY command, running in backend with "
256260
"effective uid %d, could not open file '%s' for "
@@ -277,7 +281,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
277281
mode_t oumask; /* Pre-existing umask value */
278282

279283
oumask = umask((mode_t) 0);
284+
#ifndef __CYGWIN32__
280285
fp = AllocateFile(filename, "w");
286+
#else
287+
fp = AllocateFile(filename, "wb");
288+
#endif
281289
umask(oumask);
282290
if (fp == NULL)
283291
elog(ERROR, "COPY command, running in backend with "

src/backend/commands/dbcommands.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.28 1998/12/15 12:45:55 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.29 1999/01/17 06:18:17 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -305,7 +305,11 @@ stop_vacuum(char *dbpath, char *dbname)
305305
else
306306
snprintf(filename, 256, "%s%c%s.vacuum", dbpath, SEP_CHAR, dbname);
307307

308+
#ifndef __CYGWIN32__
308309
if ((fp = AllocateFile(filename, "r")) != NULL)
310+
#else
311+
if ((fp = AllocateFile(filename, "rb")) != NULL)
312+
#endif
309313
{
310314
fscanf(fp, "%d", &pid);
311315
FreeFile(fp);

src/backend/commands/vacuum.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.92 1998/12/15 12:46:01 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.93 1999/01/17 06:18:18 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -187,7 +187,11 @@ vc_init()
187187
{
188188
int fd;
189189

190+
#ifndef __CYGWIN32__
190191
if ((fd = open("pg_vlock", O_CREAT | O_EXCL, 0600)) < 0)
192+
#else
193+
if ((fd = open("pg_vlock", O_CREAT | O_EXCL | O_BINARY, 0600)) < 0)
194+
#endif
191195
{
192196
elog(ERROR, "Can't create lock file. Is another vacuum cleaner running?\n\
193197
\tIf not, you may remove the pg_vlock file in the %s\n\

src/backend/executor/nodeHash.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $Id: nodeHash.c,v 1.28 1998/12/15 12:46:06 vadim Exp $
9+
* $Id: nodeHash.c,v 1.29 1999/01/17 06:18:19 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -100,8 +100,13 @@ ExecHash(Hash *node)
100100
batches = (File *) palloc(nbatch * sizeof(File));
101101
for (i = 0; i < nbatch; i++)
102102
{
103+
#ifndef __CYGWIN32__
103104
batches[i] = FileNameOpenFile(ABSADDR(innerbatchNames[i]),
104105
O_CREAT | O_RDWR, 0600);
106+
#else
107+
batches[i] = FileNameOpenFile(ABSADDR(innerbatchNames[i]),
108+
O_CREAT | O_RDWR | O_BINARY, 0600);
109+
#endif
105110
}
106111
hashstate->hashBatches = batches;
107112
batchPos = (RelativeAddr *) ABSADDR(hashtable->innerbatchPos);

src/backend/executor/nodeHashjoin.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.14 1998/11/27 19:52:02 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.15 1999/01/17 06:18:21 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -172,9 +172,15 @@ ExecHashJoin(HashJoin *node)
172172
palloc(nbatch * sizeof(File));
173173
for (i = 0; i < nbatch; i++)
174174
{
175+
#ifndef __CYGWIN32__
175176
outerbatches[i] = FileNameOpenFile(
176-
ABSADDR(outerbatchNames[i]),
177-
O_CREAT | O_RDWR, 0600);
177+
ABSADDR(outerbatchNames[i]),
178+
O_CREAT | O_RDWR, 0600);
179+
#else
180+
outerbatches[i] = FileNameOpenFile(
181+
ABSADDR(outerbatchNames[i]),
182+
O_CREAT | O_RDWR | O_BINARY, 0600);
183+
#endif
178184
}
179185
hjstate->hj_OuterBatches = outerbatches;
180186

0 commit comments

Comments
 (0)