Back-port several small portability fixes to get contrib building
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 2 Aug 2005 01:35:23 +0000 (01:35 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 2 Aug 2005 01:35:23 +0000 (01:35 +0000)
cleanly on AIX in the 8.0 branch.  Rocco Altier

13 files changed:
contrib/cube/Makefile
contrib/tsearch2/dict.c
contrib/tsearch2/dict_ex.c
contrib/tsearch2/dict_ispell.c
contrib/tsearch2/dict_snowball.c
contrib/tsearch2/dict_syn.c
contrib/tsearch2/prs_dcfg.c
contrib/tsearch2/snmap.c
contrib/tsearch2/ts_cfg.c
contrib/tsearch2/wparser.c
contrib/tsearch2/wparser_def.c
src/backend/Makefile
src/port/getopt_long.c

index 216cf5ec6040f4e8944baf625612ed1e232b7a22..2b2fa3c86c8402e81fcaa8e6551b86e96dc18d3c 100644 (file)
@@ -9,6 +9,7 @@ REGRESS = cube
 
 EXTRA_CLEAN = cubeparse.c cubeparse.h cubescan.c y.tab.c y.tab.h
 
+SHLIB_LINK += $(filter -lm, $(LIBS))
 
 ifdef USE_PGXS
 PGXS = $(shell pg_config --pgxs)
index 357097681e55d0a839c95aeb1e50eab2fb22b6f8..b2a82688194fb2ad55d60ce2c5219de6a5fb7437 100644 (file)
@@ -2,16 +2,15 @@
  * interface functions to dictionary
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
+#include "postgres.h"
+
 #include <ctype.h>
 
-#include "postgres.h"
-#include "fmgr.h"
-#include "utils/array.h"
 #include "catalog/pg_type.h"
 #include "executor/spi.h"
+#include "fmgr.h"
+#include "utils/array.h"
+#include "utils/memutils.h"
 
 #include "dict.h"
 #include "common.h"
@@ -92,7 +91,9 @@ reset_dict(void)
 static int
 comparedict(const void *a, const void *b)
 {
-       return ((DictInfo *) a)->dict_id - ((DictInfo *) b)->dict_id;
+       if ( ((DictInfo *) a)->dict_id == ((DictInfo *) b)->dict_id )
+               return 0;
+       return ( ((DictInfo *) a)->dict_id < ((DictInfo *) b)->dict_id ) ? -1 : 1;
 }
 
 DictInfo *
index a8fb20453ba2125bed97bbadc0cfff28cef5112f..ab1d2925f864756133dfc5b09c29db770531bbbd 100644 (file)
@@ -2,10 +2,6 @@
  * example of dictionary
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "postgres.h"
 
 #include "dict.h"
index 5725c8fb3629020d8efaa3d3c475879e80c301e2..a66a55f1505dcb2fcb5017a74a4c37f3ee93afe3 100644 (file)
@@ -2,12 +2,10 @@
  * ISpell interface
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
 #include "postgres.h"
 
+#include <ctype.h>
+
 #include "dict.h"
 #include "common.h"
 #include "ispell/spell.h"
index 51dba0444994e36eb8017aaa8c3b86287054151b..ddb9cd169eab2a5c117709c77682aca7ad6495f3 100644 (file)
@@ -3,9 +3,6 @@
  * http://snowball.tartarus.org/
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <stdlib.h>
-#include <string.h>
-
 #include "postgres.h"
 
 #include "dict.h"
index 046a59490394195501c35adf1178f6edaba7448a..df616e0aad28d06592f8593626c352c1ad0cb752 100644 (file)
@@ -2,13 +2,10 @@
  * ISpell interface
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-
 #include "postgres.h"
 
+#include <ctype.h>
+
 #include "dict.h"
 #include "common.h"
 
index 0837451f22727e040ea176555dfc452a69d2cb97..af83b6506d47dace4588c54396647ca5d88e5d73 100644 (file)
@@ -2,12 +2,10 @@
  * Simple config parser
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
 #include "postgres.h"
 
+#include <ctype.h>
+
 #include "dict.h"
 #include "common.h"
 
index c152b1ac2386a9b890cde14b5f5b8f3ba60b1697..9aa0e2214f6bf96acbf5121edf90b34519570f4f 100644 (file)
@@ -2,11 +2,8 @@
  * simple but fast map from str to Oid
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "postgres.h"
+
 #include "snmap.h"
 #include "common.h"
 
index afebb11319963885595e3b7a364a9720169ee787..ac8381904e614d9ab784cad1784b1356b56e2acf 100644 (file)
@@ -2,17 +2,16 @@
  * interface functions to tscfg
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
+#include "postgres.h"
+
 #include <ctype.h>
 #include <locale.h>
 
-#include "postgres.h"
-#include "fmgr.h"
-#include "utils/array.h"
 #include "catalog/pg_type.h"
 #include "executor/spi.h"
+#include "fmgr.h"
+#include "utils/array.h"
+#include "utils/memutils.h"
 
 #include "ts_cfg.h"
 #include "dict.h"
@@ -186,7 +185,9 @@ reset_cfg(void)
 static int
 comparecfg(const void *a, const void *b)
 {
-       return ((TSCfgInfo *) a)->id - ((TSCfgInfo *) b)->id;
+       if ( ((TSCfgInfo *) a)->id == ((TSCfgInfo *) b)->id )
+               return 0;
+       return ( ((TSCfgInfo *) a)->id < ((TSCfgInfo *) b)->id ) ? -1 : 1;
 }
 
 TSCfgInfo *
index 554c2684b9bfc2a445b14967e0df049ac7e90a11..39cd673bb0b43bd616ecca72389784a58d7f3e69 100644 (file)
@@ -2,17 +2,16 @@
  * interface functions to parser
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
+#include "postgres.h"
+
 #include <ctype.h>
 
-#include "postgres.h"
-#include "fmgr.h"
-#include "utils/array.h"
 #include "catalog/pg_type.h"
 #include "executor/spi.h"
+#include "fmgr.h"
 #include "funcapi.h"
+#include "utils/array.h"
+#include "utils/memutils.h"
 
 #include "wparser.h"
 #include "ts_cfg.h"
@@ -93,7 +92,9 @@ reset_prs(void)
 static int
 compareprs(const void *a, const void *b)
 {
-       return ((WParserInfo *) a)->prs_id - ((WParserInfo *) b)->prs_id;
+       if ( ((WParserInfo *) a)->prs_id == ((WParserInfo *) b)->prs_id )
+               return 0;
+       return ( ((WParserInfo *) a)->prs_id < ((WParserInfo *) b)->prs_id ) ? -1 : 1;
 }
 
 WParserInfo *
index 93368b1e8974ea89b5de8e30c0e92fae81fa6e40..a33bacf31bc2df599a2341eae93e0cb909c585a1 100644 (file)
@@ -2,11 +2,8 @@
  * default word parser
  * Teodor Sigaev <teodor@sigaev.ru>
  */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "postgres.h"
+
 #include "utils/builtins.h"
 
 #include "dict.h"
index 719b81ed8ee8d5ed1a0a9ad32e424d9551221ad5..4c33630af83e44c9c59ac3887bfb77f243c151df 100644 (file)
@@ -17,19 +17,21 @@ DIRS := access bootstrap catalog parser commands executor lib libpq \
        main nodes optimizer port postmaster regex rewrite \
        storage tcop utils $(top_builddir)/src/timezone
 
-OBJS := $(DIRS:%=%/SUBSYS.o)
+SUBSYSOBJS := $(DIRS:%=%/SUBSYS.o)
+
+OBJS := $(SUBSYSOBJS) $(top_builddir)/src/port/libpgport_srv.a
+
+# We put libpgport into OBJS, so remove it from LIBS
+LIBS := $(patsubst -lpgport, , $(LIBS))
 
 ifeq ($(PORTNAME), qnx4)
 # This file crashes qnx4's wlink and is therefore not in
 # bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
 # necessary?) [ Yes, until the Watcom compiler goes open source it's
 # effectively unsupported ]
-OBJS+= bootstrap/bootstrap.o
+OBJS += bootstrap/bootstrap.o
 endif
 
-# Use server version of port library
-LIBS := $(patsubst -lpgport,-lpgport_srv, $(LIBS))
-
 ##########################################################################
 
 all: submake-libpgport postgres $(POSTGRES_IMP)
@@ -48,7 +50,7 @@ postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
        $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
        $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack,4194304 -o $@$(X) $@.exp $(OBJS) $(LIBS)
        rm -f $@.exp $@.base
 
 postgres.def: $(OBJS)
@@ -65,11 +67,11 @@ postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(WIN32RES)
        $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(WIN32RES) $(LIBS)
        $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
-       $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(WIN32RES) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack=4194304 -o $@$(X) $@.exp $(OBJS) $(WIN32RES) $(LIBS)
        rm -f $@.exp $@.base
 
 postgres.def: $(OBJS)
-       $(DLLTOOL) --export-all --output-def $@ $^ $(top_builddir)/src/port/libpgport.a
+       $(DLLTOOL) --export-all --output-def $@ $^
 
 libpostgres.a: postgres.def
        $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
@@ -98,7 +100,7 @@ endif
 endif # aix
 
 # Parallel make trickery
-$(OBJS): $(DIRS:%=%-recursive) ;
+$(SUBSYSOBJS): $(DIRS:%=%-recursive) ;
 
 .PHONY: $(DIRS:%=%-recursive)
 # Update the commonly used headers before building the subdirectories
index 950d468acc913f8139158cd1810363a5baf52bcb..08e4d5374a044128590d6c4f1bccb49a97e56016 100644 (file)
  * $PostgreSQL$
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "c.h"
 
 #include "getopt_long.h"
 
+#ifndef HAVE_INT_OPTRESET
+int                    optreset;
+#endif
+
 #define BADCH  '?'
 #define BADARG ':'
 #define EMSG   ""
 
+
 int
 getopt_long(int argc, char *const argv[],
                        const char *optstring,