Re: [pgsql-hackers-win32] Contrib modules on Win32
Claudio Natoli <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.devel.patches,gmane.comp.db.postgresql.devel.win32 |
|---|---|
| Message-ID | <[email protected]> |
Win32 compile fixes for pgbench, pgcrypto, and tsearch. Note: pgbench is the only one I actually use, and hence have tested Cheers, Claudio --- Certain disclaimers and policies apply to all email sent from Memetrics. For the full text of these disclaimers and policies see <a href="http://www.memetrics.com/emailpolicy.html">http://www.memetrics.com/em ailpolicy.html</a> ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster
diff.patch
(application/octet-stream, 7.2 KB)
Index: contrib/pgbench/pgbench.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/pgbench/pgbench.c,v
retrieving revision 1.32
diff -c -w -r1.32 pgbench.c
*** contrib/pgbench/pgbench.c 29 Aug 2004 05:06:36 -0000 1.32
--- contrib/pgbench/pgbench.c 9 Sep 2004 02:19:17 -0000
***************
*** 44,49 ****
--- 44,53 ----
extern char *optarg;
extern int optind;
+ #ifdef WIN32
+ #undef select
+ #endif
+
/********************************************************************
* some configurable parameters */
***************
*** 705,711 ****
int nsocks; /* return from select(2) */
int maxsock; /* max socket number to be waited */
! #ifndef __CYGWIN__
struct rlimit rlim;
#endif
--- 709,715 ----
int nsocks; /* return from select(2) */
int maxsock; /* max socket number to be waited */
! #if !(defined(__CYGWIN__) || defined(__MINGW32__))
struct rlimit rlim;
#endif
***************
*** 755,761 ****
fprintf(stderr, "invalid number of clients: %d\n", nclients);
exit(1);
}
! #ifndef __CYGWIN__
#ifdef RLIMIT_NOFILE /* most platform uses RLIMIT_NOFILE */
if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
{
--- 759,765 ----
fprintf(stderr, "invalid number of clients: %d\n", nclients);
exit(1);
}
! #if !(defined(__CYGWIN__) || defined(__MINGW32__))
#ifdef RLIMIT_NOFILE /* most platform uses RLIMIT_NOFILE */
if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
{
***************
*** 772,778 ****
fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
exit(1);
}
! #endif /* #ifndef __CYGWIN__ */
break;
case 'C':
is_connect = 1;
--- 776,782 ----
fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
exit(1);
}
! #endif /* #if !(defined(__CYGWIN__) || defined(__MINGW32__)) */
break;
case 'C':
is_connect = 1;
***************
*** 935,941 ****
/* set random seed */
gettimeofday(&tv1, 0);
! srand((uint) tv1.tv_usec);
/* get start up time */
gettimeofday(&tv1, 0);
--- 939,945 ----
/* set random seed */
gettimeofday(&tv1, 0);
! srand((unsigned int) tv1.tv_usec);
/* get start up time */
gettimeofday(&tv1, 0);
Index: contrib/pgcrypto/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/pgcrypto/Makefile,v
retrieving revision 1.11
diff -c -w -r1.11 Makefile
*** contrib/pgcrypto/Makefile 20 Aug 2004 20:13:06 -0000 1.11
--- contrib/pgcrypto/Makefile 9 Sep 2004 02:19:17 -0000
***************
*** 82,87 ****
--- 82,92 ----
include $(top_srcdir)/contrib/contrib-global.mk
endif
+ # to make ws2_32.lib the last library (must occur after definition of PORTNAME)
+ ifeq ($(PORTNAME),win32)
+ SHLIB_LINK += -lwsock32 -lws2_32
+ endif
+
rijndael.o: rijndael.tbl
Index: contrib/tsearch/gistidx.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/tsearch/gistidx.h,v
retrieving revision 1.4
diff -c -w -r1.4 gistidx.h
*** contrib/tsearch/gistidx.h 5 Nov 2001 17:46:23 -0000 1.4
--- contrib/tsearch/gistidx.h 9 Sep 2004 02:19:17 -0000
***************
*** 33,38 ****
--- 33,39 ----
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
#define abs(a) ((a) < (0) ? -(a) : (a))
+ #undef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
#define HASH(sign, val) SETBIT((sign), HASHVAL(val))
Index: contrib/tsearch/rewrite.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/tsearch/rewrite.c,v
retrieving revision 1.6
diff -c -w -r1.6 rewrite.c
*** contrib/tsearch/rewrite.c 27 Jul 2003 17:10:06 -0000 1.6
--- contrib/tsearch/rewrite.c 9 Sep 2004 02:19:17 -0000
***************
*** 174,179 ****
--- 174,180 ----
return plaintree(clean_NOT_intree(root), len);
}
+ #undef V_UNKNOWN
#define V_UNKNOWN 0
#define V_TRUE 1
#define V_FALSE 2
Index: contrib/tsearch/txtidx.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/tsearch/txtidx.c,v
retrieving revision 1.9
diff -c -w -r1.9 txtidx.c
*** contrib/tsearch/txtidx.c 24 Jul 2003 17:52:43 -0000 1.9
--- contrib/tsearch/txtidx.c 9 Sep 2004 02:19:18 -0000
***************
*** 342,352 ****
{
uint16 len;
char *word;
! } WORD;
typedef struct
{
! WORD *words;
int4 lenwords;
int4 curwords;
} PRSTEXT;
--- 342,352 ----
{
uint16 len;
char *word;
! } WORD_T; /* WORD type defined on win32; we'll use WORD_T */
typedef struct
{
! WORD_T *words;
int4 lenwords;
int4 curwords;
} PRSTEXT;
***************
*** 369,375 ****
if (prs->curwords == prs->lenwords)
{
prs->lenwords *= 2;
! prs->words = (WORD *) repalloc((void *) prs->words, prs->lenwords * sizeof(WORD));
}
if (tokenlen > 0xffff)
{
--- 369,375 ----
if (prs->curwords == prs->lenwords)
{
prs->lenwords *= 2;
! prs->words = (WORD_T *) repalloc((void *) prs->words, prs->lenwords * sizeof(WORD_T));
}
if (tokenlen > 0xffff)
{
***************
*** 410,427 ****
static int
compareWORD(const void *a, const void *b)
{
! if (((WORD *) a)->len == ((WORD *) b)->len)
return strncmp(
! ((WORD *) a)->word,
! ((WORD *) b)->word,
! ((WORD *) b)->len);
! return (((WORD *) a)->len > ((WORD *) b)->len) ? 1 : -1;
}
static int
! uniqueWORD(WORD * a, int4 l)
{
! WORD *ptr,
*res;
if (l == 1)
--- 410,427 ----
static int
compareWORD(const void *a, const void *b)
{
! if (((WORD_T *) a)->len == ((WORD_T *) b)->len)
return strncmp(
! ((WORD_T *) a)->word,
! ((WORD_T *) b)->word,
! ((WORD_T *) b)->len);
! return (((WORD_T *) a)->len > ((WORD_T *) b)->len) ? 1 : -1;
}
static int
! uniqueWORD(WORD_T * a, int4 l)
{
! WORD_T *ptr,
*res;
if (l == 1)
***************
*** 430,436 ****
res = a;
ptr = a + 1;
! qsort((void *) a, l, sizeof(WORD), compareWORD);
while (ptr - a < l)
{
--- 430,436 ----
res = a;
ptr = a + 1;
! qsort((void *) a, l, sizeof(WORD_T), compareWORD);
while (ptr - a < l)
{
***************
*** 500,506 ****
prs.lenwords = 32;
prs.curwords = 0;
! prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
initmorph();
parsetext(&prs, VARDATA(in), VARSIZE(in) - VARHDRSZ);
--- 500,506 ----
prs.lenwords = 32;
prs.curwords = 0;
! prs.words = (WORD_T *) palloc(sizeof(WORD_T) * prs.lenwords);
initmorph();
parsetext(&prs, VARDATA(in), VARSIZE(in) - VARHDRSZ);
***************
*** 564,570 ****
errmsg("could not find txtidx_field")));
prs.lenwords = 32;
prs.curwords = 0;
! prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
initmorph();
/* find all words in indexable column */
--- 564,570 ----
errmsg("could not find txtidx_field")));
prs.lenwords = 32;
prs.curwords = 0;
! prs.words = (WORD_T *) palloc(sizeof(WORD_T) * prs.lenwords);
initmorph();
/* find all words in indexable column */