From b89237c03e69818dbf0a48e38117beb19c804407 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 2 Aug 2005 01:35:23 +0000 Subject: [PATCH] Back-port several small portability fixes to get contrib building cleanly on AIX in the 8.0 branch. Rocco Altier --- contrib/cube/Makefile | 1 + contrib/tsearch2/dict.c | 15 ++++++++------- contrib/tsearch2/dict_ex.c | 4 ---- contrib/tsearch2/dict_ispell.c | 6 ++---- contrib/tsearch2/dict_snowball.c | 3 --- contrib/tsearch2/dict_syn.c | 7 ++----- contrib/tsearch2/prs_dcfg.c | 6 ++---- contrib/tsearch2/snmap.c | 5 +---- contrib/tsearch2/ts_cfg.c | 15 ++++++++------- contrib/tsearch2/wparser.c | 15 ++++++++------- contrib/tsearch2/wparser_def.c | 5 +---- src/backend/Makefile | 20 +++++++++++--------- src/port/getopt_long.c | 9 ++++++--- 13 files changed, 50 insertions(+), 61 deletions(-) diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile index 216cf5ec60..2b2fa3c86c 100644 --- a/contrib/cube/Makefile +++ b/contrib/cube/Makefile @@ -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) diff --git a/contrib/tsearch2/dict.c b/contrib/tsearch2/dict.c index 357097681e..b2a8268819 100644 --- a/contrib/tsearch2/dict.c +++ b/contrib/tsearch2/dict.c @@ -2,16 +2,15 @@ * interface functions to dictionary * Teodor Sigaev */ -#include -#include -#include +#include "postgres.h" + #include -#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 * diff --git a/contrib/tsearch2/dict_ex.c b/contrib/tsearch2/dict_ex.c index a8fb20453b..ab1d2925f8 100644 --- a/contrib/tsearch2/dict_ex.c +++ b/contrib/tsearch2/dict_ex.c @@ -2,10 +2,6 @@ * example of dictionary * Teodor Sigaev */ -#include -#include -#include - #include "postgres.h" #include "dict.h" diff --git a/contrib/tsearch2/dict_ispell.c b/contrib/tsearch2/dict_ispell.c index 5725c8fb36..a66a55f150 100644 --- a/contrib/tsearch2/dict_ispell.c +++ b/contrib/tsearch2/dict_ispell.c @@ -2,12 +2,10 @@ * ISpell interface * Teodor Sigaev */ -#include -#include -#include - #include "postgres.h" +#include + #include "dict.h" #include "common.h" #include "ispell/spell.h" diff --git a/contrib/tsearch2/dict_snowball.c b/contrib/tsearch2/dict_snowball.c index 51dba04449..ddb9cd169e 100644 --- a/contrib/tsearch2/dict_snowball.c +++ b/contrib/tsearch2/dict_snowball.c @@ -3,9 +3,6 @@ * http://snowball.tartarus.org/ * Teodor Sigaev */ -#include -#include - #include "postgres.h" #include "dict.h" diff --git a/contrib/tsearch2/dict_syn.c b/contrib/tsearch2/dict_syn.c index 046a594903..df616e0aad 100644 --- a/contrib/tsearch2/dict_syn.c +++ b/contrib/tsearch2/dict_syn.c @@ -2,13 +2,10 @@ * ISpell interface * Teodor Sigaev */ -#include -#include -#include -#include - #include "postgres.h" +#include + #include "dict.h" #include "common.h" diff --git a/contrib/tsearch2/prs_dcfg.c b/contrib/tsearch2/prs_dcfg.c index 0837451f22..af83b6506d 100644 --- a/contrib/tsearch2/prs_dcfg.c +++ b/contrib/tsearch2/prs_dcfg.c @@ -2,12 +2,10 @@ * Simple config parser * Teodor Sigaev */ -#include -#include -#include - #include "postgres.h" +#include + #include "dict.h" #include "common.h" diff --git a/contrib/tsearch2/snmap.c b/contrib/tsearch2/snmap.c index c152b1ac23..9aa0e2214f 100644 --- a/contrib/tsearch2/snmap.c +++ b/contrib/tsearch2/snmap.c @@ -2,11 +2,8 @@ * simple but fast map from str to Oid * Teodor Sigaev */ -#include -#include -#include - #include "postgres.h" + #include "snmap.h" #include "common.h" diff --git a/contrib/tsearch2/ts_cfg.c b/contrib/tsearch2/ts_cfg.c index afebb11319..ac8381904e 100644 --- a/contrib/tsearch2/ts_cfg.c +++ b/contrib/tsearch2/ts_cfg.c @@ -2,17 +2,16 @@ * interface functions to tscfg * Teodor Sigaev */ -#include -#include -#include +#include "postgres.h" + #include #include -#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 * diff --git a/contrib/tsearch2/wparser.c b/contrib/tsearch2/wparser.c index 554c2684b9..39cd673bb0 100644 --- a/contrib/tsearch2/wparser.c +++ b/contrib/tsearch2/wparser.c @@ -2,17 +2,16 @@ * interface functions to parser * Teodor Sigaev */ -#include -#include -#include +#include "postgres.h" + #include -#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 * diff --git a/contrib/tsearch2/wparser_def.c b/contrib/tsearch2/wparser_def.c index 93368b1e89..a33bacf31b 100644 --- a/contrib/tsearch2/wparser_def.c +++ b/contrib/tsearch2/wparser_def.c @@ -2,11 +2,8 @@ * default word parser * Teodor Sigaev */ -#include -#include -#include - #include "postgres.h" + #include "utils/builtins.h" #include "dict.h" diff --git a/src/backend/Makefile b/src/backend/Makefile index 719b81ed8e..4c33630af8 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -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 diff --git a/src/port/getopt_long.c b/src/port/getopt_long.c index 950d468acc..08e4d5374a 100644 --- a/src/port/getopt_long.c +++ b/src/port/getopt_long.c @@ -38,16 +38,19 @@ * $PostgreSQL$ */ -#include -#include -#include +#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, -- 2.39.5