-# PGAC_C_INLINE
-# -------------
-# Check if the C compiler understands inline functions without being
-# noisy about unused static inline functions. Some older compilers
-# understand inline functions (as tested by AC_C_INLINE) but warn about
-# them if they aren't used in a translation unit.
-#
-# This test used to just define an inline function, but some compilers
-# (notably clang) got too smart and now warn about unused static
-# inline functions when defined inside a .c file, but not when defined
-# in an included header. Since the latter is what we want to use, test
-# to see if the warning appears when the function is in a header file.
-# Not pretty, but it works.
-#
-# Defines: inline, PG_USE_INLINE
-AC_DEFUN([PGAC_C_INLINE],
-[AC_C_INLINE
-AC_CACHE_CHECK([for quiet inline (no complaint if unreferenced)], pgac_cv_c_inline_quietly,
- [pgac_cv_c_inline_quietly=no
- if test "$ac_cv_c_inline" != no; then
- pgac_c_inline_save_werror=$ac_c_werror_flag
- ac_c_werror_flag=yes
- AC_LINK_IFELSE([AC_LANG_PROGRAM([#include "$srcdir/config/test_quiet_include.h"],[])],
- [pgac_cv_c_inline_quietly=yes])
- ac_c_werror_flag=$pgac_c_inline_save_werror
- fi])
-if test "$pgac_cv_c_inline_quietly" != no; then
- AC_DEFINE_UNQUOTED([PG_USE_INLINE], 1,
- [Define to 1 if "static inline" works without unwanted warnings from ]
- [compilations where static inline functions are defined but not called.])
-fi
-])# PGAC_C_INLINE
-
-
# PGAC_C_PRINTF_ARCHETYPE
# -----------------------
# Set the format archetype used by gcc to check printf type functions. We
+++ /dev/null
-/*
- * For the raison d'etre of this file, check the comment above the definition
- * of the PGAC_C_INLINE macro in config/c-compiler.m4.
- */
-static inline int
-fun()
-{
- return 0;
-}
-
-/*
- * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
- * expansions of ginCompareItemPointers() "long long" arithmetic. To take
- * advantage of inlining, build a 64-bit PostgreSQL.
- */
-#if defined(__ILP32__) && defined(__IBMC__)
-#error "known inlining bug"
-#endif
;;
esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for quiet inline (no complaint if unreferenced)" >&5
-$as_echo_n "checking for quiet inline (no complaint if unreferenced)... " >&6; }
-if ${pgac_cv_c_inline_quietly+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- pgac_cv_c_inline_quietly=no
- if test "$ac_cv_c_inline" != no; then
- pgac_c_inline_save_werror=$ac_c_werror_flag
- ac_c_werror_flag=yes
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include "$srcdir/config/test_quiet_include.h"
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- pgac_cv_c_inline_quietly=yes
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- ac_c_werror_flag=$pgac_c_inline_save_werror
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_c_inline_quietly" >&5
-$as_echo "$pgac_cv_c_inline_quietly" >&6; }
-if test "$pgac_cv_c_inline_quietly" != no; then
-
-cat >>confdefs.h <<_ACEOF
-#define PG_USE_INLINE 1
-_ACEOF
-
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf format archetype" >&5
$as_echo_n "checking for printf format archetype... " >&6; }
if ${pgac_cv_printf_archetype+:} false; then :
m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
AC_C_BIGENDIAN
-PGAC_C_INLINE
+AC_C_INLINE
PGAC_PRINTF_ARCHETYPE
AC_C_FLEXIBLE_ARRAY_MEMBER
PGAC_C_SIGNED
*/
#include "postgres.h"
-/* See ilist.h */
-#define ILIST_INCLUDE_DEFINITIONS
-
#include "lib/ilist.h"
/*
*/
#include "postgres.h"
-/* see pg_list.h */
-#define PG_LIST_INCLUDE_DEFINITIONS
-
#include "nodes/pg_list.h"
*/
#include "postgres.h"
-/*
- * 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.
- */
-#define ATOMICS_INCLUDE_DEFINITIONS
-
#include "miscadmin.h"
#include "port/atomics.h"
#include "storage/spin.h"
#endif
#include <math.h>
-/* See arrayaccess.h */
-#define ARRAYACCESS_INCLUDE_DEFINITIONS
-
#include "access/htup_details.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
*-------------------------------------------------------------------------
*/
-/* see palloc.h. Must be before postgres.h */
-#define MCXT_INCLUDE_DEFINITIONS
-
#include "postgres.h"
#include "miscadmin.h"
#include "postgres.h"
-/* See sortsupport.h */
-#define SORTSUPPORT_INCLUDE_DEFINITIONS
-
#include "access/nbtree.h"
#include "fmgr.h"
#include "utils/lsyscache.h"
/*
* Merging the results of several gin scans compares item pointers a lot,
- * so we want this to be inlined. But if the compiler doesn't support that,
- * fall back on the non-inline version from itemptr.c. See STATIC_IF_INLINE in
- * c.h.
+ * so we want this to be inlined.
*/
-#ifdef PG_USE_INLINE
static inline int
ginCompareItemPointers(ItemPointer a, ItemPointer b)
{
else
return -1;
}
-#else
-#define ginCompareItemPointers(a, b) ItemPointerCompare(a, b)
-#endif /* PG_USE_INLINE */
#endif /* GIN_PRIVATE_H */
#include "pg_config.h"
#include "pg_config_manual.h" /* must be after pg_config.h */
+/*
+ * Force disable inlining if PG_FORCE_DISABLE_INLINE is defined. This is used
+ * to work around compiler bugs and might also be useful for investigatory
+ * purposes.
+ *
+ * This is done early (in slightly the wrong section) for two reasons: a) we
+ * don't want to include headers with different settings of this b)
+ * functionality later in this file might want to rely on inline functions.
+ */
+#ifdef PG_FORCE_DISABLE_INLINE
+#undef inline
+#define inline
+#endif
+
/*
* We always rely on the WIN32 macro being set by our build system,
* but _WIN32 is the compiler pre-defined macro. So make sure we define
#endif
-/*
- * Function inlining support -- Allow modules to define functions that may be
- * inlined, if the compiler supports it.
- *
- * The function bodies must be defined in the module header prefixed by
- * STATIC_IF_INLINE, protected by a cpp symbol that the module's .c file must
- * define. If the compiler doesn't support inline functions, the function
- * definitions are pulled in by the .c file as regular (not inline) symbols.
- *
- * The header must also declare the functions' prototypes, protected by
- * !PG_USE_INLINE.
- */
-
-/* declarations which are only visible when not inlining and in the .c file */
-#ifdef PG_USE_INLINE
-#define STATIC_IF_INLINE static inline
-#else
-#define STATIC_IF_INLINE
-#endif /* PG_USE_INLINE */
-
-/* declarations which are marked inline when inlining, extern otherwise */
-#ifdef PG_USE_INLINE
-#define STATIC_IF_INLINE_DECLARE static inline
-#else
-#define STATIC_IF_INLINE_DECLARE extern
-#endif /* PG_USE_INLINE */
-
-
/* ----------------------------------------------------------------
* Section 8: random stuff
* ----------------------------------------------------------------
#define slist_check(head) ((void) (head))
#endif /* ILIST_DEBUG */
+/* doubly linked list implementation */
-/*
- * 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 dlist_init(dlist_head *head);
-extern bool dlist_is_empty(dlist_head *head);
-extern void dlist_push_head(dlist_head *head, dlist_node *node);
-extern void dlist_push_tail(dlist_head *head, dlist_node *node);
-extern void dlist_insert_after(dlist_node *after, dlist_node *node);
-extern void dlist_insert_before(dlist_node *before, dlist_node *node);
-extern void dlist_delete(dlist_node *node);
-extern dlist_node *dlist_pop_head_node(dlist_head *head);
-extern void dlist_move_head(dlist_head *head, dlist_node *node);
-extern bool dlist_has_next(dlist_head *head, dlist_node *node);
-extern bool dlist_has_prev(dlist_head *head, dlist_node *node);
-extern dlist_node *dlist_next_node(dlist_head *head, dlist_node *node);
-extern dlist_node *dlist_prev_node(dlist_head *head, dlist_node *node);
-extern dlist_node *dlist_head_node(dlist_head *head);
-extern dlist_node *dlist_tail_node(dlist_head *head);
-
-/* dlist macro support functions */
-extern void *dlist_tail_element_off(dlist_head *head, size_t off);
-extern void *dlist_head_element_off(dlist_head *head, size_t off);
-#endif /* !PG_USE_INLINE */
-
-#if defined(PG_USE_INLINE) || defined(ILIST_INCLUDE_DEFINITIONS)
/*
* Initialize a doubly linked list.
* Previous state will be thrown away without any cleanup.
*/
-STATIC_IF_INLINE void
+static inline void
dlist_init(dlist_head *head)
{
head->head.next = head->head.prev = &head->head;
*
* An empty list has either its first 'next' pointer set to NULL, or to itself.
*/
-STATIC_IF_INLINE bool
+static inline bool
dlist_is_empty(dlist_head *head)
{
dlist_check(head);
/*
* Insert a node at the beginning of the list.
*/
-STATIC_IF_INLINE void
+static inline void
dlist_push_head(dlist_head *head, dlist_node *node)
{
if (head->head.next == NULL) /* convert NULL header to circular */
/*
* Insert a node at the end of the list.
*/
-STATIC_IF_INLINE void
+static inline void
dlist_push_tail(dlist_head *head, dlist_node *node)
{
if (head->head.next == NULL) /* convert NULL header to circular */
/*
* Insert a node after another *in the same list*
*/
-STATIC_IF_INLINE void
+static inline void
dlist_insert_after(dlist_node *after, dlist_node *node)
{
node->prev = after;
/*
* Insert a node before another *in the same list*
*/
-STATIC_IF_INLINE void
+static inline void
dlist_insert_before(dlist_node *before, dlist_node *node)
{
node->prev = before->prev;
/*
* Delete 'node' from its list (it must be in one).
*/
-STATIC_IF_INLINE void
+static inline void
dlist_delete(dlist_node *node)
{
node->prev->next = node->next;
/*
* Remove and return the first node from a list (there must be one).
*/
-STATIC_IF_INLINE dlist_node *
+static inline dlist_node *
dlist_pop_head_node(dlist_head *head)
{
dlist_node *node;
*
* Undefined behaviour if 'node' is not already part of the list.
*/
-STATIC_IF_INLINE void
+static inline void
dlist_move_head(dlist_head *head, dlist_node *node)
{
/* fast path if it's already at the head */
* Check whether 'node' has a following node.
* Caution: unreliable if 'node' is not in the list.
*/
-STATIC_IF_INLINE bool
+static inline bool
dlist_has_next(dlist_head *head, dlist_node *node)
{
return node->next != &head->head;
* Check whether 'node' has a preceding node.
* Caution: unreliable if 'node' is not in the list.
*/
-STATIC_IF_INLINE bool
+static inline bool
dlist_has_prev(dlist_head *head, dlist_node *node)
{
return node->prev != &head->head;
/*
* Return the next node in the list (there must be one).
*/
-STATIC_IF_INLINE dlist_node *
+static inline dlist_node *
dlist_next_node(dlist_head *head, dlist_node *node)
{
Assert(dlist_has_next(head, node));
/*
* Return previous node in the list (there must be one).
*/
-STATIC_IF_INLINE dlist_node *
+static inline dlist_node *
dlist_prev_node(dlist_head *head, dlist_node *node)
{
Assert(dlist_has_prev(head, node));
}
/* internal support function to get address of head element's struct */
-STATIC_IF_INLINE void *
+static inline void *
dlist_head_element_off(dlist_head *head, size_t off)
{
Assert(!dlist_is_empty(head));
/*
* Return the first node in the list (there must be one).
*/
-STATIC_IF_INLINE dlist_node *
+static inline dlist_node *
dlist_head_node(dlist_head *head)
{
return (dlist_node *) dlist_head_element_off(head, 0);
}
/* internal support function to get address of tail element's struct */
-STATIC_IF_INLINE void *
+static inline void *
dlist_tail_element_off(dlist_head *head, size_t off)
{
Assert(!dlist_is_empty(head));
/*
* Return the last node in the list (there must be one).
*/
-STATIC_IF_INLINE dlist_node *
+static inline dlist_node *
dlist_tail_node(dlist_head *head)
{
return (dlist_node *) dlist_tail_element_off(head, 0);
}
-#endif /* PG_USE_INLINE || ILIST_INCLUDE_DEFINITIONS */
/*
* Return the containing struct of 'type' where 'membername' is the dlist_node
(iter).cur = (iter).cur->prev)
-/*
- * 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 slist_init(slist_head *head);
-extern bool slist_is_empty(slist_head *head);
-extern void slist_push_head(slist_head *head, slist_node *node);
-extern void slist_insert_after(slist_node *after, slist_node *node);
-extern slist_node *slist_pop_head_node(slist_head *head);
-extern bool slist_has_next(slist_head *head, slist_node *node);
-extern slist_node *slist_next_node(slist_head *head, slist_node *node);
-extern slist_node *slist_head_node(slist_head *head);
-extern void slist_delete_current(slist_mutable_iter *iter);
-
-/* slist macro support function */
-extern void *slist_head_element_off(slist_head *head, size_t off);
-#endif
+/* singly linked list implementation */
-#if defined(PG_USE_INLINE) || defined(ILIST_INCLUDE_DEFINITIONS)
/*
* Initialize a singly linked list.
* Previous state will be thrown away without any cleanup.
*/
-STATIC_IF_INLINE void
+static inline void
slist_init(slist_head *head)
{
head->head.next = NULL;
/*
* Is the list empty?
*/
-STATIC_IF_INLINE bool
+static inline bool
slist_is_empty(slist_head *head)
{
slist_check(head);
/*
* Insert a node at the beginning of the list.
*/
-STATIC_IF_INLINE void
+static inline void
slist_push_head(slist_head *head, slist_node *node)
{
node->next = head->head.next;
/*
* Insert a node after another *in the same list*
*/
-STATIC_IF_INLINE void
+static inline void
slist_insert_after(slist_node *after, slist_node *node)
{
node->next = after->next;
/*
* Remove and return the first node from a list (there must be one).
*/
-STATIC_IF_INLINE slist_node *
+static inline slist_node *
slist_pop_head_node(slist_head *head)
{
slist_node *node;
/*
* Check whether 'node' has a following node.
*/
-STATIC_IF_INLINE bool
+static inline bool
slist_has_next(slist_head *head, slist_node *node)
{
slist_check(head);
/*
* Return the next node in the list (there must be one).
*/
-STATIC_IF_INLINE slist_node *
+static inline slist_node *
slist_next_node(slist_head *head, slist_node *node)
{
Assert(slist_has_next(head, node));
}
/* internal support function to get address of head element's struct */
-STATIC_IF_INLINE void *
+static inline void *
slist_head_element_off(slist_head *head, size_t off)
{
Assert(!slist_is_empty(head));
/*
* Return the first node in the list (there must be one).
*/
-STATIC_IF_INLINE slist_node *
+static inline slist_node *
slist_head_node(slist_head *head)
{
return (slist_node *) slist_head_element_off(head, 0);
* Caution: this modifies iter->cur, so don't use that again in the current
* loop iteration.
*/
-STATIC_IF_INLINE void
+static inline void
slist_delete_current(slist_mutable_iter *iter)
{
/*
*/
iter->cur = iter->prev;
}
-#endif /* PG_USE_INLINE || ILIST_INCLUDE_DEFINITIONS */
/*
* Return the containing struct of 'type' where 'membername' is the slist_node
/*
* These routines are used frequently. However, we can't implement
* them as macros, since we want to avoid double-evaluation of macro
- * arguments. Therefore, we implement them using static inline functions
- * if supported by the compiler, or as regular functions otherwise.
- * See STATIC_IF_INLINE in c.h.
+ * arguments.
*/
-#ifndef PG_USE_INLINE
-extern ListCell *list_head(const List *l);
-extern ListCell *list_tail(List *l);
-extern int list_length(const List *l);
-#endif /* PG_USE_INLINE */
-#if defined(PG_USE_INLINE) || defined(PG_LIST_INCLUDE_DEFINITIONS)
-STATIC_IF_INLINE ListCell *
+static inline ListCell *
list_head(const List *l)
{
return l ? l->head : NULL;
}
-STATIC_IF_INLINE ListCell *
+static inline ListCell *
list_tail(List *l)
{
return l ? l->tail : NULL;
}
-STATIC_IF_INLINE int
+static inline int
list_length(const List *l)
{
return l ? l->length : 0;
}
-#endif /*-- PG_USE_INLINE || PG_LIST_INCLUDE_DEFINITIONS */
/*
* NB: There is an unfortunate legacy from a previous incarnation of
/* Define to gnu_printf if compiler supports it, else printf. */
#undef PG_PRINTF_ATTRIBUTE
-/* Define to 1 if "static inline" works without unwanted warnings from
- compilations where static inline functions are defined but not called. */
-#undef PG_USE_INLINE
-
/* PostgreSQL version as a string */
#undef PG_VERSION
*
* HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_GETOPT, HAVE_GETOPT_H, HAVE_INTTYPES_H,
* HAVE_GETOPT_LONG, HAVE_LOCALE_T, HAVE_RINT, HAVE_STRINGS_H, HAVE_STRTOLL,
- * HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY, PG_USE_INLINE,
+ * HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY,
* inline, USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
*/
/* Define to 1 to build with Bonjour support. (--with-bonjour) */
/* #undef USE_BONJOUR */
-/* Define to 1 if "static inline" works without unwanted warnings from
- compilations where static inline functions are defined but not called. */
-#define PG_USE_INLINE 1
-
/* Define to 1 if you want 64-bit integer timestamp and interval support.
(--enable-integer-datetimes) */
/* #undef USE_INTEGER_DATETIMES */
*/
#include "port/atomics/generic.h"
-/*
- * Provide declarations for all functions here - on most platforms static
- * inlines are used and these aren't necessary, but when static inline is
- * unsupported these will be external functions.
- */
-STATIC_IF_INLINE_DECLARE void pg_atomic_init_flag(volatile pg_atomic_flag *ptr);
-STATIC_IF_INLINE_DECLARE bool pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr);
-STATIC_IF_INLINE_DECLARE bool pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr);
-STATIC_IF_INLINE_DECLARE void pg_atomic_clear_flag(volatile pg_atomic_flag *ptr);
-
-STATIC_IF_INLINE_DECLARE void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr);
-STATIC_IF_INLINE_DECLARE void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval);
-STATIC_IF_INLINE_DECLARE bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr,
- uint32 *expected, uint32 newval);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_);
-STATIC_IF_INLINE_DECLARE uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_);
-
-#ifdef PG_HAVE_ATOMIC_U64_SUPPORT
-
-STATIC_IF_INLINE_DECLARE void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val_);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr);
-STATIC_IF_INLINE_DECLARE void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval);
-STATIC_IF_INLINE_DECLARE bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr,
- uint64 *expected, uint64 newval);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_);
-STATIC_IF_INLINE_DECLARE uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_);
-
-#endif /* PG_HAVE_64_BIT_ATOMICS */
-
/*
* pg_compiler_barrier - prevent the compiler from moving code across
*/
#define pg_spin_delay() pg_spin_delay_impl()
-/*
- * The following functions are wrapper functions around the platform specific
- * implementation of the atomic operations performing common checks.
- */
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
/*
* pg_atomic_init_flag - initialize atomic flag.
*
* No barrier semantics.
*/
-STATIC_IF_INLINE_DECLARE void
+static inline void
pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
{
AssertPointerAlignment(ptr, sizeof(*ptr));
*
* Acquire (including read barrier) semantics.
*/
-STATIC_IF_INLINE_DECLARE bool
+static inline bool
pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr)
{
AssertPointerAlignment(ptr, sizeof(*ptr));
*
* No barrier semantics.
*/
-STATIC_IF_INLINE_DECLARE bool
+static inline bool
pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr)
{
AssertPointerAlignment(ptr, sizeof(*ptr));
*
* Release (including write barrier) semantics.
*/
-STATIC_IF_INLINE_DECLARE void
+static inline void
pg_atomic_clear_flag(volatile pg_atomic_flag *ptr)
{
AssertPointerAlignment(ptr, sizeof(*ptr));
*
* No barrier semantics.
*/
-STATIC_IF_INLINE_DECLARE void
+static inline void
pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
{
AssertPointerAlignment(ptr, 4);
*
* No barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
{
AssertPointerAlignment(ptr, 4);
*
* No barrier semantics.
*/
-STATIC_IF_INLINE_DECLARE void
+static inline void
pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
{
AssertPointerAlignment(ptr, 4);
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
{
AssertPointerAlignment(ptr, 4);
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE bool
+static inline bool
pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr,
uint32 *expected, uint32 newval)
{
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
{
AssertPointerAlignment(ptr, 4);
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
{
AssertPointerAlignment(ptr, 4);
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
{
AssertPointerAlignment(ptr, 4);
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
{
AssertPointerAlignment(ptr, 4);
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
{
AssertPointerAlignment(ptr, 4);
*
* Full barrier semantics.
*/
-STATIC_IF_INLINE uint32
+static inline uint32
pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
{
AssertPointerAlignment(ptr, 4);
*/
#ifdef PG_HAVE_ATOMIC_U64_SUPPORT
-STATIC_IF_INLINE_DECLARE void
+static inline void
pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
{
AssertPointerAlignment(ptr, 8);
pg_atomic_init_u64_impl(ptr, val);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
{
AssertPointerAlignment(ptr, 8);
return pg_atomic_read_u64_impl(ptr);
}
-STATIC_IF_INLINE void
+static inline void
pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
{
AssertPointerAlignment(ptr, 8);
pg_atomic_write_u64_impl(ptr, val);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
{
AssertPointerAlignment(ptr, 8);
return pg_atomic_exchange_u64_impl(ptr, newval);
}
-STATIC_IF_INLINE bool
+static inline bool
pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr,
uint64 *expected, uint64 newval)
{
return pg_atomic_compare_exchange_u64_impl(ptr, expected, newval);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
{
AssertPointerAlignment(ptr, 8);
return pg_atomic_fetch_add_u64_impl(ptr, add_);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
{
AssertPointerAlignment(ptr, 8);
return pg_atomic_fetch_sub_u64_impl(ptr, sub_);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_)
{
AssertPointerAlignment(ptr, 8);
return pg_atomic_fetch_and_u64_impl(ptr, and_);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_)
{
AssertPointerAlignment(ptr, 8);
return pg_atomic_fetch_or_u64_impl(ptr, or_);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
{
AssertPointerAlignment(ptr, 8);
return pg_atomic_add_fetch_u64_impl(ptr, add_);
}
-STATIC_IF_INLINE uint64
+static inline uint64
pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
{
AssertPointerAlignment(ptr, 8);
#endif /* PG_HAVE_64_BIT_ATOMICS */
-#endif /* defined(PG_USE_INLINE) ||
- * defined(ATOMICS_INCLUDE_DEFINITIONS) */
-
#undef INSIDE_ATOMICS_H
#endif /* ATOMICS_H */
#endif /* defined(__GNUC__) && !defined(__INTEL_COMPILER) */
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
#if !defined(PG_HAVE_SPIN_DELAY)
/*
* This sequence is equivalent to the PAUSE instruction ("rep" is
#endif /* defined(__GNUC__) && !defined(__INTEL_COMPILER) */
#endif /* HAVE_ATOMICS */
-
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
#endif /* PG_HAVE_ATOMIC_U32_SUPPORT */
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
#ifdef PG_HAVE_ATOMIC_FLAG_SIMULATION
#define PG_HAVE_ATOMIC_INIT_FLAG
extern uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_);
#endif /* PG_HAVE_ATOMIC_U32_SIMULATION */
-
-
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
volatile uint64 value;
} pg_atomic_uint64;
-#endif /* defined(HAVE_ATOMICS) */
-
-
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
-#if defined(HAVE_ATOMICS)
#define MINOR_FENCE (_Asm_fence) (_UP_CALL_FENCE | _UP_SYS_FENCE | \
_DOWN_CALL_FENCE | _DOWN_SYS_FENCE )
#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32
-STATIC_IF_INLINE bool
+static inline bool
pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr,
uint32 *expected, uint32 newval)
{
#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64
-STATIC_IF_INLINE bool
+static inline bool
pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr,
uint64 *expected, uint64 newval)
{
#undef MINOR_FENCE
#endif /* defined(HAVE_ATOMICS) */
-
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
# define pg_write_barrier_impl() __atomic_thread_fence(__ATOMIC_RELEASE)
#endif
+
#ifdef HAVE_ATOMICS
/* generic gcc based atomic flag implementation */
#endif /* defined(HAVE_GCC__ATOMIC_INT64_CAS) || defined(HAVE_GCC__SYNC_INT64_CAS) */
-/*
- * Implementation follows. Inlined or directly included from atomics.c
- */
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
#ifdef PG_HAVE_ATOMIC_FLAG_SUPPORT
#if defined(HAVE_GCC__SYNC_CHAR_TAS) || defined(HAVE_GCC__SYNC_INT32_TAS)
#endif /* !defined(PG_DISABLE_64_BIT_ATOMICS) */
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
-
#endif /* defined(HAVE_ATOMICS) */
volatile uint64 value;
} pg_atomic_uint64;
-#endif /* defined(HAVE_ATOMICS) */
-
-
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
-#if defined(HAVE_ATOMICS)
#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32
static inline bool
#endif /* _WIN64 */
#endif /* HAVE_ATOMICS */
-
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
#endif /* defined(HAVE_ATOMICS) */
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
#if defined(HAVE_ATOMICS)
#ifdef HAVE_ATOMIC_H
#endif /* HAVE_ATOMIC_H */
#endif /* defined(HAVE_ATOMICS) */
-
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
#endif /* __64BIT__ */
-#endif /* defined(HAVE_ATOMICS) */
-
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
-#if defined(HAVE_ATOMICS)
-
#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32
static inline bool
pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr,
#endif /* PG_HAVE_ATOMIC_U64_SUPPORT */
#endif /* defined(HAVE_ATOMICS) */
-
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
typedef pg_atomic_uint32 pg_atomic_flag;
#endif
-#if defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS)
-
#ifndef PG_HAVE_ATOMIC_READ_U32
#define PG_HAVE_ATOMIC_READ_U32
static inline uint32
#endif
#endif /* PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64 */
-
-#endif /* defined(PG_USE_INLINE) || defined(ATOMICS_INCLUDE_DEFINITIONS) */
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))
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)
{
return ret;
}
-#endif /* defined(PG_USE_INLINE) ||
- * defined(ARRAYACCESS_INCLUDE_DEFINITIONS) */
-
#endif /* ARRAYACCESS_H */
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
*/
#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;
CurrentMemoryContext = context;
return old;
}
-#endif /* PG_USE_INLINE || MCXT_INCLUDE_DEFINITIONS */
#endif /* FRONTEND */
/* Registration of memory context reset/delete callbacks */
} 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)
* 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)
return compare;
}
-#endif /*-- PG_USE_INLINE || SORTSUPPORT_INCLUDE_DEFINITIONS */
/* Other functions in utils/sort/sortsupport.c */
extern void PrepareSortSupportComparisonShim(Oid cmpFunc, SortSupport ssup);
esac
fi
+# "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
+# expansions of ginCompareItemPointers() "long long" arithmetic. To
+# take advantage of inlining, build a 64-bit PostgreSQL.
+test "$GCC" != yes -a $(getconf HARDWARE_BITMODE) == '32'; then
+ echo "$as_me: WARNING: disabling inlining on 32 bit aix due to a bug in xlc" 2>&1
+ CPPFLAGS="$CPPFLAGS -DPG_FORCE_DISABLE_INLINE"
+fi
+
# Native memset() is faster, tested on:
# AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
# AIX 5.3 ML3, gcc 4.0.1