if (!mm_array) {
static knot_mm_t mm_array_default = { 0 };
if (!mm_array_default.ctx)
- mm_ctx_init_aligned(&mm_array_default, __alignof(struct lru));
+ mm_ctx_init_aligned(&mm_array_default, alignof(struct lru));
mm_array = &mm_array_default;
}
assert(mm_array->alloc != mm_malloc && mm_array->alloc != (knot_mm_alloc_t)mp_alloc);
#pragma once
#include <assert.h>
-#include <stdint.h>
+#include <stdalign.h>
#include <stddef.h>
+#include <stdint.h>
#include "contrib/ucw/lib.h"
#include "lib/utils.h"
* @note The pointers to memory contexts need to remain valid
* during the whole life of the structure (or be NULL).
*/
+/* Pragmas: C11 only standardizes alignof on type names, not on expressions.
+ * That's a GNU extension; in clang it's supported but may generate warnings.
+ * It seems hard to disable warnings that are only supported by some compilers. */
#define lru_create(ptable, max_slots, mm_ctx_array, mm_ctx) do { \
(void)(((__typeof__((*(ptable))->pdata_t))0) == (void *)0); /* typecheck lru_t */ \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wpragmas\"") \
+ _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") \
+ _Pragma("GCC diagnostic ignored \"-Wgnu-alignof-expression\"") \
*(ptable) = (__typeof__(*(ptable))) \
- lru_create_impl((max_slots), __alignof(*( (*(ptable))->pdata_t )), \
+ lru_create_impl((max_slots), alignof(*( (*(ptable))->pdata_t )), \
(mm_ctx_array), (mm_ctx)); \
+ _Pragma("GCC diagnostic pop") \
} while (false)
/** @brief Free an LRU created by lru_create (it can be NULL). */