Skip to content

Commit bf06825

Browse files
committed
Win32 compile fixes for pgbench, pgcrypto, and tsearch.
Claudio Natoli
1 parent fc56468 commit bf06825

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

contrib/pgbench/pgbench.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.32 2004/08/29 05:06:36 momjian Exp $
2+
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.33 2004/09/14 03:39:23 tgl Exp $
33
*
44
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -44,6 +44,10 @@
4444
extern char *optarg;
4545
extern int optind;
4646

47+
#ifdef WIN32
48+
#undef select
49+
#endif
50+
4751

4852
/********************************************************************
4953
* some configurable parameters */
@@ -705,7 +709,7 @@ main(int argc, char **argv)
705709
int nsocks; /* return from select(2) */
706710
int maxsock; /* max socket number to be waited */
707711

708-
#ifndef __CYGWIN__
712+
#if !(defined(__CYGWIN__) || defined(__MINGW32__))
709713
struct rlimit rlim;
710714
#endif
711715

@@ -755,7 +759,7 @@ main(int argc, char **argv)
755759
fprintf(stderr, "invalid number of clients: %d\n", nclients);
756760
exit(1);
757761
}
758-
#ifndef __CYGWIN__
762+
#if !(defined(__CYGWIN__) || defined(__MINGW32__))
759763
#ifdef RLIMIT_NOFILE /* most platform uses RLIMIT_NOFILE */
760764
if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
761765
{
@@ -772,7 +776,7 @@ main(int argc, char **argv)
772776
fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
773777
exit(1);
774778
}
775-
#endif /* #ifndef __CYGWIN__ */
779+
#endif /* #if !(defined(__CYGWIN__) || defined(__MINGW32__)) */
776780
break;
777781
case 'C':
778782
is_connect = 1;
@@ -935,7 +939,7 @@ main(int argc, char **argv)
935939

936940
/* set random seed */
937941
gettimeofday(&tv1, 0);
938-
srand((uint) tv1.tv_usec);
942+
srand((unsigned int) tv1.tv_usec);
939943

940944
/* get start up time */
941945
gettimeofday(&tv1, 0);

contrib/pgcrypto/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.11 2004/08/20 20:13:06 momjian Exp $
2+
# $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.12 2004/09/14 03:39:48 tgl Exp $
33
#
44

55
# either 'builtin', 'mhash', 'openssl'
@@ -82,6 +82,11 @@ include $(top_builddir)/src/Makefile.global
8282
include $(top_srcdir)/contrib/contrib-global.mk
8383
endif
8484

85+
# to make ws2_32.lib the last library (must occur after definition of PORTNAME)
86+
ifeq ($(PORTNAME),win32)
87+
SHLIB_LINK += -lwsock32 -lws2_32
88+
endif
89+
8590

8691
rijndael.o: rijndael.tbl
8792

contrib/tsearch/gistidx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ typedef char *BITVECP;
3333
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
3434

3535
#define abs(a) ((a) < (0) ? -(a) : (a))
36+
#ifdef min
37+
#undef min
38+
#endif
3639
#define min(a,b) ((a) < (b) ? (a) : (b))
3740
#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
3841
#define HASH(sign, val) SETBIT((sign), HASHVAL(val))

contrib/tsearch/rewrite.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ clean_NOT(ITEM * ptr, int4 *len)
174174
return plaintree(clean_NOT_intree(root), len);
175175
}
176176

177+
#ifdef V_UNKNOWN /* apparently Windows defines this :-( */
178+
#undef V_UNKNOWN
179+
#endif
177180
#define V_UNKNOWN 0
178181
#define V_TRUE 1
179182
#define V_FALSE 2

contrib/tsearch/txtidx.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ typedef struct
342342
{
343343
uint16 len;
344344
char *word;
345-
} WORD;
345+
} WORD_T; /* WORD type defined on win32; we'll use WORD_T */
346346

347347
typedef struct
348348
{
349-
WORD *words;
349+
WORD_T *words;
350350
int4 lenwords;
351351
int4 curwords;
352352
} PRSTEXT;
@@ -369,7 +369,7 @@ parsetext(PRSTEXT * prs, char *buf, int4 buflen)
369369
if (prs->curwords == prs->lenwords)
370370
{
371371
prs->lenwords *= 2;
372-
prs->words = (WORD *) repalloc((void *) prs->words, prs->lenwords * sizeof(WORD));
372+
prs->words = (WORD_T *) repalloc((void *) prs->words, prs->lenwords * sizeof(WORD_T));
373373
}
374374
if (tokenlen > 0xffff)
375375
{
@@ -410,18 +410,18 @@ parsetext(PRSTEXT * prs, char *buf, int4 buflen)
410410
static int
411411
compareWORD(const void *a, const void *b)
412412
{
413-
if (((WORD *) a)->len == ((WORD *) b)->len)
413+
if (((WORD_T *) a)->len == ((WORD_T *) b)->len)
414414
return strncmp(
415-
((WORD *) a)->word,
416-
((WORD *) b)->word,
417-
((WORD *) b)->len);
418-
return (((WORD *) a)->len > ((WORD *) b)->len) ? 1 : -1;
415+
((WORD_T *) a)->word,
416+
((WORD_T *) b)->word,
417+
((WORD_T *) b)->len);
418+
return (((WORD_T *) a)->len > ((WORD_T *) b)->len) ? 1 : -1;
419419
}
420420

421421
static int
422-
uniqueWORD(WORD * a, int4 l)
422+
uniqueWORD(WORD_T * a, int4 l)
423423
{
424-
WORD *ptr,
424+
WORD_T *ptr,
425425
*res;
426426

427427
if (l == 1)
@@ -430,7 +430,7 @@ uniqueWORD(WORD * a, int4 l)
430430
res = a;
431431
ptr = a + 1;
432432

433-
qsort((void *) a, l, sizeof(WORD), compareWORD);
433+
qsort((void *) a, l, sizeof(WORD_T), compareWORD);
434434

435435
while (ptr - a < l)
436436
{
@@ -500,7 +500,7 @@ txt2txtidx(PG_FUNCTION_ARGS)
500500

501501
prs.lenwords = 32;
502502
prs.curwords = 0;
503-
prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
503+
prs.words = (WORD_T *) palloc(sizeof(WORD_T) * prs.lenwords);
504504

505505
initmorph();
506506
parsetext(&prs, VARDATA(in), VARSIZE(in) - VARHDRSZ);
@@ -564,7 +564,7 @@ tsearch(PG_FUNCTION_ARGS)
564564
errmsg("could not find txtidx_field")));
565565
prs.lenwords = 32;
566566
prs.curwords = 0;
567-
prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
567+
prs.words = (WORD_T *) palloc(sizeof(WORD_T) * prs.lenwords);
568568

569569
initmorph();
570570
/* find all words in indexable column */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy