Fix missing casts for c++
[openssl.git] / include / openssl / lhash.h
index d5097cddd61a57497f704c6e6f1c73b9ea0cff49..f4ea37b8a1b33e52f03606699326a8d81d85d894 100644 (file)
@@ -113,15 +113,6 @@ typedef void (*LHASH_DOALL_ARG_FN_TYPE) (void *, void *);
                 return name##_cmp(a,b); }
 # define LHASH_COMP_FN(name) name##_LHASH_COMP
 
-/* Third: "doall" functions */
-# define DECLARE_LHASH_DOALL_FN(name, o_type) \
-        void name##_LHASH_DOALL(void *);
-# define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \
-        void name##_LHASH_DOALL(void *arg) { \
-                o_type *a = arg; \
-                name##_doall(a); }
-# define LHASH_DOALL_FN(name) name##_LHASH_DOALL
-
 /* Fourth: "doall_arg" functions */
 # define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
         void name##_LHASH_DOALL_ARG(void *, void *);
@@ -193,66 +184,91 @@ void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
 
 # define LHASH_OF(type) struct lhash_st_##type
 
-# define DECLARE_LHASH_OF(type) \
+# define DEFINE_LHASH_OF(type) \
     LHASH_OF(type) { int dummy; }; \
-    static inline void lh_##type##_free(LHASH_OF(type) *lh) \
+    static ossl_inline LHASH_OF(type) * \
+        lh_##type##_new(unsigned long (*hfn)(const type *), \
+                        int (*cfn)(const type *, const type *)) \
+    { \
+        return (LHASH_OF(type) *) \
+            lh_new((LHASH_HASH_FN_TYPE) hfn, (LHASH_COMP_FN_TYPE)cfn); \
+    } \
+    static ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \
     { \
         lh_free((_LHASH *)lh); \
     } \
-    static inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \
+    static ossl_inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \
     { \
-        return lh_insert((_LHASH *)lh, d); \
+        return (type *)lh_insert((_LHASH *)lh, d); \
     } \
-    static inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \
+    static ossl_inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \
     { \
-        return lh_delete((_LHASH *)lh, d); \
+        return (type *)lh_delete((_LHASH *)lh, d); \
     } \
-    static inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \
+    static ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \
     { \
-        return lh_retrieve((_LHASH *)lh, d); \
+        return (type *)lh_retrieve((_LHASH *)lh, d); \
     } \
-    static inline int lh_##type##_error(LHASH_OF(type) *lh) \
+    static ossl_inline int lh_##type##_error(LHASH_OF(type) *lh) \
     { \
         return lh_error((_LHASH *)lh); \
     } \
-    static inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \
+    static ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \
     { \
         return lh_num_items((_LHASH *)lh); \
     } \
-    static inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
+    static ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
     { \
         lh_node_stats_bio((_LHASH *)lh, out); \
     } \
-    static inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
+    static ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
     { \
         lh_node_usage_stats_bio((_LHASH *)lh, out); \
     } \
-    static inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
+    static ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \
     { \
         lh_stats_bio((_LHASH *)lh, out); \
     } \
-    static inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \
+    static ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \
     { \
         return lh_get_down_load((_LHASH *)lh); \
     } \
-    static inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \
+    static ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \
     { \
         lh_set_down_load((_LHASH *)lh, dl); \
     } \
+    static ossl_inline void lh_##type##_doall(LHASH_OF(type) *lh, \
+                                         void (*doall)(type *)) \
+    { \
+        lh_doall((_LHASH *)lh, (LHASH_DOALL_FN_TYPE)doall); \
+    } \
+    LHASH_OF(type)
+
+#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \
+    int_implement_lhash_doall(type, argtype, const type)
+
+#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \
+    int_implement_lhash_doall(type, argtype, type)
+
+#define int_implement_lhash_doall(type, argtype, cbargtype) \
+    static ossl_inline void \
+        lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \
+                                   void (*fn)(cbargtype *, argtype *), \
+                                   argtype *arg) \
+    { \
+        lh_doall_arg((_LHASH *)lh, (LHASH_DOALL_ARG_FN_TYPE)fn, (void *)arg); \
+    } \
     LHASH_OF(type)
 
 # define CHECKED_LHASH_OF(type,lh) \
   ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))
 
 /* Define wrapper functions. */
-# define LHM_lh_new(type, name) \
-  ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))
-# define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)
 # define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \
   lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))
 
-DECLARE_LHASH_OF(OPENSSL_STRING);
-DECLARE_LHASH_OF(OPENSSL_CSTRING);
+DEFINE_LHASH_OF(OPENSSL_STRING);
+DEFINE_LHASH_OF(OPENSSL_CSTRING);
 
 #ifdef  __cplusplus
 }