({(void)COMPILE_ERROR_IF_TRUE( \
sizeof((*table)._key) != sizeof(void *) || \
sizeof((*table)._value) != sizeof(void *)); \
- (void)COMPILE_ERROR_IF_TRUE( \
- !__builtin_types_compatible_p(typeof(&key_cmp_cb), \
- int (*)(typeof((*table)._key), typeof((*table)._key))) && \
- !__builtin_types_compatible_p(typeof(&key_cmp_cb), \
- int (*)(typeof((*table)._const_key), typeof((*table)._const_key)))); \
- (void)COMPILE_ERROR_IF_TRUE( \
- !__builtin_types_compatible_p(typeof(&hash_cb), \
- unsigned int (*)(typeof((*table)._key))) && \
- !__builtin_types_compatible_p(typeof(&hash_cb), \
- unsigned int (*)(typeof((*table)._const_key)))); \
hash_table_create(&(*table)._table, pool, size, \
(hash_callback_t *)hash_cb, \
(hash_cmp_callback_t *)key_cmp_cb);})
void *hash_table_lookup(const struct hash_table *table, const void *key) ATTR_PURE;
#define hash_table_lookup(table, key) \
HASH_VALUE_CAST(table)hash_table_lookup((table)._table, \
- (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._key, (table)._const_key, key)))
+ (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key)))
bool hash_table_lookup_full(const struct hash_table *table,
const void *lookup_key,
void **orig_key_r, void **value_r);
#define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \
hash_table_lookup_full((table)._table, \
- (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \
+ (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, lookup_key)), \
(void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*orig_key_r) != sizeof(void *))), \
(void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \
void hash_table_remove(struct hash_table *table, const void *key);
#define hash_table_remove(table, key) \
hash_table_remove((table)._table, \
- (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, key)))
+ (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key)))
unsigned int hash_table_count(const struct hash_table *table) ATTR_PURE;
#define hash_table_count(table) \
hash_table_count((table)._table)
COMPILE_ERROR_IF_TRUE( \
!__builtin_types_compatible_p(typeof(_a1), typeof(_b)) && \
!__builtin_types_compatible_p(typeof(_a2), typeof(_b)))
+#define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) \
+ COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a, typeof(const typeof(*_a) *), _b)
#else
# define COMPILE_ERROR_IF_TRUE(condition) 0
# define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) 0
# define COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a1, _a2, _b) 0
+# define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) 0
#endif
#if __GNUC__ > 2