summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-09-11 13:22:40 +0100
committerMatt Caswell <matt@openssl.org>2020-09-18 13:30:44 +0100
commit726b3293399cee7b1eedcfb3a524b91537bd5118 (patch)
tree24a01e5fdc8ba3568600ff6c92dfe138798f4a42 /include
parentecf15b16ee8223a9a383b97ee41126fbedf89bb5 (diff)
Provide basis for fixing lhash code
Following on from the earlier safestack work we provide the basis for fixing the lhash code such that unused static inline functions do not cause linker errors for applications including those headers. This brings the lhash code into line with the safestack code. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12860)
Diffstat (limited to 'include')
-rw-r--r--include/openssl/lhash.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/openssl/lhash.h b/include/openssl/lhash.h
index 5ad9b16ab2..816b613eaf 100644
--- a/include/openssl/lhash.h
+++ b/include/openssl/lhash.h
@@ -125,6 +125,42 @@ void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
# define LHASH_OF(type) struct lhash_st_##type
+/* Helper macro for internal use */
+# define DEFINE_LHASH_OF_INTERNAL(type) \
+ LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \
+ typedef int (*lh_##type##_compfunc)(const type *a, const type *b); \
+ typedef unsigned long (*lh_##type##_hashfunc)(const type *a); \
+ typedef void (*lh_##type##_doallfunc)(type *a); \
+ static ossl_unused ossl_inline type *ossl_check_##type##_lh_plain_type(type *ptr) \
+ { \
+ return ptr; \
+ } \
+ static ossl_unused ossl_inline const type *ossl_check_const_##type##_lh_plain_type(const type *ptr) \
+ { \
+ return ptr; \
+ } \
+ static ossl_unused ossl_inline const OPENSSL_LHASH *ossl_check_const_##type##_lh_type(const LHASH_OF(type) *lh) \
+ { \
+ return (const OPENSSL_LHASH *)lh; \
+ } \
+ static ossl_unused ossl_inline OPENSSL_LHASH *ossl_check_##type##_lh_type(LHASH_OF(type) *lh) \
+ { \
+ return (OPENSSL_LHASH *)lh; \
+ } \
+ static ossl_unused ossl_inline OPENSSL_LH_COMPFUNC ossl_check_##type##_lh_compfunc_type(lh_##type##_compfunc cmp) \
+ { \
+ return (OPENSSL_LH_COMPFUNC)cmp; \
+ } \
+ static ossl_unused ossl_inline OPENSSL_LH_HASHFUNC ossl_check_##type##_lh_hashfunc_type(lh_##type##_hashfunc hfn) \
+ { \
+ return (OPENSSL_LH_HASHFUNC)hfn; \
+ } \
+ static ossl_unused ossl_inline OPENSSL_LH_DOALL_FUNC ossl_check_##type##_lh_doallfunc_type(lh_##type##_doallfunc dfn) \
+ { \
+ return (OPENSSL_LH_DOALL_FUNC)dfn; \
+ } \
+ LHASH_OF(type)
+
# define DEFINE_LHASH_OF(type) \
LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \
static ossl_unused ossl_inline LHASH_OF(type) *lh_##type##_new(unsigned long (*hfn)(const type *), \