void
_PG_init(void)
{
- /* Asserts verify that typedefs above match original declarations */
- AssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t);
+ /* Static asserts verify that typedefs above match original declarations */
+ StaticAssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t);
hstoreUpgrade_p = (hstoreUpgrade_t)
load_external_function("$libdir/hstore", "hstoreUpgrade",
true, NULL);
- AssertVariableIsOfType(&hstoreUniquePairs, hstoreUniquePairs_t);
+ StaticAssertVariableIsOfType(&hstoreUniquePairs, hstoreUniquePairs_t);
hstoreUniquePairs_p = (hstoreUniquePairs_t)
load_external_function("$libdir/hstore", "hstoreUniquePairs",
true, NULL);
- AssertVariableIsOfType(&hstorePairs, hstorePairs_t);
+ StaticAssertVariableIsOfType(&hstorePairs, hstorePairs_t);
hstorePairs_p = (hstorePairs_t)
load_external_function("$libdir/hstore", "hstorePairs",
true, NULL);
- AssertVariableIsOfType(&hstoreCheckKeyLen, hstoreCheckKeyLen_t);
+ StaticAssertVariableIsOfType(&hstoreCheckKeyLen, hstoreCheckKeyLen_t);
hstoreCheckKeyLen_p = (hstoreCheckKeyLen_t)
load_external_function("$libdir/hstore", "hstoreCheckKeyLen",
true, NULL);
- AssertVariableIsOfType(&hstoreCheckValLen, hstoreCheckValLen_t);
+ StaticAssertVariableIsOfType(&hstoreCheckValLen, hstoreCheckValLen_t);
hstoreCheckValLen_p = (hstoreCheckValLen_t)
load_external_function("$libdir/hstore", "hstoreCheckValLen",
true, NULL);
void
_PG_init(void)
{
- /* Asserts verify that typedefs above match original declarations */
- AssertVariableIsOfType(&PLyObject_AsString, PLyObject_AsString_t);
+ /* Static asserts verify that typedefs above match original declarations */
+ StaticAssertVariableIsOfType(&PLyObject_AsString, PLyObject_AsString_t);
PLyObject_AsString_p = (PLyObject_AsString_t)
load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyObject_AsString",
true, NULL);
- AssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t);
+ StaticAssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t);
PLyUnicode_FromStringAndSize_p = (PLyUnicode_FromStringAndSize_t)
load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyUnicode_FromStringAndSize",
true, NULL);
- AssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t);
+ StaticAssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t);
hstoreUpgrade_p = (hstoreUpgrade_t)
load_external_function("$libdir/hstore", "hstoreUpgrade",
true, NULL);
- AssertVariableIsOfType(&hstoreUniquePairs, hstoreUniquePairs_t);
+ StaticAssertVariableIsOfType(&hstoreUniquePairs, hstoreUniquePairs_t);
hstoreUniquePairs_p = (hstoreUniquePairs_t)
load_external_function("$libdir/hstore", "hstoreUniquePairs",
true, NULL);
- AssertVariableIsOfType(&hstorePairs, hstorePairs_t);
+ StaticAssertVariableIsOfType(&hstorePairs, hstorePairs_t);
hstorePairs_p = (hstorePairs_t)
load_external_function("$libdir/hstore", "hstorePairs",
true, NULL);
- AssertVariableIsOfType(&hstoreCheckKeyLen, hstoreCheckKeyLen_t);
+ StaticAssertVariableIsOfType(&hstoreCheckKeyLen, hstoreCheckKeyLen_t);
hstoreCheckKeyLen_p = (hstoreCheckKeyLen_t)
load_external_function("$libdir/hstore", "hstoreCheckKeyLen",
true, NULL);
- AssertVariableIsOfType(&hstoreCheckValLen, hstoreCheckValLen_t);
+ StaticAssertVariableIsOfType(&hstoreCheckValLen, hstoreCheckValLen_t);
hstoreCheckValLen_p = (hstoreCheckValLen_t)
load_external_function("$libdir/hstore", "hstoreCheckValLen",
true, NULL);
void
_PG_init(void)
{
- /* Asserts verify that typedefs above match original declarations */
- AssertVariableIsOfType(&PLyObject_AsString, PLyObject_AsString_t);
+ /* Static asserts verify that typedefs above match original declarations */
+ StaticAssertVariableIsOfType(&PLyObject_AsString, PLyObject_AsString_t);
PLyObject_AsString_p = (PLyObject_AsString_t)
load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyObject_AsString",
true, NULL);
- AssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t);
+ StaticAssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t);
PLyUnicode_FromStringAndSize_p = (PLyUnicode_FromStringAndSize_t)
load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyUnicode_FromStringAndSize",
true, NULL);
- AssertVariableIsOfType(&PLy_elog_impl, PLy_elog_impl_t);
+ StaticAssertVariableIsOfType(&PLy_elog_impl, PLy_elog_impl_t);
PLy_elog_impl_p = (PLy_elog_impl_t)
load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLy_elog_impl",
true, NULL);
void
_PG_init(void)
{
- /* Asserts verify that typedefs above match original declarations */
- AssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t);
+ /* Static asserts verify that typedefs above match original declarations */
+ StaticAssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t);
PLyUnicode_FromStringAndSize_p = (PLyUnicode_FromStringAndSize_t)
load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyUnicode_FromStringAndSize",
true, NULL);
/* array of num_plan_nodes * num_workers Instrumentation objects follows */
};
#define GetInstrumentationArray(sei) \
- (AssertVariableIsOfTypeMacro(sei, SharedExecutorInstrumentation *), \
+ (StaticAssertVariableIsOfTypeMacro(sei, SharedExecutorInstrumentation *), \
(Instrumentation *) (((char *) sei) + sei->instrument_offset))
/* Context object for ExecParallelEstimate. */
Datum
AttributeTemplate(PG_FUNCTION_ARGS)
{
- AssertVariableIsOfType(&AttributeTemplate, PGFunction);
+ StaticAssertVariableIsOfType(&AttributeTemplate, PGFunction);
PG_RETURN_NULL();
}
struct ExprEvalStep *op,
ExprContext *econtext)
{
- AssertVariableIsOfType(&ExecEvalSubroutineTemplate,
- ExecEvalSubroutine);
+ StaticAssertVariableIsOfType(&ExecEvalSubroutineTemplate,
+ ExecEvalSubroutine);
}
extern bool ExecEvalBoolSubroutineTemplate(ExprState *state,
struct ExprEvalStep *op,
ExprContext *econtext)
{
- AssertVariableIsOfType(&ExecEvalBoolSubroutineTemplate,
- ExecEvalBoolSubroutine);
+ StaticAssertVariableIsOfType(&ExecEvalBoolSubroutineTemplate,
+ ExecEvalBoolSubroutine);
return false;
}
* To avoid breaking translatable messages, we're directly applying the
* LSN format instead of using a macro.
*/
-#define LSN_FORMAT_ARGS(lsn) (AssertVariableIsOfTypeMacro((lsn), XLogRecPtr), (uint32) ((lsn) >> 32)), ((uint32) (lsn))
+#define LSN_FORMAT_ARGS(lsn) (StaticAssertVariableIsOfTypeMacro((lsn), XLogRecPtr), (uint32) ((lsn) >> 32)), ((uint32) (lsn))
/*
* XLogSegNo - physical log file sequence number.
/*
* Compile-time checks that a variable (or expression) has the specified type.
*
- * AssertVariableIsOfType() can be used as a statement.
- * AssertVariableIsOfTypeMacro() is intended for use in macros, eg
- * #define foo(x) (AssertVariableIsOfTypeMacro(x, int), bar(x))
+ * StaticAssertVariableIsOfType() can be used as a statement.
+ * StaticAssertVariableIsOfTypeMacro() is intended for use in macros, eg
+ * #define foo(x) (StaticAssertVariableIsOfTypeMacro(x, int), bar(x))
*
* If we don't have __builtin_types_compatible_p, we can still assert that
* the types have the same size. This is far from ideal (especially on 32-bit
* platforms) but it provides at least some coverage.
*/
#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
-#define AssertVariableIsOfType(varname, typename) \
+#define StaticAssertVariableIsOfType(varname, typename) \
StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \
CppAsString(varname) " does not have type " CppAsString(typename))
-#define AssertVariableIsOfTypeMacro(varname, typename) \
+#define StaticAssertVariableIsOfTypeMacro(varname, typename) \
(StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
CppAsString(varname) " does not have type " CppAsString(typename)))
#else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
-#define AssertVariableIsOfType(varname, typename) \
+#define StaticAssertVariableIsOfType(varname, typename) \
StaticAssertStmt(sizeof(varname) == sizeof(typename), \
CppAsString(varname) " does not have type " CppAsString(typename))
-#define AssertVariableIsOfTypeMacro(varname, typename) \
+#define StaticAssertVariableIsOfTypeMacro(varname, typename) \
(StaticAssertExpr(sizeof(varname) == sizeof(typename), \
CppAsString(varname) " does not have type " CppAsString(typename)))
#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */
* This is used to convert a dlist_node * back to its containing struct.
*/
#define dlist_container(type, membername, ptr) \
- (AssertVariableIsOfTypeMacro(ptr, dlist_node *), \
- AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
+ (StaticAssertVariableIsOfTypeMacro(ptr, dlist_node *), \
+ StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
((type *) ((char *) (ptr) - offsetof(type, membername))))
/*
* The list must not be empty.
*/
#define dlist_head_element(type, membername, lhead) \
- (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
+ (StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
(type *) dlist_head_element_off(lhead, offsetof(type, membername)))
/*
* The list must not be empty.
*/
#define dlist_tail_element(type, membername, lhead) \
- (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
+ (StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
((type *) dlist_tail_element_off(lhead, offsetof(type, membername))))
/*
* It is *not* allowed to manipulate the list during iteration.
*/
#define dlist_foreach(iter, lhead) \
- for (AssertVariableIsOfTypeMacro(iter, dlist_iter), \
- AssertVariableIsOfTypeMacro(lhead, dlist_head *), \
+ for (StaticAssertVariableIsOfTypeMacro(iter, dlist_iter), \
+ StaticAssertVariableIsOfTypeMacro(lhead, dlist_head *), \
(iter).end = &(lhead)->head, \
(iter).cur = (iter).end->next ? (iter).end->next : (iter).end; \
(iter).cur != (iter).end; \
* fine to insert or delete adjacent nodes.
*/
#define dlist_foreach_modify(iter, lhead) \
- for (AssertVariableIsOfTypeMacro(iter, dlist_mutable_iter), \
- AssertVariableIsOfTypeMacro(lhead, dlist_head *), \
+ for (StaticAssertVariableIsOfTypeMacro(iter, dlist_mutable_iter), \
+ StaticAssertVariableIsOfTypeMacro(lhead, dlist_head *), \
(iter).end = &(lhead)->head, \
(iter).cur = (iter).end->next ? (iter).end->next : (iter).end, \
(iter).next = (iter).cur->next; \
* It is *not* allowed to manipulate the list during iteration.
*/
#define dlist_reverse_foreach(iter, lhead) \
- for (AssertVariableIsOfTypeMacro(iter, dlist_iter), \
- AssertVariableIsOfTypeMacro(lhead, dlist_head *), \
+ for (StaticAssertVariableIsOfTypeMacro(iter, dlist_iter), \
+ StaticAssertVariableIsOfTypeMacro(lhead, dlist_head *), \
(iter).end = &(lhead)->head, \
(iter).cur = (iter).end->prev ? (iter).end->prev : (iter).end; \
(iter).cur != (iter).end; \
* The list must not be empty.
*/
#define dclist_head_element(type, membername, lhead) \
- (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
+ (StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
(type *) dclist_head_element_off(lhead, offsetof(type, membername)))
/*
* The list must not be empty.
*/
#define dclist_tail_element(type, membername, lhead) \
- (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
+ (StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
((type *) dclist_tail_element_off(lhead, offsetof(type, membername))))
* This is used to convert a slist_node * back to its containing struct.
*/
#define slist_container(type, membername, ptr) \
- (AssertVariableIsOfTypeMacro(ptr, slist_node *), \
- AssertVariableIsOfTypeMacro(((type *) NULL)->membername, slist_node), \
+ (StaticAssertVariableIsOfTypeMacro(ptr, slist_node *), \
+ StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, slist_node), \
((type *) ((char *) (ptr) - offsetof(type, membername))))
/*
* The list must not be empty.
*/
#define slist_head_element(type, membername, lhead) \
- (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, slist_node), \
+ (StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, slist_node), \
(type *) slist_head_element_off(lhead, offsetof(type, membername)))
/*
* not safe.)
*/
#define slist_foreach(iter, lhead) \
- for (AssertVariableIsOfTypeMacro(iter, slist_iter), \
- AssertVariableIsOfTypeMacro(lhead, slist_head *), \
+ for (StaticAssertVariableIsOfTypeMacro(iter, slist_iter), \
+ StaticAssertVariableIsOfTypeMacro(lhead, slist_head *), \
(iter).cur = (lhead)->head.next; \
(iter).cur != NULL; \
(iter).cur = (iter).cur->next)
* deletion of nodes adjacent to the current node would misbehave.
*/
#define slist_foreach_modify(iter, lhead) \
- for (AssertVariableIsOfTypeMacro(iter, slist_mutable_iter), \
- AssertVariableIsOfTypeMacro(lhead, slist_head *), \
+ for (StaticAssertVariableIsOfTypeMacro(iter, slist_mutable_iter), \
+ StaticAssertVariableIsOfTypeMacro(lhead, slist_head *), \
(iter).prev = &(lhead)->head, \
(iter).cur = (iter).prev->next, \
(iter).next = (iter).cur ? (iter).cur->next : NULL; \
* This is used to convert a pairingheap_node * back to its containing struct.
*/
#define pairingheap_container(type, membername, ptr) \
- (AssertVariableIsOfTypeMacro(ptr, pairingheap_node *), \
- AssertVariableIsOfTypeMacro(((type *) NULL)->membername, pairingheap_node), \
+ (StaticAssertVariableIsOfTypeMacro(ptr, pairingheap_node *), \
+ StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, pairingheap_node), \
((type *) ((char *) (ptr) - offsetof(type, membername))))
/*
* Like pairingheap_container, but used when the pointer is 'const ptr'
*/
#define pairingheap_const_container(type, membername, ptr) \
- (AssertVariableIsOfTypeMacro(ptr, const pairingheap_node *), \
- AssertVariableIsOfTypeMacro(((type *) NULL)->membername, pairingheap_node), \
+ (StaticAssertVariableIsOfTypeMacro(ptr, const pairingheap_node *), \
+ StaticAssertVariableIsOfTypeMacro(((type *) NULL)->membername, pairingheap_node), \
((const type *) ((const char *) (ptr) - offsetof(type, membername))))
/*
*/
#define Int64GetDatumFast(X) \
- (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
+ (StaticAssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
#define Float8GetDatumFast(X) \
- (AssertVariableIsOfTypeMacro(X, double), Float8GetDatum(X))
+ (StaticAssertVariableIsOfTypeMacro(X, double), Float8GetDatum(X))
/* ----------------------------------------------------------------
* node with proclist_delete(list, iter.cur, node_offset).
*/
#define proclist_foreach_modify(iter, lhead, link_member) \
- for (AssertVariableIsOfTypeMacro(iter, proclist_mutable_iter), \
- AssertVariableIsOfTypeMacro(lhead, proclist_head *), \
+ for (StaticAssertVariableIsOfTypeMacro(iter, proclist_mutable_iter), \
+ StaticAssertVariableIsOfTypeMacro(lhead, proclist_head *), \
(iter).cur = (lhead)->head, \
(iter).next = (iter).cur == INVALID_PROC_NUMBER ? INVALID_PROC_NUMBER : \
proclist_node_get((iter).cur, \
/* Macros to convert between page numbers (expressed as Size) and pointers. */
#define fpm_page_to_pointer(base, page) \
- (AssertVariableIsOfTypeMacro(page, Size), \
+ (StaticAssertVariableIsOfTypeMacro(page, Size), \
(base) + FPM_PAGE_SIZE * (page))
#define fpm_pointer_to_page(base, ptr) \
(((Size) (((char *) (ptr)) - (base))) / FPM_PAGE_SIZE)
#ifdef HAVE_TYPEOF
#define relptr_access(base, rp) \
- (AssertVariableIsOfTypeMacro(base, char *), \
+ (StaticAssertVariableIsOfTypeMacro(base, char *), \
(typeof((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \
(base) + (rp).relptr_off - 1))
#else
#define relptr_access(base, rp) \
- (AssertVariableIsOfTypeMacro(base, char *), \
+ (StaticAssertVariableIsOfTypeMacro(base, char *), \
(void *) ((rp).relptr_off == 0 ? NULL : (base) + (rp).relptr_off - 1))
#endif
#ifdef HAVE_TYPEOF
#define relptr_store(base, rp, val) \
- (AssertVariableIsOfTypeMacro(base, char *), \
- AssertVariableIsOfTypeMacro(val, typeof((rp).relptr_type)), \
+ (StaticAssertVariableIsOfTypeMacro(base, char *), \
+ StaticAssertVariableIsOfTypeMacro(val, typeof((rp).relptr_type)), \
(rp).relptr_off = relptr_store_eval((base), (char *) (val)))
#else
#define relptr_store(base, rp, val) \
- (AssertVariableIsOfTypeMacro(base, char *), \
+ (StaticAssertVariableIsOfTypeMacro(base, char *), \
(rp).relptr_off = relptr_store_eval((base), (char *) (val)))
#endif