mirror of
https://github.com/postgres/postgres.git
synced 2026-02-03 20:40:14 -05:00
Rename AssertVariableIsOfType to StaticAssertVariableIsOfType
This keeps run-time assertions and static assertions clearly separate. Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/2273bc2a-045d-4a75-8584-7cd9396e5534%40eisentraut.org
This commit is contained in:
parent
e05a24c2d4
commit
137d05df2f
14 changed files with 67 additions and 67 deletions
|
|
@ -28,24 +28,24 @@ static hstoreCheckValLen_t hstoreCheckValLen_p;
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -35,32 +35,32 @@ static hstoreCheckValLen_t hstoreCheckValLen_p;
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -39,16 +39,16 @@ static PLyUnicode_FromStringAndSize_t PLyUnicode_FromStringAndSize_p;
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ static PLyUnicode_FromStringAndSize_t PLyUnicode_FromStringAndSize_p;
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ struct SharedExecutorInstrumentation
|
|||
/* 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. */
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ extern Datum AttributeTemplate(PG_FUNCTION_ARGS);
|
|||
Datum
|
||||
AttributeTemplate(PG_FUNCTION_ARGS)
|
||||
{
|
||||
AssertVariableIsOfType(&AttributeTemplate, PGFunction);
|
||||
StaticAssertVariableIsOfType(&AttributeTemplate, PGFunction);
|
||||
|
||||
PG_RETURN_NULL();
|
||||
}
|
||||
|
|
@ -99,8 +99,8 @@ ExecEvalSubroutineTemplate(ExprState *state,
|
|||
struct ExprEvalStep *op,
|
||||
ExprContext *econtext)
|
||||
{
|
||||
AssertVariableIsOfType(&ExecEvalSubroutineTemplate,
|
||||
ExecEvalSubroutine);
|
||||
StaticAssertVariableIsOfType(&ExecEvalSubroutineTemplate,
|
||||
ExecEvalSubroutine);
|
||||
}
|
||||
|
||||
extern bool ExecEvalBoolSubroutineTemplate(ExprState *state,
|
||||
|
|
@ -111,8 +111,8 @@ ExecEvalBoolSubroutineTemplate(ExprState *state,
|
|||
struct ExprEvalStep *op,
|
||||
ExprContext *econtext)
|
||||
{
|
||||
AssertVariableIsOfType(&ExecEvalBoolSubroutineTemplate,
|
||||
ExecEvalBoolSubroutine);
|
||||
StaticAssertVariableIsOfType(&ExecEvalBoolSubroutineTemplate,
|
||||
ExecEvalBoolSubroutine);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ typedef uint64 XLogRecPtr;
|
|||
* 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.
|
||||
|
|
|
|||
|
|
@ -955,26 +955,26 @@ pg_noreturn extern void ExceptionalCondition(const char *conditionName,
|
|||
/*
|
||||
* 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 */
|
||||
|
|
|
|||
|
|
@ -591,8 +591,8 @@ dlist_tail_node(dlist_head *head)
|
|||
* 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))))
|
||||
|
||||
/*
|
||||
|
|
@ -601,7 +601,7 @@ dlist_tail_node(dlist_head *head)
|
|||
* 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)))
|
||||
|
||||
/*
|
||||
|
|
@ -610,7 +610,7 @@ dlist_tail_node(dlist_head *head)
|
|||
* 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))))
|
||||
|
||||
/*
|
||||
|
|
@ -621,8 +621,8 @@ dlist_tail_node(dlist_head *head)
|
|||
* 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; \
|
||||
|
|
@ -638,8 +638,8 @@ dlist_tail_node(dlist_head *head)
|
|||
* 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; \
|
||||
|
|
@ -652,8 +652,8 @@ dlist_tail_node(dlist_head *head)
|
|||
* 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; \
|
||||
|
|
@ -953,7 +953,7 @@ dclist_count(const dclist_head *head)
|
|||
* 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)))
|
||||
|
||||
/*
|
||||
|
|
@ -962,7 +962,7 @@ dclist_count(const dclist_head *head)
|
|||
* 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))))
|
||||
|
||||
|
||||
|
|
@ -1104,8 +1104,8 @@ slist_delete_current(slist_mutable_iter *iter)
|
|||
* 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))))
|
||||
|
||||
/*
|
||||
|
|
@ -1114,7 +1114,7 @@ slist_delete_current(slist_mutable_iter *iter)
|
|||
* 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)))
|
||||
|
||||
/*
|
||||
|
|
@ -1130,8 +1130,8 @@ slist_delete_current(slist_mutable_iter *iter)
|
|||
* 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)
|
||||
|
|
@ -1146,8 +1146,8 @@ slist_delete_current(slist_mutable_iter *iter)
|
|||
* 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; \
|
||||
|
|
|
|||
|
|
@ -41,16 +41,16 @@ typedef struct pairingheap_node
|
|||
* 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))))
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -533,9 +533,9 @@ Float8GetDatum(float8 X)
|
|||
*/
|
||||
|
||||
#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))
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -204,8 +204,8 @@ proclist_pop_head_node_offset(proclist_head *list, size_t node_offset)
|
|||
* 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, \
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ struct FreePageManager
|
|||
|
||||
/* 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)
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@
|
|||
|
||||
#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
|
||||
|
||||
|
|
@ -70,12 +70,12 @@ relptr_store_eval(char *base, char *val)
|
|||
|
||||
#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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue