summaryrefslogtreecommitdiff
path: root/src/include/utils
diff options
context:
space:
mode:
authorAndres Freund2015-08-05 16:19:52 +0000
committerAndres Freund2015-08-05 16:19:52 +0000
commitde6fd1c898f6eca82c2130a9dbb42d00da68d79e (patch)
tree2387db94ee7d19f19ec45dbfc31c3a6c3494a62c /src/include/utils
parenta855118be3f0682a2061448db5a87dec50717af4 (diff)
Rely on inline functions even if that causes warnings in older compilers.
So far we have worked around the fact that some very old compilers do not support 'inline' functions by only using inline functions conditionally (or not at all). Since such compilers are very rare by now, we have decided to rely on inline functions from 9.6 onwards. To avoid breaking these old compilers inline is defined away when not supported. That'll cause "function x defined but not used" type of warnings, but since nobody develops on such compilers anymore that's ok. This change in policy will allow us to more easily employ inline functions. I chose to remove code previously conditional on PG_USE_INLINE as it seemed confusing to have code dependent on a define that's always defined. Blacklisting of compilers, like in c53f73879f, now has to be done differently. A platform template can define PG_FORCE_DISABLE_INLINE to force inline to be defined empty. Discussion: 20150701161447.GB30708@awork2.anarazel.de
Diffstat (limited to 'src/include/utils')
-rw-r--r--src/include/utils/arrayaccess.h19
-rw-r--r--src/include/utils/palloc.h11
-rw-r--r--src/include/utils/sortsupport.h18
3 files changed, 5 insertions, 43 deletions
diff --git a/src/include/utils/arrayaccess.h b/src/include/utils/arrayaccess.h
index 72575d4a829..af808fd9add 100644
--- a/src/include/utils/arrayaccess.h
+++ b/src/include/utils/arrayaccess.h
@@ -44,20 +44,8 @@ typedef struct array_iter
int bitmask; /* mask for current bit in nulls bitmap */
} array_iter;
-/*
- * We want the functions below to be inline; but if the compiler doesn't
- * support that, fall back on providing them as regular functions. See
- * STATIC_IF_INLINE in c.h.
- */
-#ifndef PG_USE_INLINE
-extern void array_iter_setup(array_iter *it, AnyArrayType *a);
-extern Datum array_iter_next(array_iter *it, bool *isnull, int i,
- int elmlen, bool elmbyval, char elmalign);
-#endif /* !PG_USE_INLINE */
-#if defined(PG_USE_INLINE) || defined(ARRAYACCESS_INCLUDE_DEFINITIONS)
-
-STATIC_IF_INLINE void
+static inline void
array_iter_setup(array_iter *it, AnyArrayType *a)
{
if (VARATT_IS_EXPANDED_HEADER(a))
@@ -89,7 +77,7 @@ array_iter_setup(array_iter *it, AnyArrayType *a)
it->bitmask = 1;
}
-STATIC_IF_INLINE Datum
+static inline Datum
array_iter_next(array_iter *it, bool *isnull, int i,
int elmlen, bool elmbyval, char elmalign)
{
@@ -127,7 +115,4 @@ array_iter_next(array_iter *it, bool *isnull, int i,
return ret;
}
-#endif /* defined(PG_USE_INLINE) ||
- * defined(ARRAYACCESS_INCLUDE_DEFINITIONS) */
-
#endif /* ARRAYACCESS_H */
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index e56f5014a3d..f2bcd00b4cb 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -98,10 +98,6 @@ extern void *MemoryContextAllocHuge(MemoryContext context, Size size);
extern void *repalloc_huge(void *pointer, Size size);
/*
- * MemoryContextSwitchTo can't be a macro in standard C compilers.
- * But we can make it an inline function if the compiler supports it.
- * See STATIC_IF_INLINE in c.h.
- *
* Although this header file is nominally backend-only, certain frontend
* programs like pg_controldata include it via postgres.h. For some compilers
* it's necessary to hide the inline definition of MemoryContextSwitchTo in
@@ -109,11 +105,7 @@ extern void *repalloc_huge(void *pointer, Size size);
*/
#ifndef FRONTEND
-#ifndef PG_USE_INLINE
-extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
-#endif /* !PG_USE_INLINE */
-#if defined(PG_USE_INLINE) || defined(MCXT_INCLUDE_DEFINITIONS)
-STATIC_IF_INLINE MemoryContext
+static inline MemoryContext
MemoryContextSwitchTo(MemoryContext context)
{
MemoryContext old = CurrentMemoryContext;
@@ -121,7 +113,6 @@ MemoryContextSwitchTo(MemoryContext context)
CurrentMemoryContext = context;
return old;
}
-#endif /* PG_USE_INLINE || MCXT_INCLUDE_DEFINITIONS */
#endif /* FRONTEND */
/* Registration of memory context reset/delete callbacks */
diff --git a/src/include/utils/sortsupport.h b/src/include/utils/sortsupport.h
index 787404ed903..42586305563 100644
--- a/src/include/utils/sortsupport.h
+++ b/src/include/utils/sortsupport.h
@@ -193,23 +193,10 @@ typedef struct SortSupportData
/*
- * ApplySortComparator should be inlined if possible. See STATIC_IF_INLINE
- * in c.h.
- */
-#ifndef PG_USE_INLINE
-extern int ApplySortComparator(Datum datum1, bool isNull1,
- Datum datum2, bool isNull2,
- SortSupport ssup);
-extern int ApplySortAbbrevFullComparator(Datum datum1, bool isNull1,
- Datum datum2, bool isNull2,
- SortSupport ssup);
-#endif /* !PG_USE_INLINE */
-#if defined(PG_USE_INLINE) || defined(SORTSUPPORT_INCLUDE_DEFINITIONS)
-/*
* Apply a sort comparator function and return a 3-way comparison result.
* This takes care of handling reverse-sort and NULLs-ordering properly.
*/
-STATIC_IF_INLINE int
+static inline int
ApplySortComparator(Datum datum1, bool isNull1,
Datum datum2, bool isNull2,
SortSupport ssup)
@@ -247,7 +234,7 @@ ApplySortComparator(Datum datum1, bool isNull1,
* authoritative comparator. This takes care of handling reverse-sort and
* NULLs-ordering properly.
*/
-STATIC_IF_INLINE int
+static inline int
ApplySortAbbrevFullComparator(Datum datum1, bool isNull1,
Datum datum2, bool isNull2,
SortSupport ssup)
@@ -279,7 +266,6 @@ ApplySortAbbrevFullComparator(Datum datum1, bool isNull1,
return compare;
}
-#endif /*-- PG_USE_INLINE || SORTSUPPORT_INCLUDE_DEFINITIONS */
/* Other functions in utils/sort/sortsupport.c */
extern void PrepareSortSupportComparisonShim(Oid cmpFunc, SortSupport ssup);