From 5936055d46c29aecb8a74db316a9421c1c62cf8b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 31 Oct 2002 19:11:48 +0000 Subject: [PATCH] Avoid use of inline functions that are not declared static. Needed to conform to C99's brain-dead notion of how inline functions should work. --- contrib/dbase/dbf2pg.c | 9 ++++--- src/backend/utils/sort/tuplesort.c | 42 +++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/contrib/dbase/dbf2pg.c b/contrib/dbase/dbf2pg.c index f8e6bafcd1..abf04dfa28 100644 --- a/contrib/dbase/dbf2pg.c +++ b/contrib/dbase/dbf2pg.c @@ -49,9 +49,10 @@ char *subarg = NULL; char escape_buff[8192]; void do_substitute(char *subarg, dbhead * dbh); -inline void strtoupper(char *string); -inline void strtolower(char *string); +static inline void strtoupper(char *string); +static inline void strtolower(char *string); + void do_create(PGconn *, char *, dbhead *); void do_inserts(PGconn *, char *, dbhead *); int check_table(PGconn *, char *); @@ -88,7 +89,7 @@ isinteger(char *buff) return 1; } -inline void +static inline void strtoupper(char *string) { while (*string != '\0') @@ -98,7 +99,7 @@ strtoupper(char *string) } } -inline void +static inline void strtolower(char *string) { while (*string != '\0') diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 38e73f8a63..164e16b1dd 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -78,7 +78,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.28 2002/10/04 17:19:55 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.29 2002/10/31 19:11:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1835,10 +1835,10 @@ myFunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2) * and return a 3-way comparison result. This takes care of handling * NULLs and sort ordering direction properly. */ -inline int32 -ApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind, - Datum datum1, bool isNull1, - Datum datum2, bool isNull2) +static inline int32 +inlineApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind, + Datum datum1, bool isNull1, + Datum datum2, bool isNull2) { switch (kind) { @@ -1903,6 +1903,20 @@ ApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind, } } +/* + * Non-inline ApplySortFunction() --- this is needed only to conform to + * C99's brain-dead notions about how to implement inline functions... + */ +int32 +ApplySortFunction(FmgrInfo *sortFunction, SortFunctionKind kind, + Datum datum1, bool isNull1, + Datum datum2, bool isNull2) +{ + return inlineApplySortFunction(sortFunction, kind, + datum1, isNull1, + datum2, isNull2); +} + /* * Routines specialized for HeapTuple case @@ -1929,9 +1943,10 @@ comparetup_heap(Tuplesortstate *state, const void *a, const void *b) datum1 = heap_getattr(ltup, attno, tupDesc, &isnull1); datum2 = heap_getattr(rtup, attno, tupDesc, &isnull2); - compare = ApplySortFunction(&scanKey->sk_func, - state->sortFnKinds[nkey], - datum1, isnull1, datum2, isnull2); + compare = inlineApplySortFunction(&scanKey->sk_func, + state->sortFnKinds[nkey], + datum1, isnull1, + datum2, isnull2); if (compare != 0) { /* dead code? SK_COMMUTE can't actually be set here, can it? */ @@ -2043,8 +2058,9 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b) /* see comments about NULLs handling in btbuild */ /* the comparison function is always of CMP type */ - compare = ApplySortFunction(&entry->sk_func, SORTFUNC_CMP, - datum1, isnull1, datum2, isnull2); + compare = inlineApplySortFunction(&entry->sk_func, SORTFUNC_CMP, + datum1, isnull1, + datum2, isnull2); if (compare != 0) return (int) compare; /* done when we find unequal @@ -2137,9 +2153,9 @@ comparetup_datum(Tuplesortstate *state, const void *a, const void *b) DatumTuple *ltup = (DatumTuple *) a; DatumTuple *rtup = (DatumTuple *) b; - return ApplySortFunction(&state->sortOpFn, state->sortFnKind, - ltup->val, ltup->isNull, - rtup->val, rtup->isNull); + return inlineApplySortFunction(&state->sortOpFn, state->sortFnKind, + ltup->val, ltup->isNull, + rtup->val, rtup->isNull); } static void *